Skip to content

Commit b0ea019

Browse files
committed
[UI] Project wizard #323
1 parent 67983d1 commit b0ea019

9 files changed

Lines changed: 361 additions & 168 deletions

File tree

frontend/src/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export const API = {
5858
BASE: () => `${API.BASE()}/projects`,
5959
LIST: () => `${API.PROJECTS.BASE()}/list`,
6060
CREATE: () => `${API.PROJECTS.BASE()}/create`,
61+
CREATE_WIZARD: () => `${API.PROJECTS.BASE()}/create_wizard`,
6162
DELETE: () => `${API.PROJECTS.BASE()}/delete`,
6263
DETAILS: (name: IProject['project_name']) => `${API.PROJECTS.BASE()}/${name}`,
6364
DETAILS_INFO: (name: IProject['project_name']) => `${API.PROJECTS.DETAILS(name)}/get`,
@@ -112,6 +113,7 @@ export const API = {
112113
BACKENDS: {
113114
BASE: () => `${API.BASE()}/backends`,
114115
LIST_TYPES: () => `${API.BACKENDS.BASE()}/list_types`,
116+
LIST_BASE_TYPES: () => `${API.BACKENDS.BASE()}/list_base_types`,
115117
CONFIG_VALUES: () => `${API.BACKENDS.BASE()}/config_values`,
116118
},
117119

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import { Controller, FieldValues } from 'react-hook-form';
3+
import Cards from '@cloudscape-design/components/cards';
4+
import { CardsProps } from '@cloudscape-design/components/cards';
5+
6+
import { FormCardsProps } from './types';
7+
8+
export const FormCards = <T extends FieldValues>({
9+
name,
10+
control,
11+
onSelectionChange: onSelectionChangeProp,
12+
...props
13+
}: FormCardsProps<T>) => {
14+
return (
15+
<Controller
16+
name={name}
17+
control={control}
18+
render={({ field: { onChange, ...fieldRest } }) => {
19+
const onSelectionChange: CardsProps['onSelectionChange'] = (event) => {
20+
onChange(event.detail.selectedItems.map(({ value }) => value));
21+
onSelectionChangeProp?.(event);
22+
};
23+
24+
const selectedItems = props.items.filter((item) => fieldRest.value?.includes(item.value));
25+
26+
return (
27+
<Cards
28+
onSelectionChange={onSelectionChange}
29+
trackBy="value"
30+
{...fieldRest}
31+
{...props}
32+
selectedItems={selectedItems}
33+
/>
34+
);
35+
}}
36+
/>
37+
);
38+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Control, FieldValues, Path } from 'react-hook-form';
2+
import { CardsProps } from '@cloudscape-design/components/cards';
3+
4+
export type FormCardsProps<T extends FieldValues> = CardsProps & {
5+
control: Control<T, object>;
6+
name: Path<T>;
7+
};

frontend/src/components/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type { LineChartProps } from '@cloudscape-design/components/line-chart/in
6161
export type { ModalProps } from '@cloudscape-design/components/modal';
6262
export { default as AnchorNavigation } from '@cloudscape-design/components/anchor-navigation';
6363
export { default as ExpandableSection } from '@cloudscape-design/components/expandable-section';
64+
export { default as KeyValuePairs } from '@cloudscape-design/components/key-value-pairs';
6465
export { I18nProvider } from '@cloudscape-design/components/i18n';
6566
export { default as Wizard } from '@cloudscape-design/components/wizard';
6667

@@ -81,6 +82,8 @@ export type { FormMultiselectOptions, FormMultiselectProps } from './form/Multis
8182
export { FormS3BucketSelector } from './form/S3BucketSelector';
8283
export type { FormTilesProps } from './form/Tiles/types';
8384
export { FormTiles } from './form/Tiles';
85+
export type { FormCardsProps } from './form/Cards/types';
86+
export { FormCards } from './form/Cards';
8487
export { Notifications } from './Notifications';
8588
export { ConfirmationDialog } from './ConfirmationDialog';
8689
export { FileUploader } from './FileUploader';
Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
import { FormMultiselectOptions } from 'components';
2-
3-
export const backendOptions: FormMultiselectOptions = [
4-
{ label: 'aws', value: 'aws' },
5-
{ label: 'azure', value: 'azure' },
6-
{ label: 'cudo', value: 'cudo' },
7-
{ label: 'datacrunch', value: 'datacrunch' },
8-
{ label: 'dstack', value: 'dstack' },
9-
{ label: 'gcp', value: 'gcp' },
10-
{ label: 'kubernetes', value: 'kubernetes' },
11-
{ label: 'lambda', value: 'lambda' },
12-
{ label: 'local', value: 'local' },
13-
{ label: 'nebius', value: 'nebius' },
14-
{ label: 'remote', value: 'remote' },
15-
{ label: 'oci', value: 'oci' },
16-
{ label: 'runpod', value: 'runpod' },
17-
{ label: 'tensordock', value: 'tensordock' },
18-
{ label: 'vastai', value: 'vastai' },
19-
{ label: 'cloudrift', value: 'cloudrift' },
20-
{ label: 'hotaisle', value: 'hotaisle' },
21-
{ label: 'vultr', value: 'vultr' },
1+
export const projectTypeOptions = [
2+
{
3+
label: 'GPU marketplace',
4+
description:
5+
'Find the cheapest GPUs available in our marketplace. Enjoy $5 in free credits, and easily top up your balance with a credit card.',
6+
value: 'gpu_marketplace',
7+
},
8+
{
9+
label: 'Your cloud accounts',
10+
description: 'Connect and manage your cloud accounts. dstack supports all major GPU cloud providers.',
11+
value: 'own_cloud',
12+
},
2213
];

0 commit comments

Comments
 (0)