Role CRUD LiveViews closes #325 #326

Merged
moritz merged 28 commits from feature/325_role_view into main 2026-01-08 16:21:42 +01:00
Owner

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

What has been changed?

Definition of Done

Code Quality

  • No new technical depths
  • Linting passed
  • Documentation is added were needed

Accessibility

  • New elements are properly defined with html-tags
  • Colour contrast follows WCAG criteria
  • Aria labels are added when needed
  • Everything is accessible by keyboard
  • Tab-Order is comprehensible
  • All interactive elements have a visible focus

Testing

  • Tests for new code are written
  • All tests pass
  • axe-core dev tools show no critical or major issues

Additional Notes

## Description of the implemented changes The changes were: - [ ] Bugfixing - [x] New Feature - [ ] Breaking Change - [ ] Refactoring <!--- Describe the goal of the PR in a few words --> ## What has been changed? <!--- List the things you changed --> ## Definition of Done ### Code Quality - [ ] No new technical depths - [ ] Linting passed - [ ] Documentation is added were needed ### Accessibility - [ ] New elements are properly defined with html-tags - [ ] Colour contrast follows WCAG criteria - [ ] Aria labels are added when needed - [ ] Everything is accessible by keyboard - [ ] Tab-Order is comprehensible - [ ] All interactive elements have a visible focus ### Testing - [x] Tests for new code are written - [x] All tests pass - [x] axe-core dev tools show no critical or major issues ## Additional Notes <!--- Add any additional information for the reviewers here -->
moritz self-assigned this 2026-01-06 23:57:05 +01:00
moritz added 5 commits 2026-01-06 23:57:06 +01:00
Implement MvWeb.Authorization module with can?/3 and can_access_page?/2
functions for conditional rendering in LiveView templates.

- can?/3 supports both resource atoms and record structs with scope checking
- can_access_page?/2 checks page access permissions
- All functions use PermissionSets module for consistency with backend
- Graceful handling of nil users and invalid permission sets
- Comprehensive test coverage with 17 test cases
Add complete CRUD interface for role management under /admin/roles.

- Index page with table showing name, description, permission_set_name, is_system_role
- Show page for role details
- Form component for create/edit with permission_set_name dropdown
- System role badge and disabled delete button
- Flash messages for success/error
- Authorization checks using MvWeb.Authorization helpers
- Comprehensive test coverage (22 tests)

Routes added under /admin scope. All LiveViews load user role
for authorization checks. Form uses custom dropdown for permission sets.
Fix compiler warning for unused variable in role_live_test.exs
- Add text labels to Edit and Delete buttons in index page
- Change button size from btn-xs to btn-sm for better visibility
- Add Delete button to show page for non-system roles
- Implement handle_event for delete in show page
- Add format_error helper to show page
feat: assign admin role to admin user in seeds
Some checks failed
continuous-integration/drone/push Build is failing
a5081793b0
- Create Admin role if it doesn't exist
- Assign Admin role to admin@mv.local user
- Remove separate create_admin_role script (integrated into seeds)
moritz added 2 commits 2026-01-07 00:04:43 +01:00
Extract role loading logic into separate private functions to fix Credo warning about nested function body.
feat: add German translations for role management
All checks were successful
continuous-integration/drone/push Build is passing
250035b5c6
moritz added 3 commits 2026-01-08 12:02:17 +01:00
- Add Users column showing number of users assigned to each role
- Load user counts efficiently in single query to avoid N+1
- Similar implementation to membership fee types member count
- Convert Settings menu item to dropdown (similar to Contributions)
- Add Global Settings and Roles as sub-items
- Update German translations: 'Global Settings' and 'Roles'
fix: improve contrast for 'No description' text to meet WCAG 2 AA
All checks were successful
continuous-integration/drone/push Build is passing
1dd7c0eaa0
Change text-base-content/50 to text-base-content/70 for better
accessibility contrast ratio in role index and show pages
moritz added 1 commit 2026-01-08 12:07:51 +01:00
feat: prevent deletion of roles with assigned users
All checks were successful
continuous-integration/drone/push Build is passing
8afccf1dd0
moritz added 3 commits 2026-01-08 13:33:30 +01:00
Replace raise with reraise to preserve the original stacktrace when
re-raising exceptions in rescue blocks, improving error debugging.
chore: update gettext files and test cleanup
All checks were successful
continuous-integration/drone/push Build is passing
586985f7f0
Update translation files after code changes and remove unused
debug logging code from tests.
moritz added 4 commits 2026-01-08 13:58:28 +01:00
Ensure consistent authorization by passing actor parameter to
get_role call, matching the pattern used in Show LiveView.
Calculate user_count once and reuse the value instead of calling
recalculate_user_count twice, reducing unnecessary database queries.
Move duplicate ensure_user_role_loaded logic into MvWeb.LiveHelpers
on_mount hook to eliminate code duplication across RoleLive modules
and centralize security-related user role loading.
refactor: replace cond with if in handle_delete_role functions
All checks were successful
continuous-integration/drone/push Build is passing
c27b903018
moritz added 6 commits 2026-01-08 15:30:29 +01:00
Add actor parameter to load_user_counts and recalculate_user_count
in Index LiveView to ensure consistent authorization and policy
enforcement. Also add domain parameter for clarity.
Add actor and domain parameters to recalculate_user_count and
load_user_count to ensure consistent authorization. Clarify that
load_user_count is for initial display while recalculate_user_count
is for fresh count before deletion.
Use self as actor when loading user role relationship to ensure
proper authorization and policy enforcement.
Extract format_error and permission_set_badge_class functions into
MvWeb.RoleLive.Helpers module to eliminate code duplication between
Index and Show LiveViews.
Only show Roles link in Settings dropdown for users with admin
permissions, preventing unauthorized access attempts.
fix: correct German translations for role management
All checks were successful
continuous-integration/drone/push Build is passing
bcd3871245
Fix incorrect translations:
- 'Listing Roles' -> 'Rollen auflisten' (was 'Benutzer*innen auflisten')
- 'Custom' -> 'Benutzerdefiniert' (was 'Benutzerdefinierte Felder')
moritz force-pushed feature/325_role_view from bcd3871245 to 5998fb643d 2026-01-08 16:04:49 +01:00 Compare
moritz force-pushed feature/325_role_view from 5998fb643d to 68c09b761e 2026-01-08 16:20:39 +01:00 Compare
moritz changed title from WIP: Role CRUD LiveViews closes #325 to Role CRUD LiveViews closes #325 2026-01-08 16:21:09 +01:00
moritz merged commit 05b611d880 into main 2026-01-08 16:21:42 +01:00
moritz deleted branch feature/325_role_view 2026-01-08 16:21:43 +01:00
Sign in to join this conversation.
No description provided.