Skip to content

Commit

Permalink
feat: display kernel node id and idx in Kernel select component (#2832)
Browse files Browse the repository at this point in the history
Resolves #2833

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/XqC2uNFuj0wg8I60sMUh/e321356d-7cb2-46cb-b595-116a90f6428e.png)

**Changes:**
Enhances the container log modal dropdown by adding node IDs alongside cluster roles. The first 5 characters of each node's row_id are now displayed in a monospace font next to the cluster role, making it easier to identify specific nodes.

**Visual Impact:**
The dropdown now shows entries in the format: `cluster_role (12345)` where the ID portion is styled with a monospace font and secondary color.
  • Loading branch information
yomybaby committed Nov 11, 2024
1 parent a888e3e commit 90496bc
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions react/src/components/ComputeSessionNodeItems/ContainerLogModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { downloadBlob } from '../../helper/csv-util';
import { useSuspendedBackendaiClient } from '../../hooks';
import { useCurrentUserRole } from '../../hooks/backendai';
import { useTanQuery } from '../../hooks/reactQueryAlias';
import { useMemoWithPrevious } from '../../hooks/useMemoWithPrevious';
import BAIModal, { BAIModalProps } from '../BAIModal';
Expand Down Expand Up @@ -33,6 +34,7 @@ const ContainerLogModal: React.FC<ContainerLogModalProps> = ({
}) => {
const baiClient = useSuspendedBackendaiClient();
const { token } = theme.useToken();
const userRole = useCurrentUserRole();

const session = useFragment(
graphql`
Expand All @@ -48,6 +50,7 @@ const ContainerLogModal: React.FC<ContainerLogModalProps> = ({
id
row_id
container_id
cluster_idx
cluster_role
}
}
Expand Down Expand Up @@ -170,13 +173,31 @@ const ContainerLogModal: React.FC<ContainerLogModalProps> = ({
resetPreviousLineNumber();
}}
options={_.chain(session?.kernel_nodes?.edges)
.sortBy((e) => `${e?.node?.cluster_role} ${e?.node?.cluster_idx}`)
.map((e) => {
return {
label: e?.node?.cluster_role,
label: (
<>
{e?.node?.cluster_role}
{e?.node?.cluster_role !== 'main'
? e?.node?.cluster_idx
: ''}
{userRole === 'admin' || userRole === 'superadmin' ? (
<Typography.Text
style={{
fontFamily: 'monospace',
fontSize: token.fontSizeSM,
}}
type="secondary"
>
({(e?.node?.row_id || '').substring(0, 5)})
</Typography.Text>
) : null}
</>
),
value: e?.node?.row_id,
};
})
.sortBy('label')
.value()}
/>
<Divider type="vertical" />
Expand Down

0 comments on commit 90496bc

Please sign in to comment.