Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: archive is now part of project feature list #8587

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something that's blocking for now, but is "Show only archived is true" really the best way to phrase it / display it to users? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most easiest to understand, we can change it in overhaul.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we show these? Is this the bar in the screenshot or is it a row? Just wondering whether we're always showing the option to revive and delete or if it's done conditionally somehow. I'm assuming that it's only shown where it makes sense, but I'm not seeing exactly where that's happening 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only if archived filter is on, so only archived flags are displayed.

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,
};
};
Loading