diff --git a/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/PaginatedProjectFeatureToggles.tsx b/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/PaginatedProjectFeatureToggles.tsx index 6744d46ddb..041b9a3ecc 100644 --- a/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/PaginatedProjectFeatureToggles.tsx +++ b/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/PaginatedProjectFeatureToggles.tsx @@ -481,6 +481,7 @@ export const PaginatedProjectFeatureToggles = ({ data={features} projectId={projectId} onResetSelection={table.resetRowSelection} + onChange={refetch} /> diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx index 9f9fff890e..46438eb2ec 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeatureToggles.tsx @@ -693,6 +693,7 @@ export const ProjectFeatureToggles = ({ data={features} projectId={projectId} onResetSelection={() => toggleAllRowsSelected(false)} + onChange={onChange} /> diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ManageTags.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ManageTags.tsx index a2a5ba9460..a6a7268412 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ManageTags.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ManageTags.tsx @@ -6,7 +6,6 @@ import { ITag } from 'interfaces/tags'; import useTagApi from 'hooks/api/actions/useTagApi/useTagApi'; import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; -import useProject from 'hooks/api/getters/useProject/useProject'; import { PermissionHOC } from 'component/common/PermissionHOC/PermissionHOC'; import { UPDATE_FEATURE } from 'component/providers/AccessProvider/permissions'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; @@ -14,11 +13,15 @@ import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; interface IManageTagsProps { data: FeatureSchema[]; projectId: string; + onChange?: () => void; } -export const ManageTags: VFC = ({ projectId, data }) => { +export const ManageTags: VFC = ({ + projectId, + data, + onChange, +}) => { const { bulkUpdateTags } = useTagApi(); - const { refetch } = useProject(projectId); const { setToastData, setToastApiError } = useToast(); const { trackEvent } = usePlausibleTracker(); const [isOpen, setIsOpen] = useState(false); @@ -60,7 +63,6 @@ export const ManageTags: VFC = ({ projectId, data }) => { const payload = { features, tags: { addedTags, removedTags } }; try { await bulkUpdateTags(payload, projectId); - refetch(); const added = addedTags.length ? `Added tags: ${addedTags .map(({ type, value }) => `${type}:${value}`) @@ -86,6 +88,7 @@ export const ManageTags: VFC = ({ projectId, data }) => { } catch (error: unknown) { setToastApiError(formatUnknownError(error)); } + onChange?.(); setIsOpen(false); }; diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/MoreActions.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/MoreActions.tsx index bcc0dce167..8aec687e88 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/MoreActions.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/MoreActions.tsx @@ -15,7 +15,6 @@ import { MoreVert, WatchLater } from '@mui/icons-material'; import type { FeatureSchema } from 'openapi'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi'; -import useProject from 'hooks/api/getters/useProject/useProject'; import useToast from 'hooks/useToast'; import { formatUnknownError } from 'utils/formatUnknownError'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; @@ -24,12 +23,16 @@ import { MORE_BATCH_ACTIONS } from 'utils/testIds'; interface IMoreActionsProps { projectId: string; data: FeatureSchema[]; + onChange?: () => void; } const menuId = 'selection-actions-menu'; -export const MoreActions: VFC = ({ projectId, data }) => { - const { refetch } = useProject(projectId); +export const MoreActions: VFC = ({ + projectId, + data, + onChange, +}) => { const [anchorEl, setAnchorEl] = useState(null); const { staleFeatures } = useProjectApi(); const { setToastData, setToastApiError } = useToast(); @@ -52,7 +55,7 @@ export const MoreActions: VFC = ({ projectId, data }) => { try { handleClose(); await staleFeatures(projectId, selectedIds); - await refetch(); + onChange?.(); setToastData({ title: 'State updated', text: 'Feature toggles marked as stale', @@ -72,7 +75,7 @@ export const MoreActions: VFC = ({ projectId, data }) => { try { handleClose(); await staleFeatures(projectId, selectedIds, false); - await refetch(); + onChange?.(); setToastData({ title: 'State updated', text: 'Feature toggles unmarked as stale', diff --git a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ProjectFeaturesBatchActions.tsx b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ProjectFeaturesBatchActions.tsx index 3f960a9a67..58cc7cfc5a 100644 --- a/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ProjectFeaturesBatchActions.tsx +++ b/frontend/src/component/project/Project/ProjectFeatureToggles/ProjectFeaturesBatchActions/ProjectFeaturesBatchActions.tsx @@ -16,11 +16,12 @@ interface IProjectFeaturesBatchActionsProps { data: FeatureSchema[]; projectId: string; onResetSelection: () => void; + onChange?: () => void; } export const ProjectFeaturesBatchActions: FC< IProjectFeaturesBatchActionsProps -> = ({ selectedIds, data, projectId, onResetSelection }) => { +> = ({ selectedIds, data, projectId, onResetSelection, onChange }) => { const { uiConfig } = useUiConfig(); const [showExportDialog, setShowExportDialog] = useState(false); const [showBulkEnableDialog, setShowBulkEnableDialog] = useState(false); @@ -39,21 +40,24 @@ export const ProjectFeaturesBatchActions: FC< return Array.from(new Set(envs)); }, [selectedData]); - const trackExport = () => { + const confirmExport = () => { + onChange?.(); trackEvent('batch_operations', { props: { eventType: 'features exported', }, }); }; - const trackBulkEnabled = () => { + const confirmBulkEnabled = () => { + onChange?.(); trackEvent('batch_operations', { props: { eventType: 'features enabled', }, }); }; - const trackBulkDisabled = () => { + const confirmBulkDisabled = () => { + onChange?.(); trackEvent('batch_operations', { props: { eventType: 'features disabled', @@ -61,6 +65,11 @@ export const ProjectFeaturesBatchActions: FC< }); }; + const confirmArchive = () => { + onChange?.(); + onResetSelection(); + }; + return ( <> - - + + setShowExportDialog(false)} environments={environments} - onConfirm={trackExport} + onConfirm={confirmExport} /> setShowBulkEnableDialog(false)} environments={environments} projectId={projectId} - onConfirm={trackBulkEnabled} + onConfirm={confirmBulkEnabled} /> setShowBulkDisableDialog(false)} environments={environments} projectId={projectId} - onConfirm={trackBulkDisabled} + onConfirm={confirmBulkDisabled} /> );