Skip to content

Commit

Permalink
add region and hardware title getters, fix pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
orangecoloured committed May 10, 2024
1 parent 69ecffd commit 40d46a1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
12 changes: 12 additions & 0 deletions packages/design-system/src/ui-helpers/getModelHardwareToolkit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const getModelHardwareToolkit = (hardwareName: string) => {
switch (hardwareName) {
case 'CPU':
return 'CPU';
case 'NVIDIA_TESLA_T4':
return 'Nvidia Tesla T4';
case 'NVIDIA_L4':
return 'Nvidia L4';
case 'NVIDIA_A100':
return 'Nvidia A100';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const getModelRegionToolkit = (regionName: string) => {
switch (regionName) {
case 'REGION_GCP_EUROPE_WEST4':
return 'GCP Europe-West4'
}
}
2 changes: 2 additions & 0 deletions packages/design-system/src/ui-helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { getModelInstanceTaskToolkit } from "./getModelInstanceTaskToolkit";
export { getModelDefinitionToolkit } from "./getModelDefinitionToolkit";
export { getPipelineModeToolkit } from "./getPipelineModeToolkit";
export { getModelRegionToolkit } from './getModelRegionToolkit';
export { getModelHardwareToolkit } from './getModelHardwareToolkit';
7 changes: 3 additions & 4 deletions packages/toolkit/src/components/card-model/CardModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { Menu } from "./Menu";
import { Tags } from "./Tags";
import { Stats } from "./Stats";
import { Model, Nullable, sendAmplitudeData, useAmplitudeCtx, useDeleteModel } from "../../lib";
import { generateRegionTitle } from "../../lib/generateRegionTitle";
import React from "react";
import { useToast } from "@instill-ai/design-system";
import { useToast, getModelHardwareToolkit, getModelRegionToolkit } from "@instill-ai/design-system";
import axios from "axios";
import { useParams } from "next/navigation";

Expand Down Expand Up @@ -91,8 +90,8 @@ export const CardModel = (props: CardModelProps) => {
<a href={`/${entity}/models/${model.id}`} className="break-all text-semantic-accent-default hover:!underline font-medium">{model.id}</a>
<Tags
isPrivate={model.visibility === 'VISIBILITY_PRIVATE'}
region={generateRegionTitle(model.region)}
hardware={model.hardware}
region={getModelRegionToolkit(model.region)}
hardware={getModelHardwareToolkit(model.hardware)}
/>
<Menu handleDeleteModel={handleDeleteModel} model={model} />
</div>
Expand Down
3 changes: 0 additions & 3 deletions packages/toolkit/src/lib/generateRegionTitle.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/toolkit/src/view/model/ModelHubListPageMainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export const ModelHubListPageMainView = (
</Select.Trigger>
<Select.Content>
<Select.Group>
<Select.Item value="VISIBILITY_UNSPECIFIED">All</Select.Item>
<Select.Item value="VISIBILITY_PUBLIC">Public</Select.Item>
<Select.Item value="VISIBILITY_PRIVATE">Private</Select.Item>
<Select.Item value="VISIBILITY_UNSPECIFIED" label="All" />
<Select.Item value="VISIBILITY_PUBLIC" label="Public" />
<Select.Item value="VISIBILITY_PRIVATE" label="Private" />
</Select.Group>
</Select.Content>
</Select.Root>
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/view/model/ModelsListPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ModelsListPagination = ({ models, pageNumber, setPageNumber }: Mode
}
}, [models, pageNumber])

if (!models.data || paginationProps.totalPages === 0) {
if (!models.data || paginationProps.totalPages <= 1) {
return null;
}

Expand Down

0 comments on commit 40d46a1

Please sign in to comment.