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

Refactor group permission function. #332

Merged
merged 11 commits into from
Jan 6, 2023

Conversation

Jonas-Sander
Copy link
Collaborator

@Jonas-Sander Jonas-Sander commented Jan 4, 2023

I stumbled on the requestPermission function in our code which was used to check if a user can perform a certain action, e.g. adding homework or changing course settings.

This function was weirdly named and had logic for enum values which were not in use anymore.

I changed the function to an extension method on MemberRole and removed the unused enums.
Additionally I moved the files from the additional to groups folder.
Lastly I renamed the function isUserAdminOrOwnerFromCourse to isUserAdminOrOwnerOfGroup in the same file.

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

Visit the preview URL for this PR (updated for commit 25287db):

https://sharezone-test--pr332-course-permission-fu-vc3kafwv.web.app

(expires Fri, 13 Jan 2023 17:15:54 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 4cb3ae61e1e018abfd9841fd3239f5b49ccc034b

Copy link
Member

@nilsreichardt nilsreichardt left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Would be great to also add a few tests for the group_permission.dart file, but we can also do this later.

app/lib/groups/group_permission.dart Outdated Show resolved Hide resolved
app/lib/groups/group_permission.dart Outdated Show resolved Hide resolved
app/lib/groups/group_permission.dart Outdated Show resolved Hide resolved
@Jonas-Sander
Copy link
Collaborator Author

LGTM 👍

Would be great to also add a few tests for the group_permission.dart file, but we can also do this later.

Since I didn't touch any behavior (just deleted unused code) and the code is really dead simple I don't see that much reason to write tests. They would just mirror the implementation.

I feel like it would make more sense to write tests in the future that test this function through the code that uses it.
This will require more refactoring though.

@nilsreichardt
Copy link
Member

nilsreichardt commented Jan 6, 2023

⬇️ Generated builds by Codemagic for commit 25287db ⬇️

Note: Only Sharezone team members are able to install the iOS app.

iOS Android
image
Download link
image
Download link

@Jonas-Sander Jonas-Sander enabled auto-merge (squash) January 6, 2023 17:12
@Jonas-Sander Jonas-Sander merged commit 78317de into main Jan 6, 2023
@Jonas-Sander Jonas-Sander deleted the course-permission-function-refactor branch January 6, 2023 17:41
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.

2 participants