- New k8s_pod_spec form sections (image credentials, node selector, gpu vendor overrides) under k8s_options, replacing the legacy flat k8s_volume_mounts list. UI keys aligned to the backend wire shape (snake_case k8s_options + camelCase inside). - System default container registry is pre-filled into the first image credential when creating a new cluster; empty username/password are coerced to null on submit to match the Optional[str] backend schema. - Register cluster flow supports multi-runtime selection gated by the cluster's gpuVendorOverrides: non-override vendors stay single-select with an inline hint; multi-add only opens once an override vendor is picked, and non-override cards become disabled in that state. - Manifest URL emits multiple ?runtime= params; check-env step combines per-vendor commands; downstream steps are disabled when no vendor is selected. - Pre-validate gpuVendorOverrides at save time (non-empty selector, no duplicates across vendors, no key clash with base nodeSelector) so the user sees the error before hitting the manifest endpoint. - Misc: dark-mode background of the k8s_pod_spec / volume mount titles no longer clashes with the drawer; cluster Steps no longer leaks the internal showModules/showForms props to the DOM.
174 lines
4.2 KiB
TypeScript
174 lines
4.2 KiB
TypeScript
import { IconFont, TemplateCard } from '@gpustack/core-ui';
|
|
import { useIntl } from '@umijs/max';
|
|
import { Tooltip } from 'antd';
|
|
import React, { useMemo } from 'react';
|
|
import styled from 'styled-components';
|
|
import { ProviderType } from '../config';
|
|
|
|
const Wrapper = styled.div<{ $cols?: number }>`
|
|
width: 100%;
|
|
display: grid;
|
|
grid-template-columns: repeat(${(props) => props.$cols || 3}, 1fr);
|
|
gap: 16px;
|
|
.template-card-wrapper {
|
|
padding: 10px 16px;
|
|
}
|
|
.template-card-inner {
|
|
justify-content: center;
|
|
}
|
|
`;
|
|
|
|
const Container = styled.div`
|
|
display: flex;
|
|
margin: 0 auto;
|
|
flex-direction: column;
|
|
gap: 24px;
|
|
`;
|
|
|
|
const Title = styled.span`
|
|
display: flex;
|
|
gap: 8px;
|
|
align-items: center;
|
|
font-weight: 500;
|
|
font-size: 14px;
|
|
margin-bottom: 16px;
|
|
.icon {
|
|
color: var(--ant-color-text-secondary);
|
|
border-radius: 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 24px;
|
|
height: 24px;
|
|
background-color: var(--ant-color-fill-tertiary);
|
|
}
|
|
`;
|
|
|
|
const Header = styled.div`
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 4px;
|
|
.title {
|
|
font-weight: 500;
|
|
}
|
|
.description {
|
|
font-size: 13px;
|
|
font-weight: 400;
|
|
color: var(--ant-color-text-tertiary);
|
|
}
|
|
`;
|
|
|
|
const CardBox = styled.div`
|
|
display: flex;
|
|
overflow: hidden;
|
|
`;
|
|
|
|
interface ProviderCatalogProps {
|
|
onSelect?: (provider: string, item: any) => void;
|
|
groupIcons?: Record<string, string>;
|
|
cols?: number;
|
|
// Single value (legacy) or array of selected keys for multi-select.
|
|
current?: ProviderType | string | string[];
|
|
clickable?: boolean;
|
|
height: string | number;
|
|
showTooltip?: boolean;
|
|
dataList: {
|
|
label: string;
|
|
key: string;
|
|
locale?: boolean;
|
|
disabled?: boolean;
|
|
icon?: React.ReactNode;
|
|
description?: string;
|
|
group?: string;
|
|
}[];
|
|
}
|
|
|
|
const ProviderCatalog: React.FC<ProviderCatalogProps> = ({
|
|
onSelect,
|
|
groupIcons,
|
|
cols = 3,
|
|
dataList,
|
|
clickable,
|
|
height,
|
|
current,
|
|
showTooltip = false
|
|
}) => {
|
|
const intl = useIntl();
|
|
|
|
const groupList = useMemo(() => {
|
|
if (!dataList) return {};
|
|
return dataList?.reduce(
|
|
(acc, item) => {
|
|
(acc[item.group || 'default'] ??= []).push(item);
|
|
return acc;
|
|
},
|
|
{} as Record<string, typeof dataList>
|
|
);
|
|
}, [dataList]);
|
|
|
|
const renderTitle = (item: any) => {
|
|
if (item.hiddenTitle) {
|
|
return <>{item.extra && <span className="extra">{item.extra}</span>}</>;
|
|
}
|
|
return (
|
|
<Header>
|
|
<span className="title">
|
|
{item.locale ? intl.formatMessage({ id: item.label }) : item.label}
|
|
</span>
|
|
{item.description && (
|
|
<span className="description">
|
|
{intl.formatMessage({ id: item.description })}
|
|
</span>
|
|
)}
|
|
{item.extra && <span className="extra">{item.extra}</span>}
|
|
</Header>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<Container>
|
|
{Object.entries(groupList).map(([groupName, items]) => (
|
|
<div key={groupName}>
|
|
{groupName !== 'default' && (
|
|
<Title>
|
|
{groupIcons && groupIcons[groupName] && (
|
|
<span className="icon">
|
|
<IconFont type={groupIcons[groupName]} />
|
|
</span>
|
|
)}
|
|
<span>{intl.formatMessage({ id: groupName })}</span>
|
|
</Title>
|
|
)}
|
|
<Wrapper $cols={cols}>
|
|
{items?.map((action) => (
|
|
<Tooltip
|
|
title={showTooltip ? action.label : false}
|
|
key={action.key}
|
|
>
|
|
<CardBox>
|
|
<TemplateCard
|
|
height={height}
|
|
onClick={() => onSelect?.(action.key as string, action)}
|
|
active={
|
|
Array.isArray(current)
|
|
? current.includes(action.key)
|
|
: current === action.key
|
|
}
|
|
disabled={action.disabled}
|
|
clickable={clickable}
|
|
header={renderTitle(action)}
|
|
icon={action.icon}
|
|
></TemplateCard>
|
|
</CardBox>
|
|
</Tooltip>
|
|
))}
|
|
</Wrapper>
|
|
</div>
|
|
))}
|
|
</Container>
|
|
);
|
|
};
|
|
|
|
export default ProviderCatalog;
|