Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

feat: hide interaction action elements in dashboard #2121

Conversation

Sboonny
Copy link
Member

@Sboonny Sboonny commented Dec 20, 2022

  • I have read Chapter's contributing guidelines.
  • My pull request has a descriptive title (not a vague title like Update README.md).
  • My pull request targets the main branch of Chapter.

Closes #1961

Sponsor has add new and stuff already built in it
https://github.com/Sboonny/chapter/blob/71fc140bc1f87f01e9977eb96cda6cdf33191933/client/src/modules/dashboard/Sponsors/pages/SponsorsPage.tsx#L19-L22

@ghost
Copy link

ghost commented Dec 20, 2022

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@Sboonny Sboonny marked this pull request as ready for review December 20, 2022 09:27
@Sboonny Sboonny requested a review from a team December 20, 2022 09:27
@gikf gikf added the UI/UX This issue deals with UI/UX label Dec 21, 2022
Comment on lines 24 to 29
const hasPermissionToCreateEvent = checkPermission(
user,
Permission.EventCreate,
);

const hasPermissionToEditEvent = checkPermission(user, Permission.EventEdit);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these checks need to have either eventId or chapterId passed. Otherwise only check will be done only on the instance permissions.

Copy link
Member Author

@Sboonny Sboonny Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in some cases (mostly "add new" something buttons), we will have code that looks like this, which will create an array of the permissions.

data.dashboardEvents.map(({id})=>checkPermission(
    user,
    Permission.EventCreate,
    {id}
  ));

What are your thoughts about keeping the instance's permission for most cases except "create new event", and "create new venue" 🤔? Because these are the only ones currently, that admins interact with

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For current roles that would be enough. But to give ability to add custom and more granular role permissions, I think it would be better to pass the event id and/or chapter id to checkPermission as well. Even if so far these permissions would be only on some instance roles.

Copy link
Member Author

@Sboonny Sboonny Jan 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last question 👍, do I add the ability to filter the data that aren't editable in this PR?

Edit: we don't have the rule of organizer, so thinking of features for them isn't necessary currently.

@Sboonny Sboonny marked this pull request as draft January 3, 2023 20:03
@Sboonny Sboonny marked this pull request as ready for review January 21, 2023 16:45
Copy link
Contributor

@ojeytonwilliams ojeytonwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Sboonny, I split checkPermission into two functions in #2268, so you can use checkChapterPermission from client/src/util/check-permission.ts

The idea is that you might have permission for a specific Chapter, so we have to pass the chapter's chapterId to the function, so it can check that.

There are flaws with the functions, tracked in #2269, but for this PR all you need do is pass chapterId in when calling checkChapterPermission.

@Sboonny Sboonny marked this pull request as draft January 27, 2023 13:52
@Sboonny Sboonny marked this pull request as ready for review January 29, 2023 13:20
@Sboonny Sboonny marked this pull request as ready for review February 6, 2023 14:33
@ojeytonwilliams ojeytonwilliams merged commit c61cb81 into freeCodeCamp:main Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: ready for review UI/UX This issue deals with UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use client permissions check to modify UI in dashboards
3 participants