-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature/95/archive project #99
Draft
martinrobled0
wants to merge
6
commits into
main
Choose a base branch
from
feature/95/archive-project
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8c26933
feat: archive and unarchive projects
martinrobled0 8e439d2
hide archive projects
martinrobled0 d1d457d
merge changes of main
martinrobled0 f0948ec
identify archived projects in my proposals and change animation of ar…
martinrobled0 2d856e0
adding a new tab for admins to display archive projects
martinrobled0 cb0b4c7
doing changes
martinrobled0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Archive } from "@mui/icons-material"; | ||
import { | ||
Button, | ||
CircularProgress, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogTitle, | ||
IconButton, | ||
Tooltip, | ||
} from "@mui/material"; | ||
import { Form, useTransition } from "@remix-run/react"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export const ArchiveProject = ({ projectId }: { projectId?: string }) => { | ||
const [open, setOpen] = useState(false); | ||
const [isButtonDisabled, setisButtonDisabled] = useState(true); | ||
|
||
const handleClickOpen = () => { | ||
setOpen(true); | ||
|
||
setTimeout(() => setisButtonDisabled(false), 5000); | ||
}; | ||
|
||
const handleClose = () => { | ||
setisButtonDisabled(true); | ||
setOpen(false); | ||
}; | ||
|
||
const transition = useTransition(); | ||
useEffect(() => { | ||
if (transition.type == "actionRedirect") { | ||
setOpen(false); | ||
} | ||
}, [transition]); | ||
|
||
return ( | ||
<> | ||
<Tooltip title="Archive project"> | ||
<IconButton | ||
onClick={handleClickOpen} | ||
aria-label="Archive-project-button" | ||
> | ||
<Archive /> | ||
</IconButton> | ||
</Tooltip> | ||
|
||
<Dialog onClose={handleClose} open={open}> | ||
<DialogTitle> | ||
Are you sure you want to archive this proposal? | ||
</DialogTitle> | ||
<Form action={`/projects/archive`} method="post"> | ||
<DialogContent> | ||
You can unarchive the project later. | ||
<input type="hidden" name="projectId" value={projectId} /> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button className="primary" onClick={handleClose}> | ||
Cancel | ||
</Button> | ||
|
||
<Button | ||
disabled={isButtonDisabled} | ||
type="submit" | ||
variant="contained" | ||
color="warning" | ||
> | ||
Yes, archive it | ||
</Button> | ||
{isButtonDisabled && ( | ||
<CircularProgress | ||
size={24} | ||
sx={{ | ||
position: "absolute", | ||
left: "80%", | ||
marginTop: "-1px", | ||
marginLeft: "-1px", | ||
}} | ||
/> | ||
)} | ||
</DialogActions> | ||
</Form> | ||
</Dialog> | ||
</> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Unarchive } from "@mui/icons-material"; | ||
import { | ||
Button, | ||
CircularProgress, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogTitle, | ||
IconButton, | ||
Tooltip, | ||
} from "@mui/material"; | ||
import { Form, useTransition } from "@remix-run/react"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export const UnarchiveProject = ({ projectId }: { projectId?: string }) => { | ||
const [open, setOpen] = useState(false); | ||
const [isButtonDisabled, setisButtonDisabled] = useState(true); | ||
|
||
const handleClickOpen = () => { | ||
setOpen(true); | ||
|
||
setTimeout(() => setisButtonDisabled(false), 5000); | ||
}; | ||
|
||
const handleClose = () => { | ||
setisButtonDisabled(true); | ||
setOpen(false); | ||
}; | ||
|
||
const transition = useTransition(); | ||
useEffect(() => { | ||
if (transition.type == "actionRedirect") { | ||
setOpen(false); | ||
} | ||
}, [transition]); | ||
|
||
return ( | ||
<> | ||
<Tooltip title="Unarchive project"> | ||
<IconButton | ||
onClick={handleClickOpen} | ||
aria-label="Unarchive-project-button" | ||
> | ||
<Unarchive color="secondary" /> | ||
</IconButton> | ||
</Tooltip> | ||
|
||
<Dialog onClose={handleClose} open={open}> | ||
<DialogTitle> | ||
Are you sure you want to unarchive this proposal? | ||
</DialogTitle> | ||
<Form action={`/projects/unarchive`} method="post"> | ||
<DialogContent> | ||
This action will unarchive the project and will be available again. | ||
<input type="hidden" name="projectId" value={projectId} /> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button className="primary" onClick={handleClose}> | ||
Cancel | ||
</Button> | ||
<Button | ||
disabled={isButtonDisabled} | ||
type="submit" | ||
variant="contained" | ||
color="warning" | ||
> | ||
Unarchive it | ||
</Button> | ||
{isButtonDisabled && ( | ||
<CircularProgress | ||
size={24} | ||
sx={{ | ||
position: "absolute", | ||
left: "85%", | ||
marginTop: "-1px", | ||
marginLeft: "-1px", | ||
}} | ||
/> | ||
)} | ||
</DialogActions> | ||
</Form> | ||
</Dialog> | ||
</> | ||
); | ||
}; |
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.
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.
I'm thinking we should move these validation functions out of the *.server.ts files, and instead do them inside the
action
functions. That way the database layer will be cleaner, and authorization logic will live close to the view/controller layer.What do you think?
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.
For an example of this, look at the
app/routes/projects/$projectId/updateRelatedProjects.ts
file.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.
ok, makes sense for me. Do you want me to start it on this ticket? 👀
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.
Yes, but only for the validations you added. To move them to the
app/routes/projects/archive.tsx
action.