Skip to content
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

Draft
wants to merge 83 commits into
base: master
Choose a base branch
from

Conversation

chinook25
Copy link
Contributor

@chinook25 chinook25 commented Sep 23, 2024

What are the main changes you did:

how to test:

  • Run the ui app in dev mode
  • Go to localhost:3000
  • Login as admin
  • Click on the newly appeared admin button
  • .... wip

Other tests:

  • go to localhost:3000/admin
  • see that your redirected to the login screen

todo:

  • updated docs in case of new feature
  • added/updated tests
  • added/updated testplan to include a test for this fix, including ref to bug using # notation

@chinook25 chinook25 self-assigned this Sep 26, 2024
Comment on lines 49 to 76

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;
}
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link

sonarcloud bot commented Nov 13, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants