Skip to content

Commit

Permalink
feat: archive is now part of project feature list (#8587)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus authored Oct 30, 2024
1 parent 916e890 commit 5f67dce
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IArchivedFeatureDeleteConfirmProps {
deletedFeatures: string[];
projectId: string;
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
setOpen: (open: boolean) => void;
refetch: () => void;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Alert, styled } from '@mui/material';
import type React from 'react';
import { Dialogue } from 'component/common/Dialogue/Dialogue';
import { formatUnknownError } from 'utils/formatUnknownError';
import useToast from 'hooks/useToast';
Expand All @@ -11,7 +10,7 @@ interface IArchivedFeatureReviveConfirmProps {
revivedFeatures: string[];
projectId: string;
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
setOpen: (open: boolean) => void;
refetch: () => void;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import { ProjectOnboarding } from '../../../onboarding/flow/ProjectOnboarding';
import { useLocalStorageState } from 'hooks/useLocalStorageState';
import { ProjectOnboarded } from 'component/onboarding/flow/ProjectOnboarded';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { ArchivedFeatureActionCell } from '../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureActionCell';
import { ArchiveBatchActions } from '../../../archive/ArchiveTable/ArchiveBatchActions';

interface IPaginatedProjectFeatureTogglesProps {
environments: string[];
Expand Down Expand Up @@ -115,6 +117,8 @@ export const ProjectFeatureToggles = ({
setFeatureArchiveState,
setFeatureStaleDialogState,
setShowMarkCompletedDialogue,
setShowFeatureReviveDialogue,
setShowFeatureDeleteDialogue,
} = useRowActions(refetch, projectId);

const isPlaceholder = Boolean(initialLoad || (loading && total));
Expand Down Expand Up @@ -321,14 +325,32 @@ export const ProjectFeatureToggles = ({
columnHelper.display({
id: 'actions',
header: '',
cell: ({ row }) => (
<ActionsCell
row={row}
projectId={projectId}
onOpenArchiveDialog={setFeatureArchiveState}
onOpenStaleDialog={setFeatureStaleDialogState}
/>
),
cell: ({ row }) =>
tableState.archived ? (
<ArchivedFeatureActionCell
project={projectId}
onRevive={() => {
setShowFeatureReviveDialogue({
featureId: row.id,
open: true,
});
}}
onDelete={() => {
setShowFeatureDeleteDialogue({
featureId: row.id,
open: true,
});
}}
/>
) : (
<ActionsCell
row={row}
projectId={projectId}
onOpenArchiveDialog={setFeatureArchiveState}
onOpenStaleDialog={setFeatureStaleDialogState}
/>
),

enableSorting: false,
enableHiding: false,
meta: {
Expand Down Expand Up @@ -585,13 +607,24 @@ export const ProjectFeatureToggles = ({
}
/>
<BatchSelectionActionsBar count={selectedData.length}>
<ProjectFeaturesBatchActions
selectedIds={Object.keys(rowSelection)}
data={selectedData}
projectId={projectId}
onResetSelection={table.resetRowSelection}
onChange={refetch}
/>
{tableState.archived ? (
<ArchiveBatchActions
selectedIds={Object.keys(rowSelection)}
projectId={projectId}
onConfirm={() => {
refetch();
table.resetRowSelection();
}}
/>
) : (
<ProjectFeaturesBatchActions
selectedIds={Object.keys(rowSelection)}
data={selectedData}
projectId={projectId}
onResetSelection={table.resetRowSelection}
onChange={refetch}
/>
)}
</BatchSelectionActionsBar>
</Container>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export const ProjectOverviewFilters: VFC<IProjectOverviewFilters> = ({
singularOperators: ['IS', 'IS_NOT'],
pluralOperators: ['IS_ANY_OF', 'IS_NONE_OF'],
},
{
label: 'Show only archived',
icon: 'inventory',
options: [{ label: 'True', value: 'true' }],
filterKey: 'archived',
singularOperators: ['IS'],
pluralOperators: ['IS_ANY_OF'],
},
];

setAvailableFilters(availableFilters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useState } from 'react';
import { FeatureArchiveDialog } from 'component/common/FeatureArchiveDialog/FeatureArchiveDialog';
import { FeatureStaleDialog } from 'component/common/FeatureStaleDialog/FeatureStaleDialog';
import { MarkCompletedDialogue } from 'component/feature/FeatureView/FeatureOverview/FeatureLifecycle/MarkCompletedDialogue';
import { ArchivedFeatureDeleteConfirm } from '../../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureDeleteConfirm/ArchivedFeatureDeleteConfirm';
import { ArchivedFeatureReviveConfirm } from '../../../../archive/ArchiveTable/ArchivedFeatureActionCell/ArchivedFeatureReviveConfirm/ArchivedFeatureReviveConfirm';

export const useRowActions = (onChange: () => void, projectId: string) => {
const [featureArchiveState, setFeatureArchiveState] = useState<
Expand All @@ -20,6 +22,21 @@ export const useRowActions = (onChange: () => void, projectId: string) => {
featureId: 'default',
open: false,
});
const [showFeatureReviveDialogue, setShowFeatureReviveDialogue] = useState<{
featureId: string;
open: boolean;
}>({
featureId: 'default',
open: false,
});
const [showFeatureDeleteDialogue, setShowFeatureDeleteDialogue] = useState<{
featureId: string;
open: boolean;
}>({
featureId: 'default',
open: false,
});

const rowActionsDialogs = (
<>
<FeatureStaleDialog
Expand Down Expand Up @@ -54,6 +71,36 @@ export const useRowActions = (onChange: () => void, projectId: string) => {
featureId={showMarkCompletedDialogue.featureId}
onComplete={onChange}
/>
<ArchivedFeatureDeleteConfirm
deletedFeatures={[showFeatureDeleteDialogue.featureId]}
projectId={projectId}
open={showFeatureDeleteDialogue.open}
setOpen={(open) => {
setShowFeatureDeleteDialogue((prev) => ({
...prev,
open,
}));
}}
refetch={onChange}
/>
<ArchivedFeatureReviveConfirm
revivedFeatures={[showFeatureReviveDialogue.featureId]}
projectId={projectId}
open={showFeatureReviveDialogue.open}
setOpen={(open) => {
setShowFeatureReviveDialogue((prev) => ({
...prev,
open,
}));
}}
refetch={() => {
setShowFeatureReviveDialogue((prev) => ({
...prev,
open: false,
}));
onChange();
}}
/>
</>
);

Expand All @@ -62,5 +109,7 @@ export const useRowActions = (onChange: () => void, projectId: string) => {
setFeatureArchiveState,
setFeatureStaleDialogState,
setShowMarkCompletedDialogue,
setShowFeatureReviveDialogue,
setShowFeatureDeleteDialogue,
};
};

0 comments on commit 5f67dce

Please sign in to comment.