Added permission for context center action buttons
Describe your changes:
Fixes 29399
I worked on ... because ...
Type of change:
- [ ] Bug fix
- [ ] Improvement
- [ ] New feature
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation
High-level design:
N/A โ small change.
Tests:
Use cases covered
Unit tests
Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
UI screen recording / screenshots:
Not applicable.
Checklist:
- [x] I have read the CONTRIBUTING document.
- [ ] My PR title is
Fixes <issue-number>: <short explanation> - [ ] My PR is linked to a GitHub issue via
Fixes #<issue-number>above. - [ ] I have commented on my code, particularly in hard-to-understand areas.
- [ ] For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
- [ ] For UI changes: I attached a screen recording and/or screenshots above.
- [ ] I have added tests (unit / integration / Playwright as applicable) and listed them above.
Greptile Summary
This PR adds permission-based visibility for action buttons (create, edit, delete, restore) across the Context Center's documents, memories, and archive pages. It also extracts shared navigation helpers into ContextCenterUtil.ts and introduces a comprehensive ContextCenterPermission.spec.ts covering the full create/edit/delete/view-only permission matrix.
ContextCenterArchivePage:canRestoreis now correctly gated onEditAll(notDelete), resolving the concern from a previous review thread.ContextCenterMemoriesPageandContextCenterDocumentsPage:fetchPermissionwired up viausePermissionProvider, withhasCreatePermission,hasDeletePermission, andhasEditPermissionflags flowing down to child components.ContextCenterHeader: rendersactionsSlot ?? defaultActionsonly whenhasPermissionis truthy โ confirmed safe.
Confidence Score: 5/5
Safe to merge โ all permission gates are correctly wired and the previous restore-permission concern is resolved.
The permission flow is sound: ContextCenterHeader gates the actionsSlot on hasPermission, row-level memory actions double-check ownership/admin status, and canRestore now uses EditAll instead of Delete.
ContextCenterDocumentsPage.tsx โ confirm whether KNOWLEDGE_PAGE is intentional for file upload/delete permission checks.
Important Files Changed
| Filename | Overview |
|---|---|
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterArchivePage/ContextCenterArchivePage.tsx | Fixed: canRestore now uses permissions.EditAll (not Delete). canDelete correctly uses permissions.Delete. |
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx | Permission fetch wired to CONTEXT_MEMORY. Memory row and modal delete/edit gated on both global permission and owner/admin check. |
| openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterDocumentsPage/ContextCenterDocumentsPage.tsx | Uses KNOWLEDGE_PAGE for document permission checks โ may conflict with per-resource-type admin policies. |
| openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx | Row-level edit/delete double-guarded on canActOnMemory (owner/admin) AND global canEdit/canDelete. |
| openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ContextCenterPermission.spec.ts | Comprehensive 1881-line permission matrix spec across all Context Center sections. |
| openmetadata-ui/src/main/resources/ui/playwright/utils/ContextCenterUtil.ts | Navigation helpers and buildPermissionRule extracted cleanly from spec files. |
| openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/ContextCenter.spec.ts | Permission tests moved out; memories tests added. Minor no-op alias in import. |
| openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.interface.ts | CONTEXT_MEMORY added to ResourceEntity enum. |
Reviews (12): Last reviewed commit: "Merge branch 'main' into context-center-..." | Re-trigger Greptile
๐ก Playwright Results โ all passed (8 flaky)
โ 4426 passed ยท โ 0 failed ยท ๐ก 8 flaky ยท โญ๏ธ 88 skipped
| Shard | Passed | Failed | Flaky | Skipped |
|---|---|---|---|---|
| ๐ก Shard 1 | 324 | 0 | 1 | 4 |
| ๐ก Shard 2 | 830 | 0 | 1 | 9 |
| ๐ก Shard 3 | 828 | 0 | 2 | 8 |
| ๐ก Shard 4 | 829 | 0 | 1 | 9 |
| โ Shard 5 | 819 | 0 | 0 | 50 |
| ๐ก Shard 6 | 796 | 0 | 3 | 8 |
๐ก 8 flaky test(s) (passed on retry)
Flow/SearchRBAC.spec.tsโบ a dashboard-scoped user sees dashboards but never tables (shard 1, 2 retries)Features/DataQuality/ColumnLevelTests.spec.tsโบ Column Value StdDev To Be Between (shard 2, 1 retry)Features/Tasks/TaskNavigation.spec.tsโบ navigating to /table/TASK-XXXXX should show 404 (invalid URL pattern) (shard 3, 1 retry)Flow/ExploreDiscovery.spec.tsโบ Should display domain and owner of deleted asset in suggestions when showDeleted is on (shard 3, 1 retry)Flow/PersonaFlow.spec.tsโบ Set default persona for team should work properly (shard 4, 1 retry)Pages/Lineage/LineageFilters.spec.tsโบ Verify lineage schema filter selection (shard 6, 1 retry)Pages/Lineage/LineageRightPanel.spec.tsโบ Verify custom properties tab IS visible for supported type: searchIndex (shard 6, 1 retry)Pages/Lineage/PlatformLineage.spec.tsโบ Verify domain platform view (shard 6, 1 retry)
๐ฆ Download artifacts
How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace
Jest test Coverage
UI tests summary
| Lines | Statements | Branches | Functions |
|---|---|---|---|
| 63.46% (69440/109413) | 45.72% (39689/86802) | 47.65% (12080/25348) |
Quality Gate passed for 'open-metadata-ui'
Issues
1160 New issues
0 Accepted issues
Measures
13 Security Hotspots
0.0% Coverage on New Code
3.5% Duplication on New Code
Enforces permission gating for Context Center action buttons and adds a dedicated ๐ openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterArchivePage/ContextCenterArchivePage.tsx:261-262 ๐ openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterDocumentsPage/ContextCenterDocumentsPage.tsx:88
In Suggested: ๐ openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx:154-156 ๐ openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/MemoriesView/MemoriesView.component.tsx:307 ๐ openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:991-1005 ๐ openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx:752-761
The row-level edit gate and the modal-level save/edit gate use inconsistent ownership semantics for admin users. In Clicking it calls Result: an admin can open a memory they don't own in full edit mode (all fields editable), make changes, but there is no Save button โ a dead-end edit experience. The same mismatch hides the view-modal "Edit" switch button (line 992) for admin non-owners even though the row exposes editing. Suggested fix: make the modal's edit/save gating account for admin the same way the row does (e.g., pass ๐ openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:259-268
In This means the memo only recomputes when one of the listed deps changes. Add Display: compact โ Showing less information. Comment with these commands to change:Code Review โ
Approved 3 resolved / 3 findings
CONTEXT_MEMORY resource entity. Addresses previously stale UI states and inconsistent restore/edit permissions while introducing comprehensive Playwright coverage.โ
3 resolved
โ
Quality: Inconsistent restore permission semantics in archive page
ContextCenterArchivePage.tsx the restore action is gated with canRestore={permissions?.EditAll || permissions?.Delete}, whereas every other edit-type action in this PR is gated by EditAll alone (e.g. single-file move and bulk move in DocumentsView use canEdit = permissions.EditAll). Restoring a soft-deleted item is an edit/undelete operation, so allowing a user who only has Delete (but not EditAll) to restore is inconsistent with the rest of the gating and slightly surprising. This is UI-only (the backend still enforces authorization), so impact is low, but consider gating restore on EditAll for consistency, or document why Delete should also grant restore.canRestore={permissions?.EditAll}.โ
Bug: Admin non-owner sees edit button but modal has no Save
MemoriesView.component.tsx, the row edit button renders when canActOnMemory && canEdit && onEditMemory, where canActOnMemory = isOwner || Boolean(isAdminUser) (line 156). So for an admin who is NOT the owner of a memory, the edit-memory button IS shown (admin gets EditAll, so canEdit is true).handleEditMemory, which sets memoryToEdit and opens the create/edit modal with viewOnly unset (non-view mode). In CreateMemoryModal.component.tsx, the modal's isOwner is computed purely from ownership (memoryToEdit?.owners?.some(...) ?? false) with no admin consideration. The Save button condition is (memoryToEdit ? isOwner && canEdit : canCreate) (line 1001). For an admin non-owner, isOwner is false, so the Save button is hidden.isAdminUser into the modal and treat isOwner || isAdmin as the edit predicate), or stop showing the row edit button for admin non-owners so the gating is consistent end-to-end.โ
Bug: useMemo missing memoryToEdit dependency causes stale submit button
CreateMemoryModal.component.tsx the new useMemo that computes showEditButton/showSubmitButton reads memoryToEdit in its body (memoryToEdit ? canEditMemory : canCreate) but memoryToEdit is not in the dependency array [isViewOnly, isOwner, isAdminUser, canEdit, canCreate].isOwner happens to depend on memoryToEdit, but isOwner only changes value when ownership status flips. Consider the case where memoryToEdit transitions from undefined (create mode) to a defined memory that is NOT owned by the current user: isOwner stays false, none of the other deps change, so the memo does not re-run and showSubmitButton retains its previous value (canCreate) instead of switching to the edit-permission branch (canEditMemory). This can show or hide the submit button incorrectly, undermining the permission gating this PR introduces. It is also an react-hooks/exhaustive-deps violation that may trip the lint-src CI check.memoryToEdit to the dependency array.Options
Compact
gitar display:verbose
Was this helpful? React with ๐ / ๐ | Gitar