52 lines
1.9 KiB
Markdown
52 lines
1.9 KiB
Markdown
# Department Permission And Admin Refactor Plan
|
|
|
|
> For this round, continue based on the existing implementation and do not rebuild from scratch.
|
|
|
|
## Goal
|
|
|
|
Refactor the admin and permission model so that:
|
|
|
|
- the `admin` account is the only `super_admin`
|
|
- permissions are centered on departments instead of direct user-to-knowledge-base bindings
|
|
- knowledge bases belong to departments
|
|
- workspace visibility is filtered by department
|
|
- the admin page becomes a focused permission management console
|
|
- Dify health moves into a user-menu dialog
|
|
|
|
## Scope
|
|
|
|
### Backend
|
|
|
|
- Add `Department` and `UserDepartmentAccess` models
|
|
- Add `primary_department_id` to `users`
|
|
- Add `department_id` to `groups`
|
|
- Backfill existing users and knowledge bases into a default department
|
|
- Enforce `admin` as the only `super_admin`
|
|
- Replace group visibility calculation from `UserGroupAccess` to department-based access
|
|
- Add department CRUD and user permission management endpoints
|
|
|
|
### Frontend
|
|
|
|
- Replace admin page with permission management
|
|
- Move Dify health to a modal entry under the user menu
|
|
- Rename user menu setting entry to `Dify设置`
|
|
- Change inline user editing to dialog-driven create/edit flows
|
|
- Add department selector to workspace sidebar and group creation flow
|
|
- Keep UI feedback lightweight with toast-style transient notices
|
|
|
|
### Validation
|
|
|
|
- Update backend tests for new department-based access model
|
|
- Run full backend pytest
|
|
- Run frontend build
|
|
- Deploy `api + worker + frontend`
|
|
- Verify role enforcement, department visibility, and Dify dialogs on server
|
|
|
|
## Implementation Order
|
|
|
|
1. Introduce department data model and migration with safe backfill.
|
|
2. Update permission helpers, group/file APIs, and admin APIs to use departments.
|
|
3. Rebuild the admin page into permission management and move Dify health into a dialog.
|
|
4. Update workspace department filter and knowledge-base ownership UX.
|
|
5. Run full validation and deploy.
|