diff --git a/.changeset/generic-catalog-import-descriptions.md b/.changeset/generic-catalog-import-descriptions.md new file mode 100644 index 0000000000000..8f28ce4afdab7 --- /dev/null +++ b/.changeset/generic-catalog-import-descriptions.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-import': patch +--- + +Add more generic descriptions for the catalog-import form. diff --git a/plugins/catalog-import/src/components/ImportComponentForm.tsx b/plugins/catalog-import/src/components/ImportComponentForm.tsx index b6070c47939c3..7434f07b1012d 100644 --- a/plugins/catalog-import/src/components/ImportComponentForm.tsx +++ b/plugins/catalog-import/src/components/ImportComponentForm.tsx @@ -46,9 +46,14 @@ const useStyles = makeStyles(theme => ({ type Props = { nextStep: () => void; saveConfig: (configFile: ConfigSpec) => void; + repository: string; }; -export const RegisterComponentForm = ({ nextStep, saveConfig }: Props) => { +export const RegisterComponentForm = ({ + nextStep, + saveConfig, + repository, +}: Props) => { const { register, handleSubmit, errors, formState } = useForm({ mode: 'onChange', }); @@ -103,7 +108,7 @@ export const RegisterComponentForm = ({ nextStep, saveConfig }: Props) => { name="componentLocation" required margin="normal" - helperText="Enter the full path to the repository in GitHub to start tracking your component." + helperText={`Enter the full path to the repository in ${repository} to start tracking your component.`} inputRef={register({ required: true, validate: ComponentIdValidators, diff --git a/plugins/catalog-import/src/components/ImportComponentPage.tsx b/plugins/catalog-import/src/components/ImportComponentPage.tsx index 303c70cc7fa7c..7e0d0ff92e8ea 100644 --- a/plugins/catalog-import/src/components/ImportComponentPage.tsx +++ b/plugins/catalog-import/src/components/ImportComponentPage.tsx @@ -24,6 +24,9 @@ import { SupportButton, ContentHeader, RouteRef, + useApi, + configApiRef, + ConfigApi, } from '@backstage/core'; import { RegisterComponentForm } from './ImportComponentForm'; import ImportStepper from './ImportStepper'; @@ -37,6 +40,28 @@ export type ConfigSpec = { config: PartialEntity[]; }; +function manifestGenerationAvailable(configApi: ConfigApi): boolean { + return configApi.has('integrations.github'); +} + +function repositories(configApi: ConfigApi): string[] { + const integrations = configApi.getConfig('integrations'); + const repositories = []; + if (integrations.has('github')) { + repositories.push('GitHub'); + } + if (integrations.has('bitbucket')) { + repositories.push('Bitbucket'); + } + if (integrations.has('gitlab')) { + repositories.push('GitLab'); + } + if (integrations.has('azure')) { + repositories.push('Azure'); + } + return repositories; +} + export const ImportComponentPage = ({ catalogRouteRef, }: { @@ -53,13 +78,17 @@ export const ImportComponentPage = ({ setActiveStep(step => (options?.reset ? 0 : step + 1)); }; + const configApi = useApi(configApiRef); + const appTitle = configApi.getOptional('app.title') || 'Backstage'; + const repos = repositories(configApi); + const repositoryString = repos.join(', ').replace(/, (\w*)$/, ' or $1'); return (
- + - Start tracking your component in Backstage by adding it to the + Start tracking your component in {appTitle} by adding it to the software catalog. @@ -73,21 +102,28 @@ export const ImportComponentPage = ({ }} > - There are two ways to register an existing component. - - GitHub Repo - - If you already have code in a GitHub repository, enter the full - URL to your repo and a new pull request with a sample Backstage - metadata Entity File (catalog-info.yaml) will be - opened for you. + Ways to register an existing component + + {manifestGenerationAvailable(configApi) && ( + + GitHub Repo + + If you already have code in a GitHub repository, enter the + full URL to your repo and a new pull request with a sample + Backstage metadata Entity File ( + catalog-info.yaml) will be opened for you. + + + )} - GitHub Repo & Entity File + {repos.length === 1 ? `${repos[0]} ` : ''} Repository & + Entity File - If you've already created a Backstage metadata file and put it - in your repo, you can enter the full URL to that Entity File. + If you've already created a {appTitle} metadata file and put it + in your {repositoryString} repository, you can enter the full + URL to that Entity File. @@ -96,11 +132,14 @@ export const ImportComponentPage = ({ ), },