-
Notifications
You must be signed in to change notification settings - Fork 2
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: Remove a User #3706
feat: Remove a User #3706
Conversation
editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.archiveUser.test.tsx
Outdated
Show resolved
Hide resolved
f916143
to
e0879f5
Compare
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Outdated
Show resolved
Hide resolved
The lock files have a huge amount of changes where |
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Outdated
Show resolved
Hide resolved
Removed vultr server and associated DNS entries |
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.
A few small nits and comments on PR, please see below. I think the main areas to focus on is how the refactor of the SettingsModal
is handled, and how shared types should work.
Pizza working as expected, but I hit a bug related to the cache of existing users persisting - I think we encountered and resolved something similar before?
Screen.Recording.2024-09-23.at.07.39.53.mov
The lock files have a huge amount of changes where ' become " - is there a way I can stop this?
There's some linting inconsistencies across our devices - clearly husky or prettier is not configured correctly. Let's try and solve this IRL this week 👍
editor.planx.uk/src/pages/FlowEditor/components/Team/TeamMembers.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/SettingsModal.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/EditorUpsertModal.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/EditorUpsertModal.tsx
Show resolved
Hide resolved
fdeb6aa
to
30214e2
Compare
@DafyddLlyr for the bug, to solve the caching issue, would I need to trigger a re-rendering of the component? Would there be a reason this doesn't happen when I set state in the global store here: export const optimisticallyUpdateExistingMember = async (
values: UpdateEditorFormValues,
userId: number
) => {
const existingMembers = useStore.getState().teamMembers;
const updatedMembers: TeamMember[] = existingMembers.map((member) => {
if (member.id === userId) {
return { ...values, id: userId, role: member.role };
}
return member;
});
await useStore.getState().setTeamMembers(updatedMembers);
}; See the bug is present when editing a users details as well, but not when adding, so I wonder why this is performing differently. Does Zustand not see a difference between the old array of TeamMembers and the new? |
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/RemoveUserModal.tsx
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/SettingsModal.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/tests/TeamMembers.removeUser.test.tsx
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/TeamMembers.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/TeamMembers.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/MembersTable.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/SettingsModal.tsx
Outdated
Show resolved
Hide resolved
editor.planx.uk/src/pages/FlowEditor/components/Team/components/EditorUpsertModal.tsx
Show resolved
Hide resolved
@@ -56,6 +56,7 @@ const teamMembersRoutes = compose( | |||
} = await client.query<GetUsersForTeam>({ | |||
query: GET_USERS_FOR_TEAM_QUERY, | |||
variables: { teamSlug }, | |||
fetchPolicy: "no-cache", |
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.
@DafyddLlyr added this to resolve the caching bug when removing a user
@@ -157,4 +158,13 @@ export const teamStore: StateCreator< | |||
setTeamMembers: async (teamMembers: TeamMember[]) => { | |||
set(() => ({ teamMembers })); | |||
}, | |||
deleteUser: async (userId: number) => { | |||
try { |
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.
trycatch()
block added to throw useful error on mutation failure.
@@ -16,3 +17,14 @@ export const StyledTableRow = styled(TableRow)(({ theme }) => ({ | |||
background: theme.palette.background.paper, | |||
}, | |||
})); | |||
|
|||
export const SettingsDialog = styled(Dialog)(({ theme }) => ({ |
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.
This works for now, but a future PR should refactor this into a global Editor style override in the theme.ts
file
</Permission.IsPlatformAdmin> | ||
</TableCell> | ||
<TableCell> | ||
<Permission.IsPlatformAdmin> |
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.
Permission level moved inside <TableCell>
to ensure consistent UI across different permission levels
const Root = styled(Box, { | ||
shouldForwardProp: (prop) => prop !== "background", | ||
})<RootProps>(({ background, theme }) => ({ | ||
})<BoxProps & { background?: boolean }>(({ background, theme }) => ({ |
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.
Had to revert bgcolor
since background
was a boolean to conditionally style the ServiceSettings
component
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 found this when running tests and seeing the other places this component was used
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.
Looking good - thanks for those changes 👍
What does this PR do?
This PR tackles the Trello Ticket: https://trello.com/c/0jbcXque/3012-remove-user-in-editor?filter=member:rorydoak2
It includes a range of refactors which build on the Add User and Edit User work. We are using a Styled Component called
SettingsDialog
to ensure consistent styling across different modal uses. This should be extended to a style override in thetheme.ts
file governing the whole editor. This has been outlined as a future refactoring PR.Unit tests have been written to ensure removing a user follows a predictable path with correct messaging while being available at the right permission level.
I had to make an adjustment to the
deleteUser
mutation in planx-core. It wasn't breaking but was throwing an error due to a typo in return bool.theopensystemslab/planx-core#516