Show asset creator + admin owner filter#12
Open
haphantran wants to merge 2 commits into
Open
Conversation
- Add a reusable CreatedBy label and surface 'Created by {email}' on the
Models, Metamodels, Views, and Viewpoints listings. Owner data already
rides on the API listings (ownerEmail for non-owned, current user
otherwise); thread isOwner/ownerEmail through the frontend asset types
and preserve them in the transformation-rule mapping.
- Add a global, admin-only 'Filter by owner' control in the sidebar
(OwnerFilterContext + OwnerFilterControl) so admins can narrow the
browse lists to specific users and reduce on-screen clutter. Renders
nothing for non-admins, so it has no effect for them.
There was a problem hiding this comment.
Pull request overview
Adds creator attribution to asset listings and introduces an admin-only global “Filter by owner” to reduce clutter when browsing assets (follow-up to the admin view-all-assets work).
Changes:
- Thread
isOwner/ownerEmailmetadata through frontend asset types and API sync, and render a reusableCreatedBylabel in key lists. - Add
OwnerFilterContext+OwnerFilterControland apply the matcher to Models, Metamodels, and Diagrams browse lists. - Add unit tests for
CreatedBy/resolveOwnerEmail.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/services/transformation/transformation-api-sync.service.ts | Threads isOwner/ownerEmail through transformation rule hydration from API. |
| frontend/src/services/testing/testing-types.ts | Extends TestCase type with ownership metadata fields. |
| frontend/src/services/common/ownership.ts | Introduces shared ownership metadata + resolveOwnerEmail helper. |
| frontend/src/models/types.ts | Adds ownership metadata fields across core asset interfaces. |
| frontend/src/contexts/OwnerFilterContext.tsx | Adds global owner-filter context and matcher hook. |
| frontend/src/components/viewpoints/ViewpointManager.tsx | Renders CreatedBy for viewpoints (derived from parent metamodel). |
| frontend/src/components/model/ModelManager.tsx | Applies owner filtering to model list + renders CreatedBy per model. |
| frontend/src/components/metamodel/MetamodelManager.tsx | Applies owner filtering to metamodel list + renders CreatedBy per metamodel. |
| frontend/src/components/layout/Sidebar.tsx | Adds admin-only sidebar control for selecting owner filter. |
| frontend/src/components/common/OwnerFilterControl.tsx | New admin UI control that fetches users and sets selected owners. |
| frontend/src/components/common/index.ts | Exports CreatedBy and ownership helpers via the common barrel. |
| frontend/src/components/common/CreatedBy.tsx | New “Created by {email}” label component. |
| frontend/src/App.tsx | Wraps app with OwnerFilterProvider, applies filtering to diagrams list, renders CreatedBy in diagram cards. |
| frontend/src/tests/components/CreatedBy.test.tsx | Adds tests for CreatedBy and resolveOwnerEmail. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+32
to
+43
| export const useOwnerFilterMatcher = (): ((resource: ResourceOwnership) => boolean) => { | ||
| const { selectedOwnerEmails } = useOwnerFilter(); | ||
| const { user } = useAuth(); | ||
| return useCallback( | ||
| (resource: ResourceOwnership) => { | ||
| if (selectedOwnerEmails.length === 0) return true; | ||
| const email = resolveOwnerEmail(resource, user?.email); | ||
| return email !== undefined && selectedOwnerEmails.includes(email); | ||
| }, | ||
| [selectedOwnerEmails, user?.email] | ||
| ); | ||
| }; |
Comment on lines
+17
to
+24
| useEffect(() => { | ||
| if (!isAdmin) return; | ||
| let cancelled = false; | ||
| adminService | ||
| .getUsers({ pageSize: 100 }) | ||
| .then(res => { | ||
| if (!cancelled) setEmails(res.users.map(u => u.email)); | ||
| }) |
- resolveOwnerEmail: treat explicit isOwner=false without ownerEmail as unknown instead of attributing the resource to the current user. - useOwnerFilterMatcher: gate on the ADMIN role so a stale owner selection can never filter a non-admin who signs in on the same session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Follow-up to the admin-view-all-assets work (#11). Answers "who created this asset?" and lets admins cut on-screen clutter by focusing on specific users.
1. "Created by {email}" on asset listings
A small reusable
CreatedBylabel shows the creator on each asset. The owner already arrives on API listings (ownerEmailfor resources the user doesn't own; the current user otherwise), so this threadsisOwner/ownerEmailthrough the frontend asset types and renders them. Applied to:2. Global admin "Filter by owner"
An admin-only multi-select in the sidebar (
OwnerFilterContext+OwnerFilterControl) restricts every browse list to the selected owners. Empty = show all, and it renders nothing for non-admins (no effect for them). Applied to the Models, Metamodels, and Views lists viauseOwnerFilterMatcher.Coverage notes
Tests
tsc --noEmit: clean.CreatedBy.test.tsx: 4 tests covering owner resolution and rendering).