diff --git a/docs/features/software-templates/ui-options-examples.md b/docs/features/software-templates/ui-options-examples.md index bf8b2ef415..845da8e60b 100644 --- a/docs/features/software-templates/ui-options-examples.md +++ b/docs/features/software-templates/ui-options-examples.md @@ -488,8 +488,6 @@ repoUrl: host: github.com ``` -This value will be overridden if a different host is specified in a `RepoUrlPicker` field extension. - ### `excludedOwners` List of owners that should be excluded from autocompletion. diff --git a/docs/features/software-templates/writing-templates.md b/docs/features/software-templates/writing-templates.md index 681f5ae83c..5d9fcba603 100644 --- a/docs/features/software-templates/writing-templates.md +++ b/docs/features/software-templates/writing-templates.md @@ -570,12 +570,13 @@ Similar to the repository picker, there is a picker for owners to support autoco ui:field: RepoOwnerPicker ui:options: host: github.com + excludedOwners: + - backstage requestUserCredentials: secretsKey: USER_OAUTH_TOKEN ``` -Passing the `requestUserCredentials` and `host` properties is required for autocompletion to work. Only if the template contains a `RepoUrlPicker` field extension, `host` can be omitted as it will use the host specified in the field extension. -For more information regarding the `requestUserCredentials` object, please refer to the [Using the Users `oauth` token](#using-the-users-oauth-token) section under [The Repository Picker](#the-repository-picker). +Passing the `requestUserCredentials` and `host` properties is required for autocompletion to work. For more information regarding the `requestUserCredentials` object, please refer to the [Using the Users `oauth` token](#using-the-users-oauth-token) section under [The Repository Picker](#the-repository-picker). For a list of all possible `ui:options` input props for `RepoOwnerPicker`, please visit [here](./ui-options-examples.md#repoownerpicker). diff --git a/plugins/scaffolder/src/components/fields/RepoOwnerPicker/RepoOwnerPicker.tsx b/plugins/scaffolder/src/components/fields/RepoOwnerPicker/RepoOwnerPicker.tsx index f778ca6d43..bcb1a0001c 100644 --- a/plugins/scaffolder/src/components/fields/RepoOwnerPicker/RepoOwnerPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoOwnerPicker/RepoOwnerPicker.tsx @@ -35,19 +35,7 @@ import { GitHubRepoOwnerPicker } from './GitHubRepoOwnerPicker'; * @public */ export const RepoOwnerPicker = (props: RepoOwnerPickerProps) => { - const { - uiSchema, - onChange, - rawErrors, - formData, - schema, - formContext, - required, - } = props; - const { - formData: { repoUrl }, - } = formContext; - + const { uiSchema, onChange, rawErrors, formData, schema, required } = props; const [state, setState] = useState({ owner: formData || '', }); @@ -95,18 +83,11 @@ export const RepoOwnerPicker = (props: RepoOwnerPickerProps) => { ); useEffect(() => { - if (repoUrl) { - const url = new URL(`https://${repoUrl}`); - - setState(prevState => ({ - ...prevState, - host: url.host, - })); - } else if (uiSchema?.['ui:options']?.host) { - const hardcodedHost = uiSchema['ui:options'].host; - setState(prevState => ({ ...prevState, host: hardcodedHost })); + if (uiSchema?.['ui:options']?.host) { + const hostUiOption = uiSchema['ui:options'].host; + setState(prevState => ({ ...prevState, host: hostUiOption })); } - }, [repoUrl, uiSchema]); + }, [uiSchema]); useEffect(() => { onChange(owner);