From 6ae2c9a165f88e06d409e68266816c9a1f693e73 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Wed, 30 Nov 2022 08:55:40 +0100 Subject: [PATCH] uniquitous language cleanup (#2564) --- .../changeRequest/ChangeRequest/ChangeRequest.tsx | 8 ++------ .../src/component/changeRequest/changeRequest.types.ts | 4 ++-- .../StrategyDraggableItem/StrategyDraggableItem.tsx | 4 ++-- .../actions/useChangeRequestApi/useChangeRequestApi.ts | 8 ++++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx b/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx index ea11dcea99..9a4b5ff390 100644 --- a/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx +++ b/frontend/src/component/changeRequest/ChangeRequest/ChangeRequest.tsx @@ -147,15 +147,11 @@ export const ChangeRequest: VFC = ({ onRefetch, onNavigate, }) => { - const { discardChangeRequestEvent } = useChangeRequestApi(); + const { discardChange } = useChangeRequestApi(); const { setToastData, setToastApiError } = useToast(); const onDiscard = (id: number) => async () => { try { - await discardChangeRequestEvent( - changeRequest.project, - changeRequest.id, - id - ); + await discardChange(changeRequest.project, changeRequest.id, id); setToastData({ title: 'Change discarded from change request draft.', type: 'success', diff --git a/frontend/src/component/changeRequest/changeRequest.types.ts b/frontend/src/component/changeRequest/changeRequest.types.ts index 35de720f9b..992cb5feca 100644 --- a/frontend/src/component/changeRequest/changeRequest.types.ts +++ b/frontend/src/component/changeRequest/changeRequest.types.ts @@ -25,7 +25,7 @@ export interface IChangeRequestEnvironmentConfig { export interface IChangeRequestFeature { name: string; conflict?: string; - changes: IChangeRequestEvent[]; + changes: IChange[]; } export interface IChangeRequestApproval { @@ -82,7 +82,7 @@ export interface IChangeRequestEnabled extends IChangeRequestBase { payload: ChangeRequestEnabled; } -export type IChangeRequestEvent = +export type IChange = | IChangeRequestAddStrategy | IChangeRequestDeleteStrategy | IChangeRequestUpdateStrategy diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyDraggableItem.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyDraggableItem.tsx index 0604e2d93b..4fae3100b5 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyDraggableItem.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyDraggableItem.tsx @@ -7,7 +7,7 @@ import { IFeatureStrategy } from 'interfaces/strategy'; import { StrategyItem } from './StrategyItem/StrategyItem'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { Badge } from 'component/common/Badge/Badge'; -import { IChangeRequestEvent } from 'component/changeRequest/changeRequest.types'; +import { IChange } from 'component/changeRequest/changeRequest.types'; import { useStrategyChangeFromRequest } from './StrategyItem/useStrategyChangeFromRequest'; interface IStrategyDraggableItemProps { @@ -74,7 +74,7 @@ export const StrategyDraggableItem = ({ const ChangeRequestStatusBadge = ({ change, }: { - change: IChangeRequestEvent | undefined; + change: IChange | undefined; }) => { const theme = useTheme(); const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm')); diff --git a/frontend/src/hooks/api/actions/useChangeRequestApi/useChangeRequestApi.ts b/frontend/src/hooks/api/actions/useChangeRequestApi/useChangeRequestApi.ts index 3bab3270ca..0589065d34 100644 --- a/frontend/src/hooks/api/actions/useChangeRequestApi/useChangeRequestApi.ts +++ b/frontend/src/hooks/api/actions/useChangeRequestApi/useChangeRequestApi.ts @@ -58,7 +58,7 @@ export const useChangeRequestApi = () => { } }; - const discardChangeRequestEvent = async ( + const discardChange = async ( project: string, changeRequestId: number, changeRequestEventId: number @@ -111,10 +111,10 @@ export const useChangeRequestApi = () => { const addComment = async ( projectId: string, - changeSetId: string, + changeRequestId: string, text: string ) => { - const path = `/api/admin/projects/${projectId}/change-requests/${changeSetId}/comments`; + const path = `/api/admin/projects/${projectId}/change-requests/${changeRequestId}/comments`; const req = createRequest(path, { method: 'POST', body: JSON.stringify({ text }), @@ -130,7 +130,7 @@ export const useChangeRequestApi = () => { return { addChangeRequest, changeState, - discardChangeRequestEvent, + discardChange, updateChangeRequestEnvironmentConfig, discardDraft, addComment,