Skip to content

Commit 430f807

Browse files
committed
feat: bundle a local version of install.sh, add CLI install page
1 parent c41254b commit 430f807

File tree

7 files changed

+956
-5
lines changed

7 files changed

+956
-5
lines changed

site/src/components/CodeExample/CodeExample.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const CodeExample: FC<CodeExampleProps> = ({
6565
</span>
6666
</>
6767
) : (
68-
<>{code}</>
68+
code
6969
)}
7070
</code>
7171

site/src/modules/dashboard/Navbar/UserDropdown/UserDropdownContent.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import AccountIcon from "@mui/icons-material/AccountCircleOutlined";
88
import BugIcon from "@mui/icons-material/BugReportOutlined";
99
import ChatIcon from "@mui/icons-material/ChatOutlined";
1010
import LogoutIcon from "@mui/icons-material/ExitToAppOutlined";
11+
import InstallDesktopIcon from "@mui/icons-material/InstallDesktop";
1112
import LaunchIcon from "@mui/icons-material/LaunchOutlined";
1213
import DocsIcon from "@mui/icons-material/MenuBook";
1314
import Divider from "@mui/material/Divider";
@@ -21,7 +22,6 @@ import { Stack } from "components/Stack/Stack";
2122
import { usePopover } from "components/deprecated/Popover/Popover";
2223
import type { FC } from "react";
2324
import { Link } from "react-router-dom";
24-
2525
export const Language = {
2626
accountLabel: "Account",
2727
signOutLabel: "Sign Out",
@@ -76,6 +76,13 @@ export const UserDropdownContent: FC<UserDropdownContentProps> = ({
7676

7777
<Divider css={{ marginBottom: 8 }} />
7878

79+
<Link to="/install" css={styles.link}>
80+
<MenuItem css={styles.menuItem} onClick={onPopoverClose}>
81+
<InstallDesktopIcon css={styles.menuItemIcon} />
82+
<span css={styles.menuItemText}>Install CLI</span>
83+
</MenuItem>
84+
</Link>
85+
7986
<Link to="/settings/account" css={styles.link}>
8087
<MenuItem css={styles.menuItem} onClick={onPopoverClose}>
8188
<AccountIcon css={styles.menuItemIcon} />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { FC } from "react";
2+
import { Helmet } from "react-helmet-async";
3+
import { pageTitle } from "utils/page";
4+
import { CliInstallPageView } from "./CliInstallPageView";
5+
6+
export const CliInstallPage: FC = () => {
7+
return (
8+
<>
9+
<Helmet>
10+
<title>{pageTitle("Install the Coder CLI")}</title>
11+
</Helmet>
12+
<CliInstallPageView />
13+
</>
14+
);
15+
};
16+
17+
export default CliInstallPage;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { CliInstallPageView } from "./CliInstallPageView";
3+
4+
const meta: Meta<typeof CliInstallPageView> = {
5+
title: "pages/CliAuthPage",
6+
component: CliInstallPageView,
7+
args: {
8+
sessionToken: "some-session-token",
9+
},
10+
};
11+
12+
export default meta;
13+
type Story = StoryObj<typeof CliInstallPageView>;
14+
15+
const Example: Story = {};
16+
17+
export { Example as CliAuthPage };
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import type { Interpolation, Theme } from "@emotion/react";
2+
import { CodeExample } from "components/CodeExample/CodeExample";
3+
import { SignInLayout } from "components/SignInLayout/SignInLayout";
4+
import { Welcome } from "components/Welcome/Welcome";
5+
import type { FC } from "react";
6+
import { Link as RouterLink } from "react-router-dom";
7+
8+
export const CliInstallPageView: FC = () => {
9+
const origin = location.origin;
10+
11+
return (
12+
<SignInLayout>
13+
<Welcome className="pb-3">Install the Coder CLI</Welcome>
14+
15+
<p css={styles.instructions}>
16+
Copy the command below and{" "}
17+
<strong css={{ display: "block" }}>paste it in your terminal.</strong>
18+
</p>
19+
20+
<CodeExample
21+
code={`curl -fsSL ${origin}/install.sh | sh`}
22+
secret={false}
23+
/>
24+
25+
<div css={{ paddingTop: 16 }}>
26+
<RouterLink to="/workspaces" css={styles.backLink}>
27+
Go to workspaces
28+
</RouterLink>
29+
</div>
30+
</SignInLayout>
31+
);
32+
};
33+
34+
const styles = {
35+
instructions: (theme) => ({
36+
fontSize: 16,
37+
color: theme.palette.text.secondary,
38+
paddingBottom: 8,
39+
textAlign: "center",
40+
lineHeight: 1.4,
41+
42+
// Have to undo styling side effects from <Welcome> component
43+
marginTop: -24,
44+
}),
45+
46+
backLink: (theme) => ({
47+
display: "block",
48+
textAlign: "center",
49+
color: theme.palette.text.primary,
50+
textDecoration: "underline",
51+
textUnderlineOffset: 3,
52+
textDecorationColor: "hsla(0deg, 0%, 100%, 0.7)",
53+
paddingTop: 16,
54+
paddingBottom: 16,
55+
56+
"&:hover": {
57+
textDecoration: "none",
58+
},
59+
}),
60+
} satisfies Record<string, Interpolation<Theme>>;

site/src/router.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ const DeploymentSettingsProvider = lazy(
3737
const OrganizationSettingsLayout = lazy(
3838
() => import("./modules/management/OrganizationSettingsLayout"),
3939
);
40-
const CliAuthenticationPage = lazy(
41-
() => import("./pages/CliAuthPage/CliAuthPage"),
40+
const CliAuthPage = lazy(() => import("./pages/CliAuthPage/CliAuthPage"));
41+
const CliInstallPage = lazy(
42+
() => import("./pages/CliInstallPage/CliInstallPage"),
4243
);
4344
const AccountPage = lazy(
4445
() => import("./pages/UserSettingsPage/AccountPage/AccountPage"),
@@ -539,6 +540,9 @@ export const router = createBrowserRouter(
539540
element={<ProvisionerDaemonsHealthPage />}
540541
/>
541542
</Route>
543+
544+
<Route path="/install" element={<CliInstallPage />} />
545+
542546
{/* Using path="*"" means "match anything", so this route
543547
acts like a catch-all for URLs that we don't have explicit
544548
routes for. */}
@@ -559,7 +563,7 @@ export const router = createBrowserRouter(
559563
path="/:username/:workspace/terminal"
560564
element={<TerminalPage />}
561565
/>
562-
<Route path="/cli-auth" element={<CliAuthenticationPage />} />
566+
<Route path="/cli-auth" element={<CliAuthPage />} />
563567
<Route path="/icons" element={<IconsPage />} />
564568
</Route>
565569
</Route>,

0 commit comments

Comments
 (0)