Skip to content

Commit

Permalink
feat: add AliasedBaseImageName
Browse files Browse the repository at this point in the history
  • Loading branch information
agatha197 committed Oct 30, 2024
1 parent 01fc2fd commit a98a494
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 28 additions & 0 deletions react/src/components/AliasedBaseImageName.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useBackendAIImageMetaData } from '../hooks';
import { AliasedBaseImageNameFragment$key } from './__generated__/AliasedBaseImageNameFragment.graphql';
import graphql from 'babel-plugin-relay/macro';
import React from 'react';
import { useFragment } from 'react-relay';

interface AliasedBaseImageNameProps {
imageFrgmt: AliasedBaseImageNameFragment$key;
}

const AliasedBaseImageName: React.FC<AliasedBaseImageNameProps> = ({
imageFrgmt,
}) => {
const images = useFragment(
graphql`
fragment AliasedBaseImageNameFragment on Image {
base_image_name @since(version: "24.09.1.")
}
`,
imageFrgmt,
);

const [, { tagAlias }] = useBackendAIImageMetaData();

return tagAlias(images?.base_image_name ?? '');
};

export default AliasedBaseImageName;
4 changes: 3 additions & 1 deletion react/src/components/ImageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useSuspendedBackendaiClient,
useUpdatableState,
} from '../hooks';
import AliasedBaseImageName from './AliasedBaseImageName';
import DoubleTag from './DoubleTag';
import ImageInstallModal from './ImageInstallModal';
import { BaseImageTags, ConstraintTags, LangTags } from './ImageTags';
Expand Down Expand Up @@ -95,6 +96,7 @@ const ImageList: React.FC<{ style?: React.CSSProperties }> = ({ style }) => {
value
}
version @since(version: "24.09.1.")
...AliasedBaseImageNameFragment
}
}
`,
Expand Down Expand Up @@ -194,7 +196,7 @@ const ImageList: React.FC<{ style?: React.CSSProperties }> = ({ style }) => {
sorter: (a: EnvironmentImage, b: EnvironmentImage) =>
localeCompare(a?.base_image_name, b?.base_image_name),
render: (text: string, row: EnvironmentImage) => (
<TextHighlighter keyword={imageSearch}>{text}</TextHighlighter>
<AliasedBaseImageName imageFrgmt={row} />
),
},
{
Expand Down

0 comments on commit a98a494

Please sign in to comment.