Skip to content

Commit

Permalink
FIx sharing project not saving
Browse files Browse the repository at this point in the history
  • Loading branch information
wniestroj committed Nov 29, 2024
1 parent 5a5afae commit 87e3c59
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
35 changes: 22 additions & 13 deletions frontend-v2/src/features/projects/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ const ProjectRow: FC<Props> = ({
() => dispatch(decrementDirtyCount()),
);
}
console.log('project', project, data.project)
if (JSON.stringify(project) !== JSON.stringify(data.project)) {
dispatch(incrementDirtyCount());
updateProject({ id: project.id, project: data.project }).then(() =>
Expand All @@ -173,9 +172,15 @@ const ProjectRow: FC<Props> = ({
);

const onCancel = () => {
setValue('project.description', project.description);
setValue("project.description", project.description);
};

const onShareCanel = () => {
setValue("project.user_access", project.user_access);
setUserAccessOpen(false);
setIsEditMode(false);
}

if (isLoading) {
return <div>Loading...</div>;
}
Expand Down Expand Up @@ -341,7 +346,10 @@ const ProjectRow: FC<Props> = ({

<Tooltip title="Share Project">
<IconButton
onClick={() => setUserAccessOpen(true)}
onClick={() => {
setIsEditMode(true);
setUserAccessOpen(true);
}}
disabled={isSharedWithMe}
>
<PersonAdd />
Expand All @@ -352,15 +360,6 @@ const ProjectRow: FC<Props> = ({
<Delete />
</IconButton>
</Tooltip>
<UserAccess
open={userAccessOpen}
onClose={userAccessClose}
control={control}
userAccess={userAccess as ProjectAccess[]}
append={append}
remove={remove}
project={project}
/>
{isSharedWithMe && (
<Tooltip title="This project is shared with me as view-only">
<div>
Expand Down Expand Up @@ -402,6 +401,16 @@ const ProjectRow: FC<Props> = ({
)}
</TableCell>
</TableRow>
<UserAccess
open={userAccessOpen}
onClose={userAccessClose}
onCancel={onShareCanel}
control={control}
userAccess={userAccess as ProjectAccess[]}
append={append}
remove={remove}
project={project}
/>
{isDescriptionModalOpen && (
<DescriptionModal
isOpen={isDescriptionModalOpen}
Expand All @@ -412,7 +421,7 @@ const ProjectRow: FC<Props> = ({
project={project}
>
<MaterialTextField
{...register('project.description')}
{...register("project.description")}
sx={{ width: "50vw" }}
disabled={!isEditMode}
multiline
Expand Down
10 changes: 9 additions & 1 deletion frontend-v2/src/features/projects/UserAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface Props {
userAccess: ProjectAccess[];
append: (value: ProjectAccess) => void;
remove: (index: number) => void;
onCancel: () => void;
control: Control<FormData>;
onClose: () => void;
}
Expand All @@ -41,7 +42,7 @@ const UserAccess: FC<Props> = ({
userAccess,
append,
remove,
control,
onCancel,
onClose,
}) => {
const { data: users } = useUserListQuery();
Expand Down Expand Up @@ -122,6 +123,13 @@ const UserAccess: FC<Props> = ({
margin: ".5rem",
}}
>
<Button
variant="outlined"
sx={{ marginLeft: "1rem" }}
onClick={onCancel}
>
Cancel
</Button>
<Button
variant="contained"
sx={{ marginLeft: "1rem" }}
Expand Down

0 comments on commit 87e3c59

Please sign in to comment.