-
Notifications
You must be signed in to change notification settings - Fork 19
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(admin): add user role management #4248
Conversation
apps/ui/pages/admin.vue
Outdated
|
||
const users = ref<IUser[]>([]); | ||
const userCount = ref(0); | ||
const totalPages = ref(0); | ||
getUsers(); | ||
|
||
function updateCurrentPage(newPage: number) { | ||
currentPage.value = newPage; | ||
getUsers(); | ||
} | ||
|
||
const users = computed(() => data.value?.data._admin.users || []); | ||
const userCount = computed(() => data.value?.data._admin.userCount ?? 0); | ||
async function getUsers() { | ||
const { data, error } = await useFetch<IAdminResponse>("/api/graphql", { | ||
method: "post", | ||
body: { | ||
query: `{ _admin { users(limit: ${LIMIT}${offset.value}) { email, settings, {key, value} } userCount } }`, | ||
}, | ||
}); | ||
if (error.value) { | ||
console.log("Error loading users: ", error.value); | ||
// todo handle error see catalogue error page | ||
} | ||
users.value = data.value?.data._admin.users || []; | ||
userCount.value = data.value?.data._admin.userCount ?? 0; | ||
const divided = userCount.value / LIMIT; | ||
totalPages.value = | ||
userCount.value % LIMIT > 0 ? Math.floor(divided) + 1 : divided; | ||
} |
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 should should work, but by keeping the useFetch at the page level and using the 'refresh' or computed there is no need for a separate getUsers func and the setup code . This has the added value of exposing the dat, status, error refs at the page level
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.
Sounds cool, didn't get it to work that way though with the pagination.
Quality Gate passedIssues Measures |
@@ -9,6 +9,8 @@ | |||
<!-- <SearchBar /> --> | |||
</div> | |||
|
|||
<slot name="admin" /> |
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 a admin slot , suggest to have slots names related to parts of the header ( left , right , info , cart ) instead of 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.
suggest to add menu item
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.
approve as wip only , ui / ux setup is not inline with new design
Suggest to align with design and code standerd before merge
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.
functionally approved. I am also happy to keep this one open in next sprint to make one round of improvements (e.g. on the in table buttons and using the full screen modal)
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.
Tested:
- Overview with users and their roles within schemas
- Create user => can enter name and password, then add user button gets grey, can be pushed, but nothing happens, Close buttons keeps yellow but also does nothing => user does not end up in the list
- Adjust password of a user NOT TESTED
- Update existing role within a schema
- Add new role within a schema
- Delete a role within a schema
- Add NEW user via settings within a schema gives error (add existing user works):
- Remove users from settings on schema level => removed from Admin tools list
At first I thought that updating /adding new roles did not work, but then I found out that I first need to push the PLUS before saving.
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.
Tested:
- General overview with users and their roles within schemas, including how many tokens they have
- Create user
- Edit user
- Disable user => DELETES THE USER!
- Adjust password of a user
- Remove token of a user => can remove, edit screen shows no token anymore, but when going to the overview it still show Tokens(1). On user level the token is also still there.
- Removing the token by the user also still show Tokens(1) in the overview, and an empty line (with trash button) in the edit screen.
- Update existing role within a schema
- Add new role within a schema
- Delete a role within a schema
- Add NEW user via settings within a schema => Visible in Admin tools overview
- Remove users from settings on schema level => removed from Admin tools list
At first I thought that updating /adding new roles did not work, but then I found out that I first need to push the PLUS before saving. This is perhaps not that intuitive.
Quality Gate passedIssues Measures |
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.
Tested:
- General overview with users and their roles within schemas, including how many tokens they have
- Create user
- Edit user
- Disable user
- Adjust password of a user
-
Remove token of a user => can remove, edit screen shows no token anymore, but when going to the overview it still show Tokens(1). On user level the token is also still there.WON'T DO => separate ticket - Removing the token by the user also still show Tokens(1) in the overview, even after re-login and private window, so seems not to be caching.
- Update existing role within a schema
- Add new role within a schema
- Delete a role within a schema
- Add NEW user via settings within a schema => Visible in Admin tools overview
- Remove users from settings on schema level => removed from Admin tools list
Regarding the tokens, if this functionality will not be implemented (separate ticket), perhaps it's better to remove the column from the overview, as now it can give false-positive information.
What are the main changes you did:
how to test:
Other thing that work:
Not implemented: token management
Other tests:
todo: