From e439e460902ed6a78655fc83c4fd48b7c9753c5e Mon Sep 17 00:00:00 2001 From: Fredrik Strand Oseberg Date: Wed, 23 Nov 2022 13:45:19 +0100 Subject: [PATCH] fix: change domain vocabulary (#2503) * Changes the naming of useOpenRequests to usePendingChangeRequests --- .../ChangeRequestOverview/ChangeRequestOverview.tsx | 4 ++-- .../ChangeRequestOverview/ReviewButton/ReviewButton.tsx | 4 ++-- .../ChangeRequestSidebar/ChangeRequestSidebar.tsx | 4 ++-- .../src/component/changeRequest/DraftBanner/DraftBanner.tsx | 4 ++-- .../FeatureStrategyCreate/FeatureStrategyCreate.tsx | 5 +++-- .../FeatureStrategyEdit/FeatureStrategyEdit.tsx | 5 +++-- .../FeatureStrategyRemove/FeatureStrategyRemove.tsx | 5 +++-- .../StrategyItem/useStrategyChangeFromRequest.tsx | 4 ++-- .../StrategyList/StrategyItem/FeatureStrategyItem.tsx | 1 - .../usePendingChangeRequests.ts} | 4 ++-- frontend/src/hooks/useChangeRequestAddStrategy.ts | 4 ++-- frontend/src/hooks/useChangeRequestToggle.ts | 5 +++-- 12 files changed, 26 insertions(+), 23 deletions(-) rename frontend/src/hooks/api/getters/{useChangeRequestOpen/useChangeRequestOpen.ts => usePendingChangeRequests/usePendingChangeRequests.ts} (90%) diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx index 1277e4b781..10d5d68481 100644 --- a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx @@ -21,7 +21,7 @@ import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser'; import AccessContext from 'contexts/AccessContext'; import { ChangeRequestComment } from './ChangeRequestComments/ChangeRequestComment'; import { AddCommentField } from './ChangeRequestComments/AddCommentField'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; const StyledAsideBox = styled(Box)(({ theme }) => ({ width: '30%', @@ -60,7 +60,7 @@ export const ChangeRequestOverview: FC = () => { ); const { changeState, addComment } = useChangeRequestApi(); const { refetch: refetchChangeRequestOpen } = - useChangeRequestOpen(projectId); + usePendingChangeRequests(projectId); const { setToastData, setToastApiError } = useToast(); if (!changeRequest) { diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx index 05aae4cb00..ced2b01a30 100644 --- a/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx @@ -20,7 +20,7 @@ import { APPROVE_CHANGE_REQUEST } from 'component/providers/AccessProvider/permi import PermissionButton from 'component/common/PermissionButton/PermissionButton'; import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser'; import AccessContext from 'contexts/AccessContext'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; export const ReviewButton = () => { const { isAdmin } = useContext(AccessContext); @@ -29,7 +29,7 @@ export const ReviewButton = () => { const { user } = useAuthUser(); const { refetchChangeRequest, data } = useChangeRequest(projectId, id); const { refetch: refetchChangeRequestOpen } = - useChangeRequestOpen(projectId); + usePendingChangeRequests(projectId); const { setToastApiError, setToastData } = useToast(); const { changeState } = useChangeRequestApi(); diff --git a/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx b/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx index 3a8a8610a4..c8f59e70c7 100644 --- a/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar.tsx @@ -16,7 +16,7 @@ import { PageHeader } from 'component/common/PageHeader/PageHeader'; import { CheckCircle, HelpOutline } from '@mui/icons-material'; import EnvironmentIcon from 'component/common/EnvironmentIcon/EnvironmentIcon'; import { ChangeRequest } from '../ChangeRequest/ChangeRequest'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import { ChangeRequestStatusBadge } from '../ChangeRequestStatusBadge/ChangeRequestStatusBadge'; import CloseIcon from '@mui/icons-material/Close'; @@ -124,7 +124,7 @@ export const ChangeRequestSidebar: VFC = ({ draft, loading, refetch: refetchChangeRequest, - } = useChangeRequestOpen(project); + } = usePendingChangeRequests(project); const { changeState, discardDraft } = useChangeRequestApi(); const theme = useTheme(); const navigate = useNavigate(); diff --git a/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx b/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx index 3c2598b45b..b1353fff3a 100644 --- a/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx +++ b/frontend/src/component/changeRequest/DraftBanner/DraftBanner.tsx @@ -4,7 +4,7 @@ import { useStyles as useAppStyles } from 'component/App.styles'; import WarningAmberIcon from '@mui/icons-material/WarningAmber'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ChangeRequestSidebar } from '../ChangeRequestSidebar/ChangeRequestSidebar'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; import { IChangeRequest } from '../changeRequest.types'; interface IDraftBannerProps { @@ -76,7 +76,7 @@ const StickyBanner = styled(Box)(({ theme }) => ({ export const DraftBanner: VFC = ({ project }) => { const [isSidebarOpen, setIsSidebarOpen] = useState(false); - const { draft, loading } = useChangeRequestOpen(project); + const { draft, loading } = usePendingChangeRequests(project); if ((!loading && !draft) || draft?.length === 0) { return null; diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate.tsx index 80954a24cf..2780c6ae4c 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyCreate/FeatureStrategyCreate.tsx @@ -29,7 +29,7 @@ import { IFeatureToggle } from 'interfaces/featureToggle'; import { comparisonModerator } from '../featureStrategy.utils'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; export const FeatureStrategyCreate = () => { const projectId = useRequiredPathParam('projectId'); @@ -52,7 +52,8 @@ export const FeatureStrategyCreate = () => { const { feature, refetchFeature } = useFeature(projectId, featureId); const ref = useRef(feature); const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId); - const { refetch: refetchChangeRequests } = useChangeRequestOpen(projectId); + const { refetch: refetchChangeRequests } = + usePendingChangeRequests(projectId); const { data, staleDataNotification, forceRefreshCache } = useCollaborateData( diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx index e273788210..24c26fbbef 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit.tsx @@ -27,7 +27,7 @@ import { IFeatureToggle } from 'interfaces/featureToggle'; import { comparisonModerator } from '../featureStrategy.utils'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; export const FeatureStrategyEdit = () => { const projectId = useRequiredPathParam('projectId'); @@ -47,7 +47,8 @@ export const FeatureStrategyEdit = () => { const navigate = useNavigate(); const { addChangeRequest } = useChangeRequestApi(); const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId); - const { refetch: refetchChangeRequests } = useChangeRequestOpen(projectId); + const { refetch: refetchChangeRequests } = + usePendingChangeRequests(projectId); const { feature, refetchFeature } = useFeature(projectId, featureId); diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyRemove/FeatureStrategyRemove.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyRemove/FeatureStrategyRemove.tsx index 5d6911c355..59a979a89d 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyRemove/FeatureStrategyRemove.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyRemove/FeatureStrategyRemove.tsx @@ -15,7 +15,7 @@ import PermissionIconButton from 'component/common/PermissionIconButton/Permissi import { Delete } from '@mui/icons-material'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; interface IFeatureStrategyRemoveProps { projectId: string; @@ -131,7 +131,8 @@ const useOnSuggestRemove = ({ strategyId, }: IRemoveProps) => { const { addChangeRequest } = useChangeRequestApi(); - const { refetch: refetchChangeRequests } = useChangeRequestOpen(projectId); + const { refetch: refetchChangeRequests } = + usePendingChangeRequests(projectId); const { setToastData, setToastApiError } = useToast(); const onSuggestRemove = async (event: React.FormEvent) => { try { diff --git a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/useStrategyChangeFromRequest.tsx b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/useStrategyChangeFromRequest.tsx index 41c495c4c0..0e50b162db 100644 --- a/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/useStrategyChangeFromRequest.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/useStrategyChangeFromRequest.tsx @@ -1,4 +1,4 @@ -import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; export const useStrategyChangeFromRequest = ( projectId: string, @@ -6,7 +6,7 @@ export const useStrategyChangeFromRequest = ( environment: string, strategyId: string ) => { - const { draft } = useChangeRequestOpen(projectId); + const { draft } = usePendingChangeRequests(projectId); const environmentDraft = draft?.find( draft => draft.environment === environment diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/FeatureStrategyItem.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/FeatureStrategyItem.tsx index 1cd32c3aa5..4d2abc390f 100644 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/FeatureStrategyItem.tsx +++ b/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/FeatureStrategyItem.tsx @@ -8,7 +8,6 @@ import { StrategyExecution } from './StrategyExecution/StrategyExecution'; import { useStyles } from './FeatureStrategyItem.styles'; import { StrategyItemContainer } from 'component/common/StrategyItemContainer/StrategyItemContainer'; import { objectId } from 'utils/objectId'; -import { IFeatureStrategy } from 'interfaces/strategy'; interface IFeatureStrategyItemProps { strategy: PlaygroundStrategySchema; diff --git a/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts b/frontend/src/hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests.ts similarity index 90% rename from frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts rename to frontend/src/hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests.ts index ebaadd68bd..01f907ff2c 100644 --- a/frontend/src/hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen.ts +++ b/frontend/src/hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests.ts @@ -10,10 +10,10 @@ const fetcher = (path: string) => { .then(res => res.json()); }; -export const useChangeRequestOpen = (project: string) => { +export const usePendingChangeRequests = (project: string) => { const { isOss } = useUiConfig(); const { data, error, mutate } = useSWR( - formatApiPath(`api/admin/projects/${project}/change-requests/open`), + formatApiPath(`api/admin/projects/${project}/change-requests/pending`), isOss() ? () => Promise.resolve([]) : fetcher ); diff --git a/frontend/src/hooks/useChangeRequestAddStrategy.ts b/frontend/src/hooks/useChangeRequestAddStrategy.ts index ad92c3175c..d9e15c0e1f 100644 --- a/frontend/src/hooks/useChangeRequestAddStrategy.ts +++ b/frontend/src/hooks/useChangeRequestAddStrategy.ts @@ -3,7 +3,7 @@ import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; import { IFeatureStrategyPayload } from '../interfaces/strategy'; import { useChangeRequestApi } from './api/actions/useChangeRequestApi/useChangeRequestApi'; -import { useChangeRequestOpen } from './api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from './api/getters/usePendingChangeRequests/usePendingChangeRequests'; export type ChangeRequestStrategyAction = | 'addStrategy' @@ -17,7 +17,7 @@ export const useChangeRequestAddStrategy = ( ) => { const { setToastData, setToastApiError } = useToast(); const { addChangeRequest } = useChangeRequestApi(); - const { refetch } = useChangeRequestOpen(project); + const { refetch } = usePendingChangeRequests(project); const [changeRequestDialogDetails, setChangeRequestDialogDetails] = useState<{ diff --git a/frontend/src/hooks/useChangeRequestToggle.ts b/frontend/src/hooks/useChangeRequestToggle.ts index d7beb9b2c0..e9ba1b402e 100644 --- a/frontend/src/hooks/useChangeRequestToggle.ts +++ b/frontend/src/hooks/useChangeRequestToggle.ts @@ -2,12 +2,13 @@ import { useCallback, useState } from 'react'; import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; import { useChangeRequestApi } from './api/actions/useChangeRequestApi/useChangeRequestApi'; -import { useChangeRequestOpen } from './api/getters/useChangeRequestOpen/useChangeRequestOpen'; +import { usePendingChangeRequests } from './api/getters/usePendingChangeRequests/usePendingChangeRequests'; export const useChangeRequestToggle = (project: string) => { const { setToastData, setToastApiError } = useToast(); const { addChangeRequest } = useChangeRequestApi(); - const { refetch: refetchChangeRequests } = useChangeRequestOpen(project); + const { refetch: refetchChangeRequests } = + usePendingChangeRequests(project); const [changeRequestDialogDetails, setChangeRequestDialogDetails] = useState<{