Skip to content

Commit

Permalink
AMD-902 [frontend] fix: remove log and remove step alert
Browse files Browse the repository at this point in the history
  • Loading branch information
yp.wu authored and yp.wu committed Apr 16, 2024
1 parent e93a483 commit becf6c8
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
initDeploymentFrequencySettings,
updateShouldGetBoardConfig,
updateShouldGetPipelineConfig,
} from '@src/context/Metrics/metricsSlice';
import { updateShouldGetBoardConfig, updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { DateRangePickerSection } from '@src/containers/ConfigStep/DateRangePicker';
import { ERROR_DATE, TIME_RANGE_ERROR_MESSAGE } from '../../fixtures';
import { render, screen, within } from '@testing-library/react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
VERIFIED,
VERIFY,
} from '../../fixtures';
import { initDeploymentFrequencySettings, updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { AXIOS_REQUEST_ERROR_CODE, SOURCE_CONTROL_TYPES } from '@src/constants/resources';
import { sourceControlClient } from '@src/clients/sourceControl/SourceControlClient';
import { updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { SourceControl } from '@src/containers/ConfigStep/SourceControl';
import { setupStore } from '../../utils/setupStoreUtil';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import {
START_DATE_INVALID_TEXT,
END_DATE_INVALID_TEXT,
} from '@src/constants/resources';
import {
updateShouldGetBoardConfig,
updateShouldGetPipelineConfig,
} from '@src/context/Metrics/metricsSlice';
import { isDateDisabled, calculateLastAvailableDate } from '@src/containers/ConfigStep/DateRangePicker/validation';
import { updateShouldGetBoardConfig, updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { IRangePickerProps } from '@src/containers/ConfigStep/DateRangePicker/types';
import { selectDateRange, updateDateRange } from '@src/context/config/configSlice';
import { useAppDispatch, useAppSelector } from '@src/hooks/useAppDispatch';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/containers/ConfigStep/SourceControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
StyledTextField,
StyledTypeSelections,
} from '@src/components/Common/ConfigForms';
import { initDeploymentFrequencySettings, updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { useVerifySourceControlTokenEffect } from '@src/hooks/useVerifySourceControlTokenEffect';
import { CONFIG_TITLE, SOURCE_CONTROL_TYPES, TOKEN_HELPER_TEXT } from '@src/constants/resources';
import { updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice';
import { ConfigButtonGrop } from '@src/containers/ConfigStep/ConfigButton';
import { useAppDispatch, useAppSelector } from '@src/hooks/useAppDispatch';
import { InputLabel, ListItemText, MenuItem, Select } from '@mui/material';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
updateMetricsPipelineBranchFormMeta,
} from '@src/context/meta/metaSlice';
import { BranchSelectionWrapper } from '@src/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection/style';
import { selectPipelineCrews, selectPipelineList, selectSourceControl } from '@src/context/config/configSlice';
import BranchChip from '@src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/BranchChip';
import { selectPipelineList, selectSourceControl } from '@src/context/config/configSlice';
import { SOURCE_CONTROL_BRANCH_INVALID_TEXT } from '@src/constants/resources';
import { Autocomplete, Checkbox, TextField } from '@mui/material';
import React, { useCallback, useEffect, useMemo } from 'react';
Expand All @@ -30,9 +30,6 @@ export const BranchSelection = (props: BranchSelectionProps) => {
const formMeta = useAppSelector(getFormMeta);
const pipelineList = useAppSelector(selectPipelineList);
const sourceControlFields = useAppSelector(selectSourceControl);

const pipeCrews = useAppSelector(selectPipelineCrews);

const currentPipeline = useMemo(
() => pipelineList.find((pipeline) => pipeline.name === pipelineName && pipeline.orgName === organization),
[organization, pipelineList, pipelineName],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const PipelineMetricSelection = ({
isLoadingRef.current = isLoading;
}, [isLoading, setLoadingCompletedNumber, totalPipelineNumber, shouldGetPipelineConfig]);

const handleGetPipelineData = (_pipelineName: string) => {
const handleGetPipelineData = (_pipelineName: string, flag = false) => {
const { params, buildId, organizationId, pipelineType, token } = selectStepsParams(
store.getState(),
organization,
Expand All @@ -121,7 +121,7 @@ export const PipelineMetricSelection = ({
pipelineCrews,
}),
);
res?.haveStep && dispatch(updatePipelineStep({ steps, id, type, branches, pipelineCrews }));
res?.haveStep && dispatch(updatePipelineStep({ steps, id, type, branches, pipelineCrews, flag }));
dispatch(updateShouldGetPipelineConfig(false));
}
res && setIsShowNoStepWarning(!res.haveStep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface Props {
id: number;
isError?: boolean;
errorText?: string;
onGetSteps?: (pipelineName: string) => void;
onGetSteps?: (pipelineName: string, flag: boolean) => void;
onUpDatePipeline: (id: number, label: string, value: string | []) => void;
}

Expand All @@ -40,7 +40,7 @@ export const SingleSelection = ({
if (onGetSteps) {
onUpDatePipeline(id, 'Step', '');
onUpDatePipeline(id, 'Branches', []);
onGetSteps(value);
onGetSteps(value, true);
dispatch(initSinglePipelineListBranches(id));
}
onUpDatePipeline(id, label, value);
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/context/Metrics/metricsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,12 @@ export const metricsSlice = createSlice({
state.deploymentWarningMessage = getPipelinesWarningMessage(deploymentSettings);
},
updatePipelineStep: (state, action) => {
const { steps, id, branches, pipelineCrews } = action.payload;
const { steps, id, branches, pipelineCrews, flag } = action.payload;
const selectedPipelineStep = state.deploymentFrequencySettings.find((pipeline) => pipeline.id === id)?.step ?? '';

state.pipelineCrews = intersection(pipelineCrews, state.pipelineCrews);
const stepWarningMessage = (selectedStep: string) => (steps.includes(selectedStep) ? null : MESSAGE.STEP_WARNING);
const stepWarningMessage = (selectedStep: string) =>
steps.includes(selectedStep) || flag || selectedStep === '' ? null : MESSAGE.STEP_WARNING;

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

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/context/config/configSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { pipeline } from '@src/context/config/pipelineTool/verifyResponseSlice';
import { uniqPipelineListCrews, updateResponseCrews } from '@src/utils/util';
import { createSlice } from '@reduxjs/toolkit';
import type { RootState } from '@src/store';
import { isArray, uniq } from 'lodash';
import merge from 'lodash/merge';
import { isArray } from 'lodash';
import dayjs from 'dayjs';

export type TDateRange = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ICycleTimeSetting, IPipelineConfig } from '@src/context/Metrics/metrics
import { ITargetFieldType } from '@src/components/Common/MultiAutoComplete/styles';
import { pipeline } from '@src/context/config/pipelineTool/verifyResponseSlice';
import { DATE_FORMAT_TEMPLATE } from '@src/constants/template';
import { includes, isEqual, sortBy, uniq } from 'lodash';
import { TDateRange } from '@src/context/config/configSlice';
import { includes, isEqual, sortBy, uniq } from 'lodash';

import duration from 'dayjs/plugin/duration';
import dayjs from 'dayjs';
Expand Down

0 comments on commit becf6c8

Please sign in to comment.