Skip to content

Commit ffa77ba

Browse files
feat(site): show CLI flags and env variables for the options (coder#9757)
1 parent 94cccd0 commit ffa77ba

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

site/src/api/api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ export interface DeploymentOption {
10141014
readonly value: unknown;
10151015
readonly hidden: boolean;
10161016
readonly group?: DeploymentGroup;
1017+
readonly env?: string;
10171018
}
10181019

10191020
export type DeploymentConfig = {

site/src/components/DeploySettingsLayout/Option.tsx

+40
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { makeStyles } from "@mui/styles";
22
import { PropsWithChildren, FC } from "react";
33
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
44
import { DisabledBadge, EnabledBadge } from "./Badges";
5+
import Box, { BoxProps } from "@mui/material/Box";
56

67
export const OptionName: FC<PropsWithChildren> = ({ children }) => {
78
const styles = useStyles();
@@ -57,6 +58,45 @@ export const OptionValue: FC<{ children?: unknown }> = ({ children }) => {
5758
return <span className={styles.optionValue}>{JSON.stringify(children)}</span>;
5859
};
5960

61+
export const OptionConfig = (props: BoxProps) => {
62+
return (
63+
<Box
64+
{...props}
65+
sx={{
66+
fontSize: 13,
67+
fontFamily: MONOSPACE_FONT_FAMILY,
68+
fontWeight: 600,
69+
backgroundColor: (theme) => theme.palette.background.paperLight,
70+
display: "inline-flex",
71+
alignItems: "center",
72+
borderRadius: 0.25,
73+
padding: (theme) => theme.spacing(0, 1),
74+
border: (theme) => `1px solid ${theme.palette.divider}`,
75+
...props.sx,
76+
}}
77+
/>
78+
);
79+
};
80+
81+
export const OptionConfigFlag = (props: BoxProps) => {
82+
return (
83+
<Box
84+
{...props}
85+
sx={{
86+
fontSize: 10,
87+
fontWeight: 600,
88+
margin: (theme) => theme.spacing(0, 0.75, 0, -0.5),
89+
display: "block",
90+
backgroundColor: (theme) => theme.palette.divider,
91+
lineHeight: 1,
92+
padding: (theme) => theme.spacing(0.25, 0.5),
93+
borderRadius: 0.25,
94+
...props.sx,
95+
}}
96+
/>
97+
);
98+
};
99+
60100
const useStyles = makeStyles((theme) => ({
61101
optionName: {
62102
display: "block",

site/src/components/DeploySettingsLayout/OptionsTable.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import TableContainer from "@mui/material/TableContainer";
66
import TableHead from "@mui/material/TableHead";
77
import TableRow from "@mui/material/TableRow";
88
import {
9+
OptionConfig,
10+
OptionConfigFlag,
911
OptionDescription,
1012
OptionName,
1113
OptionValue,
1214
} from "components/DeploySettingsLayout/Option";
1315
import { FC } from "react";
1416
import { optionValue } from "./optionValue";
1517
import { DeploymentOption } from "api/api";
18+
import Box from "@mui/material/Box";
1619

1720
const OptionsTable: FC<{
1821
options: DeploymentOption[];
@@ -46,6 +49,33 @@ const OptionsTable: FC<{
4649
<TableCell>
4750
<OptionName>{option.name}</OptionName>
4851
<OptionDescription>{option.description}</OptionDescription>
52+
<Box
53+
sx={{
54+
marginTop: 3,
55+
display: "flex",
56+
flexWrap: "wrap",
57+
gap: 1,
58+
}}
59+
>
60+
{option.flag && (
61+
<OptionConfig>
62+
<OptionConfigFlag>CLI</OptionConfigFlag>
63+
--{option.flag}
64+
</OptionConfig>
65+
)}
66+
{option.flag_shorthand && (
67+
<OptionConfig>
68+
<OptionConfigFlag>CLI</OptionConfigFlag>-
69+
{option.flag_shorthand}
70+
</OptionConfig>
71+
)}
72+
{option.env && (
73+
<OptionConfig>
74+
<OptionConfigFlag>ENV</OptionConfigFlag>
75+
{option.env}
76+
</OptionConfig>
77+
)}
78+
</Box>
4979
</TableCell>
5080

5181
<TableCell>

0 commit comments

Comments
 (0)