-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist schedule prompt on launch fields when editing (#14736)
* persist schedule prompt on launch fields when editing * Merge job template default credentials with schedule overrides in schedule prompt * rename vars for clarity * handle undefined defaultCredentials --------- Co-authored-by: Michael Abashian <mabashia@redhat.com>
1 parent
19dff9c
commit 2529fdc
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
awx/ui/src/components/Schedule/shared/mergeArraysByCredentialType.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default function mergeArraysByCredentialType( | ||
defaultCredentials = [], | ||
overrides = [] | ||
) { | ||
const mergedArray = [...defaultCredentials]; | ||
|
||
overrides.forEach((override) => { | ||
const index = mergedArray.findIndex( | ||
(defaultCred) => defaultCred.credential_type === override.credential_type | ||
); | ||
if (index !== -1) { | ||
mergedArray.splice(index, 1); | ||
} | ||
mergedArray.push(override); | ||
}); | ||
|
||
return mergedArray; | ||
} |