Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@
"@cloudscape-design/global-styles": "^1.0.45",
"@hookform/resolvers": "^2.9.10",
"@reduxjs/toolkit": "^1.9.1",
"@types/yup": "^0.29.14",
"ace-builds": "^1.36.3",
"classnames": "^2.5.1",
"css-minimizer-webpack-plugin": "^4.2.2",
"date-fns": "^2.29.3",
"i18next": "^24.0.2",
"lodash": "^4.17.21",
"openai": "^4.33.1",
"prismjs": "^1.29.0",
"prismjs": "^1.30.0",
"rc-tooltip": "^5.2.2",
"react": "^18.3.1",
"react-avatar": "^5.0.3",
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/App/Login/LoginByGithubCallback/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { UnauthorizedLayout } from 'layouts/UnauthorizedLayout';
import { useAppDispatch } from 'hooks';
import { ROUTES } from 'routes';
import { useGithubCallbackMutation } from 'services/auth';
import { useLazyGetProjectsQuery } from 'services/project';

import { AuthErrorMessage } from 'App/AuthErrorMessage';
import { Loading } from 'App/Loading';
Expand All @@ -22,13 +23,24 @@ export const LoginByGithubCallback: React.FC = () => {
const dispatch = useAppDispatch();

const [githubCallback] = useGithubCallbackMutation();
const [getProjects] = useLazyGetProjectsQuery();

const checkCode = () => {
if (code) {
githubCallback({ code })
.unwrap()
.then(({ creds: { token } }) => {
.then(async ({ creds: { token } }) => {
dispatch(setAuthData({ token }));

if (process.env.UI_VERSION === 'sky') {
const result = await getProjects().unwrap();

if (result?.length === 0) {
navigate(ROUTES.PROJECT.ADD);
return;
}
}

navigate('/');
})
.catch(() => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/App/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const getInitialState = (): IAppState => {
},

tutorialPanel: {
createProjectCompleted: false,
billingCompleted: false,
configureCLICompleted: false,
discordCompleted: false,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/App/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface IAppState {
};

tutorialPanel: {
createProjectCompleted: boolean;
billingCompleted: boolean;
configureCLICompleted: boolean;
discordCompleted: boolean;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const API = {
BASE: () => `${API.BASE()}/projects`,
LIST: () => `${API.PROJECTS.BASE()}/list`,
CREATE: () => `${API.PROJECTS.BASE()}/create`,
CREATE_WIZARD: () => `${API.PROJECTS.BASE()}/create_wizard`,
DELETE: () => `${API.PROJECTS.BASE()}/delete`,
DETAILS: (name: IProject['project_name']) => `${API.PROJECTS.BASE()}/${name}`,
DETAILS_INFO: (name: IProject['project_name']) => `${API.PROJECTS.DETAILS(name)}/get`,
Expand Down Expand Up @@ -112,6 +113,7 @@ export const API = {
BACKENDS: {
BASE: () => `${API.BASE()}/backends`,
LIST_TYPES: () => `${API.BACKENDS.BASE()}/list_types`,
LIST_BASE_TYPES: () => `${API.BACKENDS.BASE()}/list_base_types`,
CONFIG_VALUES: () => `${API.BACKENDS.BASE()}/config_values`,
},

Expand Down
38 changes: 38 additions & 0 deletions frontend/src/components/form/Cards/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import { Controller, FieldValues } from 'react-hook-form';
import Cards from '@cloudscape-design/components/cards';
import { CardsProps } from '@cloudscape-design/components/cards';

import { FormCardsProps } from './types';

export const FormCards = <T extends FieldValues>({
name,
control,
onSelectionChange: onSelectionChangeProp,
...props
}: FormCardsProps<T>) => {
return (
<Controller
name={name}
control={control}
render={({ field: { onChange, ...fieldRest } }) => {
const onSelectionChange: CardsProps['onSelectionChange'] = (event) => {
onChange(event.detail.selectedItems.map(({ value }) => value));
onSelectionChangeProp?.(event);
};

const selectedItems = props.items.filter((item) => fieldRest.value?.includes(item.value));

return (
<Cards
onSelectionChange={onSelectionChange}
trackBy="value"
{...fieldRest}
{...props}
selectedItems={selectedItems}
/>
);
}}
/>
);
};
7 changes: 7 additions & 0 deletions frontend/src/components/form/Cards/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Control, FieldValues, Path } from 'react-hook-form';
import { CardsProps } from '@cloudscape-design/components/cards';

export type FormCardsProps<T extends FieldValues> = CardsProps & {
control: Control<T, object>;
name: Path<T>;
};
4 changes: 4 additions & 0 deletions frontend/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export type { LineChartProps } from '@cloudscape-design/components/line-chart/in
export type { ModalProps } from '@cloudscape-design/components/modal';
export { default as AnchorNavigation } from '@cloudscape-design/components/anchor-navigation';
export { default as ExpandableSection } from '@cloudscape-design/components/expandable-section';
export { default as KeyValuePairs } from '@cloudscape-design/components/key-value-pairs';
export { I18nProvider } from '@cloudscape-design/components/i18n';
export { default as Wizard } from '@cloudscape-design/components/wizard';

// custom components
export { NavigateLink } from './NavigateLink';
Expand All @@ -80,6 +82,8 @@ export type { FormMultiselectOptions, FormMultiselectProps } from './form/Multis
export { FormS3BucketSelector } from './form/S3BucketSelector';
export type { FormTilesProps } from './form/Tiles/types';
export { FormTiles } from './form/Tiles';
export type { FormCardsProps } from './form/Cards/types';
export { FormCards } from './form/Cards';
export { Notifications } from './Notifications';
export { ConfirmationDialog } from './ConfirmationDialog';
export { FileUploader } from './FileUploader';
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const container = document.getElementById('root');

const theme: Theme = {
tokens: {
fontFamilyBase: 'metro-web, Metro, -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',
fontFamilyBase:
'metro-web, Metro, -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',
fontSizeHeadingS: '15px',
fontSizeHeadingL: '19px',
fontSizeHeadingXl: '22px',
Expand Down
28 changes: 27 additions & 1 deletion frontend/src/layouts/AppLayout/TutorialPanel/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export enum HotspotIds {
ADD_TOP_UP_BALANCE = 'billing-top-up-balance',
PAYMENT_CONTINUE_BUTTON = 'billing-payment-continue-button',
CONFIGURE_CLI_COMMAND = 'configure-cli-command',
CREATE_FIRST_PROJECT = 'create-first-project',
}

export const BILLING_TUTORIAL: TutorialPanelProps.Tutorial = {
Expand All @@ -52,7 +53,7 @@ export const BILLING_TUTORIAL: TutorialPanelProps.Tutorial = {
description: (
<>
<Box variant="p" color="text-body-secondary" padding={{ top: 'n' }}>
Top up your balance via a credit card to use GPU by dstack Sky.
If you plan to use the GPU marketplace, top up your balance with a credit card.
</Box>
</>
),
Expand Down Expand Up @@ -101,6 +102,31 @@ export const CONFIGURE_CLI_TUTORIAL: TutorialPanelProps.Tutorial = {
],
};

export const CREATE_FIRST_PROJECT: TutorialPanelProps.Tutorial = {
completed: false,
title: 'Create a project',
description: (
<>
<Box variant="p" color="text-body-secondary" padding={{ top: 'n' }}>
Create your first project. Choose to use the GPU marketplace or configure your own cloud credentials.
</Box>
</>
),
completedScreenDescription: 'TBA',
tasks: [
{
title: 'Create the first project',
steps: [
{
title: 'Create the first project',
content: 'Create the first project',
hotspotId: HotspotIds.CREATE_FIRST_PROJECT,
},
],
},
],
};

export const JOIN_DISCORD_TUTORIAL: TutorialPanelProps.Tutorial = {
completed: false,
title: 'Community',
Expand Down
Loading
Loading