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:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user