Skip to content

Commit 242676b

Browse files
authored
feat: add storybook for /deployment/gitauth (#5596)
* refactor: move GitAuthSettingsPage to dir * refactor: split page and view GitAuthSettingsPage * fixup!: formatting * refactor: narrow props in git auth view * feat: add storybook for GitAuthSettingsPageView * fixup: formatting
1 parent aa68e0f commit 242676b

File tree

4 files changed

+64
-13
lines changed

4 files changed

+64
-13
lines changed

site/src/AppRouter.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ const UserAuthSettingsPage = lazy(
8989
() => import("./pages/DeploySettingsPage/UserAuthSettingsPage"),
9090
)
9191
const GitAuthSettingsPage = lazy(
92-
() => import("./pages/DeploySettingsPage/GitAuthSettingsPage"),
92+
() =>
93+
import(
94+
"./pages/DeploySettingsPage/GitAuthSettingsPage/GitAuthSettingsPage"
95+
),
9396
)
9497
const NetworkSettingsPage = lazy(
9598
() => import("./pages/DeploySettingsPage/NetworkSettingsPage"),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useDeploySettings } from "components/DeploySettingsLayout/DeploySettingsLayout"
2+
import React from "react"
3+
import { Helmet } from "react-helmet-async"
4+
import { pageTitle } from "util/page"
5+
import { GitAuthSettingsPageView } from "./GitAuthSettingsPageView"
6+
7+
const GitAuthSettingsPage: React.FC = () => {
8+
const { deploymentConfig: deploymentConfig } = useDeploySettings()
9+
10+
return (
11+
<>
12+
<Helmet>
13+
<title>{pageTitle("Git Authentication Settings")}</title>
14+
</Helmet>
15+
16+
<GitAuthSettingsPageView deploymentConfig={deploymentConfig} />
17+
</>
18+
)
19+
}
20+
21+
export default GitAuthSettingsPage
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ComponentMeta, Story } from "@storybook/react"
2+
import {
3+
GitAuthSettingsPageView,
4+
GitAuthSettingsPageViewProps,
5+
} from "./GitAuthSettingsPageView"
6+
7+
export default {
8+
title: "pages/GitAuthSettingsPageView",
9+
component: GitAuthSettingsPageView,
10+
argTypes: {
11+
deploymentConfig: {
12+
defaultValue: {
13+
gitauth: {
14+
name: "Git Auth",
15+
usage: "Automatically authenticate Git inside workspaces.",
16+
value: [
17+
{
18+
id: "123",
19+
client_id: "575",
20+
},
21+
],
22+
},
23+
},
24+
},
25+
},
26+
} as ComponentMeta<typeof GitAuthSettingsPageView>
27+
28+
const Template: Story<GitAuthSettingsPageViewProps> = (args) => (
29+
<GitAuthSettingsPageView {...args} />
30+
)
31+
export const Page = Template.bind({})

site/src/pages/DeploySettingsPage/GitAuthSettingsPage.tsx renamed to site/src/pages/DeploySettingsPage/GitAuthSettingsPage/GitAuthSettingsPageView.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ import TableCell from "@material-ui/core/TableCell"
55
import TableContainer from "@material-ui/core/TableContainer"
66
import TableHead from "@material-ui/core/TableHead"
77
import TableRow from "@material-ui/core/TableRow"
8+
import { DeploymentConfig } from "api/typesGenerated"
89
import { AlertBanner } from "components/AlertBanner/AlertBanner"
910
import { EnterpriseBadge } from "components/DeploySettingsLayout/Badges"
10-
import { useDeploySettings } from "components/DeploySettingsLayout/DeploySettingsLayout"
1111
import { Header } from "components/DeploySettingsLayout/Header"
12-
import React from "react"
13-
import { Helmet } from "react-helmet-async"
14-
import { pageTitle } from "util/page"
1512

16-
const GitAuthSettingsPage: React.FC = () => {
13+
export type GitAuthSettingsPageViewProps = {
14+
deploymentConfig: Pick<DeploymentConfig, "gitauth">
15+
}
16+
17+
export const GitAuthSettingsPageView = ({
18+
deploymentConfig,
19+
}: GitAuthSettingsPageViewProps): JSX.Element => {
1720
const styles = useStyles()
18-
const { deploymentConfig: deploymentConfig } = useDeploySettings()
1921

2022
return (
2123
<>
22-
<Helmet>
23-
<title>{pageTitle("Git Authentication Settings")}</title>
24-
</Helmet>
25-
2624
<Header
2725
title="Git Authentication"
2826
description="Coder integrates with GitHub, GitLab, BitBucket, and Azure Repos to authenticate developers with your Git provider."
@@ -105,5 +103,3 @@ const useStyles = makeStyles((theme) => ({
105103
textAlign: "center",
106104
},
107105
}))
108-
109-
export default GitAuthSettingsPage

0 commit comments

Comments
 (0)