Skip to content

Commit

Permalink
Update tutorial panel dstackai/dstack-cloud#205 (#1659)
Browse files Browse the repository at this point in the history
  • Loading branch information
olgenn authored Sep 4, 2024
1 parent e4d467d commit dd550dc
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 20 deletions.
1 change: 1 addition & 0 deletions frontend/src/App/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const getInitialState = (): IAppState => {
configureCLICompleted: false,
discordCompleted: false,
tallyCompleted: false,
quickStartCompleted: 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 @@ -36,5 +36,6 @@ export interface IAppState {
configureCLICompleted: boolean;
discordCompleted: boolean;
tallyCompleted: boolean;
quickStartCompleted: boolean;
};
}
1 change: 1 addition & 0 deletions frontend/src/components/Code/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
padding: 8px;
background-color: awsui.$color-background-input-disabled;
border-radius: 8px;
white-space: pre-wrap;
}
1 change: 1 addition & 0 deletions frontend/src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const DATE_TIME_FORMAT = 'MM/dd/yyyy HH:mm';
export const DISCORD_URL = 'https://discord.gg/u8SmfwPpMd';
export const QUICK_START_URL = 'https://dstack.ai/docs/quickstart/';
export const TALLY_FORM_ID = '3xYlYG';
export const DOCS_URL = 'https://dstack.ai/docs/';
export const DEFAULT_TABLE_PAGE_SIZE = 20;
18 changes: 16 additions & 2 deletions frontend/src/layouts/AppLayout/TutorialPanel/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const BILLING_TUTORIAL: TutorialPanelProps.Tutorial = {

export const CONFIGURE_CLI_TUTORIAL: TutorialPanelProps.Tutorial = {
completed: false,
title: 'Configure the CLI',
title: 'Set up the CLI',
description: (
<>
<Box variant="p" color="text-body-secondary" padding={{ top: 'n' }}>
Expand All @@ -103,7 +103,7 @@ export const CONFIGURE_CLI_TUTORIAL: TutorialPanelProps.Tutorial = {

export const JOIN_DISCORD_TUTORIAL: TutorialPanelProps.Tutorial = {
completed: false,
title: 'Join Discord',
title: 'Community',
description: (
<>
<Box variant="p" color="text-body-secondary" padding={{ top: 'n' }}>
Expand All @@ -115,6 +115,20 @@ export const JOIN_DISCORD_TUTORIAL: TutorialPanelProps.Tutorial = {
tasks: [],
};

export const QUICKSTART_TUTORIAL: TutorialPanelProps.Tutorial = {
completed: false,
title: 'Quickstart',
description: (
<>
<Box variant="p" color="text-body-secondary" padding={{ top: 'n' }}>
Check out the quickstart guide to get started with dstack
</Box>
</>
),
completedScreenDescription: 'TBA',
tasks: [],
};

export const CREDITS_TUTORIAL: TutorialPanelProps.Tutorial = {
completed: false,
title: 'Get free credits',
Expand Down
53 changes: 37 additions & 16 deletions frontend/src/layouts/AppLayout/TutorialPanel/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { useNavigate } from 'react-router-dom';

import { DISCORD_URL, TALLY_FORM_ID } from 'consts';
import { DISCORD_URL, QUICK_START_URL, TALLY_FORM_ID } from 'consts';
import { useAppDispatch, useAppSelector } from 'hooks';
import { goToUrl } from 'libs';
import { useGetRunsQuery } from 'services/run';
Expand All @@ -10,7 +10,13 @@ import { useGetUserBillingInfoQuery } from 'services/user';
import { openTutorialPanel, selectTutorialPanel, selectUserName, updateTutorialPanelState } from 'App/slice';

import { useSideNavigation } from '../hooks';
import { BILLING_TUTORIAL, CONFIGURE_CLI_TUTORIAL, CREDITS_TUTORIAL, JOIN_DISCORD_TUTORIAL } from './constants';
import {
BILLING_TUTORIAL,
CONFIGURE_CLI_TUTORIAL,
// CREDITS_TUTORIAL,
JOIN_DISCORD_TUTORIAL,
QUICKSTART_TUTORIAL,
} from './constants';

import { ITutorialItem } from 'App/types';

Expand All @@ -19,7 +25,8 @@ export const useTutorials = () => {
const dispatch = useAppDispatch();
const { mainProjectSettingsUrl, billingUrl } = useSideNavigation();
const useName = useAppSelector(selectUserName);
const { billingCompleted, configureCLICompleted, discordCompleted, tallyCompleted } = useAppSelector(selectTutorialPanel);
const { billingCompleted, configureCLICompleted, discordCompleted, tallyCompleted, quickStartCompleted } =
useAppSelector(selectTutorialPanel);

const { data: userBillingData } = useGetUserBillingInfoQuery({ username: useName ?? '' }, { skip: !useName });
const { data: runsData } = useGetRunsQuery({
Expand Down Expand Up @@ -66,22 +73,27 @@ export const useTutorials = () => {
dispatch(updateTutorialPanelState({ discordCompleted: true }));
}, []);

const startCreditsTutorial = useCallback(() => {
if (typeof Tally !== 'undefined') {
Tally.openPopup(TALLY_FORM_ID);
dispatch(updateTutorialPanelState({ tallyCompleted: true }));
}
const startQuickStartTutorial = useCallback(() => {
goToUrl(QUICK_START_URL, true);
dispatch(updateTutorialPanelState({ quickStartCompleted: true }));
}, []);

// const startCreditsTutorial = useCallback(() => {
// if (typeof Tally !== 'undefined') {
// Tally.openPopup(TALLY_FORM_ID);
// dispatch(updateTutorialPanelState({ tallyCompleted: true }));
// }
// }, []);

const tutorials = useMemo<ITutorialItem[]>(() => {
return [
{
...CREDITS_TUTORIAL,
id: 1,
startWithoutActivation: true,
completed: tallyCompleted,
startCallback: startCreditsTutorial,
},
// {
// ...CREDITS_TUTORIAL,
// id: 1,
// startWithoutActivation: true,
// completed: tallyCompleted,
// startCallback: startCreditsTutorial,
// },

{
...CONFIGURE_CLI_TUTORIAL,
Expand All @@ -100,16 +112,25 @@ export const useTutorials = () => {
},

{
...JOIN_DISCORD_TUTORIAL,
...QUICKSTART_TUTORIAL,
id: 4,
startWithoutActivation: true,
completed: quickStartCompleted,
startCallback: startQuickStartTutorial,
},

{
...JOIN_DISCORD_TUTORIAL,
id: 5,
startWithoutActivation: true,
completed: discordCompleted,
startCallback: startDiscordTutorial,
},
];
}, [
mainProjectSettingsUrl,
billingUrl,
quickStartCompleted,
discordCompleted,
tallyCompleted,
billingCompleted,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Project/Details/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const ProjectSettings: React.FC = () => {
>
<SpaceBetween size="s">
<Box variant="p" color="text-body-secondary">
Run the command below to configure this project as a remote
Run the following commands to set up the CLI for this project
</Box>

<Hotspot hotspotId={HotspotIds.CONFIGURE_CLI_COMMAND}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Args = {
export const useConfigProjectCliCommand = ({ projectName }: Args) => {
const currentUserToken = useAppSelector(selectAuthToken);

const cliCommand = `dstack config --url ${location.origin} --project ${projectName} --token ${currentUserToken}`;
const cliCommand = `pip install dstack\n\ndstack config --url ${location.origin} --project ${projectName} --token ${currentUserToken}`;

const copyCliCommand = () => {
copyToClipboard(cliCommand);
Expand Down

0 comments on commit dd550dc

Please sign in to comment.