Skip to content

Commit

Permalink
Merge branch 'main' into ADM-813
Browse files Browse the repository at this point in the history
  • Loading branch information
TingyuDong authored Feb 26, 2024
2 parents 9bb9cdd + 64b96df commit 723f3c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/src/context/Metrics/metricsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ const findKeyByValues = (arrayA: { [key: string]: string }[], arrayB: string[]):
const setSelectUsers = (users: string[], importedCrews: string[]) =>
users.filter((item: string) => importedCrews?.includes(item));

const setPipelineCrews = (pipelineCrews: string[], importedPipelineCrews: string[]) => {
const setPipelineCrews = (isProjectCreated: boolean, pipelineCrews: string[], importedPipelineCrews: string[]) => {
if (_.isEmpty(pipelineCrews)) {
return [];
}
if (isProjectCreated) {
return pipelineCrews;
}
return pipelineCrews.filter((item: string) => importedPipelineCrews?.includes(item));
};

Expand Down Expand Up @@ -354,7 +357,8 @@ export const metricsSlice = createSlice({
updatePipelineSettings: (state, action) => {
const { pipelineList, isProjectCreated, pipelineCrews } = action.payload;
const { importedDeployment, importedPipelineCrews } = state.importedData;
state.pipelineCrews = isProjectCreated ? pipelineCrews : setPipelineCrews(pipelineCrews, importedPipelineCrews);

state.pipelineCrews = setPipelineCrews(isProjectCreated, pipelineCrews, importedPipelineCrews);
const orgNames: Array<string> = _.uniq(pipelineList.map((item: pipeline) => item.orgName));
const filteredPipelineNames = (organization: string) =>
pipelineList
Expand Down Expand Up @@ -407,8 +411,7 @@ export const metricsSlice = createSlice({
const updatedImportedPipelineStep = importedDeployment.find((pipeline) => pipeline.id === id)?.step ?? '';
const updatedImportedPipelineBranches = importedDeployment.find((pipeline) => pipeline.id === id)?.branches ?? [];
const selectedPipelineStep = state.deploymentFrequencySettings.find((pipeline) => pipeline.id === id)?.step ?? '';
const validPipelineCrews = _.filter(pipelineCrews, (crew) => importedPipelineCrews.includes(crew));
state.pipelineCrews = validPipelineCrews;
state.pipelineCrews = _.filter(pipelineCrews, (crew) => importedPipelineCrews.includes(crew));
const stepWarningMessage = (selectedStep: string) => (steps.includes(selectedStep) ? null : MESSAGE.STEP_WARNING);

const validStep = (selectedStep: string): string => (steps.includes(selectedStep) ? selectedStep : '');
Expand Down

0 comments on commit 723f3c5

Please sign in to comment.