diff --git a/portal-ui/src/common/types.ts b/portal-ui/src/common/types.ts index a2907e8a3..bbb5c103e 100644 --- a/portal-ui/src/common/types.ts +++ b/portal-ui/src/common/types.ts @@ -65,6 +65,13 @@ export interface ITenantCreator { encryption?: IEncryptionConfiguration; idp?: IIDPConfiguration; annotations?: Object; + image_registry?: ImageRegistry; +} + +export interface ImageRegistry { + registry: string; + username: string; + password: string; } export interface ITenantUpdateObject { diff --git a/portal-ui/src/screens/Console/Tenants/ListTenants/AddTenant.tsx b/portal-ui/src/screens/Console/Tenants/ListTenants/AddTenant.tsx index 003b436ab..b0315e7d6 100644 --- a/portal-ui/src/screens/Console/Tenants/ListTenants/AddTenant.tsx +++ b/portal-ui/src/screens/Console/Tenants/ListTenants/AddTenant.tsx @@ -189,7 +189,15 @@ const AddTenant = ({ const [encryptionValid, setEncryptionValid] = useState(false); // Custom Elements + const [customImage, setCustomImage] = useState(false); const [customDockerhub, setCustomDockerhub] = useState(false); + const [imageRegistry, setImageRegistry] = useState(""); + const [imageRegistryUsername, setImageRegistryUsername] = useState( + "" + ); + const [imageRegistryPassword, setImageRegistryPassword] = useState( + "" + ); // FilesBase64 const [filesBase64, setFilesBase64] = useState({ @@ -366,7 +374,7 @@ const AddTenant = ({ useEffect(() => { let customAccountValidation: IValidation[] = []; - if (customDockerhub) { + if (customImage) { customAccountValidation = [ ...customAccountValidation, { @@ -385,6 +393,26 @@ const AddTenant = ({ "Format must be of form: 'minio/console:VERSION'", }, ]; + if (customDockerhub) { + customAccountValidation = [ + ...customAccountValidation, + { + fieldKey: "registry", + required: true, + value: imageRegistry, + }, + { + fieldKey: "registryUsername", + required: true, + value: imageRegistryUsername, + }, + { + fieldKey: "registryPassword", + required: true, + value: imageRegistryPassword, + }, + ]; + } } const commonVal = commonFormValidation(customAccountValidation); @@ -392,7 +420,15 @@ const AddTenant = ({ setConfigureValid(Object.keys(commonVal).length === 0); setValidationErrors(commonVal); - }, [customDockerhub, imageName, consoleImage]); + }, [ + customImage, + imageName, + consoleImage, + customDockerhub, + imageRegistry, + imageRegistryUsername, + imageRegistryPassword, + ]); useEffect(() => { let customIDPValidation: IValidation[] = []; @@ -763,6 +799,17 @@ const AddTenant = ({ erasureCodingParity: parseInt(erasureCode, 10), }; + if (customDockerhub) { + dataSend = { + ...dataSend, + image_registry: { + registry: imageRegistry, + username: imageRegistryUsername, + password: imageRegistryPassword, + }, + }; + } + if (tlsType === "customcert") { let tenantCerts: any = null; let consoleCerts: any = null; @@ -1046,20 +1093,20 @@ const AddTenant = ({ { const targetD = e.target; const checked = targetD.checked; - setCustomDockerhub(checked); + setCustomImage(checked); }} label={"Use custom image"} /> - {customDockerhub && ( + {customImage && ( Please enter the MinIO image from dockerhub to use @@ -1073,7 +1120,7 @@ const AddTenant = ({ label="MinIO's Image" value={imageName} error={validationErrors["image"] || ""} - placeholder="Eg. minio/minio:RELEASE.2020-05-08T02-40-49Z" + placeholder="E.g. minio/minio:RELEASE.2020-05-08T02-40-49Z" required /> @@ -1088,7 +1135,70 @@ const AddTenant = ({ label="Console's Image" value={consoleImage} error={validationErrors["consoleImage"] || ""} - placeholder="Eg. minio/console:v0.3.13" + placeholder="E.g. minio/console:v0.3.13" + required + /> + + + )} + {customImage && ( + + + { + const targetD = e.target; + const checked = targetD.checked; + + setCustomDockerhub(checked); + }} + label={"Set/Update Image Registry"} + /> + + + )} + {customDockerhub && ( + + + ) => { + setImageRegistry(e.target.value); + }} + label="Endpoint" + value={imageRegistry} + error={validationErrors["registry"] || ""} + placeholder="E.g. https://index.docker.io/v1/" + required + /> + + + ) => { + setImageRegistryUsername(e.target.value); + }} + label="Username" + value={imageRegistryUsername} + error={validationErrors["registryUsername"] || ""} + required + /> + + + ) => { + setImageRegistryPassword(e.target.value); + }} + label="Password" + value={imageRegistryPassword} + error={validationErrors["registryPassword"] || ""} required /> @@ -2053,7 +2163,7 @@ const AddTenant = ({ {tenantName} - {customDockerhub && ( + {customImage && ( MinIO Image