|
1 |
| -importButtonfrom"@material-ui/core/Button" |
2 |
| -importFormControlLabelfrom"@material-ui/core/FormControlLabel" |
3 |
| -importFormHelperTextfrom"@material-ui/core/FormHelperText" |
4 |
| -importInputAdornmentfrom"@material-ui/core/InputAdornment" |
5 |
| -import{useTheme}from"@material-ui/core/styles" |
6 |
| -importmakeStylesfrom"@material-ui/core/styles/makeStyles" |
7 |
| -importSwitchfrom"@material-ui/core/Switch" |
8 |
| -importTextFieldfrom"@material-ui/core/TextField" |
9 |
| -import{useActor}from"@xstate/react" |
10 |
| -import{FeatureNames}from"api/types" |
11 |
| -import{AppearanceConfig}from"api/typesGenerated" |
| 1 | +import{useState}from"react" |
| 2 | +import{Header}from"components/DeploySettingsLayout/Header" |
12 | 3 | import{
|
13 | 4 | Badges,
|
14 | 5 | DisabledBadge,
|
15 | 6 | EnterpriseBadge,
|
16 | 7 | EntitledBadge,
|
17 | 8 | }from"components/DeploySettingsLayout/Badges"
|
| 9 | +importInputAdornmentfrom"@material-ui/core/InputAdornment" |
18 | 10 | import{Fieldset}from"components/DeploySettingsLayout/Fieldset"
|
19 |
| -import{Header}from"components/DeploySettingsLayout/Header" |
20 |
| -import{Stack}from"components/Stack/Stack" |
21 |
| -import{useFormik}from"formik" |
22 |
| -importReact,{useContext,useState}from"react" |
| 11 | +import{getFormHelpers}from"util/formUtils" |
| 12 | +importButtonfrom"@material-ui/core/Button" |
| 13 | +importFormControlLabelfrom"@material-ui/core/FormControlLabel" |
| 14 | +importFormHelperTextfrom"@material-ui/core/FormHelperText" |
23 | 15 | import{BlockPicker}from"react-color"
|
24 |
| -import{Helmet}from"react-helmet-async" |
25 | 16 | import{useTranslation}from"react-i18next"
|
26 |
| -import{getFormHelpers}from"util/formUtils" |
27 |
| -import{pageTitle}from"util/page" |
28 |
| -import{XServiceContext}from"xServices/StateContext" |
29 |
| - |
30 |
| -// ServiceBanner is unlike the other Deployment Settings pages because it |
31 |
| -// implements a form, whereas the others are read-only. We make this |
32 |
| -// exception because the Service Banner is visual, and configuring it from |
33 |
| -// the command line would be a significantly worse user experience. |
34 |
| -constAppearanceSettingsPage:React.FC=()=>{ |
35 |
| -constxServices=useContext(XServiceContext) |
36 |
| -const[appearanceXService,appearanceSend]=useActor( |
37 |
| -xServices.appearanceXService, |
38 |
| -) |
39 |
| -const[entitlementsState]=useActor(xServices.entitlementsXService) |
40 |
| -constappearance=appearanceXService.context.appearance |
41 |
| -conststyles=useStyles() |
42 |
| - |
43 |
| -constisEntitled= |
44 |
| -entitlementsState.context.entitlements.features[FeatureNames.Appearance] |
45 |
| -.entitlement!=="not_entitled" |
| 17 | +importmakeStylesfrom"@material-ui/core/styles/makeStyles" |
| 18 | +importSwitchfrom"@material-ui/core/Switch" |
| 19 | +importTextFieldfrom"@material-ui/core/TextField" |
| 20 | +import{AppearanceConfig}from"api/typesGenerated" |
| 21 | +import{Stack}from"components/Stack/Stack" |
| 22 | +import{useFormik}from"formik" |
| 23 | +import{useTheme}from"@material-ui/core/styles" |
46 | 24 |
|
47 |
| -constupdateAppearance=( |
| 25 | +exporttypeAppearanceSettingsPageViewProps={ |
| 26 | +appearance:AppearanceConfig |
| 27 | +isEntitled:boolean |
| 28 | +updateAppearance:( |
48 | 29 | newConfig:Partial<AppearanceConfig>,
|
49 | 30 | preview:boolean,
|
50 |
| -)=>{ |
51 |
| -constnewAppearance={ |
52 |
| - ...appearance, |
53 |
| - ...newConfig, |
54 |
| -} |
55 |
| -if(preview){ |
56 |
| -appearanceSend({ |
57 |
| -type:"SET_PREVIEW_APPEARANCE", |
58 |
| -appearance:newAppearance, |
59 |
| -}) |
60 |
| -return |
61 |
| -} |
62 |
| -appearanceSend({ |
63 |
| -type:"SET_APPEARANCE", |
64 |
| -appearance:newAppearance, |
65 |
| -}) |
66 |
| -} |
67 |
| - |
| 31 | +)=>void |
| 32 | +} |
| 33 | +exportconstAppearanceSettingsPageView=({ |
| 34 | + appearance, |
| 35 | + isEntitled, |
| 36 | + updateAppearance, |
| 37 | +}:AppearanceSettingsPageViewProps):JSX.Element=>{ |
| 38 | +conststyles=useStyles() |
| 39 | +consttheme=useTheme() |
| 40 | +const[t]=useTranslation("appearanceSettings") |
68 | 41 | constlogoForm=useFormik<{
|
69 | 42 | logo_url:string
|
70 | 43 | }>({
|
@@ -93,16 +66,8 @@ const AppearanceSettingsPage: React.FC = () => {
|
93 | 66 | const[backgroundColor,setBackgroundColor]=useState(
|
94 | 67 | serviceBannerForm.values.background_color,
|
95 | 68 | )
|
96 |
| - |
97 |
| -consttheme=useTheme() |
98 |
| -const[t]=useTranslation("appearanceSettings") |
99 |
| - |
100 | 69 | return(
|
101 | 70 | <>
|
102 |
| -<Helmet> |
103 |
| -<title>{pageTitle("Appearance Settings")}</title> |
104 |
| -</Helmet> |
105 |
| - |
106 | 71 | <Header
|
107 | 72 | title="Appearance"
|
108 | 73 | description="Customize the look and feel of your Coder deployment."
|
@@ -280,5 +245,3 @@ const useStyles = makeStyles((theme) => ({
|
280 | 245 | },
|
281 | 246 | },
|
282 | 247 | }))
|
283 |
| - |
284 |
| -exportdefaultAppearanceSettingsPage |