diff --git a/libs/i18n/locales/en/translation.json b/libs/i18n/locales/en/translation.json index 7c3db06d0..ea0c5e658 100644 --- a/libs/i18n/locales/en/translation.json +++ b/libs/i18n/locales/en/translation.json @@ -841,6 +841,8 @@ "Select a repository to generate the full URL": "Select a repository to generate the full URL", "Suffix that will be combined with the repository's base URL to invoke the HTTP service. Can include query parameters.": "Suffix that will be combined with the repository's base URL to invoke the HTTP service. Can include query parameters.", "Path of the file where the response will be stored in the device filesystem.": "Path of the file where the response will be stored in the device filesystem.", + "Only Git repositories can be used for Git configurations.": "Only Git repositories can be used for Git configurations.", + "Only HTTP repositories can be used for HTTP configurations.": "Only HTTP repositories can be used for HTTP configurations.", "Register all MicroShift devices to ACM": "Register all MicroShift devices to ACM", "Select this when all the devices in the fleet are running MicroShift and you want to register them to ACM.": "Select this when all the devices in the fleet are running MicroShift and you want to register them to ACM.", "To remove registration, you'll need to uncheck this option and also remove the clusters from ACM's clusters list": "To remove registration, you'll need to uncheck this option and also remove the clusters from ACM's clusters list", @@ -1075,9 +1077,9 @@ "Accessible": "Accessible", "Not accessible": "Not accessible", "Missing repository": "Missing repository", + "Create repository": "Create repository", "Repository": "Repository", "Select a repository": "Select a repository", - "Create repository": "Create repository", "Max file size {{ maxFileSize }} KB": "Max file size {{ maxFileSize }} KB", "Max file size {{ maxFileSize }} MB": "Max file size {{ maxFileSize }} MB", "File exceeds maximum allowed size.": "File exceeds maximum allowed size.", @@ -1202,6 +1204,7 @@ "Management-ready by default": "Management-ready by default", "The agent is automatically included in this image. This ensures your devices are ready to be managed immediately after they are deployed.": "The agent is automatically included in this image. This ensures your devices are ready to be managed immediately after they are deployed.", "Target repository": "Target repository", + "Only OCI registries can be used for image builds.": "Only OCI registries can be used for image builds.", "Storage repository for your completed image.": "Storage repository for your completed image.", "Image name": "Image name", "The image name that will be pushed to the repository. For example: flightctl/rhel-bootc": "The image name that will be pushed to the repository. For example: flightctl/rhel-bootc", @@ -1528,6 +1531,8 @@ "Token": "Token", "SSH private key": "SSH private key", "Private key passphrase": "Private key passphrase", + "Repository type": "Repository type", + "Why is this repository type enforced?": "Why is this repository type enforced?", "Use Git repository": "Use Git repository", "Use HTTP service": "Use HTTP service", "Use OCI registry": "Use OCI registry", diff --git a/libs/ui-components/src/components/Device/EditDeviceWizard/steps/ConfigWithRepositoryTemplateForm.tsx b/libs/ui-components/src/components/Device/EditDeviceWizard/steps/ConfigWithRepositoryTemplateForm.tsx index d056b7831..4390fdcf0 100644 --- a/libs/ui-components/src/components/Device/EditDeviceWizard/steps/ConfigWithRepositoryTemplateForm.tsx +++ b/libs/ui-components/src/components/Device/EditDeviceWizard/steps/ConfigWithRepositoryTemplateForm.tsx @@ -123,6 +123,7 @@ const ConfigWithRepositoryTemplateForm = ({ isReadOnly, canCreateRepo, }: ConfigWithRepositoryTemplateFormProps) => { + const { t } = useTranslation(); const { values } = useFormikContext(); const ct = values.configTemplates[index] as HttpConfigTemplate | GitConfigTemplate; @@ -139,6 +140,12 @@ const ConfigWithRepositoryTemplateForm = ({ isReadOnly={isReadOnly} repoRefetch={repoRefetch} isRequired + options={{ + enforcedRepoTypeMessage: + repoType === RepoSpecType.RepoSpecTypeGit + ? t('Only Git repositories can be used for Git configurations.') + : t('Only HTTP repositories can be used for HTTP configurations.'), + }} /> {repoType === RepoSpecType.RepoSpecTypeGit && ( diff --git a/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/OutputImageStep.tsx b/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/OutputImageStep.tsx index a8e2cb0ba..d28c58761 100644 --- a/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/OutputImageStep.tsx +++ b/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/OutputImageStep.tsx @@ -74,6 +74,7 @@ const OutputImageStep = () => { isRequired options={{ writeAccessOnly: true, + enforcedRepoTypeMessage: t('Only OCI registries can be used for image builds.'), }} validateRepoSelection={writableRepoValidation} helperText={t('Storage repository for your completed image.')} diff --git a/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/SourceImageStep.tsx b/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/SourceImageStep.tsx index a1a968556..bc670e4bd 100644 --- a/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/SourceImageStep.tsx +++ b/libs/ui-components/src/components/ImageBuilds/CreateImageBuildWizard/steps/SourceImageStep.tsx @@ -58,6 +58,9 @@ const SourceImageStep = () => { canCreateRepo={canCreateRepo} repoRefetch={refetch} isRequired + options={{ + enforcedRepoTypeMessage: t('Only OCI registries can be used for image builds.'), + }} /> {baseImages.length ? ( diff --git a/libs/ui-components/src/components/Repository/CreateRepository/CreateRepositoryForm.tsx b/libs/ui-components/src/components/Repository/CreateRepository/CreateRepositoryForm.tsx index 3f4f2f708..2d671d452 100644 --- a/libs/ui-components/src/components/Repository/CreateRepository/CreateRepositoryForm.tsx +++ b/libs/ui-components/src/components/Repository/CreateRepository/CreateRepositoryForm.tsx @@ -16,6 +16,7 @@ import { ModalBody, ModalFooter, ModalHeader, + Popover, Split, SplitItem, } from '@patternfly/react-core'; @@ -23,7 +24,7 @@ import { import { FieldArray, Formik, useField, useFormikContext } from 'formik'; import * as Yup from 'yup'; import { Trans } from 'react-i18next'; -import { MinusCircleIcon, PlusCircleIcon } from '@patternfly/react-icons/dist/js/icons'; +import { MinusCircleIcon, OutlinedQuestionCircleIcon, PlusCircleIcon } from '@patternfly/react-icons/dist/js/icons'; import { useTranslation } from '../../../hooks/useTranslation'; import { useFetch } from '../../../hooks/useFetch'; @@ -32,6 +33,7 @@ import CreateResourceSyncsForm from './CreateResourceSyncsForm'; import { getInitValues, + getRepoTypeLabel, getRepository, getRepositoryPatches, getResourceSync, @@ -185,7 +187,13 @@ const AdvancedSection = () => { ); }; -const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => { +const RepositoryType = ({ + isEdit, + enforcedRepoTypeMessage, +}: { + isEdit?: boolean; + enforcedRepoTypeMessage?: string; +}) => { const { t } = useTranslation(); const { values, setFieldValue, validateForm } = useFormikContext(); const [showConfirmChangeType, setShowConfirmChangeType] = React.useState(); @@ -194,7 +202,26 @@ const RepositoryType = ({ isEdit }: { isEdit?: boolean }) => { return null; } - const isRepoTypeChangeDisabled = values.allowedRepoTypes?.length === 1; + // When we don't want to hide the repository type, but a single repoType can be chosen, we show a clarifying message. + const enforcedRepoType = values.allowedRepoTypes?.length === 1 ? values.allowedRepoTypes[0] : undefined; + if (enforcedRepoType) { + const repoTypeLabel = getRepoTypeLabel(t, enforcedRepoType); + return ( + + {repoTypeLabel} + {enforcedRepoTypeMessage && ( + + - - )} {helperText && } diff --git a/libs/ui-components/src/components/modals/CreateRepositoryModal/CreateRepositoryModal.tsx b/libs/ui-components/src/components/modals/CreateRepositoryModal/CreateRepositoryModal.tsx index e177d6f5a..d488dc598 100644 --- a/libs/ui-components/src/components/modals/CreateRepositoryModal/CreateRepositoryModal.tsx +++ b/libs/ui-components/src/components/modals/CreateRepositoryModal/CreateRepositoryModal.tsx @@ -11,6 +11,7 @@ type CreateRepositoryModalProps = { onSuccess: (repository: Repository) => void; options?: { writeAccessOnly?: boolean; + enforcedRepoTypeMessage?: string; }; }; @@ -26,6 +27,7 @@ const CreateRepositoryModal = ({ type, onClose, onSuccess, options }: CreateRepo options={{ canUseResourceSyncs: false, allowedRepoTypes: [type], + enforcedRepoTypeMessage: options?.enforcedRepoTypeMessage, writeAccessOnly: options?.writeAccessOnly, }} />