-
Notifications
You must be signed in to change notification settings - Fork 39
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: 🍰 Switch User Role As Admin #4136
Conversation
Can an admin change her own role? This way we could avoid easily that at least one admin is remaining. |
…ial-Community/Ocelot-Social into 4124-switch-user-role
…ial-Community/Ocelot-Social into 4124-switch-user-role
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.
Looks like a good start! Please see my comments.
Can you add tests for the role change to user.spec.js
.
I have to add tests in the backend.
webapp/graphql/admin/Roles.js
Outdated
|
||
export const updateUserRole = (role, id) => { | ||
return gql` | ||
mutation { |
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.
Better this way:
mutation($role: UserGroup!, $id: ID!) {
switchUserRole(role: $role, id: $id) {
So we have the schema correctly in the frontend
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.
Please have two spaces as indentation
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.
If you could solve this by following @Mogge suggestion … @tippanamadhusudan
@@ -48,6 +48,23 @@ | |||
<template #createdAt="scope"> | |||
{{ scope.row.createdAt | dateTime }} | |||
</template> | |||
|
|||
<template slot="role" slot-scope="scope"> |
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.
Great! I really like the way you are using slots here!
webapp/pages/admin/users.vue
Outdated
<ApolloQuery :query="FetchAllRoles"> | ||
<template v-slot="{ result: { data } }"> | ||
<template v-if="data"> | ||
<select |
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.
Did you try ds-select
to get the standard layout for select fields?
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.
… and try this as well @tippanamadhusudan
@tippanamadhusudan I added the tests to the backend. I also made sure, that the current user cannot change the own role to make sure that there is always at least one admin left. May be you can catch this in the frontend as well. The backend throws an error when current user tries to change the own role. |
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.
Hey @tippanamadhusudan ,
your first PR is close to get merged into the master !!! 😍
And it’s a really important one, because we need it urgent for the first network wir.social
going online at the beginning of next week! 🚀🚀💫
If you could follow @Mogge suggestions 👇🏼 you have it quickly ready. 🙏🏼💪🏼
Thank you very much for helping !!! 🍀
webapp/graphql/admin/Roles.js
Outdated
|
||
export const updateUserRole = (role, id) => { | ||
return gql` | ||
mutation { |
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.
If you could solve this by following @Mogge suggestion … @tippanamadhusudan
webapp/pages/admin/users.vue
Outdated
<ApolloQuery :query="FetchAllRoles"> | ||
<template v-slot="{ result: { data } }"> | ||
<template v-if="data"> | ||
<select |
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.
… and try this as well @tippanamadhusudan
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.
You both got it together !!!
A big thank to @tippanamadhusudan !!! This will go into our first live version of ocelot.social: wir.social
next week.
Congratulations !!! 🚀🚀💫💫
… and to @Mogge as well for sure! 😘
Just a little hint … 👇🏼
webapp/pages/admin/users.spec.js
Outdated
}, | ||
}), | ||
) | ||
// await expect(mocks.$toast.success).toHaveBeenCalled() |
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.
May delete that comment in favour of the next test?
update({ __type }) { | ||
return __type.enumValues.map((item) => item.name) | ||
}, |
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.
That seems to be cool stuff! 😎🥰
…celot-Social into 4124-switch-user-role
8b7570d
to
dd8f32b
Compare
🍰 Pullrequest
An admin can change the role a user has
Issues
Todo