From f89c2aa829768eb5b6fb103738fed7a08ee56b0e Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 27 Mar 2024 10:28:43 +0200 Subject: [PATCH] chore: useProject cleanup (#6700) --- frontend/src/component/admin/users/UsersAdmin.tsx | 2 +- .../component/banners/EdgeUpgradeBanner/EdgeUpgradeBanner.tsx | 2 +- .../component/changeRequest/ChangeRequestPermissions.test.tsx | 2 +- frontend/src/component/feature/CopyFeature/CopyFeature.tsx | 4 ++-- .../component/feature/FeatureToggleList/BulkDisableDialog.tsx | 3 --- frontend/src/component/feature/FeatureView/FeatureView.tsx | 3 --- frontend/src/component/layout/Error/Error.tsx | 2 +- frontend/src/hooks/useHasAccess.ts | 4 ++-- 8 files changed, 8 insertions(+), 14 deletions(-) diff --git a/frontend/src/component/admin/users/UsersAdmin.tsx b/frontend/src/component/admin/users/UsersAdmin.tsx index c93c04bd46..f259426b7e 100644 --- a/frontend/src/component/admin/users/UsersAdmin.tsx +++ b/frontend/src/component/admin/users/UsersAdmin.tsx @@ -9,7 +9,7 @@ import { InactiveUsersList } from './InactiveUsersList/InactiveUsersList'; import { AccessMatrix } from './AccessMatrix/AccessMatrix'; import { PremiumFeature } from '../../common/PremiumFeature/PremiumFeature'; import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender'; -import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; export const UsersAdmin = () => { const { isEnterprise } = useUiConfig(); diff --git a/frontend/src/component/banners/EdgeUpgradeBanner/EdgeUpgradeBanner.tsx b/frontend/src/component/banners/EdgeUpgradeBanner/EdgeUpgradeBanner.tsx index e2a8660fdd..70f37290f5 100644 --- a/frontend/src/component/banners/EdgeUpgradeBanner/EdgeUpgradeBanner.tsx +++ b/frontend/src/component/banners/EdgeUpgradeBanner/EdgeUpgradeBanner.tsx @@ -1,4 +1,4 @@ -import { useUiFlag } from '../../../hooks/useUiFlag'; +import { useUiFlag } from 'hooks/useUiFlag'; import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender'; import { Banner } from '../Banner/Banner'; import type { IBanner } from '../../../interfaces/banner'; diff --git a/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx b/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx index 8a028c04ea..0506d732a5 100644 --- a/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestPermissions.test.tsx @@ -15,7 +15,7 @@ import { StickyProvider } from 'component/common/Sticky/StickyProvider'; const server = testServerSetup(); const projectWithCollaborationMode = (mode: ProjectMode) => - testServerRoute(server, '/api/admin/projects/default', { mode }); + testServerRoute(server, '/api/admin/projects/default/overview', { mode }); const changeRequestsEnabledIn = ( env: 'development' | 'production' | 'custom', diff --git a/frontend/src/component/feature/CopyFeature/CopyFeature.tsx b/frontend/src/component/feature/CopyFeature/CopyFeature.tsx index 55467cbbc2..a4e1991af3 100644 --- a/frontend/src/component/feature/CopyFeature/CopyFeature.tsx +++ b/frontend/src/component/feature/CopyFeature/CopyFeature.tsx @@ -22,8 +22,8 @@ import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; -import useProject from 'hooks/api/getters/useProject/useProject'; import { FeatureNamingPatternInfo } from '../FeatureNamingPatternInfo/FeatureNamingPatternInfo'; +import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview'; const StyledPage = styled(Paper)(({ theme }) => ({ overflow: 'visible', @@ -81,7 +81,7 @@ export const CopyFeatureToggle = () => { const { project: { featureNaming }, - } = useProject(projectId); + } = useProjectOverview(projectId); const setValue: ChangeEventHandler = (event) => { const value = trim(event.target.value); diff --git a/frontend/src/component/feature/FeatureToggleList/BulkDisableDialog.tsx b/frontend/src/component/feature/FeatureToggleList/BulkDisableDialog.tsx index 00c99edc9b..963adc2031 100644 --- a/frontend/src/component/feature/FeatureToggleList/BulkDisableDialog.tsx +++ b/frontend/src/component/feature/FeatureToggleList/BulkDisableDialog.tsx @@ -7,7 +7,6 @@ import type { FeatureSchema } from 'openapi'; import { formatUnknownError } from 'utils/formatUnknownError'; import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi'; -import useProject from 'hooks/api/getters/useProject/useProject'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi'; import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests'; @@ -43,7 +42,6 @@ export const BulkDisableDialog = ({ const [selected, setSelected] = useState(environments[0]); const { bulkToggleFeaturesEnvironmentOff } = useFeatureApi(); const { addChange } = useChangeRequestApi(); - const { refetch: refetchProject } = useProject(projectId); const { setToastApiError, setToastData } = useToast(); const { isChangeRequestConfigured } = useChangeRequestsEnabled(projectId); const { refetch: refetchChangeRequests } = @@ -85,7 +83,6 @@ export const BulkDisableDialog = ({ data.map((feature) => feature.name), selected, ); - refetchProject(); setToastData({ text: 'Your feature toggles have been disabled', type: 'success', diff --git a/frontend/src/component/feature/FeatureView/FeatureView.tsx b/frontend/src/component/feature/FeatureView/FeatureView.tsx index 71ff9226c3..1a28f57ecf 100644 --- a/frontend/src/component/feature/FeatureView/FeatureView.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureView.tsx @@ -21,7 +21,6 @@ import { useNavigate, } from 'react-router-dom'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; -import useProject from 'hooks/api/getters/useProject/useProject'; import { CREATE_FEATURE, DELETE_FEATURE, @@ -137,7 +136,6 @@ export const StyledLink = styled(Link)(({ theme }) => ({ export const FeatureView = () => { const projectId = useRequiredPathParam('projectId'); const featureId = useRequiredPathParam('featureId'); - const { refetch: projectRefetch } = useProject(projectId); const { favorite, unfavorite } = useFavoriteFeaturesApi(); const { refetchFeature } = useFeature(projectId, featureId); const { setToastData, setToastApiError } = useToast(); @@ -379,7 +377,6 @@ export const FeatureView = () => { { - projectRefetch(); navigate(`/projects/${projectId}`); }} onClose={() => setShowDelDialog(false)} diff --git a/frontend/src/component/layout/Error/Error.tsx b/frontend/src/component/layout/Error/Error.tsx index 43d260a230..853d530d62 100644 --- a/frontend/src/component/layout/Error/Error.tsx +++ b/frontend/src/component/layout/Error/Error.tsx @@ -4,7 +4,7 @@ import { Box, Button } from '@mui/material'; import { Dialogue } from 'component/common/Dialogue/Dialogue'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; -import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; interface IErrorProps { error: Error; diff --git a/frontend/src/hooks/useHasAccess.ts b/frontend/src/hooks/useHasAccess.ts index 038e2a1019..9460f78cab 100644 --- a/frontend/src/hooks/useHasAccess.ts +++ b/frontend/src/hooks/useHasAccess.ts @@ -9,7 +9,7 @@ import { UPDATE_FEATURE_STRATEGY, } from '../component/providers/AccessProvider/permissions'; import { useAuthPermissions } from './api/getters/useAuth/useAuthPermissions'; -import useProject from './api/getters/useProject/useProject'; +import useProjectOverview from './api/getters/useProjectOverview/useProjectOverview'; /** * This is for features not integrated with change request. @@ -90,7 +90,7 @@ const useIsProjectMember = (projectId: string) => { const useIsAllowedUser = (projectId: string) => { const isProjectMember = useIsProjectMember(projectId); - const { project } = useProject(projectId); + const { project } = useProjectOverview(projectId); const isProtectedProject = project.mode === 'protected'; return isProtectedProject ? isProjectMember : true; };