From a3bc003dc2fcedbb3c8901354ccbeebb7029ff91 Mon Sep 17 00:00:00 2001 From: guzhongren Date: Sun, 2 Jun 2024 23:23:26 +0800 Subject: [PATCH] Enum optmization (#1476)[frontend] * pref(script): update scirpt of tset * pref(enum): update enum * pref(enum): update enum * pref(enum): update enum * pref(enum): update enum * pref(enum): update enum * pref(enum): update enum AxiosRequestErrorCode * pref(enum): update enum SortingDateRangeText * pref(enum): update enum CycleTimeMetricsName --- frontend/__tests__/client/BoardClient.test.ts | 24 +- frontend/__tests__/client/CSVClient.test.ts | 6 +- .../__tests__/client/HeaderClient.test.ts | 6 +- .../__tests__/client/MetricsClient.test.ts | 10 +- .../__tests__/client/ReportClient.test.ts | 14 +- .../Common/ReportForTwoColumns.test.tsx | 12 +- .../ErrorNotification.test.tsx | 6 +- .../containers/ConfigStep/Board.test.tsx | 16 +- .../containers/ConfigStep/ConfigStep.test.tsx | 8 +- .../containers/ConfigStep/FormAlert.test.tsx | 6 +- .../ConfigStep/PipelineTool.test.tsx | 12 +- .../ConfigStep/SourceControl.test.tsx | 16 +- .../containers/MetricsStep/CycleTime.test.tsx | 6 +- .../PipelineMetricSelection.test.tsx | 4 +- ...icSelectionPopupTestPartialFailed.test.tsx | 12 +- .../MetricsStep/MetricsStep.test.tsx | 4 +- ...MetricsStepPopupTestPartialFailed.test.tsx | 8 +- .../ReportStep/ChartAndTitleWrapper.test.tsx | 20 +- .../__tests__/context/metricsSlice.test.ts | 30 +-- frontend/__tests__/fixtures.ts | 40 ++-- .../hooks/useGenerateReportEffect.test.tsx | 28 +-- .../__tests__/hooks/useGetBoardInfo.test.tsx | 4 +- .../hooks/useGetMetricsStepsEffect.test.tsx | 10 +- .../hooks/useVerifyBoardEffect.test.tsx | 4 +- .../useVerifyPipelineToolEffect.test.tsx | 4 +- ...useVerifySourceControlTokenEffect.test.tsx | 4 +- frontend/__tests__/initialConfigState.ts | 4 +- frontend/__tests__/updatedConfigState.ts | 4 +- frontend/__tests__/utils/Util.test.tsx | 40 ++-- frontend/package.json | 8 +- frontend/src/clients/HttpClient.ts | 8 +- frontend/src/clients/report/dto/request.ts | 4 +- .../src/clients/sourceControl/dto/request.ts | 6 +- .../Common/ReportForThreeColumns/index.tsx | 4 +- .../Common/ReportForTwoColumns/index.tsx | 10 +- .../src/components/ErrorContent/index.tsx | 4 +- frontend/src/components/HomeGuide/index.tsx | 12 +- .../PresentationForErrorCases/index.tsx | 4 +- frontend/src/constants/commons.ts | 40 ++-- frontend/src/constants/resources.ts | 206 +++++++++--------- frontend/src/constants/router.ts | 8 +- .../BasicInfo/RequiredMetrics/index.tsx | 4 +- .../src/containers/ConfigStep/Board/index.tsx | 6 +- .../DateRangePicker/SortingDateRange.tsx | 4 +- .../containers/ConfigStep/FormAlert/index.tsx | 8 +- .../ConfigStep/PipelineTool/index.tsx | 26 +-- .../ConfigStep/SourceControl/index.tsx | 28 +-- .../MetricsStep/CycleTime/Table/index.tsx | 8 +- .../BranchSelection/BranchChip/index.tsx | 6 +- .../PipelineMetricSelection/index.tsx | 8 +- .../DeploymentFrequencySettings/index.tsx | 4 +- frontend/src/containers/MetricsStep/index.tsx | 46 ++-- .../src/containers/MetricsStepper/index.tsx | 28 +-- .../containers/ReportButtonGroup/index.tsx | 26 +-- .../ReportStep/BoardMetrics/index.tsx | 36 +-- .../ReportStep/BoardMetricsChart/index.tsx | 10 +- .../ReportStep/ChartAndTitleWrapper/index.tsx | 22 +- .../ReportStep/ChartAndTitleWrapper/style.tsx | 2 +- .../ReportStep/DoraMetrics/index.tsx | 34 +-- .../ReportStep/DoraMetricsChart/index.tsx | 32 +-- .../ReportStep/ReportDetail/board.tsx | 12 +- .../ReportStep/ReportDetail/dora.tsx | 10 +- frontend/src/containers/ReportStep/index.tsx | 20 +- frontend/src/context/Metrics/metricsSlice.ts | 10 +- frontend/src/context/config/configSlice.ts | 26 +-- .../sourceControl/sourceControlSlice.ts | 4 +- frontend/src/hooks/reportMapper/cycleTime.ts | 12 +- frontend/src/hooks/reportMapper/velocity.ts | 8 +- frontend/src/hooks/useGenerateReportEffect.ts | 24 +- frontend/src/hooks/useGetBoardInfo.ts | 40 ++-- .../src/hooks/useGetMetricsStepsEffect.ts | 12 +- frontend/src/hooks/useVerifyBoardEffect.ts | 16 +- .../src/hooks/useVerifyPipelineToolEffect.ts | 18 +- .../useVerifySourceControlTokenEffect.ts | 16 +- frontend/src/utils/util.ts | 36 +-- 75 files changed, 636 insertions(+), 642 deletions(-) diff --git a/frontend/__tests__/client/BoardClient.test.ts b/frontend/__tests__/client/BoardClient.test.ts index 889c4586ef..2f26128b13 100644 --- a/frontend/__tests__/client/BoardClient.test.ts +++ b/frontend/__tests__/client/BoardClient.test.ts @@ -2,8 +2,8 @@ import { MOCK_BOARD_URL_FOR_JIRA, MOCK_BOARD_VERIFY_REQUEST_PARAMS, MOCK_JIRA_BOARD_VERIFY_REQUEST_PARAMS, - VERIFY_ERROR_MESSAGE, - AXIOS_ERROR_MESSAGE, + VerifyErrorMessage, + AxiosErrorMessage, } from '../fixtures'; import { boardClient } from '@src/clients/board/BoardClient'; import { http, HttpResponse } from 'msw'; @@ -54,7 +54,7 @@ describe('verify board request', () => { http.post(MOCK_BOARD_URL_FOR_JIRA, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.BAD_REQUEST, + hintInfo: VerifyErrorMessage.BadRequest, }), { status: HttpStatusCode.BadRequest, @@ -65,7 +65,7 @@ describe('verify board request', () => { boardClient.getVerifyBoard(MOCK_BOARD_VERIFY_REQUEST_PARAMS).catch((e) => { expect(e).toBeInstanceOf(Error); - expect((e as Error).message).toMatch(VERIFY_ERROR_MESSAGE.BAD_REQUEST); + expect((e as Error).message).toMatch(VerifyErrorMessage.BadRequest); }); }); @@ -74,7 +74,7 @@ describe('verify board request', () => { http.post(MOCK_BOARD_URL_FOR_JIRA, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.UNAUTHORIZED, + hintInfo: VerifyErrorMessage.Unauthorized, }), { status: HttpStatusCode.Unauthorized, @@ -85,7 +85,7 @@ describe('verify board request', () => { await expect(async () => { await boardClient.getVerifyBoard(MOCK_BOARD_VERIFY_REQUEST_PARAMS); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.UNAUTHORIZED); + }).rejects.toThrow(VerifyErrorMessage.Unauthorized); }); it('should throw error when board verify response status 500', async () => { @@ -93,7 +93,7 @@ describe('verify board request', () => { http.post(MOCK_BOARD_URL_FOR_JIRA, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR, + hintInfo: VerifyErrorMessage.InternalServerError, }), { status: HttpStatusCode.InternalServerError, @@ -104,7 +104,7 @@ describe('verify board request', () => { await expect(async () => { await boardClient.getVerifyBoard(MOCK_BOARD_VERIFY_REQUEST_PARAMS); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR); + }).rejects.toThrow(VerifyErrorMessage.InternalServerError); }); it('should throw error when board verify response status 503', async () => { @@ -112,7 +112,7 @@ describe('verify board request', () => { http.post(MOCK_BOARD_URL_FOR_JIRA, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.REQUEST_TIMEOUT, + hintInfo: VerifyErrorMessage.RequestTimeout, }), { status: HttpStatusCode.ServiceUnavailable, @@ -123,7 +123,7 @@ describe('verify board request', () => { await expect(async () => { await boardClient.getVerifyBoard(MOCK_BOARD_VERIFY_REQUEST_PARAMS); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.REQUEST_TIMEOUT); + }).rejects.toThrow(VerifyErrorMessage.RequestTimeout); }); it('should throw error when board verify response status 300', async () => { @@ -137,7 +137,7 @@ describe('verify board request', () => { await expect(async () => { await boardClient.getVerifyBoard(MOCK_BOARD_VERIFY_REQUEST_PARAMS); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.UNKNOWN); + }).rejects.toThrow(VerifyErrorMessage.Unknown); }); it('should throw `Network Error` when board verify encountered netwrok error', async () => { @@ -149,6 +149,6 @@ describe('verify board request', () => { await expect(async () => { await boardClient.getVerifyBoard(MOCK_BOARD_VERIFY_REQUEST_PARAMS); - }).rejects.toThrow(AXIOS_ERROR_MESSAGE.ERR_NETWORK); + }).rejects.toThrow(AxiosErrorMessage.ErrorNetwork); }); }); diff --git a/frontend/__tests__/client/CSVClient.test.ts b/frontend/__tests__/client/CSVClient.test.ts index cd1c21f25f..6e0a01fb75 100644 --- a/frontend/__tests__/client/CSVClient.test.ts +++ b/frontend/__tests__/client/CSVClient.test.ts @@ -1,4 +1,4 @@ -import { MOCK_EXPORT_CSV_REQUEST_PARAMS, MOCK_EXPORT_CSV_URL, VERIFY_ERROR_MESSAGE } from '../fixtures'; +import { MOCK_EXPORT_CSV_REQUEST_PARAMS, MOCK_EXPORT_CSV_URL, VerifyErrorMessage } from '../fixtures'; import { csvClient } from '@src/clients/report/CSVClient'; import { http, HttpResponse } from 'msw'; import { setupServer } from 'msw/node'; @@ -40,13 +40,13 @@ describe('verify export csv', () => { http.get(MOCK_EXPORT_CSV_URL, () => { return new HttpResponse(null, { status: HttpStatusCode.InternalServerError, - statusText: VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR, + statusText: VerifyErrorMessage.InternalServerError, }); }), ); await expect(async () => { await csvClient.exportCSVData(MOCK_EXPORT_CSV_REQUEST_PARAMS); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR); + }).rejects.toThrow(VerifyErrorMessage.InternalServerError); }); }); diff --git a/frontend/__tests__/client/HeaderClient.test.ts b/frontend/__tests__/client/HeaderClient.test.ts index 1cde59b5b2..07deb7cc9f 100644 --- a/frontend/__tests__/client/HeaderClient.test.ts +++ b/frontend/__tests__/client/HeaderClient.test.ts @@ -1,4 +1,4 @@ -import { MOCK_VERSION_URL, VERIFY_ERROR_MESSAGE, VERSION_RESPONSE } from '../fixtures'; +import { MOCK_VERSION_URL, VerifyErrorMessage, VERSION_RESPONSE } from '../fixtures'; import { headerClient } from '@src/clients/header/HeaderClient'; import { HttpResponse, http } from 'msw'; import { setupServer } from 'msw/node'; @@ -35,7 +35,7 @@ describe('header client', () => { http.get(MOCK_VERSION_URL, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR, + hintInfo: VerifyErrorMessage.InternalServerError, }), { status: HttpStatusCode.InternalServerError, @@ -46,6 +46,6 @@ describe('header client', () => { expect(async () => { await headerClient.getVersion(); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR); + }).rejects.toThrow(VerifyErrorMessage.InternalServerError); }); }); diff --git a/frontend/__tests__/client/MetricsClient.test.ts b/frontend/__tests__/client/MetricsClient.test.ts index 7f32e8160b..584e7db9a6 100644 --- a/frontend/__tests__/client/MetricsClient.test.ts +++ b/frontend/__tests__/client/MetricsClient.test.ts @@ -1,4 +1,4 @@ -import { BASE_URL, MOCK_GET_STEPS_PARAMS, VERIFY_ERROR_MESSAGE } from '../fixtures'; +import { BASE_URL, MOCK_GET_STEPS_PARAMS, VerifyErrorMessage } from '../fixtures'; import { metricsClient } from '@src/clients/MetricsClient'; import { HttpResponse, http } from 'msw'; import { setupServer } from 'msw/node'; @@ -28,7 +28,7 @@ describe('get steps from metrics response', () => { it('should throw error when getSteps response status 500', async () => { server.use( http.get(getStepsUrl, () => { - return new HttpResponse(JSON.stringify({ hintInfo: VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR }), { + return new HttpResponse(JSON.stringify({ hintInfo: VerifyErrorMessage.InternalServerError }), { status: HttpStatusCode.InternalServerError, }); }), @@ -36,13 +36,13 @@ describe('get steps from metrics response', () => { await expect(async () => { await metricsClient.getSteps(params[0], buildId, organizationId, pipelineType, token); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR); + }).rejects.toThrow(VerifyErrorMessage.InternalServerError); }); it('should throw error when getSteps response status 400', async () => { server.use( http.get(getStepsUrl, () => { - return new HttpResponse(JSON.stringify({ hintInfo: VERIFY_ERROR_MESSAGE.BAD_REQUEST }), { + return new HttpResponse(JSON.stringify({ hintInfo: VerifyErrorMessage.BadRequest }), { status: HttpStatusCode.BadRequest, }); }), @@ -50,7 +50,7 @@ describe('get steps from metrics response', () => { await expect(async () => { await metricsClient.getSteps(params[0], buildId, organizationId, pipelineType, token); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.BAD_REQUEST); + }).rejects.toThrow(VerifyErrorMessage.BadRequest); }); it('should show isNoStep True when getSteps response status 204', async () => { diff --git a/frontend/__tests__/client/ReportClient.test.ts b/frontend/__tests__/client/ReportClient.test.ts index 9eb557e28a..7f8aa491ee 100644 --- a/frontend/__tests__/client/ReportClient.test.ts +++ b/frontend/__tests__/client/ReportClient.test.ts @@ -2,7 +2,7 @@ import { MOCK_GENERATE_REPORT_REQUEST_PARAMS, MOCK_REPORT_RESPONSE, MOCK_RETRIEVE_REPORT_RESPONSE, - VERIFY_ERROR_MESSAGE, + VerifyErrorMessage, } from '../fixtures'; import { reportClient } from '@src/clients/report/ReportClient'; import { HttpResponse, http } from 'msw'; @@ -48,7 +48,7 @@ describe('report client', () => { http.post(MOCK_REPORT_URL, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR, + hintInfo: VerifyErrorMessage.InternalServerError, }), { status: HttpStatusCode.InternalServerError, @@ -59,7 +59,7 @@ describe('report client', () => { await expect(async () => { await reportClient.retrieveByUrl(MOCK_GENERATE_REPORT_REQUEST_PARAMS, '/reports'); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR); + }).rejects.toThrow(VerifyErrorMessage.InternalServerError); }); it('should throw error when generate report response status 400', async () => { @@ -67,7 +67,7 @@ describe('report client', () => { http.post(MOCK_REPORT_URL, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.BAD_REQUEST, + hintInfo: VerifyErrorMessage.BadRequest, }), { status: HttpStatusCode.BadRequest, @@ -78,7 +78,7 @@ describe('report client', () => { await expect(async () => { await reportClient.retrieveByUrl(MOCK_GENERATE_REPORT_REQUEST_PARAMS, '/reports'); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.BAD_REQUEST); + }).rejects.toThrow(VerifyErrorMessage.BadRequest); }); it('should throw error when calling pollingReport given response status 500', () => { @@ -86,7 +86,7 @@ describe('report client', () => { http.get(MOCK_REPORT_URL, () => { return new HttpResponse( JSON.stringify({ - hintInfo: VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR, + hintInfo: VerifyErrorMessage.InternalServerError, }), { status: HttpStatusCode.InternalServerError, @@ -97,7 +97,7 @@ describe('report client', () => { expect(async () => { await reportClient.polling(MOCK_REPORT_URL); - }).rejects.toThrow(VERIFY_ERROR_MESSAGE.INTERNAL_SERVER_ERROR); + }).rejects.toThrow(VerifyErrorMessage.InternalServerError); }); it('should return status and response when calling pollingReport given response status 201', async () => { diff --git a/frontend/__tests__/components/Common/ReportForTwoColumns.test.tsx b/frontend/__tests__/components/Common/ReportForTwoColumns.test.tsx index d11e268697..dcb2c12a5f 100644 --- a/frontend/__tests__/components/Common/ReportForTwoColumns.test.tsx +++ b/frontend/__tests__/components/Common/ReportForTwoColumns.test.tsx @@ -1,6 +1,6 @@ import ReportForTwoColumns from '@src/components/Common/ReportForTwoColumns'; import { CYCLE_TIME, DEPLOYMENT_FREQUENCY, VELOCITY } from '../../fixtures'; -import { REPORT_SUFFIX_UNITS } from '@src/constants/resources'; +import { ReportSuffixUnits } from '@src/constants/resources'; import { render, screen } from '@testing-library/react'; describe('Report for two columns', () => { @@ -18,9 +18,9 @@ describe('Report for two columns', () => { it('should show cycle time table row', () => { const mockData = [ - { id: 0, name: 'name1', valueList: [{ value: '1.1', units: REPORT_SUFFIX_UNITS.PER_CARD }] }, - { id: 1, name: 'name2', valueList: [{ value: '2', units: REPORT_SUFFIX_UNITS.PER_CARD }] }, - { id: 2, name:
name3
, valueList: [{ value: '3', units: REPORT_SUFFIX_UNITS.PER_CARD }] }, + { id: 0, name: 'name1', valueList: [{ value: '1.1', units: ReportSuffixUnits.DaysPerCard }] }, + { id: 1, name: 'name2', valueList: [{ value: '2', units: ReportSuffixUnits.DaysPerCard }] }, + { id: 2, name:
name3
, valueList: [{ value: '3', units: ReportSuffixUnits.DaysPerCard }] }, ]; render(); @@ -42,8 +42,8 @@ describe('Report for two columns', () => { it('should show table when data with Units is not empty', () => { const mockData = [ - { id: 0, name: 'name1', valueList: [{ value: 1, units: REPORT_SUFFIX_UNITS.PER_CARD }] }, - { id: 1, name: 'name2', valueList: [{ value: 2, units: REPORT_SUFFIX_UNITS.PER_CARD }] }, + { id: 0, name: 'name1', valueList: [{ value: 1, units: ReportSuffixUnits.DaysPerCard }] }, + { id: 1, name: 'name2', valueList: [{ value: 2, units: ReportSuffixUnits.DaysPerCard }] }, ]; render(); diff --git a/frontend/__tests__/components/ErrorNotification/ErrorNotification.test.tsx b/frontend/__tests__/components/ErrorNotification/ErrorNotification.test.tsx index 795fce98c4..e048da6767 100644 --- a/frontend/__tests__/components/ErrorNotification/ErrorNotification.test.tsx +++ b/frontend/__tests__/components/ErrorNotification/ErrorNotification.test.tsx @@ -1,13 +1,13 @@ import { ErrorNotification } from '@src/components/ErrorNotification'; -import { BOARD_TYPES, VERIFY_ERROR_MESSAGE } from '../../fixtures'; +import { BOARD_TYPES, VerifyErrorMessage } from '../../fixtures'; import { render } from '@testing-library/react'; describe('error notification', () => { it('should show error message when render error notification', () => { const { getByText } = render( - , + , ); - expect(getByText(`${BOARD_TYPES.JIRA} ${VERIFY_ERROR_MESSAGE.BAD_REQUEST}`)).toBeInTheDocument(); + expect(getByText(`${BOARD_TYPES.JIRA} ${VerifyErrorMessage.BadRequest}`)).toBeInTheDocument(); }); }); diff --git a/frontend/__tests__/containers/ConfigStep/Board.test.tsx b/frontend/__tests__/containers/ConfigStep/Board.test.tsx index fb2e73d5f1..fc307bd071 100644 --- a/frontend/__tests__/containers/ConfigStep/Board.test.tsx +++ b/frontend/__tests__/containers/ConfigStep/Board.test.tsx @@ -1,7 +1,7 @@ import { BOARD_FIELDS, BOARD_TYPES, - CONFIG_TITLE, + ConfigTitle, ERROR_MESSAGE_COLOR, MOCK_BOARD_URL_FOR_JIRA, RESET, @@ -15,8 +15,8 @@ import { import { boardConfigDefaultValues } from '@src/containers/ConfigStep/Form/useDefaultValues'; import { boardConfigSchema } from '@src/containers/ConfigStep/Form/schema'; import { render, screen, waitFor, within } from '@testing-library/react'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; import { UnauthorizedError } from '@src/errors/UnauthorizedError'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { boardClient } from '@src/clients/board/BoardClient'; import { Board } from '@src/containers/ConfigStep/Board'; import { setupStore } from '../../utils/setupStoreUtil'; @@ -82,7 +82,7 @@ describe('Board', () => { BOARD_FIELDS.map((field) => { expect(screen.getByLabelText(`${field} *`)).toBeInTheDocument(); }); - expect(screen.getAllByText(CONFIG_TITLE.BOARD)[0]).toBeInTheDocument(); + expect(screen.getAllByText(ConfigTitle.Board)[0]).toBeInTheDocument(); }); it('should show default value jira when init board component', () => { @@ -96,7 +96,7 @@ describe('Board', () => { it('should show detail options when click board field', async () => { setup(); - await userEvent.click(screen.getByRole('combobox', { name: CONFIG_TITLE.BOARD })); + await userEvent.click(screen.getByRole('combobox', { name: ConfigTitle.Board })); const listBox = within(screen.getByRole('listbox')); const options = listBox.getAllByRole('option'); const optionValue = options.map((li) => li.getAttribute('data-value')); @@ -106,7 +106,7 @@ describe('Board', () => { it('should show board type when select board field value ', async () => { setup(); - await userEvent.click(screen.getByRole('combobox', { name: CONFIG_TITLE.BOARD })); + await userEvent.click(screen.getByRole('combobox', { name: ConfigTitle.Board })); await waitFor(() => { expect(screen.getByRole('option', { name: /jira/i })).toBeInTheDocument(); @@ -181,7 +181,7 @@ describe('Board', () => { it('should hidden timeout alert when click reset button', async () => { const { getByLabelText, queryByLabelText } = setup(); await fillBoardFieldsInformation(); - const mockedError = new TimeoutError('', AXIOS_REQUEST_ERROR_CODE.TIMEOUT); + const mockedError = new TimeoutError('', AxiosRequestErrorCode.Timeout); boardClient.getVerifyBoard = jest.fn().mockImplementation(() => Promise.reject(mockedError)); await userEvent.click(screen.getByText(VERIFY)); @@ -196,7 +196,7 @@ describe('Board', () => { it('should hidden timeout alert when the error type of api call becomes other', async () => { const { getByLabelText, queryByLabelText } = setup(); await fillBoardFieldsInformation(); - const timeoutError = new TimeoutError('', AXIOS_REQUEST_ERROR_CODE.TIMEOUT); + const timeoutError = new TimeoutError('', AxiosRequestErrorCode.Timeout); boardClient.getVerifyBoard = jest.fn().mockImplementation(() => Promise.reject(timeoutError)); await userEvent.click(screen.getByText(VERIFY)); @@ -334,7 +334,7 @@ describe('Board', () => { it('should close alert modal when user manually close the alert', async () => { setup(); await fillBoardFieldsInformation(); - const timeoutError = new TimeoutError('', AXIOS_REQUEST_ERROR_CODE.TIMEOUT); + const timeoutError = new TimeoutError('', AxiosRequestErrorCode.Timeout); boardClient.getVerifyBoard = jest.fn().mockImplementation(() => Promise.reject(timeoutError)); await userEvent.click(screen.getByText(VERIFY)); diff --git a/frontend/__tests__/containers/ConfigStep/ConfigStep.test.tsx b/frontend/__tests__/containers/ConfigStep/ConfigStep.test.tsx index 3b25695ade..2baeb825fc 100644 --- a/frontend/__tests__/containers/ConfigStep/ConfigStep.test.tsx +++ b/frontend/__tests__/containers/ConfigStep/ConfigStep.test.tsx @@ -1,7 +1,7 @@ // TODO: refactor case, replace fireEvent use userEvent. @Kai Zhou import { CHINA_CALENDAR, - CONFIG_TITLE, + ConfigTitle, DEPLOYMENT_FREQUENCY, ERROR_MESSAGE_TIME_DURATION, FAKE_PIPELINE_TOKEN, @@ -214,7 +214,7 @@ describe('ConfigStep', () => { setup(); await waitFor(() => { - expect(screen.queryByText(CONFIG_TITLE.BOARD)).toBeNull(); + expect(screen.queryByText(ConfigTitle.Board)).toBeNull(); }); }); @@ -232,7 +232,7 @@ describe('ConfigStep', () => { await userEvent.click(requireDateSelection.getByRole('option', { name: /cycle time/i })); await waitFor(() => { - expect(screen.getAllByText(CONFIG_TITLE.BOARD)[0]).toBeInTheDocument(); + expect(screen.getAllByText(ConfigTitle.Board)[0]).toBeInTheDocument(); }); }); @@ -249,7 +249,7 @@ describe('ConfigStep', () => { await userEvent.click(requireDateSelection.getByRole('option', { name: 'Classification' })); await waitFor(() => { - expect(screen.getAllByText(CONFIG_TITLE.BOARD)[0]).toBeInTheDocument(); + expect(screen.getAllByText(ConfigTitle.Board)[0]).toBeInTheDocument(); }); }); diff --git a/frontend/__tests__/containers/ConfigStep/FormAlert.test.tsx b/frontend/__tests__/containers/ConfigStep/FormAlert.test.tsx index 0610851581..8567d01b98 100644 --- a/frontend/__tests__/containers/ConfigStep/FormAlert.test.tsx +++ b/frontend/__tests__/containers/ConfigStep/FormAlert.test.tsx @@ -13,7 +13,7 @@ describe('FormAlert', () => { }; it('should render board message given moduleType is board and timeout alert', () => { - const mockTimeoutAlertType = formAlertTypes.TIMEOUT; + const mockTimeoutAlertType = formAlertTypes.Timeout; setup(onCloseSpy, true, 'Board', mockTimeoutAlertType); const message = screen.getByText('Board'); @@ -21,7 +21,7 @@ describe('FormAlert', () => { }); it('should render board verify failed message given board verify alert', () => { - const mockBoardVerifyAlertType = formAlertTypes.BOARD_VERIFY; + const mockBoardVerifyAlertType = formAlertTypes.BoardVerify; setup(onCloseSpy, true, '', mockBoardVerifyAlertType); render(); const elements = screen.getAllByText('Email'); @@ -31,7 +31,7 @@ describe('FormAlert', () => { }); it('should close alert when click the close icon', async () => { - const mockTimeoutAlertType = formAlertTypes.TIMEOUT; + const mockTimeoutAlertType = formAlertTypes.Timeout; setup(onCloseSpy, true, 'any', mockTimeoutAlertType); const closeIcon = screen.getByTestId('CloseIcon'); diff --git a/frontend/__tests__/containers/ConfigStep/PipelineTool.test.tsx b/frontend/__tests__/containers/ConfigStep/PipelineTool.test.tsx index 9fc926f944..b1a52b524a 100644 --- a/frontend/__tests__/containers/ConfigStep/PipelineTool.test.tsx +++ b/frontend/__tests__/containers/ConfigStep/PipelineTool.test.tsx @@ -1,5 +1,5 @@ import { - CONFIG_TITLE, + ConfigTitle, ERROR_MESSAGE_COLOR, PIPELINE_TOOL_FIELDS, PIPELINE_TOOL_TYPES, @@ -18,7 +18,7 @@ import { pipelineToolClient } from '@src/clients/pipeline/PipelineToolClient'; import { pipelineToolSchema } from '@src/containers/ConfigStep/Form/schema'; import { render, screen, waitFor, within } from '@testing-library/react'; import { PipelineTool } from '@src/containers/ConfigStep/PipelineTool'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { setupStore } from '../../utils/setupStoreUtil'; import { FormProvider } from '@test/utils/FormProvider'; import { TimeoutError } from '@src/errors/TimeoutError'; @@ -76,7 +76,7 @@ describe('PipelineTool', () => { expect(screen.getByLabelText(`${field} *`)).toBeInTheDocument(); }); - expect(screen.getAllByText(CONFIG_TITLE.PIPELINE_TOOL)[0]).toBeInTheDocument(); + expect(screen.getAllByText(ConfigTitle.PipelineTool)[0]).toBeInTheDocument(); }); it('should show default value buildKite when init pipelineTool component', () => { @@ -106,7 +106,7 @@ describe('PipelineTool', () => { it('should hidden timeout alert when click reset button', async () => { setup(); await fillPipelineToolFieldsInformation(); - pipelineToolClient.verify = jest.fn().mockResolvedValue({ code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT }); + pipelineToolClient.verify = jest.fn().mockResolvedValue({ code: AxiosRequestErrorCode.Timeout }); await userEvent.click(screen.getByText(VERIFY)); @@ -120,7 +120,7 @@ describe('PipelineTool', () => { it('should hidden timeout alert when the error type of api call becomes other', async () => { setup(); await fillPipelineToolFieldsInformation(); - pipelineToolClient.verify = jest.fn().mockResolvedValue({ code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT }); + pipelineToolClient.verify = jest.fn().mockResolvedValue({ code: AxiosRequestErrorCode.Timeout }); await userEvent.click(screen.getByText(VERIFY)); @@ -254,7 +254,7 @@ describe('PipelineTool', () => { it('should close alert modal when user manually close the alert', async () => { setup(); await fillPipelineToolFieldsInformation(); - const timeoutError = new TimeoutError('', AXIOS_REQUEST_ERROR_CODE.TIMEOUT); + const timeoutError = new TimeoutError('', AxiosRequestErrorCode.Timeout); pipelineToolClient.verify = jest.fn().mockImplementation(() => Promise.resolve(timeoutError)); await userEvent.click(screen.getByText(VERIFY)); diff --git a/frontend/__tests__/containers/ConfigStep/SourceControl.test.tsx b/frontend/__tests__/containers/ConfigStep/SourceControl.test.tsx index ac28cb8691..b4f8f088a7 100644 --- a/frontend/__tests__/containers/ConfigStep/SourceControl.test.tsx +++ b/frontend/__tests__/containers/ConfigStep/SourceControl.test.tsx @@ -1,5 +1,5 @@ import { - CONFIG_TITLE, + ConfigTitle, ERROR_MESSAGE_COLOR, MOCK_SOURCE_CONTROL_VERIFY_ERROR_CASE_TEXT, MOCK_SOURCE_CONTROL_VERIFY_TOKEN_URL, @@ -11,8 +11,8 @@ import { VERIFY, } from '../../fixtures'; import { sourceControlDefaultValues } from '@src/containers/ConfigStep/Form/useDefaultValues'; -import { AXIOS_REQUEST_ERROR_CODE, SOURCE_CONTROL_TYPES } from '@src/constants/resources'; import { sourceControlClient } from '@src/clients/sourceControl/SourceControlClient'; +import { AxiosRequestErrorCode, SourceControlTypes } from '@src/constants/resources'; import { updateShouldGetPipelineConfig } from '@src/context/Metrics/metricsSlice'; import { sourceControlSchema } from '@src/containers/ConfigStep/Form/schema'; import { SourceControl } from '@src/containers/ConfigStep/SourceControl'; @@ -79,7 +79,7 @@ describe('SourceControl', () => { it('should show sourceControl title and fields when render sourceControl component', () => { setup(); - expect(screen.getAllByText(CONFIG_TITLE.SOURCE_CONTROL)[0]).toBeInTheDocument(); + expect(screen.getAllByText(ConfigTitle.SourceControl)[0]).toBeInTheDocument(); SOURCE_CONTROL_FIELDS.map((field) => { expect(screen.getByLabelText(`${field} *`)).toBeInTheDocument(); }); @@ -87,7 +87,7 @@ describe('SourceControl', () => { it('should show default value gitHub when init sourceControl component', () => { setup(); - const sourceControlType = screen.getByText(SOURCE_CONTROL_TYPES.GITHUB); + const sourceControlType = screen.getByText(SourceControlTypes.GitHub); expect(sourceControlType).toBeInTheDocument(); }); @@ -106,7 +106,7 @@ describe('SourceControl', () => { }); expect(tokenInput.value).toEqual(''); - expect(screen.getByText(SOURCE_CONTROL_TYPES.GITHUB)).toBeInTheDocument(); + expect(screen.getByText(SourceControlTypes.GitHub)).toBeInTheDocument(); expect(screen.queryByRole('button', { name: RESET })).not.toBeTruthy(); expect(screen.getByRole('button', { name: VERIFY })).toBeDisabled(); }); @@ -115,7 +115,7 @@ describe('SourceControl', () => { const { getByLabelText, queryByLabelText } = setup(); await fillSourceControlFieldsInformation(); sourceControlClient.verifyToken = jest.fn().mockResolvedValue({ - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, }); await userEvent.click(screen.getByText(VERIFY)); @@ -130,7 +130,7 @@ describe('SourceControl', () => { const { getByLabelText, queryByLabelText } = setup(); await fillSourceControlFieldsInformation(); sourceControlClient.verifyToken = jest.fn().mockResolvedValue({ - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, }); await userEvent.click(screen.getByText(VERIFY)); @@ -249,7 +249,7 @@ describe('SourceControl', () => { setup(); await fillSourceControlFieldsInformation(); sourceControlClient.verifyToken = jest.fn().mockResolvedValue({ - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, }); await userEvent.click(screen.getByText(VERIFY)); diff --git a/frontend/__tests__/containers/MetricsStep/CycleTime.test.tsx b/frontend/__tests__/containers/MetricsStep/CycleTime.test.tsx index 363e4cb1a0..9a3593954e 100644 --- a/frontend/__tests__/containers/MetricsStep/CycleTime.test.tsx +++ b/frontend/__tests__/containers/MetricsStep/CycleTime.test.tsx @@ -6,7 +6,7 @@ import { updateTreatFlagCardAsBlock, } from '@src/context/Metrics/metricsSlice'; import { BOARD_MAPPING, ERROR_MESSAGE_TIME_DURATION, LIST_OPEN, NO_RESULT_DASH } from '../../fixtures'; -import { CYCLE_TIME_SETTINGS_TYPES, MESSAGE, METRICS_CONSTANTS } from '@src/constants/resources'; +import { CycleTimeSettingsTypes, MESSAGE, METRICS_CONSTANTS } from '@src/constants/resources'; import { act, render, screen, waitFor, within } from '@testing-library/react'; import { CycleTime } from '@src/containers/MetricsStep/CycleTime'; import { setupStore } from '../../utils/setupStoreUtil'; @@ -321,7 +321,7 @@ describe('CycleTime', () => { await userEvent.click(screen.getByRole('radio', { name: cycleTimeTypeLabels[1] })); expect(mockedUseAppDispatch).toHaveBeenCalledTimes(4); - expect(mockedUseAppDispatch).toHaveBeenCalledWith(setCycleTimeSettingsType(CYCLE_TIME_SETTINGS_TYPES.BY_STATUS)); + expect(mockedUseAppDispatch).toHaveBeenCalledWith(setCycleTimeSettingsType(CycleTimeSettingsTypes.BY_STATUS)); expect(mockedUseAppDispatch).toHaveBeenCalledWith( updateCycleTimeSettings( cycleTimeSettings.map((item) => ({ @@ -408,7 +408,7 @@ describe('CycleTime', () => { }); }); - [CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN].forEach((cycleTimeSettingsType) => { + [CycleTimeSettingsTypes.BY_STATUS, CycleTimeSettingsTypes.BY_COLUMN].forEach((cycleTimeSettingsType) => { it('should show warning message given both mapping block column and add flag as block', () => { (selectMetricsContent as jest.Mock).mockReturnValue({ cycleTimeSettingsType, diff --git a/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection.test.tsx b/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection.test.tsx index ea2b3b4a45..088f603a43 100644 --- a/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection.test.tsx +++ b/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection.test.tsx @@ -5,7 +5,7 @@ import { MOCK_SOURCE_CONTROL_VERIFY_BRANCH_URL, ORGANIZATION, PIPELINE_NAME, - PIPELINE_SETTING_TYPES, + PipelineSettingTypes, REMOVE_BUTTON, STEP, } from '@test/fixtures'; @@ -107,7 +107,7 @@ describe('PipelineMetricSelection', () => { return render( ({ ...jest.requireActual('@src/context/notification/NotificationSlice'), @@ -47,7 +47,7 @@ describe('PipelineMetricSelection', () => { return render( { }); it('should show 4xx popup when call pipeline step to get partial 4xx error', async () => { - stepFailStatus = METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX; + stepFailStatus = MetricsDataFailStatus.PartialFailed4xx; await setup(deploymentFrequencySetting, true, false); await waitFor(() => { @@ -75,7 +75,7 @@ describe('PipelineMetricSelection', () => { }); it('should show timeout popup when call pipeline step to get partial timeout error', async () => { - stepFailStatus = METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT; + stepFailStatus = MetricsDataFailStatus.PartialFailedTimeout; await setup(deploymentFrequencySetting, true, false); await waitFor(() => { diff --git a/frontend/__tests__/containers/MetricsStep/MetricsStep.test.tsx b/frontend/__tests__/containers/MetricsStep/MetricsStep.test.tsx index 02de1c90cc..534628ed0e 100644 --- a/frontend/__tests__/containers/MetricsStep/MetricsStep.test.tsx +++ b/frontend/__tests__/containers/MetricsStep/MetricsStep.test.tsx @@ -30,7 +30,7 @@ import { import { updateJiraVerifyResponse, updateMetrics } from '@src/context/config/configSlice'; import { closeAllNotifications } from '@src/context/notification/NotificationSlice'; import { backStep, nextStep } from '@src/context/stepper/StepperSlice'; -import { CYCLE_TIME_SETTINGS_TYPES } from '@src/constants/resources'; +import { CycleTimeSettingsTypes } from '@src/constants/resources'; import userEvent from '@testing-library/user-event'; import { HttpStatusCode } from 'axios'; @@ -274,7 +274,7 @@ describe('MetricsStep', () => { }); it('should hide Real Done when cycleTime settings type is by status', async () => { - await store.dispatch(setCycleTimeSettingsType(CYCLE_TIME_SETTINGS_TYPES.BY_STATUS)); + await store.dispatch(setCycleTimeSettingsType(CycleTimeSettingsTypes.BY_STATUS)); const { queryByText } = setup(); expect(queryByText(REAL_DONE)).not.toBeInTheDocument(); diff --git a/frontend/__tests__/containers/MetricsStep/MetricsStepPopupTestPartialFailed.test.tsx b/frontend/__tests__/containers/MetricsStep/MetricsStepPopupTestPartialFailed.test.tsx index 4fd87aebd2..5501bc0c0a 100644 --- a/frontend/__tests__/containers/MetricsStep/MetricsStepPopupTestPartialFailed.test.tsx +++ b/frontend/__tests__/containers/MetricsStep/MetricsStepPopupTestPartialFailed.test.tsx @@ -4,7 +4,7 @@ import MetricsStep from '@src/containers/MetricsStep'; import { Provider } from 'react-redux'; import { addNotification } from '@src/context/notification/NotificationSlice'; -import { METRICS_DATA_FAIL_STATUS } from '@src/constants/commons'; +import { MetricsDataFailStatus } from '@src/constants/commons'; let store = setupStore(); const setup = () => @@ -19,7 +19,7 @@ jest.mock('@src/context/notification/NotificationSlice', () => ({ addNotification: jest.fn().mockReturnValue({ type: 'ADD_NEW_NOTIFICATION' }), })); -let boardInfoFailStatus = METRICS_DATA_FAIL_STATUS.NOT_FAILED; +let boardInfoFailStatus = MetricsDataFailStatus.NotFailed; jest.mock('@src/hooks/useGetBoardInfo', () => ({ ...jest.requireActual('@src/hooks/useGetBoardInfo'), @@ -41,7 +41,7 @@ describe('MetricsStep', () => { }); it('should show 4xx popup when call get partial 4xx error', async () => { - boardInfoFailStatus = METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX; + boardInfoFailStatus = MetricsDataFailStatus.PartialFailed4xx; setup(); await waitFor(() => { @@ -50,7 +50,7 @@ describe('MetricsStep', () => { }); it('should show no cards popup when call get partial no cards error', async () => { - boardInfoFailStatus = METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_NO_CARDS; + boardInfoFailStatus = MetricsDataFailStatus.PartialFailedNoCards; setup(); await waitFor(() => { diff --git a/frontend/__tests__/containers/ReportStep/ChartAndTitleWrapper.test.tsx b/frontend/__tests__/containers/ReportStep/ChartAndTitleWrapper.test.tsx index 9fffb5fdac..0190c01415 100644 --- a/frontend/__tests__/containers/ReportStep/ChartAndTitleWrapper.test.tsx +++ b/frontend/__tests__/containers/ReportStep/ChartAndTitleWrapper.test.tsx @@ -1,15 +1,15 @@ import ChartAndTitleWrapper from '@src/containers/ReportStep/ChartAndTitleWrapper'; -import { CHART_TYPE, TREND_ICON, TREND_TYPE } from '@src/constants/resources'; +import { ChartType, TrendIcon, TrendType } from '@src/constants/resources'; import { render, screen } from '@testing-library/react'; import { theme } from '@src/theme'; describe('ChartAndTitleWrapper', () => { it('should render green up icon given icon is set to up and better', () => { const testedTrendInfo = { - trendType: TREND_TYPE.BETTER, - icon: TREND_ICON.UP, + trendType: TrendType.Better, + icon: TrendIcon.Up, trendNumber: 0.83, - type: CHART_TYPE.VELOCITY, + type: ChartType.Velocity, }; render(); const icon = screen.getByTestId('TrendingUpSharpIcon'); @@ -20,10 +20,10 @@ describe('ChartAndTitleWrapper', () => { it('should render down icon given icon is set to down and worse', () => { const testedTrendInfo = { - trendType: TREND_TYPE.WORSE, - icon: TREND_ICON.DOWN, + trendType: TrendType.Worse, + icon: TrendIcon.Down, trendNumber: -0.83, - type: CHART_TYPE.VELOCITY, + type: ChartType.Velocity, }; render(); const icon = screen.getByTestId('TrendingDownSharpIcon'); @@ -34,10 +34,10 @@ describe('ChartAndTitleWrapper', () => { it('should show positive trend number even if the tend number is negative', () => { const testedTrendInfo = { - trendType: TREND_TYPE.WORSE, - icon: TREND_ICON.DOWN, + trendType: TrendType.Worse, + icon: TrendIcon.Down, trendNumber: -0.8372, - type: CHART_TYPE.VELOCITY, + type: ChartType.Velocity, }; render(); diff --git a/frontend/__tests__/context/metricsSlice.test.ts b/frontend/__tests__/context/metricsSlice.test.ts index 443f87d511..ebca16f781 100644 --- a/frontend/__tests__/context/metricsSlice.test.ts +++ b/frontend/__tests__/context/metricsSlice.test.ts @@ -42,9 +42,9 @@ import { CLASSIFICATION_WARNING_MESSAGE, DEFAULT_REWORK_SETTINGS, NO_RESULT_DASH, - PIPELINE_SETTING_TYPES, + PipelineSettingTypes, } from '../fixtures'; -import { ASSIGNEE_FILTER_TYPES, CYCLE_TIME_SETTINGS_TYPES, MESSAGE } from '@src/constants/resources'; +import { ASSIGNEE_FILTER_TYPES, CycleTimeSettingsTypes, MESSAGE } from '@src/constants/resources'; import { setupStore } from '../utils/setupStoreUtil'; import { store } from '@src/store'; @@ -57,7 +57,7 @@ const initState = { users: [], pipelineCrews: [], doneColumn: [], - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN, + cycleTimeSettingsType: CycleTimeSettingsTypes.BY_COLUMN, cycleTimeSettings: [], deploymentFrequencySettings: [], leadTimeForChanges: [{ id: 0, organization: '', pipelineName: '', step: '', branches: [] }], @@ -316,7 +316,7 @@ describe('saveMetricsSetting reducer', () => { const savedMetricsSetting = saveMetricsSettingReducer( { ...initState, - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, + cycleTimeSettingsType: CycleTimeSettingsTypes.BY_STATUS, importedData: { ...initState.importedData, importedCrews: ['User B', 'User C'], @@ -342,7 +342,7 @@ describe('saveMetricsSetting reducer', () => { const savedMetricsSetting = saveMetricsSettingReducer( { ...initState, - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, + cycleTimeSettingsType: CycleTimeSettingsTypes.BY_STATUS, importedData: { ...initState.importedData, importedCrews: ['User B', 'User C'], @@ -377,7 +377,7 @@ describe('saveMetricsSetting reducer', () => { const savedMetricsSetting = saveMetricsSettingReducer( { ...initState, - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, + cycleTimeSettingsType: CycleTimeSettingsTypes.BY_STATUS, importedData: { ...initState.importedData, importedCrews: ['User B', 'User C'], @@ -607,10 +607,10 @@ describe('saveMetricsSetting reducer', () => { it('should set cycle time setting type', () => { const setCycleTimeSettingsTypeResult = saveMetricsSettingReducer( initState, - setCycleTimeSettingsType(CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN), + setCycleTimeSettingsType(CycleTimeSettingsTypes.BY_COLUMN), ); - expect(setCycleTimeSettingsTypeResult.cycleTimeSettingsType).toBe(CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN); + expect(setCycleTimeSettingsTypeResult.cycleTimeSettingsType).toBe(CycleTimeSettingsTypes.BY_COLUMN); }); it('should update get board config info', () => { @@ -935,7 +935,7 @@ describe('saveMetricsSetting reducer', () => { steps: mockSteps, pipelineCrews: ['crew1'], branches: [], - type: PIPELINE_SETTING_TYPES.DEPLOYMENT_FREQUENCY_SETTINGS_TYPE, + type: PipelineSettingTypes.DeploymentFrequencySettingsType, expectedSettings: [ { id: 0, @@ -968,7 +968,7 @@ describe('saveMetricsSetting reducer', () => { steps: mockSteps, pipelineCrews: ['crew1'], branches: ['branch1'], - type: PIPELINE_SETTING_TYPES.DEPLOYMENT_FREQUENCY_SETTINGS_TYPE, + type: PipelineSettingTypes.DeploymentFrequencySettingsType, expectedSettings: [ { id: 0, @@ -1001,7 +1001,7 @@ describe('saveMetricsSetting reducer', () => { steps: mockSteps, pipelineCrews: ['crew1'], branches: ['branch1'], - type: PIPELINE_SETTING_TYPES.DEPLOYMENT_FREQUENCY_SETTINGS_TYPE, + type: PipelineSettingTypes.DeploymentFrequencySettingsType, expectedSettings: [ { id: 0, @@ -1039,7 +1039,7 @@ describe('saveMetricsSetting reducer', () => { steps: mockSteps, pipelineCrews: ['crew1'], branches: ['branch1'], - type: PIPELINE_SETTING_TYPES.DEPLOYMENT_FREQUENCY_SETTINGS_TYPE, + type: PipelineSettingTypes.DeploymentFrequencySettingsType, expectedSettings: [ { id: 0, @@ -1172,7 +1172,7 @@ describe('saveMetricsSetting reducer', () => { }, ); - it.each([CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN, CYCLE_TIME_SETTINGS_TYPES.BY_STATUS])( + it.each([CycleTimeSettingsTypes.BY_COLUMN, CycleTimeSettingsTypes.BY_STATUS])( 'should update cycle time settings correctly when reload metrics page', (cycleTimeSettingsType) => { const savedMetricsSetting = saveMetricsSettingReducer( @@ -1522,14 +1522,14 @@ describe('saveMetricsSetting reducer', () => { updatePipelineStep({ steps: mockSteps, id: 0, - type: PIPELINE_SETTING_TYPES.DEPLOYMENT_FREQUENCY_SETTINGS_TYPE, + type: PipelineSettingTypes.DeploymentFrequencySettingsType, }), ); await store.dispatch( updatePipelineStep({ steps: mockSteps, id: 1, - type: PIPELINE_SETTING_TYPES.DEPLOYMENT_FREQUENCY_SETTINGS_TYPE, + type: PipelineSettingTypes.DeploymentFrequencySettingsType, }), ); }); diff --git a/frontend/__tests__/fixtures.ts b/frontend/__tests__/fixtures.ts index 6f6ecb94ab..5021e0b57c 100644 --- a/frontend/__tests__/fixtures.ts +++ b/frontend/__tests__/fixtures.ts @@ -1,10 +1,10 @@ -import { DATA_LOADING_FAILED, DEFAULT_MESSAGE, SOURCE_CONTROL_TYPES } from '@src/constants/resources'; +import { DATA_LOADING_FAILED, DEFAULT_MESSAGE, SourceControlTypes } from '@src/constants/resources'; import { CSVReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request'; import { SortType } from '@src/containers/ConfigStep/DateRangePicker/types'; import { ReportResponseDTO } from '@src/clients/report/dto/response'; import { IReportInfo } from '@src/hooks/useGenerateReportEffect'; import { IStepsParams } from '@src/clients/MetricsClient'; -import { METRIC_TYPES } from '@src/constants/commons'; +import { MetricTypes } from '@src/constants/commons'; export const PROJECT_NAME = 'Heartbeat'; export const PROJECT_DESCRIPTION = @@ -100,10 +100,10 @@ export const PIPELINE_TOOL_TYPES = { BUILD_KITE: 'BuildKite', }; -export enum CONFIG_TITLE { - BOARD = 'Board', - PIPELINE_TOOL = 'Pipeline Tool', - SOURCE_CONTROL = 'Source Control', +export enum ConfigTitle { + Board = 'Board', + PipelineTool = 'Pipeline Tool', + SourceControl = 'Source Control', } export const BOARD_FIELDS = ['Board', 'Board Id', 'Email', 'Site', 'Token']; @@ -127,18 +127,18 @@ export const VERSION_RESPONSE = { version: '1.11', }; -export enum VERIFY_ERROR_MESSAGE { - BAD_REQUEST = 'Please reconfirm the input', - UNAUTHORIZED = 'Token is incorrect', - INTERNAL_SERVER_ERROR = 'Internal server error', - NOT_FOUND = 'Not found', - PERMISSION_DENIED = 'Permission denied', - REQUEST_TIMEOUT = 'Request Timeout', - UNKNOWN = 'Unknown', +export enum VerifyErrorMessage { + BadRequest = 'Please reconfirm the input', + Unauthorized = 'Token is incorrect', + InternalServerError = 'Internal server error', + NotFound = 'Not found', + PermissionDenied = 'Permission denied', + RequestTimeout = 'Request Timeout', + Unknown = 'Unknown', } -export enum AXIOS_ERROR_MESSAGE { - ERR_NETWORK = 'Network Error', +export enum AxiosErrorMessage { + ErrorNetwork = 'Network Error', } export const VERIFY_FAILED = 'verify failed'; @@ -174,7 +174,7 @@ export const MOCK_PIPELINE_VERIFY_REQUEST_PARAMS = { export const MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS = { token: 'mockToken', - type: SOURCE_CONTROL_TYPES.GITHUB, + type: SourceControlTypes.GitHub, }; export const MOCK_GENERATE_REPORT_REQUEST_PARAMS: ReportRequestDTO = { @@ -232,7 +232,7 @@ export const MOCK_GENERATE_REPORT_REQUEST_PARAMS: ReportRequestDTO = { excludedStates: [], }, }, - metricTypes: [METRIC_TYPES.BOARD, METRIC_TYPES.DORA], + metricTypes: [MetricTypes.Board, MetricTypes.DORA], }; export const IMPORTED_NEW_CONFIG_FIXTURE = { @@ -380,8 +380,8 @@ export const CLASSIFICATION_SETTING = 'Classification setting'; export const REAL_DONE = 'Real done setting'; export const DEPLOYMENT_FREQUENCY_SETTINGS = 'Pipeline settings'; -export enum PIPELINE_SETTING_TYPES { - DEPLOYMENT_FREQUENCY_SETTINGS_TYPE = 'DeploymentFrequencySettings', +export enum PipelineSettingTypes { + DeploymentFrequencySettingsType = 'DeploymentFrequencySettings', } export const CONFIRM_DIALOG_DESCRIPTION = 'All the filled data will be cleared. Continue to Home page?'; diff --git a/frontend/__tests__/hooks/useGenerateReportEffect.test.tsx b/frontend/__tests__/hooks/useGenerateReportEffect.test.tsx index 59474be55c..3fd04f8132 100644 --- a/frontend/__tests__/hooks/useGenerateReportEffect.test.tsx +++ b/frontend/__tests__/hooks/useGenerateReportEffect.test.tsx @@ -12,14 +12,14 @@ import { MOCK_RETRIEVE_REPORT_RESPONSE, MockedDateRanges, } from '../fixtures'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; import { updateDateRange } from '@src/context/config/configSlice'; import { act, renderHook, waitFor } from '@testing-library/react'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { reportClient } from '@src/clients/report/ReportClient'; import { setupStore } from '@test/utils/setupStoreUtil'; import { TimeoutError } from '@src/errors/TimeoutError'; import { UnknownError } from '@src/errors/UnknownError'; -import { METRIC_TYPES } from '@src/constants/commons'; +import { MetricTypes } from '@src/constants/commons'; import React, { ReactNode } from 'react'; import { Provider } from 'react-redux'; import { HttpStatusCode } from 'axios'; @@ -28,11 +28,11 @@ import resetAllMocks = jest.resetAllMocks; const MOCK_GENERATE_REPORT_REQUEST_PARAMS_WITH_BOARD_METRIC_TYPE = { ...MOCK_GENERATE_REPORT_REQUEST_PARAMS, - metricTypes: [METRIC_TYPES.BOARD], + metricTypes: [MetricTypes.Board], }; const MOCK_GENERATE_REPORT_REQUEST_PARAMS_WITH_DORA_METRIC_TYPE = { ...MOCK_GENERATE_REPORT_REQUEST_PARAMS, - metricTypes: [METRIC_TYPES.DORA], + metricTypes: [MetricTypes.DORA], }; let store = setupStore(); @@ -63,7 +63,7 @@ describe('use generate report effect', () => { it('should set "Data loading failed" for all board metrics when board data retrieval times out', async () => { reportClient.retrieveByUrl = jest .fn() - .mockRejectedValue(new TimeoutError('timeout error', AXIOS_REQUEST_ERROR_CODE.TIMEOUT)); + .mockRejectedValue(new TimeoutError('timeout error', AxiosRequestErrorCode.Timeout)); reportClient.polling = jest.fn(); const { result } = setup(); @@ -85,7 +85,7 @@ describe('use generate report effect', () => { it('should set "Data loading failed" for dora metrics when dora data retrieval times out', async () => { reportClient.retrieveByUrl = jest .fn() - .mockRejectedValueOnce(new TimeoutError('timeout error', AXIOS_REQUEST_ERROR_CODE.TIMEOUT)) + .mockRejectedValueOnce(new TimeoutError('timeout error', AxiosRequestErrorCode.Timeout)) .mockResolvedValueOnce(async () => MOCK_RETRIEVE_REPORT_RESPONSE); reportClient.polling = jest @@ -130,7 +130,7 @@ describe('use generate report effect', () => { status: HttpStatusCode.Ok, response: { ...MOCK_REPORT_RESPONSE, allMetricsCompleted: false }, }) - .mockRejectedValue(new TimeoutError('timeout error', AXIOS_REQUEST_ERROR_CODE.TIMEOUT)) + .mockRejectedValue(new TimeoutError('timeout error', AxiosRequestErrorCode.Timeout)) .mockReturnValueOnce({ status: HttpStatusCode.Ok, response: { ...MOCK_REPORT_RESPONSE, allMetricsCompleted: true }, @@ -148,10 +148,10 @@ describe('use generate report effect', () => { }); expect(reportClient.polling).toHaveBeenCalledTimes(3); - expect(result.current.reportInfos[0][TimeoutErrorKey[METRIC_TYPES.ALL] as keyof IReportError].message).toEqual( + expect(result.current.reportInfos[0][TimeoutErrorKey[MetricTypes.All] as keyof IReportError].message).toEqual( 'Data loading failed', ); - expect(result.current.reportInfos[0][TimeoutErrorKey[METRIC_TYPES.ALL] as keyof IReportError].shouldShow).toEqual( + expect(result.current.reportInfos[0][TimeoutErrorKey[MetricTypes.All] as keyof IReportError].shouldShow).toEqual( true, ); }); @@ -177,15 +177,15 @@ describe('use generate report effect', () => { it.each([ { params: MOCK_GENERATE_REPORT_REQUEST_PARAMS_WITH_BOARD_METRIC_TYPE, - errorKey: GeneralErrorKey[METRIC_TYPES.BOARD], + errorKey: GeneralErrorKey[MetricTypes.Board], }, { params: MOCK_GENERATE_REPORT_REQUEST_PARAMS_WITH_DORA_METRIC_TYPE, - errorKey: GeneralErrorKey[METRIC_TYPES.DORA], + errorKey: GeneralErrorKey[MetricTypes.DORA], }, { params: MOCK_GENERATE_REPORT_REQUEST_PARAMS, - errorKey: GeneralErrorKey[METRIC_TYPES.ALL], + errorKey: GeneralErrorKey[MetricTypes.All], }, ])('should set "Data loading failed" for board metric when request given UnknownException', async (_) => { reportClient.retrieveByUrl = jest.fn().mockRejectedValue(new UnknownError()); @@ -255,7 +255,7 @@ describe('use generate report effect', () => { reportClient.retrieveByUrl = jest.fn().mockImplementation(async () => MOCK_RETRIEVE_REPORT_RESPONSE); reportClient.polling = jest .fn() - .mockRejectedValue(new TimeoutError('timeout error', AXIOS_REQUEST_ERROR_CODE.TIMEOUT)); + .mockRejectedValue(new TimeoutError('timeout error', AxiosRequestErrorCode.Timeout)); const { result } = setup(); await act(async () => { await result.current.startToRequestData(MOCK_GENERATE_REPORT_REQUEST_PARAMS_WITH_BOARD_METRIC_TYPE); @@ -265,7 +265,7 @@ describe('use generate report effect', () => { await act(async () => { await result.current.closeReportInfosErrorStatus( MockedDateRanges[0].startDate, - TimeoutErrorKey[METRIC_TYPES.DORA], + TimeoutErrorKey[MetricTypes.DORA], ); }); expect(result.current.reportInfos[0].timeout4Dora.shouldShow).toEqual(false); diff --git a/frontend/__tests__/hooks/useGetBoardInfo.test.tsx b/frontend/__tests__/hooks/useGetBoardInfo.test.tsx index ff6ac62485..49ff9783e7 100644 --- a/frontend/__tests__/hooks/useGetBoardInfo.test.tsx +++ b/frontend/__tests__/hooks/useGetBoardInfo.test.tsx @@ -1,7 +1,7 @@ import { MOCK_BOARD_INFO_URL, FAKE_TOKEN, FAKE_DATE_EARLIER, FAKE_DATE_LATER } from '@test/fixtures'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; import { useGetBoardInfoEffect } from '@src/hooks/useGetBoardInfo'; import { renderHook, act, waitFor } from '@testing-library/react'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { setupStore } from '@test/utils/setupStoreUtil'; import React, { ReactNode } from 'react'; import { HttpResponse, http } from 'msw'; @@ -146,7 +146,7 @@ describe('use get board info', () => { http.post(MOCK_BOARD_INFO_URL, () => { return new HttpResponse( JSON.stringify({ - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, }), { status: HttpStatusCode.Unused, diff --git a/frontend/__tests__/hooks/useGetMetricsStepsEffect.test.tsx b/frontend/__tests__/hooks/useGetMetricsStepsEffect.test.tsx index 9cf13d518f..756100d165 100644 --- a/frontend/__tests__/hooks/useGetMetricsStepsEffect.test.tsx +++ b/frontend/__tests__/hooks/useGetMetricsStepsEffect.test.tsx @@ -1,7 +1,7 @@ import { useGetMetricsStepsEffect } from '@src/hooks/useGetMetricsStepsEffect'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; import { act, renderHook, waitFor } from '@testing-library/react'; -import { METRICS_DATA_FAIL_STATUS } from '@src/constants/commons'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; +import { MetricsDataFailStatus } from '@src/constants/commons'; import { metricsClient } from '@src/clients/MetricsClient'; import { setupStore } from '@test/utils/setupStoreUtil'; import { TimeoutError } from '@src/errors/TimeoutError'; @@ -84,7 +84,7 @@ describe('use get steps effect', () => { await act(async () => { await result.current.getSteps(params, buildId, organizationId, pipelineType, token); }); - expect(result.current.stepFailedStatus).toEqual(METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX); + expect(result.current.stepFailedStatus).toEqual(MetricsDataFailStatus.PartialFailed4xx); }); it('should get the steps failed status when partial timeout response from steps res', async () => { @@ -103,7 +103,7 @@ describe('use get steps effect', () => { await act(async () => { await result.current.getSteps(params, buildId, organizationId, pipelineType, token); }); - expect(result.current.stepFailedStatus).toEqual(METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT); + expect(result.current.stepFailedStatus).toEqual(MetricsDataFailStatus.PartialFailedTimeout); }); it('should set error message when get steps throw error', async () => { @@ -142,7 +142,7 @@ describe('use get steps effect', () => { it('should set error message when get steps responses are timeout', async () => { metricsClient.getSteps = jest.fn().mockImplementation(() => { - return Promise.reject(new TimeoutError('error', AXIOS_REQUEST_ERROR_CODE.TIMEOUT)); + return Promise.reject(new TimeoutError('error', AxiosRequestErrorCode.Timeout)); }); const { result } = setup(); await act(async () => { diff --git a/frontend/__tests__/hooks/useVerifyBoardEffect.test.tsx b/frontend/__tests__/hooks/useVerifyBoardEffect.test.tsx index e45e580c72..c0747dfbd9 100644 --- a/frontend/__tests__/hooks/useVerifyBoardEffect.test.tsx +++ b/frontend/__tests__/hooks/useVerifyBoardEffect.test.tsx @@ -2,8 +2,8 @@ import { boardConfigDefaultValues } from '@src/containers/ConfigStep/Form/useDef import { boardConfigSchema } from '@src/containers/ConfigStep/Form/schema'; import { useVerifyBoardEffect } from '@src/hooks/useVerifyBoardEffect'; import { InternalServerError } from '@src/errors/InternalServerError'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; import { UnauthorizedError } from '@src/errors/UnauthorizedError'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { boardClient } from '@src/clients/board/BoardClient'; import { NotFoundError } from '@src/errors/NotFoundError'; import { TimeoutError } from '@src/errors/TimeoutError'; @@ -129,7 +129,7 @@ describe('use verify board state', () => { }); it('should set timeout is true given getVerifyBoard api is timeout', async () => { - const mockedError = new TimeoutError('', AXIOS_REQUEST_ERROR_CODE.TIMEOUT); + const mockedError = new TimeoutError('', AxiosRequestErrorCode.Timeout); boardClient.getVerifyBoard = jest.fn().mockImplementation(() => Promise.reject(mockedError)); const { result } = setup(); diff --git a/frontend/__tests__/hooks/useVerifyPipelineToolEffect.test.tsx b/frontend/__tests__/hooks/useVerifyPipelineToolEffect.test.tsx index d379a3a39b..8811caec74 100644 --- a/frontend/__tests__/hooks/useVerifyPipelineToolEffect.test.tsx +++ b/frontend/__tests__/hooks/useVerifyPipelineToolEffect.test.tsx @@ -7,7 +7,7 @@ import { pipelineToolDefaultValues } from '@src/containers/ConfigStep/Form/useDe import { useVerifyPipelineToolEffect } from '@src/hooks/useVerifyPipelineToolEffect'; import { pipelineToolClient } from '@src/clients/pipeline/PipelineToolClient'; import { pipelineToolSchema } from '@src/containers/ConfigStep/Form/schema'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { FormProvider } from '@test/utils/FormProvider'; import { setupStore } from '../utils/setupStoreUtil'; import { renderHook } from '@testing-library/react'; @@ -102,7 +102,7 @@ describe('use verify pipelineTool state', () => { }, { mock: { - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, errorTitle: '', }, field: 'token', diff --git a/frontend/__tests__/hooks/useVerifySourceControlTokenEffect.test.tsx b/frontend/__tests__/hooks/useVerifySourceControlTokenEffect.test.tsx index 4602088f6c..7605c1582f 100644 --- a/frontend/__tests__/hooks/useVerifySourceControlTokenEffect.test.tsx +++ b/frontend/__tests__/hooks/useVerifySourceControlTokenEffect.test.tsx @@ -3,7 +3,7 @@ import { sourceControlDefaultValues } from '@src/containers/ConfigStep/Form/useD import { MOCK_PIPELINE_VERIFY_UNAUTHORIZED_TEXT, UNKNOWN_ERROR_TEXT } from '../fixtures'; import { sourceControlClient } from '@src/clients/sourceControl/SourceControlClient'; import { sourceControlSchema } from '@src/containers/ConfigStep/Form/schema'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { FormProvider } from '@test/utils/FormProvider'; import { setupStore } from '../utils/setupStoreUtil'; import { renderHook } from '@testing-library/react'; @@ -85,7 +85,7 @@ describe('use verify sourceControl token', () => { }, { mock: { - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, errorTitle: '', }, field: 'token', diff --git a/frontend/__tests__/initialConfigState.ts b/frontend/__tests__/initialConfigState.ts index d71e47f4a3..28c6daea7e 100644 --- a/frontend/__tests__/initialConfigState.ts +++ b/frontend/__tests__/initialConfigState.ts @@ -1,7 +1,7 @@ import { BOARD_TYPES, PIPELINE_TOOL_TYPES, REGULAR_CALENDAR } from './fixtures'; import { SortType } from '@src/containers/ConfigStep/DateRangePicker/types'; import { BasicConfigState } from '@src/context/config/configSlice'; -import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; +import { SourceControlTypes } from '@src/constants/resources'; const initialConfigState: BasicConfigState = { isProjectCreated: true, @@ -45,7 +45,7 @@ const initialConfigState: BasicConfigState = { }, sourceControl: { config: { - type: SOURCE_CONTROL_TYPES.GITHUB, + type: SourceControlTypes.GitHub, token: '', }, isShow: false, diff --git a/frontend/__tests__/updatedConfigState.ts b/frontend/__tests__/updatedConfigState.ts index e359353db6..20c3f08626 100644 --- a/frontend/__tests__/updatedConfigState.ts +++ b/frontend/__tests__/updatedConfigState.ts @@ -1,5 +1,5 @@ import { BOARD_TYPES, CHINA_CALENDAR, CONFIG_PAGE_VERIFY_IMPORT_ERROR_MESSAGE, PIPELINE_TOOL_TYPES } from './fixtures'; -import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; +import { SourceControlTypes } from '@src/constants/resources'; const updatedConfigState = { isProjectCreated: true, @@ -40,7 +40,7 @@ const updatedConfigState = { }, sourceControl: { config: { - type: SOURCE_CONTROL_TYPES.GITHUB, + type: SourceControlTypes.GitHub, token: '', }, isShow: false, diff --git a/frontend/__tests__/utils/Util.test.tsx b/frontend/__tests__/utils/Util.test.tsx index 3e4eaf1dd2..b5fd8f900d 100644 --- a/frontend/__tests__/utils/Util.test.tsx +++ b/frontend/__tests__/utils/Util.test.tsx @@ -20,12 +20,12 @@ import { xAxisLabelDateFormatter, } from '@src/utils/util'; import { - CHART_TYPE, - CYCLE_TIME_SETTINGS_TYPES, + ChartType, + CycleTimeSettingsTypes, DOWN_TREND_IS_BETTER, METRICS_CONSTANTS, - TREND_ICON, - TREND_TYPE, + TrendIcon, + TrendType, UP_TREND_IS_BETTER, } from '@src/constants/resources'; import { CleanedBuildKiteEmoji, OriginBuildKiteEmoji } from '@src/constants/emojis/emoji'; @@ -224,19 +224,19 @@ const MOCK_CYCLE_TIME_SETTING_WITH_MUTIPLE_DONE = [ describe('getRealDoneStatus', () => { it('should return selected done status given cycle time settings only one done value and type is by column', () => { - const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_With_ONE_DONE, CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN, []); + const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_With_ONE_DONE, CycleTimeSettingsTypes.BY_COLUMN, []); expect(result).toEqual(['DONE']); }); it('should return selected done status given cycle time settings only one done value and type is by status', () => { - const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_With_ONE_DONE, CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, []); + const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_With_ONE_DONE, CycleTimeSettingsTypes.BY_STATUS, []); expect(result).toEqual(['DONE']); }); it('should return status from real done settings given cycle time settings type is by column', () => { - const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_WITH_MUTIPLE_DONE, CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN, [ + const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_WITH_MUTIPLE_DONE, CycleTimeSettingsTypes.BY_COLUMN, [ 'Doing', ]); @@ -244,7 +244,7 @@ describe('getRealDoneStatus', () => { }); it('should return selected done status given cycle time settings type is by column', () => { - const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_WITH_MUTIPLE_DONE, CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, [ + const result = getRealDoneStatus(MOCK_CYCLE_TIME_SETTING_WITH_MUTIPLE_DONE, CycleTimeSettingsTypes.BY_STATUS, [ 'something', ]); @@ -373,7 +373,7 @@ describe('convertCycleTimeSettings function', () => { DONE: '', }, ]; - const result = convertCycleTimeSettings(CYCLE_TIME_SETTINGS_TYPES.BY_STATUS, mockCycleTime); + const result = convertCycleTimeSettings(CycleTimeSettingsTypes.BY_STATUS, mockCycleTime); expect(result).toStrictEqual(expectResult); }); it('convert cycle time settings correctly by column', () => { @@ -400,7 +400,7 @@ describe('convertCycleTimeSettings function', () => { Done: '----', }, ]; - const result = convertCycleTimeSettings(CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN, mockCycleTime); + const result = convertCycleTimeSettings(CycleTimeSettingsTypes.BY_COLUMN, mockCycleTime); expect(result).toStrictEqual(expectResult); }); }); @@ -636,13 +636,13 @@ describe('calculateTrendInfo function', () => { ]; it('should only return type given the valid data length is less 2', () => { const dataList = [0, 0, 3, 0]; - const result = calculateTrendInfo(dataList, dateRangeList, CHART_TYPE.VELOCITY); + const result = calculateTrendInfo(dataList, dateRangeList, ChartType.Velocity); expect(result.dateRangeList).toEqual(undefined); expect(result.trendNumber).toEqual(undefined); expect(result.trendType).toEqual(undefined); expect(result.icon).toEqual(undefined); - expect(result.type).toEqual(CHART_TYPE.VELOCITY); + expect(result.type).toEqual(ChartType.Velocity); }); it.each(UP_TREND_IS_BETTER)( 'should get better result given the type is the up trend is better and the data is up', @@ -653,8 +653,8 @@ describe('calculateTrendInfo function', () => { expect(result.dateRangeList).toEqual(['2024/01/22-2024/01/23', '2024/01/15-2024/01/19']); expect(result.trendNumber).toEqual(2); - expect(result.trendType).toEqual(TREND_TYPE.BETTER); - expect(result.icon).toEqual(TREND_ICON.UP); + expect(result.trendType).toEqual(TrendType.Better); + expect(result.icon).toEqual(TrendIcon.Up); expect(result.type).toEqual(type); }, ); @@ -668,8 +668,8 @@ describe('calculateTrendInfo function', () => { expect(result.dateRangeList).toEqual(['2024/01/22-2024/01/23', '2024/01/15-2024/01/19']); expect(Number(result.trendNumber?.toFixed(2))).toEqual(-0.67); - expect(result.trendType).toEqual(TREND_TYPE.WORSE); - expect(result.icon).toEqual(TREND_ICON.DOWN); + expect(result.trendType).toEqual(TrendType.Worse); + expect(result.icon).toEqual(TrendIcon.Down); expect(result.type).toEqual(type); }, ); @@ -683,8 +683,8 @@ describe('calculateTrendInfo function', () => { expect(result.dateRangeList).toEqual(['2024/01/22-2024/01/23', '2024/01/15-2024/01/19']); expect(Number(result.trendNumber?.toFixed(2))).toEqual(-0.67); - expect(result.trendType).toEqual(TREND_TYPE.BETTER); - expect(result.icon).toEqual(TREND_ICON.DOWN); + expect(result.trendType).toEqual(TrendType.Better); + expect(result.icon).toEqual(TrendIcon.Down); expect(result.type).toEqual(type); }, ); @@ -698,8 +698,8 @@ describe('calculateTrendInfo function', () => { expect(result.dateRangeList).toEqual(['2024/01/22-2024/01/23', '2024/01/15-2024/01/19']); expect(result.trendNumber).toEqual(2); - expect(result.trendType).toEqual(TREND_TYPE.WORSE); - expect(result.icon).toEqual(TREND_ICON.UP); + expect(result.trendType).toEqual(TrendType.Worse); + expect(result.icon).toEqual(TrendIcon.Up); expect(result.type).toEqual(type); }, ); diff --git a/frontend/package.json b/frontend/package.json index 780fa55b1d..75ec4ef71e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,10 +12,10 @@ "lint": "eslint -c .eslintrc.json ./ && prettier --check ./", "fix": "eslint -c .eslintrc.json --fix && npx prettier --write . --ignore-unknown", "audit": "npx audit-ci@^6 --config ./audit-ci.jsonc", - "test": "jest", - "test:watch": "jest --watchAll", - "coverage": "jest --watchAll=false --coverage", - "coverage:silent": "jest --watchAll=false --coverage --silent", + "test": "NODE_EV=test jest", + "test:watch": "pnpm run test --watchAll", + "coverage": "pnpm run test --watchAll=false --coverage", + "coverage:silent": "pnpm run test --watchAll=false --coverage --silent", "pre-e2e": "./scripts/generate-config-files.sh", "e2e": "pnpm exec playwright test", "e2e:major": "pnpm run pre-e2e && pnpm exec playwright test /major-path --project='Google Chrome'", diff --git a/frontend/src/clients/HttpClient.ts b/frontend/src/clients/HttpClient.ts index 81d9f65389..b08574319e 100644 --- a/frontend/src/clients/HttpClient.ts +++ b/frontend/src/clients/HttpClient.ts @@ -1,5 +1,5 @@ /* istanbul ignore file */ // to cover #29 -import { AXIOS_NETWORK_ERROR_CODES, AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AXIOS_NETWORK_ERROR_CODES, AxiosRequestErrorCode } from '@src/constants/resources'; import { InternalServerError } from '@src/errors/InternalServerError'; import { UnauthorizedError } from '@src/errors/UnauthorizedError'; import { BadRequestError } from '@src/errors/BadRequestError'; @@ -8,7 +8,7 @@ import { ForbiddenError } from '@src/errors/ForbiddenError'; import { NotFoundError } from '@src/errors/NotFoundError'; import { UnknownError } from '@src/errors/UnknownError'; import { TimeoutError } from '@src/errors/TimeoutError'; -import { ROUTE } from '@src/constants/router'; +import { Route } from '@src/constants/router'; export class HttpClient { protected httpTimeout = 300000; @@ -24,7 +24,7 @@ export class HttpClient { (error) => { const { code, response } = error; if (AXIOS_NETWORK_ERROR_CODES.some((predefinedCode) => predefinedCode === code)) { - throw new TimeoutError(error?.message, AXIOS_REQUEST_ERROR_CODE.TIMEOUT); + throw new TimeoutError(error?.message, AxiosRequestErrorCode.Timeout); // Can't find any solution to cover below line due to upgrading the msw from v1 to v2 /* istanbul ignore branch */ } else if (response && response.status && response.status > 0) { @@ -42,7 +42,7 @@ export class HttpClient { throw new ForbiddenError(errorMessage, HttpStatusCode.Forbidden, description); default: if (status >= 500) { - window.location.href = ROUTE.ERROR_PAGE; + window.location.href = Route.ErrorPage; throw new InternalServerError(errorMessage, status, description); } throw new UnknownError(); diff --git a/frontend/src/clients/report/dto/request.ts b/frontend/src/clients/report/dto/request.ts index e338e88ce5..a1b04b9990 100644 --- a/frontend/src/clients/report/dto/request.ts +++ b/frontend/src/clients/report/dto/request.ts @@ -1,4 +1,4 @@ -import { METRIC_TYPES } from '@src/constants/commons'; +import { MetricTypes } from '@src/constants/commons'; export interface ReportRequestDTO extends IBasicReportRequestDTO { buildKiteSetting?: { @@ -59,7 +59,7 @@ export interface IBasicReportRequestDTO { doneColumn: string[]; }; csvTimeStamp?: number; - metricTypes: METRIC_TYPES[]; + metricTypes: MetricTypes[]; } export interface CSVReportRequestDTO { diff --git a/frontend/src/clients/sourceControl/dto/request.ts b/frontend/src/clients/sourceControl/dto/request.ts index 4102e0210d..86145ca9b8 100644 --- a/frontend/src/clients/sourceControl/dto/request.ts +++ b/frontend/src/clients/sourceControl/dto/request.ts @@ -1,12 +1,12 @@ -import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; +import { SourceControlTypes } from '@src/constants/resources'; export interface SourceControlVerifyRequestDTO { - type: SOURCE_CONTROL_TYPES; + type: SourceControlTypes; token: string; } export interface SourceControlInfoRequestDTO { - type: SOURCE_CONTROL_TYPES; + type: SourceControlTypes; branch: string; repository: string; token: string; diff --git a/frontend/src/components/Common/ReportForThreeColumns/index.tsx b/frontend/src/components/Common/ReportForThreeColumns/index.tsx index c85e059a54..ce21a5ba90 100644 --- a/frontend/src/components/Common/ReportForThreeColumns/index.tsx +++ b/frontend/src/components/Common/ReportForThreeColumns/index.tsx @@ -5,8 +5,8 @@ import { Row, StyledTableCell, } from '@src/components/Common/ReportForTwoColumns/style'; -import { AVERAGE_FIELD, METRICS_TITLE, REPORT_SUFFIX_UNITS } from '@src/constants/resources'; import { ReportDataWithThreeColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; +import { AVERAGE_FIELD, MetricsTitle, ReportSuffixUnits } from '@src/constants/resources'; import { EmojiWrap, StyledAvatar, StyledTypography } from '@src/constants/emojis/style'; import { getEmojiUrls, removeExtraEmojiName } from '@src/constants/emojis/emoji'; import { ReportSelectionTitle } from '@src/containers/MetricsStep/style'; @@ -83,7 +83,7 @@ export const ReportForThreeColumns = ({ }); const getTitleUnit = (title: string) => { - return title === METRICS_TITLE.LEAD_TIME_FOR_CHANGES ? REPORT_SUFFIX_UNITS.HOURS : ''; + return title === MetricsTitle.LeadTimeForChanges ? ReportSuffixUnits.Hours : ''; }; const renderLoading = () => ( diff --git a/frontend/src/components/Common/ReportForTwoColumns/index.tsx b/frontend/src/components/Common/ReportForTwoColumns/index.tsx index cc668b12df..f2661eccdc 100644 --- a/frontend/src/components/Common/ReportForTwoColumns/index.tsx +++ b/frontend/src/components/Common/ReportForTwoColumns/index.tsx @@ -8,7 +8,7 @@ import { import { ReportDataWithTwoColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; import { EmojiWrap, StyledAvatar, StyledTypography } from '@src/constants/emojis/style'; import { getEmojiUrls, removeExtraEmojiName } from '@src/constants/emojis/emoji'; -import { METRICS_TITLE, REPORT_SUFFIX_UNITS } from '@src/constants/resources'; +import { MetricsTitle, ReportSuffixUnits } from '@src/constants/resources'; import { ReportSelectionTitle } from '@src/containers/MetricsStep/style'; import { Table, TableBody, TableHead, TableRow } from '@mui/material'; import React, { Fragment } from 'react'; @@ -78,10 +78,10 @@ export const ReportForTwoColumns = ({ title, data }: ReportForTwoColumnsProps) = const getTitleUnit = (title: string) => { switch (title) { - case METRICS_TITLE.DEV_MEAN_TIME_TO_RECOVERY: - return REPORT_SUFFIX_UNITS.HOURS; - case METRICS_TITLE.DEPLOYMENT_FREQUENCY: - return REPORT_SUFFIX_UNITS.DEPLOYMENTS_DAY; + case MetricsTitle.DevMeanTimeToRecovery: + return ReportSuffixUnits.Hours; + case MetricsTitle.DeploymentFrequency: + return ReportSuffixUnits.DeploymentsPerDay; default: return ''; } diff --git a/frontend/src/components/ErrorContent/index.tsx b/frontend/src/components/ErrorContent/index.tsx index c158600eb0..d6dada7753 100644 --- a/frontend/src/components/ErrorContent/index.tsx +++ b/frontend/src/components/ErrorContent/index.tsx @@ -13,14 +13,14 @@ import { import { MESSAGE } from '@src/constants/resources'; import ErrorIcon from '@src/assets/ErrorIcon.svg'; import { useNavigate } from 'react-router-dom'; -import { ROUTE } from '@src/constants/router'; +import { Route } from '@src/constants/router'; import React from 'react'; export const ErrorContent = () => { const navigate = useNavigate(); const backToHomePage = () => { - navigate(ROUTE.BASE_PAGE); + navigate(Route.BasePage); }; return ( diff --git a/frontend/src/components/HomeGuide/index.tsx b/frontend/src/components/HomeGuide/index.tsx index 6ab6df6b2c..7fbd3ee8be 100644 --- a/frontend/src/components/HomeGuide/index.tsx +++ b/frontend/src/components/HomeGuide/index.tsx @@ -8,12 +8,12 @@ import { resetImportedData, updateBasicConfigState, updateProjectCreatedState } import { GuideButton, HomeGuideContainer, ImportFileWrapper, StyledStack } from '@src/components/HomeGuide/style'; import { convertToNewFileConfig, NewFileConfig, OldFileConfig } from '@src/constants/fileConfig'; import { WarningNotification } from '@src/components/Common/WarningNotification'; -import { CYCLE_TIME_SETTINGS_TYPES, MESSAGE } from '@src/constants/resources'; +import { CycleTimeSettingsTypes, MESSAGE } from '@src/constants/resources'; import { resetStep } from '@src/context/stepper/StepperSlice'; import { resetFormMeta } from '@src/context/meta/metaSlice'; import { useAppDispatch } from '@src/hooks/useAppDispatch'; import { useNavigate } from 'react-router-dom'; -import { ROUTE } from '@src/constants/router'; +import { Route } from '@src/constants/router'; import { useRef, useState } from 'react'; export const HomeGuide = () => { @@ -32,9 +32,9 @@ export const HomeGuide = () => { }; const getCycleTimeSettingsType = (typeInConfig?: string) => - (Object.values(CYCLE_TIME_SETTINGS_TYPES) as string[]).includes(typeInConfig || '') + (Object.values(CycleTimeSettingsTypes) as string[]).includes(typeInConfig || '') ? typeInConfig - : CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN; + : CycleTimeSettingsTypes.BY_COLUMN; const handleChange = (e: React.ChangeEvent) => { const input = e.target.files?.[0]; @@ -50,7 +50,7 @@ export const HomeGuide = () => { dispatch(updateMetricsImportedData(config)); dispatch(savePipelineCrews(config.pipelineCrews)); dispatch(setCycleTimeSettingsType(getCycleTimeSettingsType(config.cycleTime?.type))); - navigate(ROUTE.METRICS_PAGE); + navigate(Route.MetricsPage); } else { setValidConfig(false); } @@ -82,7 +82,7 @@ export const HomeGuide = () => { const createNewProject = () => { resetState(); - navigate(ROUTE.METRICS_PAGE); + navigate(Route.MetricsPage); }; return ( diff --git a/frontend/src/components/Metrics/MetricsStep/DeploymentFrequencySettings/PresentationForErrorCases/index.tsx b/frontend/src/components/Metrics/MetricsStep/DeploymentFrequencySettings/PresentationForErrorCases/index.tsx index 1f0efcce60..8da82e6dce 100644 --- a/frontend/src/components/Metrics/MetricsStep/DeploymentFrequencySettings/PresentationForErrorCases/index.tsx +++ b/frontend/src/components/Metrics/MetricsStep/DeploymentFrequencySettings/PresentationForErrorCases/index.tsx @@ -8,7 +8,7 @@ import { import { StyledErrorMessage, StyledErrorSection, StyledErrorTitle } from '@src/components/Common/EmptyContent/styles'; import { PIPELINE_TOOL_RETRY_MESSAGE, PIPELINE_TOOL_RETRY_TRIGGER_MESSAGE } from '@src/constants/resources'; import { IGetPipelineToolInfoResult } from '@src/clients/pipeline/PipelineToolClient'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import errorSvg from '@src/assets/PipelineInfoError.svg'; import React, { useCallback } from 'react'; @@ -19,7 +19,7 @@ export interface IPresentationForErrorCasesProps extends IGetPipelineToolInfoRes const PresentationForErrorCases = (props: IPresentationForErrorCasesProps) => { const handleRetry = useCallback(() => !props.isLoading && props.retry(), [props]); - const isShowRetryUI = AXIOS_REQUEST_ERROR_CODE.TIMEOUT === props.code; + const isShowRetryUI = AxiosRequestErrorCode.Timeout === props.code; return ( diff --git a/frontend/src/constants/commons.ts b/frontend/src/constants/commons.ts index baaf28afb5..4179daf950 100644 --- a/frontend/src/constants/commons.ts +++ b/frontend/src/constants/commons.ts @@ -69,20 +69,20 @@ export const Z_INDEX = { FIXED: 1070, }; -export enum REPORT_TYPES { - METRICS = 'metric', - BOARD = 'board', - PIPELINE = 'pipeline', +export enum ReportTypes { + Metrics = 'metric', + Board = 'board', + Pipeline = 'pipeline', } export enum formAlertTypes { - TIMEOUT, - BOARD_VERIFY, + Timeout, + BoardVerify, } -export enum METRIC_TYPES { - ALL = 'ALL', - BOARD = 'BOARD', +export enum MetricTypes { + All = 'ALL', + Board = 'BOARD', DORA = 'DORA', } @@ -109,18 +109,18 @@ export const GRID_CONFIG = { FULL: { XS: 12, MAX_INDEX: 4, FLEX: 0.25 }, }; -export enum METRICS_DATA_FAIL_STATUS { - NOT_FAILED, - PARTIAL_FAILED_4XX, - PARTIAL_FAILED_TIMEOUT, - PARTIAL_FAILED_NO_CARDS, - ALL_FAILED_4XX, - ALL_FAILED_TIMEOUT, - ALL_FAILED_NO_CARDS, +export enum MetricsDataFailStatus { + NotFailed, + PartialFailed4xx, + PartialFailedTimeout, + PartialFailedNoCards, + AllFailed4xx, + AllFailedTimeout, + AllFailedNoCards, } export const DOWNLOAD_DIALOG_TITLE = { - [REPORT_TYPES.METRICS]: 'Metrics', - [REPORT_TYPES.BOARD]: 'Board', - [REPORT_TYPES.PIPELINE]: 'Pipeline', + [ReportTypes.Metrics]: 'Metrics', + [ReportTypes.Board]: 'Board', + [ReportTypes.Pipeline]: 'Pipeline', }; diff --git a/frontend/src/constants/resources.ts b/frontend/src/constants/resources.ts index f0f0517dfe..d5bd333e81 100644 --- a/frontend/src/constants/resources.ts +++ b/frontend/src/constants/resources.ts @@ -50,15 +50,15 @@ export const DORA_METRICS_MAPPING: Record = { 'Dev mean time to recovery': 'devMeanTimeToRecovery', }; -export enum REQUIRED_DATA { - VELOCITY = 'Velocity', - CYCLE_TIME = 'Cycle time', - CLASSIFICATION = 'Classification', - REWORK_TIMES = 'Rework times', - LEAD_TIME_FOR_CHANGES = 'Lead time for changes', - DEPLOYMENT_FREQUENCY = 'Deployment frequency', - DEV_CHANGE_FAILURE_RATE = 'Dev change failure rate', - DEV_MEAN_TIME_TO_RECOVERY = 'Dev mean time to recovery', +export enum RequiredData { + Velocity = 'Velocity', + CycleTime = 'Cycle time', + Classification = 'Classification', + ReworkTimes = 'Rework times', + LeadTimeForChanges = 'Lead time for changes', + DeploymentFrequency = 'Deployment frequency', + DevChangeFailureRate = 'Dev change failure rate', + DevMeanTimeToRecovery = 'Dev mean time to recovery', } export const IMPORT_METRICS_MAPPING: Record = { @@ -74,110 +74,110 @@ export const IMPORT_METRICS_MAPPING: Record = { 'Mean time to recovery': 'Dev mean time to recovery', }; -export enum METRICS_TITLE { - VELOCITY = 'Velocity', - CYCLE_TIME = 'Cycle Time', - CLASSIFICATION = 'Classification', - REWORK = 'Rework', - LEAD_TIME_FOR_CHANGES = 'Lead Time For Changes', - DEPLOYMENT_FREQUENCY = 'Deployment Frequency', - DEV_CHANGE_FAILURE_RATE = 'Dev Change Failure Rate', - DEV_MEAN_TIME_TO_RECOVERY = 'Dev Mean Time To Recovery', +export enum MetricsTitle { + Velocity = 'Velocity', + CycleTime = 'Cycle Time', + Classification = 'Classification', + Rework = 'Rework', + LeadTimeForChanges = 'Lead Time For Changes', + DeploymentFrequency = 'Deployment Frequency', + DevChangeFailureRate = 'Dev Change Failure Rate', + DevMeanTimeToRecovery = 'Dev Mean Time To Recovery', } -export enum CHART_TYPE { - VELOCITY = 'Velocity', - AVERAGE_CYCLE_TIME = 'Average Cycle Time', - CYCLE_TIME_ALLOCATION = 'Cycle Time Allocation', - REWORK = 'Rework', - LEAD_TIME_FOR_CHANGES = 'Lead Time For Changes', - DEPLOYMENT_FREQUENCY = 'Deployment Frequency', - DEV_CHANGE_FAILURE_RATE = 'Dev Change Failure Rate', - DEV_MEAN_TIME_TO_RECOVERY = 'Dev Mean Time To Recovery', +export enum ChartType { + Velocity = 'Velocity', + AverageCycleTime = 'Average Cycle Time', + CycleTimeAllocation = 'Cycle Time Allocation', + Rework = 'Rework', + LeadTimeForChanges = 'Lead Time For Changes', + DeploymentFrequency = 'Deployment Frequency', + DevChangeFailureRate = 'Dev Change Failure Rate', + DevMeanTimeToRecovery = 'Dev Mean Time To Recovery', } -export enum TREND_ICON { - UP = 'UP', - DOWN = 'DOWN', +export enum TrendIcon { + Up = 'UP', + Down = 'DOWN', } -export enum TREND_TYPE { - BETTER = 'BETTER', - WORSE = 'WORSE', +export enum TrendType { + Better = 'BETTER', + Worse = 'WORSE', } export const CHART_TREND_TIP = { - [CHART_TYPE.VELOCITY]: 'Velocity(Story point)', - [CHART_TYPE.AVERAGE_CYCLE_TIME]: 'Days/Story point', - [CHART_TYPE.CYCLE_TIME_ALLOCATION]: 'Total development time/Total cycle time', - [CHART_TYPE.REWORK]: 'Total rework times', - [CHART_TYPE.LEAD_TIME_FOR_CHANGES]: 'PR Lead Time', - [CHART_TYPE.DEPLOYMENT_FREQUENCY]: 'Mean Time To Recovery', - [CHART_TYPE.DEV_CHANGE_FAILURE_RATE]: 'Dev Change Failure Rate', - [CHART_TYPE.DEV_MEAN_TIME_TO_RECOVERY]: 'Dev Mean Time To Recovery', + [ChartType.Velocity]: 'Velocity(Story point)', + [ChartType.AverageCycleTime]: 'Days/Story point', + [ChartType.CycleTimeAllocation]: 'Total development time/Total cycle time', + [ChartType.Rework]: 'Total rework times', + [ChartType.LeadTimeForChanges]: 'PR Lead Time', + [ChartType.DeploymentFrequency]: 'Mean Time To Recovery', + [ChartType.DevChangeFailureRate]: 'Dev Change Failure Rate', + [ChartType.DevMeanTimeToRecovery]: 'Dev Mean Time To Recovery', }; -export const UP_TREND_IS_BETTER: CHART_TYPE[] = [ - CHART_TYPE.VELOCITY, - CHART_TYPE.CYCLE_TIME_ALLOCATION, - CHART_TYPE.DEPLOYMENT_FREQUENCY, +export const UP_TREND_IS_BETTER: ChartType[] = [ + ChartType.Velocity, + ChartType.CycleTimeAllocation, + ChartType.DeploymentFrequency, ]; -export const DOWN_TREND_IS_BETTER: CHART_TYPE[] = [ - CHART_TYPE.REWORK, - CHART_TYPE.AVERAGE_CYCLE_TIME, - CHART_TYPE.LEAD_TIME_FOR_CHANGES, - CHART_TYPE.DEV_MEAN_TIME_TO_RECOVERY, - CHART_TYPE.DEV_CHANGE_FAILURE_RATE, +export const DOWN_TREND_IS_BETTER: ChartType[] = [ + ChartType.Rework, + ChartType.AverageCycleTime, + ChartType.LeadTimeForChanges, + ChartType.DevMeanTimeToRecovery, + ChartType.DevChangeFailureRate, ]; -export enum METRICS_SUBTITLE { - PR_LEAD_TIME = 'PR Lead Time(Hours)', - PIPELINE_LEAD_TIME = 'Pipeline Lead Time(Hours)', - TOTAL_DELAY_TIME = 'Total Lead Time(Hours)', - DEPLOYMENT_FREQUENCY = '(Deployments/Days)', - DEV_MEAN_TIME_TO_RECOVERY_HOURS = '(Hours)', - FAILURE_RATE = '', - AVERAGE_CYCLE_TIME_PRE_SP = 'Average Cycle Time(Days/SP)', - AVERAGE_CYCLE_TIME_PRE_CARD = 'Average Cycle Time(Days/Card)', - THROUGHPUT = 'Throughput(Cards Count)', - VELOCITY = 'Velocity(Story Point)', - TOTAL_REWORK_TIMES = 'Total rework times', - TOTAL_REWORK_CARDS = 'Total rework cards', - REWORK_CARDS_RATIO = 'Rework cards ratio', +export enum MetricsSubtitle { + PRLeadTime = 'PR Lead Time(Hours)', + PipelineLeadTime = 'Pipeline Lead Time(Hours)', + TotalDelayTime = 'Total Lead Time(Hours)', + DeploymentFrequency = '(Deployments/Days)', + DevMeanTimeToRecoveryHours = '(Hours)', + FailureRate = '', + AverageCycleTimePerSP = 'Average Cycle Time(Days/SP)', + AverageCycleTimePerCard = 'Average Cycle Time(Days/Card)', + Throughput = 'Throughput(Cards Count)', + Velocity = 'Velocity(Story Point)', + TotalReworkTimes = 'Total rework times', + TotalReworkCards = 'Total rework cards', + ReworkCardsRatio = 'Rework cards ratio', } -export const SOURCE_CONTROL_METRICS: string[] = [REQUIRED_DATA.LEAD_TIME_FOR_CHANGES]; +export const SOURCE_CONTROL_METRICS: string[] = [RequiredData.LeadTimeForChanges]; export const PIPELINE_METRICS: string[] = [ - REQUIRED_DATA.DEPLOYMENT_FREQUENCY, - REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE, - REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY, + RequiredData.DeploymentFrequency, + RequiredData.DevChangeFailureRate, + RequiredData.DevMeanTimeToRecovery, ]; export const DORA_METRICS: string[] = [ - REQUIRED_DATA.LEAD_TIME_FOR_CHANGES, - REQUIRED_DATA.DEPLOYMENT_FREQUENCY, - REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE, - REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY, + RequiredData.LeadTimeForChanges, + RequiredData.DeploymentFrequency, + RequiredData.DevChangeFailureRate, + RequiredData.DevMeanTimeToRecovery, ]; export const BOARD_METRICS: string[] = [ - REQUIRED_DATA.VELOCITY, - REQUIRED_DATA.CYCLE_TIME, - REQUIRED_DATA.CLASSIFICATION, - REQUIRED_DATA.REWORK_TIMES, + RequiredData.Velocity, + RequiredData.CycleTime, + RequiredData.Classification, + RequiredData.ReworkTimes, ]; export const BOARD_METRICS_EXCLUDE_CLASSIFICATION: string[] = [ - REQUIRED_DATA.VELOCITY, - REQUIRED_DATA.CYCLE_TIME, - REQUIRED_DATA.REWORK_TIMES, + RequiredData.Velocity, + RequiredData.CycleTime, + RequiredData.ReworkTimes, ]; -export enum CONFIG_TITLE { - BOARD = 'Board', - PIPELINE_TOOL = 'Pipeline Tool', - SOURCE_CONTROL = 'Source Control', +export enum ConfigTitle { + Board = 'Board', + PipelineTool = 'Pipeline Tool', + SourceControl = 'Source Control', } export const BOARD_TYPES = { @@ -188,13 +188,13 @@ export const PIPELINE_TOOL_TYPES = { BUILD_KITE: 'BuildKite', }; -export enum SOURCE_CONTROL_TYPES { - GITHUB = 'GitHub', +export enum SourceControlTypes { + GitHub = 'GitHub', } -export enum PIPELINE_SETTING_TYPES { - DEPLOYMENT_FREQUENCY_SETTINGS_TYPE = 'DeploymentFrequencySettings', - LEAD_TIME_FOR_CHANGES_TYPE = 'LeadTimeForChanges', +export enum PipelineSettingTypes { + DeploymentFrequencySettingType = 'DeploymentFrequencySettings', + LeadTimeForChangesType = 'LeadTimeForChanges', } export const ASSIGNEE_FILTER_TYPES = { @@ -277,12 +277,12 @@ export const TIPS = { TIME_RANGE_PICKER: 'The report page will generate charts to compare metrics data over multiple time ranges', }; -export enum VELOCITY_METRICS_NAME { - VELOCITY_SP = 'Velocity(Story Point)', - THROUGHPUT_CARDS_COUNT = 'Throughput(Cards Count)', +export enum VelocityMetricsName { + VelocitySP = 'Velocity(Story Point)', + ThroughputCardsCount = 'Throughput(Cards Count)', } -export enum CYCLE_TIME_METRICS_NAME { +export enum CycleTimeMetricsName { AVERAGE_CYCLE_TIME = 'Average cycle time', DEVELOPMENT_PROPORTION = 'Total development time / Total cycle time', WAITING_PROPORTION = 'Total waiting for testing time / Total cycle time', @@ -331,11 +331,11 @@ export const SUBTITLE = 'Subtitle'; export const AVERAGE_FIELD = 'Average'; -export enum REPORT_SUFFIX_UNITS { - PER_SP = '(Days/SP)', - PER_CARD = '(Days/Card)', - HOURS = '(Hours)', - DEPLOYMENTS_DAY = '(Deployments/Day)', +export enum ReportSuffixUnits { + DaysPerSP = '(Days/SP)', + DaysPerCard = '(Days/Card)', + Hours = '(Hours)', + DeploymentsPerDay = '(Deployments/Day)', } export const MESSAGE = { @@ -411,7 +411,7 @@ export const REPORT_PAGE = { }, }; -export enum CYCLE_TIME_SETTINGS_TYPES { +export enum CycleTimeSettingsTypes { BY_COLUMN = 'byColumn', BY_STATUS = 'byStatus', } @@ -420,9 +420,9 @@ export const AXIOS_NETWORK_ERROR_CODES = [AxiosError.ECONNABORTED, AxiosError.ET export const NO_PIPELINE_STEP_ERROR = 'No steps for this pipeline!'; -export enum AXIOS_REQUEST_ERROR_CODE { - TIMEOUT = 'NETWORK_TIMEOUT', - NO_CARDS = 'NO_CARDS', +export enum AxiosRequestErrorCode { + Timeout = 'NETWORK_TIMEOUT', + NoCards = 'NO_CARDS', } export const BOARD_CONFIG_INFO_TITLE = { @@ -518,7 +518,7 @@ export const ADD_TIME_RANGE_BUTTON_TEXT = 'New time range'; export const REMOVE_BUTTON_TEXT = 'Remove'; export const MAX_TIME_RANGE_AMOUNT = 6; -export enum SORTING_DATE_RANGE_TEXT { +export enum SortingDateRangeText { DEFAULT = 'Default sort', ASCENDING = 'Ascending', DESCENDING = 'Descending', diff --git a/frontend/src/constants/router.ts b/frontend/src/constants/router.ts index f421479251..1bba1f81d7 100644 --- a/frontend/src/constants/router.ts +++ b/frontend/src/constants/router.ts @@ -1,5 +1,5 @@ -export enum ROUTE { - BASE_PAGE = '/', - ERROR_PAGE = '/error-page', - METRICS_PAGE = '/metrics', +export enum Route { + BasePage = '/', + ErrorPage = '/error-page', + MetricsPage = '/metrics', } diff --git a/frontend/src/containers/ConfigStep/BasicInfo/RequiredMetrics/index.tsx b/frontend/src/containers/ConfigStep/BasicInfo/RequiredMetrics/index.tsx index e75fcacb05..9b33a2f0b2 100644 --- a/frontend/src/containers/ConfigStep/BasicInfo/RequiredMetrics/index.tsx +++ b/frontend/src/containers/ConfigStep/BasicInfo/RequiredMetrics/index.tsx @@ -6,10 +6,10 @@ import { useAppDispatch, useAppSelector } from '@src/hooks/useAppDispatch'; import { METRICS_LITERAL } from '@src/containers/ConfigStep/Form/literal'; import { SELECTED_VALUE_SEPARATOR } from '@src/constants/commons'; import { Controller, useFormContext } from 'react-hook-form'; -import { REQUIRED_DATA } from '@src/constants/resources'; +import { RequiredData } from '@src/constants/resources'; const ALL = 'All'; -const ALL_REQUIRED_DATA = Object.values(REQUIRED_DATA) as string[]; +const ALL_REQUIRED_DATA = Object.values(RequiredData) as string[]; export const RequiredMetrics = () => { const dispatch = useAppDispatch(); diff --git a/frontend/src/containers/ConfigStep/Board/index.tsx b/frontend/src/containers/ConfigStep/Board/index.tsx index 98c539b015..e75ac5cf94 100644 --- a/frontend/src/containers/ConfigStep/Board/index.tsx +++ b/frontend/src/containers/ConfigStep/Board/index.tsx @@ -6,7 +6,7 @@ import { ConfigButtonGrop } from '@src/containers/ConfigStep/ConfigButton'; import { ConfigSelectionTitle } from '@src/containers/MetricsStep/style'; import { useVerifyBoardEffect } from '@src/hooks/useVerifyBoardEffect'; import { StyledAlterWrapper } from '@src/containers/ConfigStep/style'; -import { CONFIG_TITLE, BOARD_TYPES } from '@src/constants/resources'; +import { ConfigTitle, BOARD_TYPES } from '@src/constants/resources'; import { FormAlert } from '@src/containers/ConfigStep/FormAlert'; import { formAlertTypes } from '@src/constants/commons'; import { Loading } from '@src/components/Loading'; @@ -26,7 +26,7 @@ export const Board = () => { errors.token?.message === BOARD_CONFIG_ERROR_MESSAGE.token.verifyFailed; const isVerified = isValid && isSubmitSuccessful; const showAlert = alertVisible && (isVerifyTimeOut || isBoardVerifyFailed); - const formAlertType = isVerifyTimeOut ? formAlertTypes.TIMEOUT : formAlertTypes.BOARD_VERIFY; + const formAlertType = isVerifyTimeOut ? formAlertTypes.Timeout : formAlertTypes.BoardVerify; const onSubmit = async () => await verifyJira(); const closeAlert = () => setAlertVisible(false); @@ -39,7 +39,7 @@ export const Board = () => { return ( {isLoading && } - {CONFIG_TITLE.BOARD} + {ConfigTitle.Board} {showAlert && ( diff --git a/frontend/src/containers/ConfigStep/DateRangePicker/SortingDateRange.tsx b/frontend/src/containers/ConfigStep/DateRangePicker/SortingDateRange.tsx index caa318d3cc..927c3caa25 100644 --- a/frontend/src/containers/ConfigStep/DateRangePicker/SortingDateRange.tsx +++ b/frontend/src/containers/ConfigStep/DateRangePicker/SortingDateRange.tsx @@ -8,8 +8,8 @@ import { import { selectDateRangeSortType, updateDateRangeSortType } from '@src/context/config/configSlice'; import { SortType } from '@src/containers/ConfigStep/DateRangePicker/types'; import { useAppDispatch, useAppSelector } from '@src/hooks/useAppDispatch'; -import { SORTING_DATE_RANGE_TEXT } from '@src/constants/resources'; import { ArrowDropDown, ArrowDropUp } from '@mui/icons-material'; +import { SortingDateRangeText } from '@src/constants/resources'; import { Box } from '@mui/material'; type Props = { @@ -33,7 +33,7 @@ export const SortingDateRange = ({ disabled }: Props) => { return ( - {SORTING_DATE_RANGE_TEXT[currentSortType]} + {SortingDateRangeText[currentSortType]} {currentSortType === SortType.ASCENDING ? ( diff --git a/frontend/src/containers/ConfigStep/FormAlert/index.tsx b/frontend/src/containers/ConfigStep/FormAlert/index.tsx index 4b452fd05f..013db85fb6 100644 --- a/frontend/src/containers/ConfigStep/FormAlert/index.tsx +++ b/frontend/src/containers/ConfigStep/FormAlert/index.tsx @@ -14,8 +14,8 @@ interface PropsInterface { const FormAlertAriaLabelMap = (formAlertType: formAlertTypes): string => { const formAlertAriaLabelMap = { - [formAlertTypes.TIMEOUT]: 'timeout alert', - [formAlertTypes.BOARD_VERIFY]: 'board verify alert', + [formAlertTypes.Timeout]: 'timeout alert', + [formAlertTypes.BoardVerify]: 'board verify alert', }; return formAlertAriaLabelMap[formAlertType]; @@ -23,13 +23,13 @@ const FormAlertAriaLabelMap = (formAlertType: formAlertTypes): string => { export const FormAlert = ({ showAlert, onClose, moduleType, formAlertType }: PropsInterface) => { const renderMessage = () => { - if (formAlertType === formAlertTypes.TIMEOUT) { + if (formAlertType === formAlertTypes.Timeout) { return ( Submission timeout on {moduleType}, please reverify! ); - } else if (formAlertType === formAlertTypes.BOARD_VERIFY) { + } else if (formAlertType === formAlertTypes.BoardVerify) { return ( Email and Token are bound for verification. Please modify one of the diff --git a/frontend/src/containers/ConfigStep/PipelineTool/index.tsx b/frontend/src/containers/ConfigStep/PipelineTool/index.tsx index b27b68599c..190c3d1341 100644 --- a/frontend/src/containers/ConfigStep/PipelineTool/index.tsx +++ b/frontend/src/containers/ConfigStep/PipelineTool/index.tsx @@ -1,8 +1,8 @@ import { ConfigSectionContainer, StyledForm, StyledTextField } from '@src/components/Common/ConfigForms'; -import { FIELD_KEY, useVerifyPipelineToolEffect } from '@src/hooks/useVerifyPipelineToolEffect'; +import { FieldKey, useVerifyPipelineToolEffect } from '@src/hooks/useVerifyPipelineToolEffect'; import { PIPELINE_TOOL_ERROR_MESSAGE } from '@src/containers/ConfigStep/Form/literal'; import { FormSingleSelect } from '@src/containers/ConfigStep/Form/FormSelect'; -import { CONFIG_TITLE, PIPELINE_TOOL_TYPES } from '@src/constants/resources'; +import { ConfigTitle, PIPELINE_TOOL_TYPES } from '@src/constants/resources'; import { ConfigButtonGrop } from '@src/containers/ConfigStep/ConfigButton'; import { IPipelineToolData } from '@src/containers/ConfigStep/Form/schema'; import { ConfigSelectionTitle } from '@src/containers/MetricsStep/style'; @@ -30,47 +30,47 @@ export const PipelineTool = () => { const isVerified = isValid && isSubmitSuccessful; const onSubmit = async () => await verifyPipelineTool(); - const closeTimeoutAlert = () => clearErrors(fields[FIELD_KEY.TOKEN].key); + const closeTimeoutAlert = () => clearErrors(fields[FieldKey.Token].key); return ( {isLoading && } - {CONFIG_TITLE.PIPELINE_TOOL} + {ConfigTitle.PipelineTool} { return ( { if (field.value === '') { - setError(fields[FIELD_KEY.TOKEN].key, { + setError(fields[FieldKey.Token].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.required, }); } diff --git a/frontend/src/containers/ConfigStep/SourceControl/index.tsx b/frontend/src/containers/ConfigStep/SourceControl/index.tsx index 5c4e8eb95b..d5e99fe784 100644 --- a/frontend/src/containers/ConfigStep/SourceControl/index.tsx +++ b/frontend/src/containers/ConfigStep/SourceControl/index.tsx @@ -1,10 +1,10 @@ -import { FIELD_KEY, useVerifySourceControlTokenEffect } from '@src/hooks/useVerifySourceControlTokenEffect'; +import { FieldKey, useVerifySourceControlTokenEffect } from '@src/hooks/useVerifySourceControlTokenEffect'; import { ConfigSectionContainer, StyledForm, StyledTextField } from '@src/components/Common/ConfigForms'; import { SOURCE_CONTROL_ERROR_MESSAGE } from '@src/containers/ConfigStep/Form/literal'; import { FormSingleSelect } from '@src/containers/ConfigStep/Form/FormSelect'; -import { CONFIG_TITLE, SOURCE_CONTROL_TYPES } from '@src/constants/resources'; import { ISourceControlData } from '@src/containers/ConfigStep/Form/schema'; import { ConfigButtonGrop } from '@src/containers/ConfigStep/ConfigButton'; +import { ConfigTitle, SourceControlTypes } from '@src/constants/resources'; import { ConfigSelectionTitle } from '@src/containers/MetricsStep/style'; import { StyledAlterWrapper } from '@src/containers/ConfigStep/style'; import { updateSourceControl } from '@src/context/config/configSlice'; @@ -30,46 +30,46 @@ export const SourceControl = () => { const isVerified = isValid && isSubmitSuccessful; const onSubmit = async () => await verifyToken(); - const closeTimeoutAlert = () => clearErrors(fields[FIELD_KEY.TOKEN].key); + const closeTimeoutAlert = () => clearErrors(fields[FieldKey.Token].key); return ( {isLoading && } - {CONFIG_TITLE.SOURCE_CONTROL} + {ConfigTitle.SourceControl} { return ( { if (field.value === '') { - setError(fields[FIELD_KEY.TOKEN].key, { + setError(fields[FieldKey.Token].key, { message: SOURCE_CONTROL_ERROR_MESSAGE.token.required, }); } diff --git a/frontend/src/containers/MetricsStep/CycleTime/Table/index.tsx b/frontend/src/containers/MetricsStep/CycleTime/Table/index.tsx index 56f6aa7eda..47bb826a99 100644 --- a/frontend/src/containers/MetricsStep/CycleTime/Table/index.tsx +++ b/frontend/src/containers/MetricsStep/CycleTime/Table/index.tsx @@ -8,7 +8,7 @@ import { ICycleTimeSetting, } from '@src/context/Metrics/metricsSlice'; import { - CYCLE_TIME_SETTINGS_TYPES, + CycleTimeSettingsTypes, DONE, METRICS_CONSTANTS, METRICS_CYCLE_SETTING_TABLE_HEADER_BY_COLUMN, @@ -31,7 +31,7 @@ import { theme } from '@src/theme'; const CycleTimeTable = () => { const dispatch = useAppDispatch(); const { cycleTimeSettings, cycleTimeSettingsType } = useAppSelector(selectMetricsContent); - const isColumnAsKey = cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN; + const isColumnAsKey = cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN; const resetRealDoneColumn = useCallback( (name: string, value: string) => { @@ -111,8 +111,8 @@ const CycleTimeTable = () => { return ( <> - } label='By Column' /> - } label='By Status' /> + } label='By Column' /> + } label='By Status' /> diff --git a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/BranchChip/index.tsx b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/BranchChip/index.tsx index 53f9b92cc9..01bac8be7a 100644 --- a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/BranchChip/index.tsx +++ b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/BranchChip/index.tsx @@ -1,6 +1,6 @@ -import { AXIOS_REQUEST_ERROR_CODE, SOURCE_CONTROL_TYPES } from '@src/constants/resources'; import { sourceControlClient } from '@src/clients/sourceControl/SourceControlClient'; import { SourceControlInfoRequestDTO } from '@src/clients/sourceControl/dto/request'; +import { AxiosRequestErrorCode, SourceControlTypes } from '@src/constants/resources'; import { selectSourceControl } from '@src/context/config/configSlice'; import { FormFieldWithMeta } from '@src/context/meta/metaSlice'; import ChipExtended from '@src/components/Common/ChipExtended'; @@ -23,7 +23,7 @@ const BranchChip = ({ value, needVerify, error, updateBranchMeta, repository, er pending.current = true; const params: SourceControlInfoRequestDTO = { - type: sourceControlFields.type as SOURCE_CONTROL_TYPES, + type: sourceControlFields.type as SourceControlTypes, token: sourceControlFields.token, branch: value, repository, @@ -55,7 +55,7 @@ const BranchChip = ({ value, needVerify, error, updateBranchMeta, repository, er label={value} loading={needVerify} error={error} - showRetry={errorDetail === AXIOS_REQUEST_ERROR_CODE.TIMEOUT} + showRetry={errorDetail === AxiosRequestErrorCode.Timeout} onRetry={handleRetry} /> ); diff --git a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection/index.tsx b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection/index.tsx index 0b0614cf0e..47e879e1a0 100644 --- a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection/index.tsx +++ b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection/index.tsx @@ -27,7 +27,7 @@ import { uniqPipelineListCrews, updateResponseCrews } from '@src/utils/util'; import { MESSAGE, NO_PIPELINE_STEP_ERROR } from '@src/constants/resources'; import { shouldMetricsLoaded } from '@src/context/stepper/StepperSlice'; import { ErrorNotification } from '@src/components/ErrorNotification'; -import { METRICS_DATA_FAIL_STATUS } from '@src/constants/commons'; +import { MetricsDataFailStatus } from '@src/constants/commons'; import { useAppDispatch, useAppSelector } from '@src/hooks'; import { useEffect, useRef, useState } from 'react'; import { Loading } from '@src/components/Loading'; @@ -130,7 +130,7 @@ export const PipelineMetricSelection = ({ useEffect(() => { const popup = () => { - if (stepFailedStatus === METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX) { + if (stepFailedStatus === MetricsDataFailStatus.PartialFailed4xx) { dispatch( addNotification({ type: 'warning', @@ -138,8 +138,8 @@ export const PipelineMetricSelection = ({ }), ); } else if ( - stepFailedStatus === METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_NO_CARDS || - stepFailedStatus === METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT + stepFailedStatus === MetricsDataFailStatus.PartialFailedNoCards || + stepFailedStatus === MetricsDataFailStatus.PartialFailedTimeout ) { dispatch( addNotification({ diff --git a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/index.tsx b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/index.tsx index c8c56b6881..2aa9187df5 100644 --- a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/index.tsx +++ b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/index.tsx @@ -14,7 +14,7 @@ import { StyledAlertWrapper } from '@src/containers/MetricsStep/style'; import { selectPipelineCrews } from '@src/context/config/configSlice'; import { AddButton } from '@src/components/Common/AddButtonOneLine'; import { PipelineMetricSelection } from './PipelineMetricSelection'; -import { PIPELINE_SETTING_TYPES } from '@src/constants/resources'; +import { PipelineSettingTypes } from '@src/constants/resources'; import { useAppDispatch, useAppSelector } from '@src/hooks'; import { Crews } from '@src/containers/MetricsStep/Crews'; import { Loading } from '@src/components/Loading'; @@ -63,7 +63,7 @@ export const DeploymentFrequencySettings = () => { 1} onRemovePipeline={(id) => handleRemovePipeline(id)} diff --git a/frontend/src/containers/MetricsStep/index.tsx b/frontend/src/containers/MetricsStep/index.tsx index b19eab95b2..69396e9ce6 100644 --- a/frontend/src/containers/MetricsStep/index.tsx +++ b/frontend/src/containers/MetricsStep/index.tsx @@ -21,13 +21,7 @@ import { StyledErrorMessage, StyledRetryButton, } from '@src/containers/MetricsStep/style'; -import { - AXIOS_REQUEST_ERROR_CODE, - CYCLE_TIME_SETTINGS_TYPES, - DONE, - MESSAGE, - REQUIRED_DATA, -} from '@src/constants/resources'; +import { AxiosRequestErrorCode, CycleTimeSettingsTypes, DONE, MESSAGE, RequiredData } from '@src/constants/resources'; import { DeploymentFrequencySettings } from '@src/containers/MetricsStep/DeploymentFrequencySettings'; import { addNotification, closeAllNotifications } from '@src/context/notification/NotificationSlice'; import { Classification } from '@src/containers/MetricsStep/Classification'; @@ -36,10 +30,10 @@ import DateRangeViewer from '@src/components/Common/DateRangeViewer'; import { useGetBoardInfoEffect } from '@src/hooks/useGetBoardInfo'; import { combineBoardInfo, sortDateRanges } from '@src/utils/util'; import { CycleTime } from '@src/containers/MetricsStep/CycleTime'; -import { METRICS_DATA_FAIL_STATUS } from '@src/constants/commons'; import { RealDone } from '@src/containers/MetricsStep/RealDone'; import { useCallback, useEffect, useLayoutEffect } from 'react'; import EmptyContent from '@src/components/Common/EmptyContent'; +import { MetricsDataFailStatus } from '@src/constants/commons'; import { useAppDispatch, useAppSelector } from '@src/hooks'; import { Crews } from '@src/containers/MetricsStep/Crews'; import { Loading } from '@src/components/Loading'; @@ -62,12 +56,12 @@ const MetricsStep = () => { const { startDate, endDate } = descendingSortedDateRanges[0]; const isShowCrewsAndRealDone = - requiredData.includes(REQUIRED_DATA.VELOCITY) || - requiredData.includes(REQUIRED_DATA.CYCLE_TIME) || - requiredData.includes(REQUIRED_DATA.CLASSIFICATION) || - requiredData.includes(REQUIRED_DATA.REWORK_TIMES); + requiredData.includes(RequiredData.Velocity) || + requiredData.includes(RequiredData.CycleTime) || + requiredData.includes(RequiredData.Classification) || + requiredData.includes(RequiredData.ReworkTimes); const isShowRealDone = - cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN && + cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN && cycleTimeSettings.filter((e) => e.value === DONE).length > 1; const { getBoardInfo, isLoading, errorMessage, boardInfoFailedStatus } = useGetBoardInfoEffect(); const shouldLoad = useAppSelector(shouldMetricsLoaded); @@ -94,7 +88,7 @@ const MetricsStep = () => { useEffect(() => { const popup = () => { - if (boardInfoFailedStatus === METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX) { + if (boardInfoFailedStatus === MetricsDataFailStatus.PartialFailed4xx) { dispatch( addNotification({ type: 'warning', @@ -102,8 +96,8 @@ const MetricsStep = () => { }), ); } else if ( - boardInfoFailedStatus === METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_NO_CARDS || - boardInfoFailedStatus === METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT + boardInfoFailedStatus === MetricsDataFailStatus.PartialFailedNoCards || + boardInfoFailedStatus === MetricsDataFailStatus.PartialFailedTimeout ) { dispatch( addNotification({ @@ -138,9 +132,9 @@ const MetricsStep = () => { Board configuration {isEmpty(errorMessage) || - (boardInfoFailedStatus !== METRICS_DATA_FAIL_STATUS.ALL_FAILED_4XX && - boardInfoFailedStatus !== METRICS_DATA_FAIL_STATUS.ALL_FAILED_TIMEOUT && - boardInfoFailedStatus !== METRICS_DATA_FAIL_STATUS.ALL_FAILED_NO_CARDS) ? ( + (boardInfoFailedStatus !== MetricsDataFailStatus.AllFailed4xx && + boardInfoFailedStatus !== MetricsDataFailStatus.AllFailedTimeout && + boardInfoFailedStatus !== MetricsDataFailStatus.AllFailedNoCards) ? ( <> @@ -150,21 +144,21 @@ const MetricsStep = () => { )} - {requiredData.includes(REQUIRED_DATA.CLASSIFICATION) && ( + {requiredData.includes(RequiredData.Classification) && ( )} - {requiredData.includes(REQUIRED_DATA.REWORK_TIMES) && } + {requiredData.includes(RequiredData.ReworkTimes) && } ) : ( @@ -178,10 +172,10 @@ const MetricsStep = () => { )} - {(requiredData.includes(REQUIRED_DATA.DEPLOYMENT_FREQUENCY) || - requiredData.includes(REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE) || - requiredData.includes(REQUIRED_DATA.LEAD_TIME_FOR_CHANGES) || - requiredData.includes(REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY)) && ( + {(requiredData.includes(RequiredData.DeploymentFrequency) || + requiredData.includes(RequiredData.DevChangeFailureRate) || + requiredData.includes(RequiredData.LeadTimeForChanges) || + requiredData.includes(RequiredData.DevMeanTimeToRecovery)) && ( Pipeline configuration diff --git a/frontend/src/containers/MetricsStepper/index.tsx b/frontend/src/containers/MetricsStepper/index.tsx index 6cfd93f7c0..2bdba3b904 100644 --- a/frontend/src/containers/MetricsStepper/index.tsx +++ b/frontend/src/containers/MetricsStepper/index.tsx @@ -23,7 +23,7 @@ import { selectCycleTimeSettings, selectMetricsContent, } from '@src/context/Metrics/metricsSlice'; -import { CYCLE_TIME_SETTINGS_TYPES, DONE, METRICS_CONSTANTS, REQUIRED_DATA, TIPS } from '@src/constants/resources'; +import { CycleTimeSettingsTypes, DONE, METRICS_CONSTANTS, RequiredData, TIPS } from '@src/constants/resources'; import { backStep, nextStep, selectStepNumber, updateTimeStamp } from '@src/context/stepper/StepperSlice'; import { useMetricsStepValidationCheckContext } from '@src/hooks/useMetricsStepValidationCheckContext'; import { convertCycleTimeSettings, exportToJsonFile, onlyEmptyAndDoneState } from '@src/utils/util'; @@ -37,7 +37,7 @@ import { getFormMeta } from '@src/context/meta/metaSlice'; import SaveAltIcon from '@mui/icons-material/SaveAlt'; import { yupResolver } from '@hookform/resolvers/yup'; import { useNavigate } from 'react-router-dom'; -import { ROUTE } from '@src/constants/router'; +import { Route } from '@src/constants/router'; import { useForm } from 'react-hook-form'; import { Tooltip } from '@mui/material'; import isEmpty from 'lodash/isEmpty'; @@ -130,28 +130,28 @@ const MetricsStepper = () => { ); const isShowCycleTimeSettings = - requiredData.includes(REQUIRED_DATA.CYCLE_TIME) || - requiredData.includes(REQUIRED_DATA.CLASSIFICATION) || - requiredData.includes(REQUIRED_DATA.VELOCITY); + requiredData.includes(RequiredData.CycleTime) || + requiredData.includes(RequiredData.Classification) || + requiredData.includes(RequiredData.Velocity); const isCycleTimeSettingsVerified = cycleTimeSettings.some((e) => e.value === DONE); const boardingMappingStatus = [...new Set(cycleTimeSettings.map((item) => item.value))]; const isOnlyEmptyAndDoneState = onlyEmptyAndDoneState(boardingMappingStatus); - const onlyIncludeReworkMetrics = requiredData.includes(REQUIRED_DATA.REWORK_TIMES) && requiredData.length === 1; - const isShowClassificationSetting = requiredData.includes(REQUIRED_DATA.CLASSIFICATION); - const isShowReworkSettings = requiredData.includes(REQUIRED_DATA.REWORK_TIMES); + const onlyIncludeReworkMetrics = requiredData.includes(RequiredData.ReworkTimes) && requiredData.length === 1; + const isShowClassificationSetting = requiredData.includes(RequiredData.Classification); + const isShowReworkSettings = requiredData.includes(RequiredData.ReworkTimes); const isClassificationSettingVerified = metricsConfig.targetFields.some((item) => item.flag); const isReworkStateSelected = !!metricsConfig.importedData.reworkTimesSettings.reworkState; const { metrics, projectName, dateRange } = config.basic; const isShowRealDone = isShowBoard && - metricsConfig.cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN && + metricsConfig.cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN && metricsConfig.cycleTimeSettings.filter(({ value }) => value === METRICS_CONSTANTS.doneValue).length > 1; const isShowDeploymentFrequency = - requiredData.includes(REQUIRED_DATA.DEPLOYMENT_FREQUENCY) || - requiredData.includes(REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE) || - requiredData.includes(REQUIRED_DATA.LEAD_TIME_FOR_CHANGES) || - requiredData.includes(REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY); + requiredData.includes(RequiredData.DeploymentFrequency) || + requiredData.includes(RequiredData.DevChangeFailureRate) || + requiredData.includes(RequiredData.LeadTimeForChanges) || + requiredData.includes(RequiredData.DevMeanTimeToRecovery); const isCrewsSettingValid = metricsConfig.users.length > 0; const isRealDoneValid = metricsConfig.doneColumn.length > 0; @@ -305,7 +305,7 @@ const MetricsStepper = () => { }; const backToHomePage = () => { - navigate(ROUTE.BASE_PAGE); + navigate(Route.BasePage); setIsDialogShowing(false); window.location.reload(); }; diff --git a/frontend/src/containers/ReportButtonGroup/index.tsx b/frontend/src/containers/ReportButtonGroup/index.tsx index 10e14dc284..b3a44c9139 100644 --- a/frontend/src/containers/ReportButtonGroup/index.tsx +++ b/frontend/src/containers/ReportButtonGroup/index.tsx @@ -1,5 +1,5 @@ import { StyledButtonGroup, StyledExportButton, StyledRightButtonGroup } from '@src/containers/ReportButtonGroup/style'; -import { COMMON_BUTTONS, DOWNLOAD_DIALOG_TITLE, REPORT_TYPES } from '@src/constants/commons'; +import { COMMON_BUTTONS, DOWNLOAD_DIALOG_TITLE, ReportTypes } from '@src/constants/commons'; import { DateRangeItem, DownloadDialog } from '@src/containers/ReportStep/DownloadDialog'; import { BackButton, SaveButton } from '@src/containers/MetricsStepper/style'; import { ExpiredDialog } from '@src/containers/ReportStep/ExpiredDialog'; @@ -45,7 +45,7 @@ export const ReportButtonGroup = ({ }: ReportButtonGroupProps) => { const [isShowDialog, setIsShowDialog] = useState(false); const [downloadReportList, setDownloadReportList] = useState([]); - const [dataType, setDataType] = useState(null); + const [dataType, setDataType] = useState(null); const { fetchExportData, isExpired } = useExportCsvEffect(); const isReportHasError = (reportMetricsError: AllErrorResponse) => { @@ -93,14 +93,14 @@ export const ReportButtonGroup = ({ dateRangeListWithStatus.some(({ enableExportPipelineData }) => enableExportPipelineData), }; - const exportCSV = (dataType: REPORT_TYPES, startDate: string, endDate: string): CSVReportRequestDTO => ({ + const exportCSV = (dataType: ReportTypes, startDate: string, endDate: string): CSVReportRequestDTO => ({ dataType: dataType, csvTimeStamp: csvTimeStamp, startDate: startDate, endDate: endDate, }); - const handleDownload = (dateRange: DateRangeItem[], dataType: REPORT_TYPES) => { + const handleDownload = (dateRange: DateRangeItem[], dataType: ReportTypes) => { if (dateRange.length > 1) { setDownloadReportList(dateRange); setDataType(dataType); @@ -115,11 +115,11 @@ export const ReportButtonGroup = ({ setDataType(null); }; - const getDownloadInfos = (dataType: REPORT_TYPES): DateRangeItem[] => { + const getDownloadInfos = (dataType: ReportTypes): DateRangeItem[] => { const REPORT_TYPE_MAPPING = { - [REPORT_TYPES.BOARD]: SINGLE_DATE_RANGE_DOWNLOAD_KEY.ENABLE_EXPORT_BOARD_DATA, - [REPORT_TYPES.PIPELINE]: SINGLE_DATE_RANGE_DOWNLOAD_KEY.ENABLE_EXPORT_PIPELINE_DATA, - [REPORT_TYPES.METRICS]: SINGLE_DATE_RANGE_DOWNLOAD_KEY.ENABLE_EXPORT_METRIC_DATA, + [ReportTypes.Board]: SINGLE_DATE_RANGE_DOWNLOAD_KEY.ENABLE_EXPORT_BOARD_DATA, + [ReportTypes.Pipeline]: SINGLE_DATE_RANGE_DOWNLOAD_KEY.ENABLE_EXPORT_PIPELINE_DATA, + [ReportTypes.Metrics]: SINGLE_DATE_RANGE_DOWNLOAD_KEY.ENABLE_EXPORT_METRIC_DATA, }; return dateRangeListWithStatus.map((dateRangeWithStatus) => ({ startDate: dateRangeWithStatus.startDate, @@ -154,7 +154,7 @@ export const ReportButtonGroup = ({ {isShowExportMetrics && ( handleDownload(getDownloadInfos(REPORT_TYPES.METRICS), REPORT_TYPES.METRICS)} + onClick={() => handleDownload(getDownloadInfos(ReportTypes.Metrics), ReportTypes.Metrics)} > {COMMON_BUTTONS.EXPORT_METRIC_DATA} @@ -162,7 +162,7 @@ export const ReportButtonGroup = ({ {isShowExportBoardButton && ( handleDownload(getDownloadInfos(REPORT_TYPES.BOARD), REPORT_TYPES.BOARD)} + onClick={() => handleDownload(getDownloadInfos(ReportTypes.Board), ReportTypes.Board)} > {COMMON_BUTTONS.EXPORT_BOARD_DATA} @@ -170,7 +170,7 @@ export const ReportButtonGroup = ({ {isShowExportPipelineButton && ( handleDownload(getDownloadInfos(REPORT_TYPES.PIPELINE), REPORT_TYPES.PIPELINE)} + onClick={() => handleDownload(getDownloadInfos(ReportTypes.Pipeline), ReportTypes.Pipeline)} > {COMMON_BUTTONS.EXPORT_PIPELINE_DATA} @@ -178,7 +178,7 @@ export const ReportButtonGroup = ({ {isShowExportBoardChartButton && ( handleDownload(getDownloadInfos(REPORT_TYPES.BOARD), REPORT_TYPES.BOARD)} + onClick={() => handleDownload(getDownloadInfos(ReportTypes.Board), ReportTypes.Board)} > {COMMON_BUTTONS.EXPORT_BOARD_CHART} @@ -186,7 +186,7 @@ export const ReportButtonGroup = ({ {isShowExportDoraChartButton && ( handleDownload(getDownloadInfos(REPORT_TYPES.PIPELINE), REPORT_TYPES.PIPELINE)} + onClick={() => handleDownload(getDownloadInfos(ReportTypes.Pipeline), ReportTypes.Pipeline)} > {COMMON_BUTTONS.EXPORT_DORA_CHART} diff --git a/frontend/src/containers/ReportStep/BoardMetrics/index.tsx b/frontend/src/containers/ReportStep/BoardMetrics/index.tsx index 62e867df04..0df7485ebf 100644 --- a/frontend/src/containers/ReportStep/BoardMetrics/index.tsx +++ b/frontend/src/containers/ReportStep/BoardMetrics/index.tsx @@ -9,10 +9,10 @@ import { import { BOARD_METRICS, BOARD_METRICS_MAPPING, - METRICS_SUBTITLE, - METRICS_TITLE, + MetricsSubtitle, + MetricsTitle, REPORT_PAGE, - REQUIRED_DATA, + RequiredData, RETRY, SHOW_MORE, } from '@src/constants/resources'; @@ -42,7 +42,7 @@ const BoardMetrics = ({ startToRequestBoardData, onShowDetail, boardReport, erro const boardingMappingStates = [...new Set(cycleTimeSettings.map((item) => item.value))]; const isOnlyEmptyAndDoneState = onlyEmptyAndDoneState(boardingMappingStates); const boardMetricsCompleted = ( - isOnlyEmptyAndDoneState ? boardMetrics.filter((metric) => metric !== REQUIRED_DATA.REWORK_TIMES) : boardMetrics + isOnlyEmptyAndDoneState ? boardMetrics.filter((metric) => metric !== RequiredData.ReworkTimes) : boardMetrics ) .map((metric) => BOARD_METRICS_MAPPING[metric]) .every((metric) => boardReport?.[metric] ?? false); @@ -51,19 +51,19 @@ const BoardMetrics = ({ startToRequestBoardData, onShowDetail, boardReport, erro const velocity = boardReport?.velocity; const cycleTime = boardReport?.cycleTime; - const velocityItems = boardMetrics.includes(REQUIRED_DATA.VELOCITY) + const velocityItems = boardMetrics.includes(RequiredData.Velocity) ? [ { - title: METRICS_TITLE.VELOCITY, + title: MetricsTitle.Velocity, items: velocity && [ { value: velocity.velocityForSP, - subtitle: METRICS_SUBTITLE.VELOCITY, + subtitle: MetricsSubtitle.Velocity, isToFixed: false, }, { value: velocity.velocityForCards, - subtitle: METRICS_SUBTITLE.THROUGHPUT, + subtitle: MetricsSubtitle.Throughput, isToFixed: false, }, ], @@ -71,18 +71,18 @@ const BoardMetrics = ({ startToRequestBoardData, onShowDetail, boardReport, erro ] : []; - const cycleTimeItems = boardMetrics.includes(REQUIRED_DATA.CYCLE_TIME) + const cycleTimeItems = boardMetrics.includes(RequiredData.CycleTime) ? [ { - title: METRICS_TITLE.CYCLE_TIME, + title: MetricsTitle.CycleTime, items: cycleTime && [ { value: cycleTime.averageCycleTimePerSP, - subtitle: METRICS_SUBTITLE.AVERAGE_CYCLE_TIME_PRE_SP, + subtitle: MetricsSubtitle.AverageCycleTimePerSP, }, { value: cycleTime.averageCycleTimePerCard, - subtitle: METRICS_SUBTITLE.AVERAGE_CYCLE_TIME_PRE_CARD, + subtitle: MetricsSubtitle.AverageCycleTimePerCard, }, ], }, @@ -95,25 +95,25 @@ const BoardMetrics = ({ startToRequestBoardData, onShowDetail, boardReport, erro const getReworkBoardItem = () => { const rework = boardReport?.rework; - const reworkItems = boardMetrics.includes(REQUIRED_DATA.REWORK_TIMES) + const reworkItems = boardMetrics.includes(RequiredData.ReworkTimes) ? [ { - title: METRICS_TITLE.REWORK, + title: MetricsTitle.Rework, items: rework && [ { value: rework.totalReworkTimes, - subtitle: METRICS_SUBTITLE.TOTAL_REWORK_TIMES, + subtitle: MetricsSubtitle.TotalReworkTimes, isToFixed: false, }, { value: rework.totalReworkCards, - subtitle: METRICS_SUBTITLE.TOTAL_REWORK_CARDS, + subtitle: MetricsSubtitle.TotalReworkCards, isToFixed: false, }, { value: Number(rework.reworkCardsRatio) * 100, extraValue: `% (${rework.totalReworkCards}/${rework.throughput})`, - subtitle: METRICS_SUBTITLE.REWORK_CARDS_RATIO, + subtitle: MetricsSubtitle.ReworkCardsRatio, }, ], }, @@ -128,7 +128,7 @@ const BoardMetrics = ({ startToRequestBoardData, onShowDetail, boardReport, erro const isShowMoreLoadingDisplay = () => boardMetrics.length === 1 && - boardMetrics[0] === REQUIRED_DATA.CLASSIFICATION && + boardMetrics[0] === RequiredData.Classification && !errorMessage && !boardReport?.boardMetricsCompleted; diff --git a/frontend/src/containers/ReportStep/BoardMetricsChart/index.tsx b/frontend/src/containers/ReportStep/BoardMetricsChart/index.tsx index 54aa85fcb6..6e7e14b168 100644 --- a/frontend/src/containers/ReportStep/BoardMetricsChart/index.tsx +++ b/frontend/src/containers/ReportStep/BoardMetricsChart/index.tsx @@ -2,7 +2,7 @@ import { stackedAreaOptionMapper, stackedBarOptionMapper, } from '@src/containers/ReportStep/BoardMetricsChart/ChartOption'; -import { CHART_TYPE, CYCLE_TIME_CHARTS_MAPPING, METRICS_CONSTANTS } from '@src/constants/resources'; +import { ChartType, CYCLE_TIME_CHARTS_MAPPING, METRICS_CONSTANTS } from '@src/constants/resources'; import ChartAndTitleWrapper from '@src/containers/ReportStep/ChartAndTitleWrapper'; import { calculateTrendInfo, xAxisLabelDateFormatter } from '@src/utils/util'; import { ReportResponse, Swimlane } from '@src/clients/report/dto/response'; @@ -63,7 +63,7 @@ function extractVelocityData(dateRanges: string[], mappedData?: ReportResponse[] const data = mappedData?.map((item) => item.velocityList); const velocity = data?.map((item) => item?.[0]?.valueList?.[0]?.value as number); const throughput = data?.map((item) => item?.[1]?.valueList?.[0]?.value as number); - const trendInfo = calculateTrendInfo(velocity, dateRanges, CHART_TYPE.VELOCITY); + const trendInfo = calculateTrendInfo(velocity, dateRanges, ChartType.Velocity); return { xAxis: { data: dateRanges, @@ -109,7 +109,7 @@ function extractAverageCycleTimeData(dateRanges: string[], mappedData?: ReportRe const data = mappedData?.map((item) => item.cycleTimeList); const storyPoints = data?.map((item) => item?.[0]?.valueList?.[0]?.value as number); const cardCount = data?.map((item) => item?.[0]?.valueList?.[1]?.value as number); - const trendInfo = calculateTrendInfo(storyPoints, dateRanges, CHART_TYPE.AVERAGE_CYCLE_TIME); + const trendInfo = calculateTrendInfo(storyPoints, dateRanges, ChartType.AverageCycleTime); return { xAxis: { data: dateRanges, @@ -162,7 +162,7 @@ function extractCycleTimeData(dateRanges: string[], mappedData?: ReportResponse[ const developmentPercentageList = indicators.find( ({ name }) => name === CYCLE_TIME_CHARTS_MAPPING[METRICS_CONSTANTS.inDevValue], )?.data; - const trendInfo = calculateTrendInfo(developmentPercentageList, dateRanges, CHART_TYPE.CYCLE_TIME_ALLOCATION); + const trendInfo = calculateTrendInfo(developmentPercentageList, dateRanges, ChartType.CycleTimeAllocation); return { xAxis: dateRanges, @@ -190,7 +190,7 @@ function extractReworkData(dateRanges: string[], mappedData?: ReportResponse[]) const totalReworkCards = data?.map((item) => item?.totalReworkCards as number); const reworkCardsRatio = data?.map((item) => (item?.reworkCardsRatio as number) * 100); - const trendInfo = calculateTrendInfo(totalReworkTimes, dateRanges, CHART_TYPE.REWORK); + const trendInfo = calculateTrendInfo(totalReworkTimes, dateRanges, ChartType.Rework); return { xAxis: { data: dateRanges, diff --git a/frontend/src/containers/ReportStep/ChartAndTitleWrapper/index.tsx b/frontend/src/containers/ReportStep/ChartAndTitleWrapper/index.tsx index a4c24a1995..bb7ce0a336 100644 --- a/frontend/src/containers/ReportStep/ChartAndTitleWrapper/index.tsx +++ b/frontend/src/containers/ReportStep/ChartAndTitleWrapper/index.tsx @@ -2,10 +2,10 @@ import { ChartTitle, StyledTooltipContent, TrendContainer, - TrendIcon, + TrendIconSpan, TrendTypeIcon, } from '@src/containers/ReportStep/ChartAndTitleWrapper/style'; -import { CHART_TREND_TIP, CHART_TYPE, TREND_ICON, TREND_TYPE, UP_TREND_IS_BETTER } from '@src/constants/resources'; +import { CHART_TREND_TIP, ChartType, TrendIcon, TrendType, UP_TREND_IS_BETTER } from '@src/constants/resources'; import TrendingDownSharpIcon from '@mui/icons-material/TrendingDownSharp'; import TrendingUpSharpIcon from '@mui/icons-material/TrendingUpSharp'; import { ChartWrapper } from '@src/containers/MetricsStep/style'; @@ -16,21 +16,21 @@ import { Tooltip } from '@mui/material'; import { theme } from '@src/theme'; export interface ITrendInfo { - icon?: TREND_ICON; + icon?: TrendIcon; trendNumber?: number; dateRangeList?: string[]; - type: CHART_TYPE; - trendType?: TREND_TYPE; + type: ChartType; + trendType?: TrendType; } const TREND_ICON_MAPPING = { - [TREND_ICON.UP]: , - [TREND_ICON.DOWN]: , + [TrendIcon.Up]: , + [TrendIcon.Down]: , }; const TREND_COLOR_MAP = { - [TREND_TYPE.BETTER]: theme.main.chartTrend.betterColor, - [TREND_TYPE.WORSE]: theme.main.chartTrend.worseColor, + [TrendType.Better]: theme.main.chartTrend.betterColor, + [TrendType.Worse]: theme.main.chartTrend.worseColor, }; const DECREASE = 'decrease'; @@ -61,7 +61,7 @@ const ChartAndTitleWrapper = forwardRef(

{`The rate of ${trendDescribe()} for ${CHART_TREND_TIP[trendInfo.type]}: `}

{trendInfo.dateRangeList?.map((dateRange) =>

{dateRange}

)} - +
@@ -77,7 +77,7 @@ const ChartAndTitleWrapper = forwardRef( color={TREND_COLOR_MAP[trendInfo.trendType!]} aria-label={trendInfo.type + ' trend container'} > - {TREND_ICON_MAPPING[trendInfo.icon!]} + {TREND_ICON_MAPPING[trendInfo.icon!]} {convertNumberToPercent(trendInfo.trendNumber)} diff --git a/frontend/src/containers/ReportStep/ChartAndTitleWrapper/style.tsx b/frontend/src/containers/ReportStep/ChartAndTitleWrapper/style.tsx index 08a1d4d076..e05170261c 100644 --- a/frontend/src/containers/ReportStep/ChartAndTitleWrapper/style.tsx +++ b/frontend/src/containers/ReportStep/ChartAndTitleWrapper/style.tsx @@ -11,7 +11,7 @@ export const ChartTitle = styled('div')({ height: '1.5rem', }); -export const TrendIcon = styled('span')({ +export const TrendIconSpan = styled('span')({ position: 'relative', fontSize: '1rem', top: '0.1rem', diff --git a/frontend/src/containers/ReportStep/DoraMetrics/index.tsx b/frontend/src/containers/ReportStep/DoraMetrics/index.tsx index 5d4cbcc82f..0e62e71e5d 100644 --- a/frontend/src/containers/ReportStep/DoraMetrics/index.tsx +++ b/frontend/src/containers/ReportStep/DoraMetrics/index.tsx @@ -1,10 +1,10 @@ import { DORA_METRICS_MAPPING, - METRICS_SUBTITLE, - METRICS_TITLE, + MetricsSubtitle, + MetricsTitle, PIPELINE_METRICS, REPORT_PAGE, - REQUIRED_DATA, + RequiredData, RETRY, SHOW_MORE, SOURCE_CONTROL_METRICS, @@ -31,7 +31,7 @@ interface DoraMetricsProps { const DoraMetrics = ({ startToRequestDoraData, onShowDetail, doraReport, errorMessage }: DoraMetricsProps) => { const configData = useAppSelector(selectConfig); const { metrics } = configData.basic; - const shouldShowSourceControl = metrics.includes(REQUIRED_DATA.LEAD_TIME_FOR_CHANGES); + const shouldShowSourceControl = metrics.includes(RequiredData.LeadTimeForChanges); const sourceControlMetricsCompleted = metrics .filter((metric) => SOURCE_CONTROL_METRICS.includes(metric)) .map((metric) => DORA_METRICS_MAPPING[metric]) @@ -45,19 +45,19 @@ const DoraMetrics = ({ startToRequestDoraData, onShowDetail, doraReport, errorMe const leadTimeForChanges = doraReport?.leadTimeForChanges; return [ { - title: METRICS_TITLE.LEAD_TIME_FOR_CHANGES, + title: MetricsTitle.LeadTimeForChanges, items: leadTimeForChanges && [ { value: formatMinToHours(leadTimeForChanges.avgLeadTimeForChanges.prLeadTime), - subtitle: METRICS_SUBTITLE.PR_LEAD_TIME, + subtitle: MetricsSubtitle.PRLeadTime, }, { value: formatMinToHours(leadTimeForChanges.avgLeadTimeForChanges.pipelineLeadTime), - subtitle: METRICS_SUBTITLE.PIPELINE_LEAD_TIME, + subtitle: MetricsSubtitle.PipelineLeadTime, }, { value: formatMinToHours(leadTimeForChanges.avgLeadTimeForChanges.totalDelayTime), - subtitle: METRICS_SUBTITLE.TOTAL_DELAY_TIME, + subtitle: MetricsSubtitle.TotalDelayTime, }, ], }, @@ -69,43 +69,43 @@ const DoraMetrics = ({ startToRequestDoraData, onShowDetail, doraReport, errorMe const devMeanTimeToRecovery = doraReport?.devMeanTimeToRecovery; const devChangeFailureRate = doraReport?.devChangeFailureRate; - const deploymentFrequencyList = metrics.includes(REQUIRED_DATA.DEPLOYMENT_FREQUENCY) + const deploymentFrequencyList = metrics.includes(RequiredData.DeploymentFrequency) ? [ { - title: METRICS_TITLE.DEPLOYMENT_FREQUENCY, + title: MetricsTitle.DeploymentFrequency, items: deploymentFrequency && [ { value: deploymentFrequency?.avgDeploymentFrequency.deploymentFrequency, - subtitle: METRICS_SUBTITLE.DEPLOYMENT_FREQUENCY, + subtitle: MetricsSubtitle.DeploymentFrequency, }, ], }, ] : []; - const devMeanTimeToRecoveryList = metrics.includes(REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY) + const devMeanTimeToRecoveryList = metrics.includes(RequiredData.DevMeanTimeToRecovery) ? [ { - title: METRICS_TITLE.DEV_MEAN_TIME_TO_RECOVERY, + title: MetricsTitle.DevMeanTimeToRecovery, items: devMeanTimeToRecovery && [ { value: formatMillisecondsToHours(devMeanTimeToRecovery.avgDevMeanTimeToRecovery.timeToRecovery), - subtitle: METRICS_SUBTITLE.DEV_MEAN_TIME_TO_RECOVERY_HOURS, + subtitle: MetricsSubtitle.DevMeanTimeToRecoveryHours, }, ], }, ] : []; - const devChangeFailureRateList = metrics.includes(REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE) + const devChangeFailureRateList = metrics.includes(RequiredData.DevChangeFailureRate) ? [ { - title: METRICS_TITLE.DEV_CHANGE_FAILURE_RATE, + title: MetricsTitle.DevChangeFailureRate, items: devChangeFailureRate && [ { value: devChangeFailureRate.avgDevChangeFailureRate.failureRate * 100, extraValue: `% (${devChangeFailureRate.avgDevChangeFailureRate.totalFailedTimes}/${devChangeFailureRate.avgDevChangeFailureRate.totalTimes})`, - subtitle: METRICS_SUBTITLE.FAILURE_RATE, + subtitle: MetricsSubtitle.FailureRate, }, ], }, diff --git a/frontend/src/containers/ReportStep/DoraMetricsChart/index.tsx b/frontend/src/containers/ReportStep/DoraMetricsChart/index.tsx index 0e03bf461f..96723e0847 100644 --- a/frontend/src/containers/ReportStep/DoraMetricsChart/index.tsx +++ b/frontend/src/containers/ReportStep/DoraMetricsChart/index.tsx @@ -1,17 +1,17 @@ import React, { useEffect, useRef } from 'react'; import * as echarts from 'echarts'; -import { - CHART_TYPE, - EMPTY_DATA_MAPPER_DORA_CHART, - LEAD_TIME_CHARTS_MAPPING, - REQUIRED_DATA, -} from '@src/constants/resources'; import { oneLineOptionMapper, Series, stackedBarOptionMapper, } from '@src/containers/ReportStep/DoraMetricsChart/ChartOption'; +import { + ChartType, + EMPTY_DATA_MAPPER_DORA_CHART, + LEAD_TIME_CHARTS_MAPPING, + RequiredData, +} from '@src/constants/resources'; import { ReportResponse, ReportResponseDTO } from '@src/clients/report/dto/response'; import ChartAndTitleWrapper from '@src/containers/ReportStep/ChartAndTitleWrapper'; import { ChartContainer } from '@src/containers/MetricsStep/style'; @@ -37,7 +37,7 @@ function extractedStackedBarData(allDateRanges: string[], mappedData: ReportResp }), ); const prLeadTimeValues = extractedValues?.map((value) => value![0]); - const trendInfo = calculateTrendInfo(prLeadTimeValues, allDateRanges, CHART_TYPE.LEAD_TIME_FOR_CHANGES); + const trendInfo = calculateTrendInfo(prLeadTimeValues, allDateRanges, ChartType.LeadTimeForChanges); return { legend: 'Lead Time For Change', @@ -69,9 +69,9 @@ function extractedDeploymentFrequencyData(allDateRanges: string[], mappedData: R const value = data?.map((item) => { return Number(item?.[0].valueList[0].value) || 0; }); - const trendInfo = calculateTrendInfo(value, allDateRanges, CHART_TYPE.DEPLOYMENT_FREQUENCY); + const trendInfo = calculateTrendInfo(value, allDateRanges, ChartType.DeploymentFrequency); return { - legend: REQUIRED_DATA.DEPLOYMENT_FREQUENCY, + legend: RequiredData.DeploymentFrequency, xAxis: allDateRanges, yAxis: { name: 'Deployments/Days', @@ -79,7 +79,7 @@ function extractedDeploymentFrequencyData(allDateRanges: string[], mappedData: R axisLabel: NO_LABEL, }, series: { - name: REQUIRED_DATA.DEPLOYMENT_FREQUENCY, + name: RequiredData.DeploymentFrequency, type: 'line', data: value!, }, @@ -94,9 +94,9 @@ function extractedChangeFailureRateData(allDateRanges: string[], mappedData: Rep return item?.[0].valueList[0].value as string; }); const value = valueStr?.map((item) => Number(item?.split('%', 1)[0])); - const trendInfo = calculateTrendInfo(value, allDateRanges, CHART_TYPE.DEV_CHANGE_FAILURE_RATE); + const trendInfo = calculateTrendInfo(value, allDateRanges, ChartType.DevChangeFailureRate); return { - legend: REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE, + legend: RequiredData.DevChangeFailureRate, xAxis: allDateRanges, yAxis: { name: 'Failed/Total', @@ -104,7 +104,7 @@ function extractedChangeFailureRateData(allDateRanges: string[], mappedData: Rep alignTick: false, }, series: { - name: REQUIRED_DATA.DEV_CHANGE_FAILURE_RATE, + name: RequiredData.DevChangeFailureRate, type: 'line', data: value!, }, @@ -118,9 +118,9 @@ function extractedMeanTimeToRecoveryDataData(allDateRanges: string[], mappedData const value = data?.map((item) => { return Number(item?.[0].valueList[0].value) || 0; }); - const trendInfo = calculateTrendInfo(value, allDateRanges, CHART_TYPE.DEV_MEAN_TIME_TO_RECOVERY); + const trendInfo = calculateTrendInfo(value, allDateRanges, ChartType.DevMeanTimeToRecovery); return { - legend: REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY, + legend: RequiredData.DevMeanTimeToRecovery, xAxis: allDateRanges, yAxis: { name: 'Hours', @@ -128,7 +128,7 @@ function extractedMeanTimeToRecoveryDataData(allDateRanges: string[], mappedData axisLabel: NO_LABEL, }, series: { - name: REQUIRED_DATA.DEV_MEAN_TIME_TO_RECOVERY, + name: RequiredData.DevMeanTimeToRecovery, type: 'line', data: value!, }, diff --git a/frontend/src/containers/ReportStep/ReportDetail/board.tsx b/frontend/src/containers/ReportStep/ReportDetail/board.tsx index 5eb9fc725a..f6573e2da0 100644 --- a/frontend/src/containers/ReportStep/ReportDetail/board.tsx +++ b/frontend/src/containers/ReportStep/ReportDetail/board.tsx @@ -1,7 +1,7 @@ import { isOnlySelectClassification, selectMetrics } from '@src/context/config/configSlice'; import { ReportDataWithTwoColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; import ReportForThreeColumns from '@src/components/Common/ReportForThreeColumns'; -import { MESSAGE, METRICS_TITLE, REQUIRED_DATA } from '@src/constants/resources'; +import { MESSAGE, MetricsTitle, RequiredData } from '@src/constants/resources'; import { addNotification } from '@src/context/notification/NotificationSlice'; import ReportForTwoColumns from '@src/components/Common/ReportForTwoColumns'; import { ReportResponseDTO } from '@src/clients/report/dto/response'; @@ -40,18 +40,18 @@ export const BoardDetail = withGoBack(({ data, errorMessage }: Property) => { return ( <> - {showSectionWith2Columns(METRICS_TITLE.VELOCITY, mappedData?.velocityList)} - {showSectionWith2Columns(METRICS_TITLE.CYCLE_TIME, mappedData?.cycleTimeList)} - {metrics.includes(REQUIRED_DATA.CLASSIFICATION) && ( + {showSectionWith2Columns(MetricsTitle.Velocity, mappedData?.velocityList)} + {showSectionWith2Columns(MetricsTitle.CycleTime, mappedData?.cycleTimeList)} + {metrics.includes(RequiredData.Classification) && ( )} - {showSectionWith2Columns(METRICS_TITLE.REWORK, mappedData?.reworkList)} + {showSectionWith2Columns(MetricsTitle.Rework, mappedData?.reworkList)} ); }); diff --git a/frontend/src/containers/ReportStep/ReportDetail/dora.tsx b/frontend/src/containers/ReportStep/ReportDetail/dora.tsx index cc4d0519bf..d1afa01fd4 100644 --- a/frontend/src/containers/ReportStep/ReportDetail/dora.tsx +++ b/frontend/src/containers/ReportStep/ReportDetail/dora.tsx @@ -1,6 +1,6 @@ import { ReportDataWithThreeColumns, ReportDataWithTwoColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; -import { METRICS_TITLE, PIPELINE_STEP, SUBTITLE } from '@src/constants/resources'; import ReportForThreeColumns from '@src/components/Common/ReportForThreeColumns'; +import { MetricsTitle, PIPELINE_STEP, SUBTITLE } from '@src/constants/resources'; import ReportForTwoColumns from '@src/components/Common/ReportForTwoColumns'; import { ReportResponseDTO } from '@src/clients/report/dto/response'; import { reportMapper } from '@src/hooks/reportMapper/report'; @@ -24,10 +24,10 @@ export const DoraDetail = withGoBack(({ data }: Property) => { return ( <> - {showTwoColumnSection(METRICS_TITLE.DEPLOYMENT_FREQUENCY, mappedData.deploymentFrequencyList)} - {showThreeColumnSection(METRICS_TITLE.LEAD_TIME_FOR_CHANGES, mappedData.leadTimeForChangesList)} - {showTwoColumnSection(METRICS_TITLE.DEV_CHANGE_FAILURE_RATE, mappedData.devChangeFailureRateList)} - {showTwoColumnSection(METRICS_TITLE.DEV_MEAN_TIME_TO_RECOVERY, mappedData.devMeanTimeToRecoveryList)} + {showTwoColumnSection(MetricsTitle.DeploymentFrequency, mappedData.deploymentFrequencyList)} + {showThreeColumnSection(MetricsTitle.LeadTimeForChanges, mappedData.leadTimeForChangesList)} + {showTwoColumnSection(MetricsTitle.DevChangeFailureRate, mappedData.devChangeFailureRateList)} + {showTwoColumnSection(MetricsTitle.DevMeanTimeToRecovery, mappedData.devMeanTimeToRecoveryList)} ); }); diff --git a/frontend/src/containers/ReportStep/index.tsx b/frontend/src/containers/ReportStep/index.tsx index b71c4d4ee6..a0f285304f 100644 --- a/frontend/src/containers/ReportStep/index.tsx +++ b/frontend/src/containers/ReportStep/index.tsx @@ -47,10 +47,10 @@ import { DORA_METRICS, MESSAGE, REPORT_PAGE_TYPE, - REQUIRED_DATA, + RequiredData, } from '@src/constants/resources'; import { IPipelineConfig, selectMetricsContent } from '@src/context/Metrics/metricsSlice'; -import { CHART_INDEX, DISPLAY_TYPE, METRIC_TYPES } from '@src/constants/commons'; +import { CHART_INDEX, DISPLAY_TYPE, MetricTypes } from '@src/constants/commons'; import { DoraMetricsChart } from '@src/containers/ReportStep/DoraMetricsChart'; import { backStep, selectTimeStamp } from '@src/context/stepper/StepperSlice'; import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted'; @@ -74,9 +74,9 @@ export interface ReportStepProps { } const timeoutNotificationMessages = { - [TimeoutErrorKey[METRIC_TYPES.BOARD]]: 'Board metrics', - [TimeoutErrorKey[METRIC_TYPES.DORA]]: 'DORA metrics', - [TimeoutErrorKey[METRIC_TYPES.ALL]]: 'Report', + [TimeoutErrorKey[MetricTypes.Board]]: 'Board metrics', + [TimeoutErrorKey[MetricTypes.DORA]]: 'DORA metrics', + [TimeoutErrorKey[MetricTypes.All]]: 'Report', }; export interface DateRangeRequestResult { @@ -142,7 +142,7 @@ const ReportStep = ({ handleSave }: ReportStepProps) => { const { metrics, calendarType } = configData.basic; const boardingMappingStates = [...new Set(cycleTimeSettings.map((item) => item.value))]; const isOnlyEmptyAndDoneState = onlyEmptyAndDoneState(boardingMappingStates); - const includeRework = metrics.includes(REQUIRED_DATA.REWORK_TIMES); + const includeRework = metrics.includes(RequiredData.ReworkTimes); const shouldShowBoardMetrics = useAppSelector(isSelectBoardMetrics); const shouldShowDoraMetrics = useAppSelector(isSelectDoraMetrics); const shouldShowTabs = allDateRanges.length > 1; @@ -264,8 +264,8 @@ const ReportStep = ({ handleSave }: ReportStepProps) => { csvTimeStamp, metrics, metricTypes: [ - ...(shouldShowBoardMetrics ? [METRIC_TYPES.BOARD] : []), - ...(shouldShowDoraMetrics ? [METRIC_TYPES.DORA] : []), + ...(shouldShowBoardMetrics ? [MetricTypes.Board] : []), + ...(shouldShowDoraMetrics ? [MetricTypes.DORA] : []), ], jiraBoardSetting: shouldShowBoardMetrics ? getJiraBoardSetting() : undefined, ...(shouldShowDoraMetrics ? getDoraSetting() : {}), @@ -274,7 +274,7 @@ const ReportStep = ({ handleSave }: ReportStepProps) => { const boardReportRequestBody = { ...basicReportRequestBody, metrics: metrics.filter((metric) => BOARD_METRICS.includes(metric)), - metricTypes: [METRIC_TYPES.BOARD], + metricTypes: [MetricTypes.Board], buildKiteSetting: undefined, codebaseSetting: undefined, }; @@ -282,7 +282,7 @@ const ReportStep = ({ handleSave }: ReportStepProps) => { const doraReportRequestBody = { ...basicReportRequestBody, metrics: metrics.filter((metric) => DORA_METRICS.includes(metric)), - metricTypes: [METRIC_TYPES.DORA], + metricTypes: [MetricTypes.DORA], jiraBoardSetting: undefined, }; diff --git a/frontend/src/context/Metrics/metricsSlice.ts b/frontend/src/context/Metrics/metricsSlice.ts index c5f95e0f17..73f46c7970 100644 --- a/frontend/src/context/Metrics/metricsSlice.ts +++ b/frontend/src/context/Metrics/metricsSlice.ts @@ -1,7 +1,7 @@ import { ASSIGNEE_FILTER_TYPES, CYCLE_TIME_LIST, - CYCLE_TIME_SETTINGS_TYPES, + CycleTimeSettingsTypes, MESSAGE, METRICS_CONSTANTS, } from '@src/constants/resources'; @@ -48,7 +48,7 @@ export interface ISavedMetricsSettingState { users: string[]; pipelineCrews: string[]; doneColumn: string[]; - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES; + cycleTimeSettingsType: CycleTimeSettingsTypes; cycleTimeSettings: ICycleTimeSetting[]; deploymentFrequencySettings: IPipelineConfig[]; leadTimeForChanges: IPipelineConfig[]; @@ -85,7 +85,7 @@ const initialState: ISavedMetricsSettingState = { users: [], pipelineCrews: [], doneColumn: [], - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN, + cycleTimeSettingsType: CycleTimeSettingsTypes.BY_COLUMN, cycleTimeSettings: [], deploymentFrequencySettings: [], leadTimeForChanges: [{ id: 0, organization: '', pipelineName: '', step: '', branches: [] }], @@ -408,7 +408,7 @@ export const metricsSlice = createSlice({ ); const metricsContainsValues = Object.values(METRICS_CONSTANTS); const importedKeyMismatchWarning = - state.cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN + state.cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN ? compareArrays(importedCycleTimeSettingsKeys, jiraColumnsNames, 'column') : compareArrays(importedCycleTimeSettingsKeys, jiraStatuses, 'status'); const importedValueMismatchWarning = findDifferentValues( @@ -446,7 +446,7 @@ export const metricsSlice = createSlice({ } if (jiraColumns) { state.cycleTimeSettings = - state.cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN + state.cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN ? getCycleTimeSettingsByColumn(state, jiraColumns) : getCycleTimeSettingsByStatus(state, jiraColumns); } diff --git a/frontend/src/context/config/configSlice.ts b/frontend/src/context/config/configSlice.ts index 897505b953..fb8a81bf5f 100644 --- a/frontend/src/context/config/configSlice.ts +++ b/frontend/src/context/config/configSlice.ts @@ -6,7 +6,7 @@ import { IMPORT_METRICS_MAPPING, MAX_TIME_RANGE_AMOUNT, MESSAGE, - REQUIRED_DATA, + RequiredData, } from '@src/constants/resources'; import { initialPipelineToolState, IPipelineToolState } from '@src/context/config/pipelineTool/pipelineToolSlice'; import { initialSourceControlState, ISourceControl } from '@src/context/config/sourceControl/sourceControlSlice'; @@ -64,19 +64,19 @@ export const initialBasicConfigState: BasicConfigState = { const getMetricsInfo = (metrics: string[]) => { const { - VELOCITY, - CYCLE_TIME, - CLASSIFICATION, - LEAD_TIME_FOR_CHANGES, - DEPLOYMENT_FREQUENCY, - DEV_CHANGE_FAILURE_RATE, - DEV_MEAN_TIME_TO_RECOVERY, - REWORK_TIMES, - } = REQUIRED_DATA; + Velocity: VELOCITY, + CycleTime: CYCLE_TIME, + Classification: CLASSIFICATION, + LeadTimeForChanges: LEAD_TIME_FOR_CHANGES, + DeploymentFrequency: DEPLOYMENT_FREQUENCY, + DevChangeFailureRate: DEV_CHANGE_FAILURE_RATE, + DevMeanTimeToRecovery: DEV_MEAN_TIME_TO_RECOVERY, + ReworkTimes: REWORK_TIMES, + } = RequiredData; return { metrics: metrics .map((metric) => IMPORT_METRICS_MAPPING[metric]) - .filter((metric) => (Object.values(REQUIRED_DATA) as string[]).includes(metric)), + .filter((metric) => (Object.values(RequiredData) as string[]).includes(metric)), shouldBoardShow: [VELOCITY, CYCLE_TIME, CLASSIFICATION, REWORK_TIMES].some((metric) => metrics.includes(metric)), shouldPipelineToolShow: [ LEAD_TIME_FOR_CHANGES, @@ -238,10 +238,10 @@ export const isSelectBoardMetrics = (state: RootState) => export const isSelectDoraMetrics = (state: RootState) => state.config.basic.metrics.some((metric) => DORA_METRICS.includes(metric)); export const isOnlySelectClassification = (state: RootState) => - state.config.basic.metrics.length === 1 && state.config.basic.metrics[0] === REQUIRED_DATA.CLASSIFICATION; + state.config.basic.metrics.length === 1 && state.config.basic.metrics[0] === RequiredData.Classification; export const isSelectDoraMetricsAndClassification = (state: RootState) => state.config.basic.metrics.some((metric) => DORA_METRICS.includes(metric)) && - state.config.basic.metrics.includes(REQUIRED_DATA.CLASSIFICATION) && + state.config.basic.metrics.includes(RequiredData.Classification) && !state.config.basic.metrics.some((metric) => BOARD_METRICS_EXCLUDE_CLASSIFICATION.includes(metric)); export const selectBoard = (state: RootState) => state.config.board.config; export const selectPipelineTool = (state: RootState) => state.config.pipelineTool.config; diff --git a/frontend/src/context/config/sourceControl/sourceControlSlice.ts b/frontend/src/context/config/sourceControl/sourceControlSlice.ts index c5d0a3bbeb..3820e6721b 100644 --- a/frontend/src/context/config/sourceControl/sourceControlSlice.ts +++ b/frontend/src/context/config/sourceControl/sourceControlSlice.ts @@ -1,5 +1,5 @@ import { initSourceControlVerifyResponseState, ISourceControlVerifyResponse } from './verifyResponseSlice'; -import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; +import { SourceControlTypes } from '@src/constants/resources'; export interface ISourceControl { config: { type: string; token: string }; @@ -9,7 +9,7 @@ export interface ISourceControl { export const initialSourceControlState: ISourceControl = { config: { - type: SOURCE_CONTROL_TYPES.GITHUB, + type: SourceControlTypes.GitHub, token: '', }, isShow: false, diff --git a/frontend/src/hooks/reportMapper/cycleTime.ts b/frontend/src/hooks/reportMapper/cycleTime.ts index 8dd4f3644e..3c7b6fc15b 100644 --- a/frontend/src/hooks/reportMapper/cycleTime.ts +++ b/frontend/src/hooks/reportMapper/cycleTime.ts @@ -1,5 +1,5 @@ -import { CYCLE_TIME_METRICS_NAME, METRICS_CONSTANTS, REPORT_SUFFIX_UNITS } from '@src/constants/resources'; import { ReportDataWithTwoColumns, ValueWithUnits } from '@src/hooks/reportMapper/reportUIDataStructure'; +import { CycleTimeMetricsName, METRICS_CONSTANTS, ReportSuffixUnits } from '@src/constants/resources'; import { CycleTimeResponse, Swimlane } from '@src/clients/report/dto/response'; export const cycleTimeMapper = ({ @@ -21,10 +21,10 @@ export const cycleTimeMapper = ({ const swimlane = getSwimlaneByItemName(itemName); return swimlane ? [ - { value: swimlane.averageTimeForSP.toFixed(2), unit: REPORT_SUFFIX_UNITS.PER_SP }, + { value: swimlane.averageTimeForSP.toFixed(2), unit: ReportSuffixUnits.DaysPerSP }, { value: swimlane.averageTimeForCards.toFixed(2), - unit: REPORT_SUFFIX_UNITS.PER_CARD, + unit: ReportSuffixUnits.DaysPerCard, }, ] : []; @@ -32,10 +32,10 @@ export const cycleTimeMapper = ({ const cycleTimeValue: { [key: string]: ValueWithUnits[] } = { AVERAGE_CYCLE_TIME: [ - { value: Number(averageCycleTimePerSP.toFixed(2)), unit: REPORT_SUFFIX_UNITS.PER_SP }, + { value: Number(averageCycleTimePerSP.toFixed(2)), unit: ReportSuffixUnits.DaysPerSP }, { value: averageCycleTimePerCard.toFixed(2), - unit: REPORT_SUFFIX_UNITS.PER_CARD, + unit: ReportSuffixUnits.DaysPerCard, }, ], DEVELOPMENT_PROPORTION: calPerColumnTotalTimeDivTotalTime(METRICS_CONSTANTS.inDevValue), @@ -50,7 +50,7 @@ export const cycleTimeMapper = ({ AVERAGE_TESTING_TIME: getAverageTimeForPerColumn(METRICS_CONSTANTS.testingValue), }; - Object.entries(CYCLE_TIME_METRICS_NAME).map(([key, cycleName]) => { + Object.entries(CycleTimeMetricsName).map(([key, cycleName]) => { if (cycleTimeValue[key].length > 0) { mappedCycleTimeValue.push({ id: mappedCycleTimeValue.length, name: cycleName, valueList: cycleTimeValue[key] }); } diff --git a/frontend/src/hooks/reportMapper/velocity.ts b/frontend/src/hooks/reportMapper/velocity.ts index 33bf5e83d7..3ab757fef9 100644 --- a/frontend/src/hooks/reportMapper/velocity.ts +++ b/frontend/src/hooks/reportMapper/velocity.ts @@ -1,16 +1,16 @@ import { ReportDataWithTwoColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; import { VelocityResponse } from '@src/clients/report/dto/response'; -import { VELOCITY_METRICS_NAME } from '@src/constants/resources'; +import { VelocityMetricsName } from '@src/constants/resources'; export const velocityMapper = ({ velocityForSP, velocityForCards }: VelocityResponse) => { const mappedVelocityValue: ReportDataWithTwoColumns[] = []; const velocityValue: { [key: string]: number } = { - VELOCITY_SP: velocityForSP, - THROUGHPUT_CARDS_COUNT: velocityForCards, + VelocitySP: velocityForSP, + ThroughputCardsCount: velocityForCards, }; - Object.entries(VELOCITY_METRICS_NAME).map(([key, velocityName], index) => { + Object.entries(VelocityMetricsName).map(([key, velocityName], index) => { mappedVelocityValue.push({ id: index, name: velocityName, diff --git a/frontend/src/hooks/useGenerateReportEffect.ts b/frontend/src/hooks/useGenerateReportEffect.ts index 97c29ac5f0..493ab027ea 100644 --- a/frontend/src/hooks/useGenerateReportEffect.ts +++ b/frontend/src/hooks/useGenerateReportEffect.ts @@ -12,7 +12,7 @@ import { IPollingRes, reportClient } from '@src/clients/report/ReportClient'; import { ReportRequestDTO } from '@src/clients/report/dto/request'; import { useAppDispatch } from '@src/hooks/useAppDispatch'; import { TimeoutError } from '@src/errors/TimeoutError'; -import { METRIC_TYPES } from '@src/constants/commons'; +import { MetricTypes } from '@src/constants/commons'; import { useAppSelector } from '@src/hooks/index'; import { useRef, useState } from 'react'; import get from 'lodash/get'; @@ -69,21 +69,21 @@ export const initReportInfo = (): IReportInfo => ({ }); export const TimeoutErrorKey = { - [METRIC_TYPES.BOARD]: 'timeout4Board', - [METRIC_TYPES.DORA]: 'timeout4Dora', - [METRIC_TYPES.ALL]: 'timeout4Report', + [MetricTypes.Board]: 'timeout4Board', + [MetricTypes.DORA]: 'timeout4Dora', + [MetricTypes.All]: 'timeout4Report', }; export const GeneralErrorKey = { - [METRIC_TYPES.BOARD]: 'generalError4Board', - [METRIC_TYPES.DORA]: 'generalError4Dora', - [METRIC_TYPES.ALL]: 'generalError4Report', + [MetricTypes.Board]: 'generalError4Board', + [MetricTypes.DORA]: 'generalError4Dora', + [MetricTypes.All]: 'generalError4Report', }; const REJECTED = 'rejected'; const FULFILLED = 'fulfilled'; -const getErrorKey = (error: Error, source: METRIC_TYPES): string => { +const getErrorKey = (error: Error, source: MetricTypes): string => { return error instanceof TimeoutError ? TimeoutErrorKey[source] : GeneralErrorKey[source]; }; @@ -143,7 +143,7 @@ export const useGenerateReportEffect = (): IUseGenerateReportEffect => { reportInfo.shouldShowPipelineMetricsError = true; reportInfo.shouldShowSourceControlMetricsError = true; } else { - const errorKey = getErrorKey(matchedRes.reason, METRIC_TYPES.ALL) as keyof IReportError; + const errorKey = getErrorKey(matchedRes.reason, MetricTypes.All) as keyof IReportError; reportInfo[errorKey] = { message: DATA_LOADING_FAILED, shouldShow: true }; } return reportInfo; @@ -194,7 +194,7 @@ export const useGenerateReportEffect = (): IUseGenerateReportEffect => { return preReportInfos.map((reportInfo) => { if (metricTypes.length === 2) { reportInfo.timeout4Report = { message: DEFAULT_MESSAGE, shouldShow: true }; - } else if (metricTypes.includes(METRIC_TYPES.BOARD)) { + } else if (metricTypes.includes(MetricTypes.Board)) { reportInfo.timeout4Board = { message: DEFAULT_MESSAGE, shouldShow: true }; } else { reportInfo.timeout4Dora = { message: DEFAULT_MESSAGE, shouldShow: true }; @@ -220,7 +220,7 @@ export const useGenerateReportEffect = (): IUseGenerateReportEffect => { const updateErrorAfterFetchReport = ( res: PromiseSettledResult[], - metricTypes: METRIC_TYPES[], + metricTypes: MetricTypes[], ) => { updateReportPageFailedTimeRangeInfosAfterReport(res); @@ -230,7 +230,7 @@ export const useGenerateReportEffect = (): IUseGenerateReportEffect => { return preReportInfos.map((resInfo, index) => { const currentRes = res[index]; if (currentRes.status === REJECTED) { - const source: METRIC_TYPES = metricTypes.length === 2 ? METRIC_TYPES.ALL : metricTypes[0]; + const source: MetricTypes = metricTypes.length === 2 ? MetricTypes.All : metricTypes[0]; const errorKey = getErrorKey(currentRes.reason, source) as keyof IReportError; resInfo[errorKey] = { message: DATA_LOADING_FAILED, shouldShow: true }; } diff --git a/frontend/src/hooks/useGetBoardInfo.ts b/frontend/src/hooks/useGetBoardInfo.ts index 725a6a5e52..b715326407 100644 --- a/frontend/src/hooks/useGetBoardInfo.ts +++ b/frontend/src/hooks/useGetBoardInfo.ts @@ -1,8 +1,8 @@ -import { AXIOS_REQUEST_ERROR_CODE, BOARD_CONFIG_INFO_ERROR, BOARD_CONFIG_INFO_TITLE } from '@src/constants/resources'; +import { AxiosRequestErrorCode, BOARD_CONFIG_INFO_ERROR, BOARD_CONFIG_INFO_TITLE } from '@src/constants/resources'; import { updateMetricsPageFailedTimeRangeInfos } from '@src/context/stepper/StepperSlice'; import { boardInfoClient } from '@src/clients/board/BoardInfoClient'; import { BoardInfoConfigDTO } from '@src/clients/board/dto/request'; -import { METRICS_DATA_FAIL_STATUS } from '@src/constants/commons'; +import { MetricsDataFailStatus } from '@src/constants/commons'; import { formatDateToTimestampString } from '@src/utils/util'; import { useAppDispatch } from '@src/hooks/index'; import { ReactNode, useState } from 'react'; @@ -25,45 +25,45 @@ export interface useGetBoardInfoInterface { getBoardInfo: (data: BoardInfoConfigDTO) => Promise | undefined>; isLoading: boolean; errorMessage: Record; - boardInfoFailedStatus: METRICS_DATA_FAIL_STATUS; + boardInfoFailedStatus: MetricsDataFailStatus; } const boardInfoPartialFailedStatusMapping = (code: string | number) => { - if (code == AXIOS_REQUEST_ERROR_CODE.TIMEOUT) { - return METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT; + if (code == AxiosRequestErrorCode.Timeout) { + return MetricsDataFailStatus.PartialFailedTimeout; } const numericCode = code as number; if (numericCode >= HttpStatusCode.BadRequest && numericCode < HttpStatusCode.InternalServerError) { - return METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX; + return MetricsDataFailStatus.PartialFailed4xx; } - return METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX; + return MetricsDataFailStatus.PartialFailed4xx; }; -const errorStatusMap = (status: METRICS_DATA_FAIL_STATUS) => { +const errorStatusMap = (status: MetricsDataFailStatus) => { const errorStatusMap = { - [METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX]: { + [MetricsDataFailStatus.PartialFailed4xx]: { errorMessage: { title: BOARD_CONFIG_INFO_TITLE.GENERAL_ERROR, message: BOARD_CONFIG_INFO_ERROR.GENERAL_ERROR, code: HttpStatusCode.BadRequest, }, - elevateStatus: METRICS_DATA_FAIL_STATUS.ALL_FAILED_4XX, + elevateStatus: MetricsDataFailStatus.AllFailed4xx, }, - [METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT]: { + [MetricsDataFailStatus.PartialFailedTimeout]: { errorMessage: { title: BOARD_CONFIG_INFO_TITLE.EMPTY, message: BOARD_CONFIG_INFO_ERROR.RETRY, - code: AXIOS_REQUEST_ERROR_CODE.TIMEOUT, + code: AxiosRequestErrorCode.Timeout, }, - elevateStatus: METRICS_DATA_FAIL_STATUS.ALL_FAILED_TIMEOUT, + elevateStatus: MetricsDataFailStatus.AllFailedTimeout, }, - [METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_NO_CARDS]: { + [MetricsDataFailStatus.PartialFailedNoCards]: { errorMessage: { title: BOARD_CONFIG_INFO_TITLE.NO_CONTENT, message: BOARD_CONFIG_INFO_ERROR.NOT_CONTENT, - code: AXIOS_REQUEST_ERROR_CODE.NO_CARDS, + code: AxiosRequestErrorCode.NoCards, }, - elevateStatus: METRICS_DATA_FAIL_STATUS.ALL_FAILED_NO_CARDS, + elevateStatus: MetricsDataFailStatus.AllFailedNoCards, }, }; return get(errorStatusMap, status); @@ -73,14 +73,14 @@ export const useGetBoardInfoEffect = (): useGetBoardInfoInterface => { const dispatch = useAppDispatch(); const [isLoading, setIsLoading] = useState(false); const [errorMessage, setErrorMessage] = useState({}); - const [boardInfoFailedStatus, setBoardInfoFailedStatus] = useState(METRICS_DATA_FAIL_STATUS.NOT_FAILED); + const [boardInfoFailedStatus, setBoardInfoFailedStatus] = useState(MetricsDataFailStatus.NotFailed); const getBoardInfo = async (data: BoardInfoConfigDTO) => { setIsLoading(true); setErrorMessage({}); const localFailedTimeRangeList: string[] = []; let errorCount = 0; - let localBoardInfoFailedStatus: METRICS_DATA_FAIL_STATUS; + let localBoardInfoFailedStatus: MetricsDataFailStatus; if (data.dateRanges) { const dateRangeCopy = Array.from(data.dateRanges); @@ -105,9 +105,9 @@ export const useGetBoardInfoEffect = (): useGetBoardInfoInterface => { .then((res) => { if (!res.data) { errorCount++; - localBoardInfoFailedStatus = METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_NO_CARDS; + localBoardInfoFailedStatus = MetricsDataFailStatus.PartialFailedNoCards; localFailedTimeRangeList.push(formatDateToTimestampString(info.startDate as string)); - setBoardInfoFailedStatus(METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_NO_CARDS); + setBoardInfoFailedStatus(MetricsDataFailStatus.PartialFailedNoCards); } return res; }) diff --git a/frontend/src/hooks/useGetMetricsStepsEffect.ts b/frontend/src/hooks/useGetMetricsStepsEffect.ts index 750e72fc40..4c5c61cc1c 100644 --- a/frontend/src/hooks/useGetMetricsStepsEffect.ts +++ b/frontend/src/hooks/useGetMetricsStepsEffect.ts @@ -1,7 +1,7 @@ import { updateMetricsPageFailedTimeRangeInfos } from '@src/context/stepper/StepperSlice'; import { updateShouldRetryPipelineConfig } from '@src/context/Metrics/metricsSlice'; import { IStepsParams, IStepsRes, metricsClient } from '@src/clients/MetricsClient'; -import { METRICS_DATA_FAIL_STATUS, DURATION } from '@src/constants/commons'; +import { MetricsDataFailStatus, DURATION } from '@src/constants/commons'; import { FULFILLED, MESSAGE, REJECTED } from '@src/constants/resources'; import { useAppDispatch } from '@src/hooks/useAppDispatch'; import { TimeoutError } from '@src/errors/TimeoutError'; @@ -17,7 +17,7 @@ export interface useGetMetricsStepsEffectInterface { ) => Promise; isLoading: boolean; errorMessage: string; - stepFailedStatus: METRICS_DATA_FAIL_STATUS; + stepFailedStatus: MetricsDataFailStatus; } const TIMEOUT = 'timeout'; @@ -32,7 +32,7 @@ export const useGetMetricsStepsEffect = (): useGetMetricsStepsEffectInterface => const dispatch = useAppDispatch(); const [isLoading, setIsLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(''); - const [stepFailedStatus, setStepFailedStatus] = useState(METRICS_DATA_FAIL_STATUS.NOT_FAILED); + const [stepFailedStatus, setStepFailedStatus] = useState(MetricsDataFailStatus.NotFailed); const getSteps = async ( params: IStepsParams[], @@ -73,13 +73,13 @@ export const useGetMetricsStepsEffect = (): useGetMetricsStepsEffectInterface => ), ); if (!hasRejected) { - setStepFailedStatus(METRICS_DATA_FAIL_STATUS.NOT_FAILED); + setStepFailedStatus(MetricsDataFailStatus.NotFailed); } else if (hasRejected && hasFulfilled) { const rejectedStep = allStepsRes.find((stepInfo) => stepInfo.status === REJECTED); if ((rejectedStep as PromiseRejectedResult).reason.code == 400) { - setStepFailedStatus(METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_4XX); + setStepFailedStatus(MetricsDataFailStatus.PartialFailed4xx); } else { - setStepFailedStatus(METRICS_DATA_FAIL_STATUS.PARTIAL_FAILED_TIMEOUT); + setStepFailedStatus(MetricsDataFailStatus.PartialFailedTimeout); } } setIsLoading(false); diff --git a/frontend/src/hooks/useVerifyBoardEffect.ts b/frontend/src/hooks/useVerifyBoardEffect.ts index 6f5e3f4796..38f7a7f7ad 100644 --- a/frontend/src/hooks/useVerifyBoardEffect.ts +++ b/frontend/src/hooks/useVerifyBoardEffect.ts @@ -1,4 +1,4 @@ -import { AXIOS_REQUEST_ERROR_CODE, UNKNOWN_ERROR_TITLE } from '@src/constants/resources'; +import { AxiosRequestErrorCode, UNKNOWN_ERROR_TITLE } from '@src/constants/resources'; import { BOARD_CONFIG_ERROR_MESSAGE } from '@src/containers/ConfigStep/Form/literal'; import { useDefaultValues } from '@src/containers/ConfigStep/Form/useDefaultValues'; import { updateTreatFlagCardAsBlock } from '@src/context/Metrics/metricsSlice'; @@ -16,12 +16,12 @@ import { isAppError } from '@src/errors'; import { HttpStatusCode } from 'axios'; import { useState } from 'react'; -export enum FIELD_KEY { - TYPE = 0, - BOARD_ID = 1, - EMAIL = 2, - SITE = 3, - TOKEN = 4, +export enum FieldKey { + Type = 0, + BoardID = 1, + EMail = 2, + Site = 3, + Token = 4, } export interface IField { @@ -117,7 +117,7 @@ export const useVerifyBoardEffect = (): useVerifyBoardStateInterface => { setError(KEYS.SITE, { message: BOARD_CONFIG_ERROR_MESSAGE.site.verifyFailed }); } else if (code === HttpStatusCode.NotFound && description === ERROR_INFO.BOARD_NOT_FOUND) { setError(KEYS.BOARD_ID, { message: BOARD_CONFIG_ERROR_MESSAGE.boardId.verifyFailed }); - } else if (code === AXIOS_REQUEST_ERROR_CODE.TIMEOUT) { + } else if (code === AxiosRequestErrorCode.Timeout) { setError(KEYS.TOKEN, { message: BOARD_CONFIG_ERROR_MESSAGE.token.timeout }); } else { setError(KEYS.TOKEN, { message: UNKNOWN_ERROR_TITLE }); diff --git a/frontend/src/hooks/useVerifyPipelineToolEffect.ts b/frontend/src/hooks/useVerifyPipelineToolEffect.ts index c07048512e..0732561437 100644 --- a/frontend/src/hooks/useVerifyPipelineToolEffect.ts +++ b/frontend/src/hooks/useVerifyPipelineToolEffect.ts @@ -7,15 +7,15 @@ import { TPipelineToolFieldKeys } from '@src/containers/ConfigStep/Form/type'; import { IPipelineVerifyRequestDTO } from '@src/clients/pipeline/dto/request'; import { IPipelineToolData } from '@src/containers/ConfigStep/Form/schema'; import { updatePipelineTool } from '@src/context/config/configSlice'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { useFormContext } from 'react-hook-form'; import { useAppDispatch } from '@src/hooks'; import { HttpStatusCode } from 'axios'; import { useState } from 'react'; -export enum FIELD_KEY { - TYPE = 0, - TOKEN = 1, +export enum FieldKey { + Type = 0, + Token = 1, } interface IField { key: TPipelineToolFieldKeys; @@ -49,14 +49,14 @@ export const useVerifyPipelineToolEffect = () => { if (response.code === HttpStatusCode.NoContent) { reset(pipelineToolOriginal, { keepValues: true }); persistReduxData(values); - } else if (response.code === AXIOS_REQUEST_ERROR_CODE.TIMEOUT) { - setError(fields[FIELD_KEY.TOKEN].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.timeout }); + } else if (response.code === AxiosRequestErrorCode.Timeout) { + setError(fields[FieldKey.Token].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.timeout }); } else if (response.code === HttpStatusCode.Unauthorized) { - setError(fields[FIELD_KEY.TOKEN].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.unauthorized }); + setError(fields[FieldKey.Token].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.unauthorized }); } else if (response.code === HttpStatusCode.Forbidden) { - setError(fields[FIELD_KEY.TOKEN].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.forbidden }); + setError(fields[FieldKey.Token].key, { message: PIPELINE_TOOL_ERROR_MESSAGE.token.forbidden }); } else { - setError(fields[FIELD_KEY.TOKEN].key, { message: response.errorTitle }); + setError(fields[FieldKey.Token].key, { message: response.errorTitle }); } setIsLoading(false); }; diff --git a/frontend/src/hooks/useVerifySourceControlTokenEffect.ts b/frontend/src/hooks/useVerifySourceControlTokenEffect.ts index 87bbbd13f6..d127cd95af 100644 --- a/frontend/src/hooks/useVerifySourceControlTokenEffect.ts +++ b/frontend/src/hooks/useVerifySourceControlTokenEffect.ts @@ -6,15 +6,15 @@ import { useDefaultValues } from '@src/containers/ConfigStep/Form/useDefaultValu import { TSourceControlFieldKeys } from '@src/containers/ConfigStep/Form/type'; import { ISourceControlData } from '@src/containers/ConfigStep/Form/schema'; import { updateSourceControl } from '@src/context/config/configSlice'; -import { AXIOS_REQUEST_ERROR_CODE } from '@src/constants/resources'; +import { AxiosRequestErrorCode } from '@src/constants/resources'; import { useAppDispatch } from '@src/hooks/index'; import { useFormContext } from 'react-hook-form'; import { HttpStatusCode } from 'axios'; import { useState } from 'react'; -export enum FIELD_KEY { - TYPE = 0, - TOKEN = 1, +export enum FieldKey { + Type = 0, + Token = 1, } interface IField { @@ -47,12 +47,12 @@ export const useVerifySourceControlTokenEffect = () => { if (response.code === HttpStatusCode.NoContent) { persistReduxData(values); reset(sourceControlOriginal, { keepValues: true }); - } else if (response.code === AXIOS_REQUEST_ERROR_CODE.TIMEOUT) { - setError(fields[FIELD_KEY.TOKEN].key, { message: SOURCE_CONTROL_ERROR_MESSAGE.token.timeout }); + } else if (response.code === AxiosRequestErrorCode.Timeout) { + setError(fields[FieldKey.Token].key, { message: SOURCE_CONTROL_ERROR_MESSAGE.token.timeout }); } else if (response.code === HttpStatusCode.Unauthorized) { - setError(fields[FIELD_KEY.TOKEN].key, { message: SOURCE_CONTROL_ERROR_MESSAGE.token.unauthorized }); + setError(fields[FieldKey.Token].key, { message: SOURCE_CONTROL_ERROR_MESSAGE.token.unauthorized }); } else { - setError(fields[FIELD_KEY.TOKEN].key, { message: response.errorTitle }); + setError(fields[FieldKey.Token].key, { message: response.errorTitle }); } setIsLoading(false); return response; diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts index 47a8444007..b9cf81f639 100644 --- a/frontend/src/utils/util.ts +++ b/frontend/src/utils/util.ts @@ -1,11 +1,11 @@ import { - CHART_TYPE, + ChartType, CYCLE_TIME_LIST, - CYCLE_TIME_SETTINGS_TYPES, + CycleTimeSettingsTypes, DOWN_TREND_IS_BETTER, METRICS_CONSTANTS, - TREND_ICON, - TREND_TYPE, + TrendIcon, + TrendType, UP_TREND_IS_BETTER, } from '@src/constants/resources'; import { CleanedBuildKiteEmoji, OriginBuildKiteEmoji } from '@src/constants/emojis/emoji'; @@ -67,7 +67,7 @@ export const filterAndMapCycleTimeSettings = (cycleTimeSettings: ICycleTimeSetti export const getRealDoneStatus = ( cycleTimeSettings: ICycleTimeSetting[], - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES, + cycleTimeSettingsType: CycleTimeSettingsTypes, realDoneStatus: string[], ) => { const selectedDoneStatus = cycleTimeSettings @@ -76,7 +76,7 @@ export const getRealDoneStatus = ( if (selectedDoneStatus.length <= 1) { return selectedDoneStatus; } - return cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN + return cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN ? realDoneStatus : cycleTimeSettings.filter(({ value }) => value === METRICS_CONSTANTS.doneValue).map(({ status }) => status); }; @@ -154,10 +154,10 @@ export const onlyEmptyAndDoneState = (boardingMappingStates: string[]) => isEqual(boardingMappingStates, [METRICS_CONSTANTS.doneValue, METRICS_CONSTANTS.cycleTimeEmptyStr]); export const convertCycleTimeSettings = ( - cycleTimeSettingsType: CYCLE_TIME_SETTINGS_TYPES, + cycleTimeSettingsType: CycleTimeSettingsTypes, cycleTimeSettings: ICycleTimeSetting[], ) => { - if (cycleTimeSettingsType === CYCLE_TIME_SETTINGS_TYPES.BY_COLUMN) { + if (cycleTimeSettingsType === CycleTimeSettingsTypes.BY_COLUMN) { return ([...new Set(cycleTimeSettings.map(({ column }: ICycleTimeSetting) => column))] as string[]).map( (uniqueColumn) => ({ [uniqueColumn]: @@ -216,7 +216,7 @@ export const xAxisLabelDateFormatter = (dateRange: string) => { return `${startMonthDay}-${endMonthDay}`; }; -export const getTrendInfo = (trendNumber: number, dateRangeList: string[], type: CHART_TYPE) => { +export const getTrendInfo = (trendNumber: number, dateRangeList: string[], type: ChartType) => { const result: ITrendInfo = { trendNumber: trendNumber, dateRangeList: dateRangeList, @@ -225,19 +225,19 @@ export const getTrendInfo = (trendNumber: number, dateRangeList: string[], type: if (UP_TREND_IS_BETTER.includes(type)) { if (trendNumber >= 0) { - result.icon = TREND_ICON.UP; - result.trendType = TREND_TYPE.BETTER; + result.icon = TrendIcon.Up; + result.trendType = TrendType.Better; } else { - result.icon = TREND_ICON.DOWN; - result.trendType = TREND_TYPE.WORSE; + result.icon = TrendIcon.Down; + result.trendType = TrendType.Worse; } } else if (DOWN_TREND_IS_BETTER.includes(type)) { if (trendNumber <= 0) { - result.icon = TREND_ICON.DOWN; - result.trendType = TREND_TYPE.BETTER; + result.icon = TrendIcon.Down; + result.trendType = TrendType.Better; } else { - result.icon = TREND_ICON.UP; - result.trendType = TREND_TYPE.WORSE; + result.icon = TrendIcon.Up; + result.trendType = TrendType.Worse; } } return result; @@ -246,7 +246,7 @@ export const getTrendInfo = (trendNumber: number, dateRangeList: string[], type: export const calculateTrendInfo = ( dataList: number[] | undefined, dateRangeList: string[], - type: CHART_TYPE, + type: ChartType, ): ITrendInfo => { if (!dataList || dataList.filter((data) => data).length < 2) return { type };