-
-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dialogs for project revive and delete (#7863)
Dialog needed to confirm revive/delete actions
- Loading branch information
Showing
13 changed files
with
200 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
frontend/src/component/project/ProjectList/ReviveProjectDialog/ReviveProjectDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Dialogue } from 'component/common/Dialogue/Dialogue'; | ||
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi'; | ||
import useProjects from 'hooks/api/getters/useProjects/useProjects'; | ||
import useToast from 'hooks/useToast'; | ||
import { formatUnknownError } from 'utils/formatUnknownError'; | ||
|
||
type ReviveProjectDialogProps = { | ||
name: string; | ||
id: string; | ||
open: boolean; | ||
onClose: () => void; | ||
}; | ||
|
||
export const ReviveProjectDialog = ({ | ||
name, | ||
id, | ||
open, | ||
onClose, | ||
}: ReviveProjectDialogProps) => { | ||
const { reviveProject } = useProjectApi(); | ||
const { refetch: refetchProjects } = useProjects(); | ||
const { refetch: refetchProjectArchive } = useProjects({ archived: true }); | ||
const { setToastData, setToastApiError } = useToast(); | ||
|
||
const onClick = async (e: React.SyntheticEvent) => { | ||
e.preventDefault(); | ||
if (!id) return; | ||
try { | ||
await reviveProject(id); | ||
refetchProjects(); | ||
refetchProjectArchive(); | ||
setToastData({ | ||
title: 'Restored project', | ||
type: 'success', | ||
text: 'Successfully restored project', | ||
}); | ||
} catch (ex: unknown) { | ||
setToastApiError(formatUnknownError(ex)); | ||
} | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Dialogue | ||
open={open} | ||
secondaryButtonText='Close' | ||
onClose={onClose} | ||
onClick={onClick} | ||
title='Restore archived project' | ||
> | ||
Are you sure you'd like to restore project <strong>{name}</strong>{' '} | ||
(id: <code>{id}</code>)? | ||
{/* TODO: more explanation */} | ||
</Dialogue> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.