Files
ctms/docs/plans/2026-05-29-project-permission-consistency-implementation.md
T
Cheng Zhou 02f2c6660b 补充权限与物资实现计划
1、记录项目权限一致性实施计划,明确前后端权限矩阵以接口权限为准。

2、列出快捷入口、参与者操作、路由权限和权限契约测试的实施任务。

3、记录物资设备详情页实施计划,覆盖路由、详情页和列表导航入口。

4、保留验证步骤与约束说明,便于后续按计划复查实现范围。
2026-06-04 11:13:28 +08:00

2.4 KiB

Project Permission Consistency Implementation Plan

For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

Goal: Make project-level backend permissions and frontend route/menu/action visibility consistent.

Architecture: Treat backend API_ENDPOINT_PERMISSIONS and effective /api-permissions/me matrix as the source of truth. Frontend route guards, menus, quick actions, page actions, and attachment controls should only project that matrix into visibility or disabled states.

Tech Stack: FastAPI, SQLAlchemy, pytest, Vue 3, Pinia, Vue Router, Element Plus, Vitest.


Task 1: Frontend Action Visibility

Files:

  • Modify: frontend/src/components/QuickActions.vue
  • Modify: frontend/src/views/ia/SubjectManagement.vue
  • Modify: frontend/src/utils/permission.ts
  • Test: frontend/src/components/QuickActions.test.ts
  • Test: frontend/src/views/ia/SubjectManagement.test.ts
  • Test: frontend/src/utils/permission.test.ts

Steps:

  1. Write failing source-level tests that prove quick actions are filtered by getProjectRoutePermission/hasProjectPermission.
  2. Write failing source-level tests that prove subject create/delete actions are guarded by subjects:create and subjects:delete.
  3. Add minimal permission checks in the affected components.
  4. Run the targeted Vitest files and confirm they pass.

Task 2: Permission Contract Coverage

Files:

  • Modify: frontend/src/utils/projectRoutePermissions.test.ts
  • Modify: backend/tests/test_api_permissions.py

Steps:

  1. Add tests for route landing paths and project route mappings using backend operation key names already present in the frontend contract.
  2. Extend backend configuration tests so service-level checks are included where feasible, especially document and attachment permission mappings.
  3. Keep tests focused on permission contract shape, not business data setup.
  4. Run targeted backend pytest files.

Task 3: Verification

Files:

  • No production files unless tests identify another mismatch.

Steps:

  1. Run targeted frontend tests.
  2. Run frontend type check if dependencies are available.
  3. Run targeted backend permission tests.
  4. Report exact commands and results.

Constraints

  • Do not create branches.
  • Do not commit.
  • Do not revert unrelated dirty worktree changes.
  • Keep changes narrow and avoid redesigning permission management.