-
Notifications
You must be signed in to change notification settings - Fork 79
feat(FR-2827): make deployment tags clickable to filter the list #7274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graphite-app
merged 1 commit into
main
from
05-07-feat_fr-2827_make_deployment_tags_clickable_to_filter_list
May 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /** | ||
| @license | ||
| Copyright (c) 2015-2026 Lablup Inc. All rights reserved. | ||
| */ | ||
| import type { DeploymentTagChips_metadata$key } from '../__generated__/DeploymentTagChips_metadata.graphql'; | ||
| import { useWebUINavigate } from '../hooks'; | ||
| import { Tag } from 'antd'; | ||
| import { BAIFlex } from 'backend.ai-ui'; | ||
| import React from 'react'; | ||
| import { graphql, useFragment } from 'react-relay'; | ||
| import { useLocation } from 'react-router-dom'; | ||
|
|
||
| interface DeploymentTagChipsProps { | ||
| metadataFrgmt: DeploymentTagChips_metadata$key | null | undefined; | ||
| /** | ||
| * When true, click and Enter/Space keypress events stop bubbling so the | ||
| * surrounding row click handler does not also fire (used inside the | ||
| * deployment list table). | ||
| */ | ||
| stopRowClick?: boolean; | ||
| /** Rendered when there are no tags to display. */ | ||
| fallback?: React.ReactNode; | ||
| } | ||
|
|
||
| /** | ||
| * Render a deployment metadata's tags as clickable chips. Activating a chip | ||
| * (mouse click or keyboard Enter/Space) navigates to the deployment list | ||
| * pre-filtered by that tag using `iContains`. Tag entries are split on | ||
| * commas so legacy comma-joined values render as individual chips. | ||
| */ | ||
| const DeploymentTagChips: React.FC<DeploymentTagChipsProps> = ({ | ||
| metadataFrgmt, | ||
| stopRowClick = false, | ||
| fallback = null, | ||
| }) => { | ||
| 'use memo'; | ||
| const webuiNavigate = useWebUINavigate(); | ||
| const location = useLocation(); | ||
|
|
||
| const metadata = useFragment( | ||
| graphql` | ||
| fragment DeploymentTagChips_metadata on ModelDeploymentMetadata { | ||
| tags | ||
| } | ||
| `, | ||
| metadataFrgmt ?? null, | ||
| ); | ||
|
|
||
| const tags = (metadata?.tags ?? []).flatMap((tag) => | ||
| tag | ||
| .split(',') | ||
| .map((t) => t.trim()) | ||
| .filter(Boolean), | ||
| ); | ||
|
|
||
| if (tags.length === 0) return <>{fallback}</>; | ||
|
|
||
| const navigateToFiltered = (tag: string) => { | ||
| const filter = JSON.stringify({ tags: { iContains: tag } }); | ||
| // Stay within the admin deployments list when activated from there; | ||
| // otherwise navigate to the user-facing deployment list. | ||
| const targetPathname = location.pathname.startsWith('/admin-deployments') | ||
| ? '/admin-deployments' | ||
| : '/deployments'; | ||
|
|
||
| webuiNavigate({ | ||
| pathname: targetPathname, | ||
| search: new URLSearchParams({ filter }).toString(), | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <BAIFlex wrap="wrap" gap="xxs"> | ||
| {tags.map((tag) => ( | ||
| <Tag | ||
| key={tag} | ||
| role="button" | ||
| tabIndex={0} | ||
| style={{ cursor: 'pointer' }} | ||
| onClick={(e) => { | ||
| if (stopRowClick) e.stopPropagation(); | ||
| navigateToFiltered(tag); | ||
| }} | ||
| onKeyDown={(e) => { | ||
| if (e.key === 'Enter' || e.key === ' ') { | ||
| e.preventDefault(); | ||
| if (stopRowClick) e.stopPropagation(); | ||
| navigateToFiltered(tag); | ||
| } | ||
| }} | ||
| > | ||
| {tag} | ||
| </Tag> | ||
| ))} | ||
| </BAIFlex> | ||
| ); | ||
| }; | ||
|
|
||
| export default DeploymentTagChips; | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.