Merge pull request #12471 from boschresearch/fix/default-value-allowed-fields

set default owner/repo when more than 1 allowed values defined
This commit is contained in:
Patrik Oldsberg
2022-07-07 13:22:45 +02:00
committed by GitHub
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Fixed that adding more than one `allowedOwner` or `allowedRepo` in the template config will now still set the first value as default in the initial form state of `RepoUrlPicker`.
@@ -89,12 +89,12 @@ export const RepoUrlPicker = (
/* we deal with calling the repo setting here instead of in each components for ease */
useEffect(() => {
if (allowedOwners.length === 1) {
if (allowedOwners.length > 0) {
setState(prevState => ({ ...prevState, owner: allowedOwners[0] }));
}
}, [setState, allowedOwners]);
useEffect(() => {
if (allowedRepos.length === 1) {
if (allowedRepos.length > 0) {
setState(prevState => ({ ...prevState, repoName: allowedRepos[0] }));
}
}, [setState, allowedRepos]);