Skip to content

Conversation

@fulleni
Copy link
Member

@fulleni fulleni commented Nov 1, 2025

Status

READY

Description

This pull request introduces a robust user management feature to the dashboard, empowering administrators with the tools to effectively oversee and control system users. It enables detailed viewing, filtering, and modification of user roles and permissions, thereby streamlining administrative tasks and enhancing the overall security and operational efficiency of the platform.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Adds the necessary route paths and names for the new user management page and its associated filter dialog.
Adds the `DataClient<User>` and `DataRepository<User>` to the application's dependency injection setup in `bootstrap.dart`.

This makes the user repository available throughout the application, enabling the new user management feature to fetch and manage user data.
Adds the `UserFilterState` class, which will hold the state for filtering the user list, including search query and selected roles.
Adds the `UserFilterEvent` sealed class and its concrete implementations. These events will be used to update the filter state for the user list, including changing the search query, updating selected roles, and resetting or applying filters.
Adds the `UserFilterBloc` to manage the state of filters for the user list. This BLoC handles events for updating the search query, selected roles, and resetting filters.
Adds the `UserManagementState` and `UserManagementStatus` enum. This state will manage the list of users, pagination, loading status, and error handling for the user management feature.
Adds the `UserManagementEvent` sealed class and its concrete implementations. These events will be used to load users with pagination and filters, and to change a user's app or dashboard role.
Adds the `UserManagementBloc` responsible for managing the state of the user list.

This BLoC handles:
- Fetching users with pagination and filters.
- Listening to the `UserFilterBloc` to react to filter changes.
- Listening to repository updates for automatic data refresh.
- Handling events to change a user's app or dashboard role.
Adds the `UserManagementPage`, which serves as the main scaffold and entry point for the user management feature.

This page includes the app bar with a title and a filter button that navigates to the user filter dialog. The body contains the `UsersPage` where the user data will be displayed.
Adds the `UsersPage` widget, which displays a paginated data table of system users.

This page:
- Listens to the `UserManagementBloc` to display users.
- Handles loading, error, and empty states.
- Implements pagination to fetch more users as the user navigates through pages.
- Defines the data source and columns for the user table.
Adds the `UserActionButtons` widget, which provides contextual actions for each user in the data table.

This widget displays a popup menu with actions based on the user's role:
- "Promote to Publisher" for standard users.
- "Demote to User" for publishers.
- "Copy User ID" for all non-admin users.

It strictly prevents any actions from being displayed or performed on users with the 'admin' role, enhancing security and data integrity.
Adds the `UserFilterDialogState` class. This state will hold the temporary filter selections within the user filter dialog before they are applied to the main `UserFilterBloc`.
Adds the `UserFilterDialogEvent` sealed class and its concrete implementations. These events will manage the temporary state of the user filter dialog, including initialization, changes to search query and roles, and resetting the filters.
Adds the `UserFilterDialogBloc` to manage the temporary state of the user filter dialog. This BLoC is initialized with the current filters, handles user changes within the dialog, and provides a mechanism to reset the selections.
Adds the `UserFilterDialog`, a full-screen dialog for filtering the user list.

This dialog allows administrators to filter users by:
- Email (via a search field)
- App Role (multi-select)
- Dashboard Role (multi-select)

It uses `UserFilterDialogBloc` to manage its temporary state and applies the selected filters to the main `UserFilterBloc` when the "Apply" button is pressed. It also includes a "Reset" button to clear all filters.
Updates `app.dart` to accept the `usersRepository` and provide the new `UserManagementBloc` and `UserFilterBloc` via the existing `MultiBlocProvider`.

This correctly integrates the new BLoCs into the application's dependency injection structure without altering the established architecture in `bootstrap.dart`.
…cture

- Move user_filter_bloc.dart, user_filter_event.dart, and user_filter_state.dart into a new user_filter directory
- This change improves the folder structure and makes it more consistent with common bloc patterns
Updates the `AppShell` to include a new `NavigationDestination` for the "User Management" feature, making it accessible from the main navigation rail/drawer.
Updates `router.dart` to integrate the new User Management feature.

This change adds a new `StatefulShellBranch` for the user management section and defines the `GoRoute` for the main `UserManagementPage`. It also includes a nested route for the `UserFilterDialog`, which is presented as a full-screen dialog and is provided with its own `UserFilterDialogBloc`.
- Add new translations for user management features in Arabic and English
- Include various elements such as navigation labels, page descriptions, table headers, and action buttons
- Cover different aspects of user management, including filtering, promoting, and demoting users
- Add new localization strings for user management feature
- Implement translations for Arabic and English languages
- Cover various aspects of user management including:
  * Navigation labels
  * Page descriptions
  * User attributes (email, roles, creation date)
  * Action labels (promote, demote)
  * Filter dialog elements
- Include new section detailing user and role management features
- Highlight granular user management capabilities
- Emphasize secure administrative access and delegation of content creation responsibilities
- Improve documentation structure for better overview of system features
- Replace hardcoded value with constant from AppConstants
- Add missing import for UI kit
- Replace direct import of AppLocalizations with flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations
- This change ensures consistency in localization import across the user management feature
- Replace incorrect import path for flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart
- Ensure proper localization functionality in user_action_buttons.dart
- Add banner_ad_shape_l10n.dart and dashboard_user_role_l10n.dart
- These new exports will enable localization for additional entities
Removes the local `AppUserRoleL10n` and `DashboardUserRoleL10n` extensions from `user_filter_dialog.dart`.

These local definitions were causing build errors due to ambiguity with the centralized extensions in `lib/shared/extensions/`. This change ensures that the dialog uses the shared, canonical extensions, resolving the conflict and adhering to DRY principles.
Swaps the `StatefulShellBranch` for Content Management and User Management in `router.dart`. This aligns the router's branch indices with the visual order of the `NavigationDestination` widgets in the `AppShell`, fixing a bug where clicking a sidebar item would navigate to the wrong page.
Refactors the user table in `users_page.dart` to improve clarity and fix display issues.

- Removes the "Dashboard Role" column as it is not relevant for all users.
- Renames the "App Role" column to "Authentication" and adds a new "Subscription" column.
- Implements logic to display derived, localized values for these new columns based on the user's `appRole`.
- Truncates long email addresses with an ellipsis to prevent wrapping.
- Updates filter logic to account for the removed dashboard role filter.
…ions

- Refactored `UserActionButtons` to display a primary action icon directly in the table row.
- Secondary actions (like "Copy User ID") are now in a `PopupMenuButton` (ellipsis icon).
- This change mimics the UI pattern of `ContentActionButtons`, creating a consistent user experience across the dashboard.
- The primary action is now an `IconButton` for "Promote" or "Demote", depending on the user's role.
- Add new translations for authentication and subscription status in Arabic and English
- Include column headers and status descriptions for both languages
- Enhance filter dialog and data table translations
- Change ColumnSize.M to ColumnSize.S for the 'created at' column in the users page table
- Add logging statements to track user dashboard role changes
- Implement try-catch block for better error handling
- Include stack trace when logging errors
- Use Logger instance for consistent logging throughout the bloc
- Add LayoutBuilder to determine screen width
- Implement conditional rendering of subscription column based on device type
- Improve table styling and responsiveness
…sed on device type

- Hide the 'authentication' column on mobile devices to improve UI/UX
- Use a conditional statement to render the column only if the device is not mobile
- Update both the DataColumn2 and DataCell related to the 'authentication' information
@fulleni fulleni linked an issue Nov 1, 2025 that may be closed by this pull request
@gemini-code-assist
Copy link

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust user management feature to the dashboard, empowering administrators with the tools to effectively oversee and control system users. It enables detailed viewing, filtering, and modification of user roles and permissions, thereby streamlining administrative tasks and enhancing the overall security and operational efficiency of the platform.

Highlights

  • New User Management Feature: A comprehensive user management system has been integrated into the dashboard, allowing for the viewing and management of all system users.
  • Granular Role Control: The system now supports promoting users to a 'Publisher' role or demoting them, providing distinct control over their dashboard permissions.
  • Advanced Filtering Capabilities: Users can now be efficiently filtered by email, application role, and dashboard role, enhancing administrative oversight.
  • UI Integration and Navigation: A new 'User Management' navigation item and a dedicated page have been added to the dashboard, providing a central hub for user administration.
  • Localization Support: New localization strings have been added for all user management UI elements, supporting both English and Arabic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully implements a comprehensive user management feature. It includes a new section in the UI for managing users, complete with filtering, pagination, and role management capabilities. The implementation follows the existing BLoC architecture well, with clear separation of concerns. The code is generally clean and well-structured. I've identified a few areas for improvement, mainly concerning error handling consistency, removal of duplicated code, and cleaning up an unused state property to enhance maintainability and robustness.

This commit enhances the _onUserAppRoleChanged method in the UserManagementBloc by introducing a try-catch block and detailed logging.

This change mirrors the robust implementation of _onUserDashboardRoleChanged, ensuring that any errors during the update process are caught, logged, and handled gracefully, preventing the BLoC's event stream from crashing and improving the overall stability of the user management feature.
This commit refactors the bootstrap.dart file to eliminate duplicated DataApi client initializations for the development and production environments.

By merging the else if (development) block into the final else block, the code is made more concise and maintainable, as the client setup for both environments is now handled in a single location.
This commit cleans up the UserFilterDialogState by removing the selectedStatus property, which was an unused artifact and not applicable to user filtering.

The constructor, copyWith method, props getter, and the reset event handler in UserFilterDialogBloc have all been updated to reflect this removal, resulting in a cleaner and more relevant state definition.
@fulleni fulleni merged commit 074c3ab into main Nov 1, 2025
1 check failed
@fulleni fulleni deleted the feat/build-full-user-management branch November 1, 2025 08:06
@fulleni fulleni added this to the Foundation Edition milestone Nov 1, 2025
@fulleni fulleni self-assigned this Nov 1, 2025
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.

feat: Build Full User Management UI

2 participants