OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

Added permission for context center action buttons

Open Rohit0301 opened this issue 5 months ago โ€ข 4 comments

Screenshot 2026-06-24 at 11 40 25โ€ฏAM

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: canRestore is now correctly gated on EditAll (not Delete), resolving the concern from a previous review thread.
  • ContextCenterMemoriesPage and ContextCenterDocumentsPage: fetchPermission wired up via usePermissionProvider, with hasCreatePermission, hasDeletePermission, and hasEditPermission flags flowing down to child components.
  • ContextCenterHeader: renders actionsSlot ?? defaultActions only when hasPermission is 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

Rohit0301 avatar Jun 22 '26 09:06 Rohit0301

๐ŸŸก 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

github-actions[bot] avatar Jun 22 '26 12:06 github-actions[bot]

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 63%
63.46% (69440/109413) 45.72% (39689/86802) 47.65% (12080/25348)

github-actions[bot] avatar Jun 22 '26 19:06 github-actions[bot]

Code Review โœ… Approved 3 resolved / 3 findings

Enforces permission gating for Context Center action buttons and adds a dedicated 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

๐Ÿ“„ 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 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.

Suggested: canRestore={permissions?.EditAll}.

โœ… Bug: Admin non-owner sees edit button but modal has no Save

๐Ÿ“„ 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 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).

Clicking it calls 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.

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 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

๐Ÿ“„ openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx:259-268 In 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].

This means the memo only recomputes when one of the listed deps changes. 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.

Add memoryToEdit to the dependency array.

Options

Display: compact โ†’ Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with ๐Ÿ‘ / ๐Ÿ‘Ž | Gitar

gitar-bot avatar Jun 25 '26 08:06 gitar-bot