-
-
Notifications
You must be signed in to change notification settings - Fork 740
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: dialogs for project revive and delete #7863
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
38c7b71
feat: dialogs for project revive and delete
Tymek 2f45a41
Merge remote-tracking branch 'origin/main' into feat/archive-project-…
Tymek e097b0a
integrate project archive and restore with api
Tymek fabe8f3
fix: dialog copy
Tymek d0acc66
refactor: simplify revive project dialog
Tymek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = { | ||
Tymek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we relax the constraint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Component was already written in a way that if any other string is provided, it will be ignored