|
1 |
| -import Button from "@material-ui/core/Button" |
2 |
| -import FormControlLabel from "@material-ui/core/FormControlLabel" |
3 |
| -import FormHelperText from "@material-ui/core/FormHelperText" |
4 |
| -import InputAdornment from "@material-ui/core/InputAdornment" |
5 |
| -import { useTheme } from "@material-ui/core/styles" |
6 |
| -import makeStyles from "@material-ui/core/styles/makeStyles" |
7 |
| -import Switch from "@material-ui/core/Switch" |
8 |
| -import TextField from "@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 | +import InputAdornment from "@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 |
| -import React, { useContext, useState } from "react" |
| 11 | +import { getFormHelpers } from "util/formUtils" |
| 12 | +import Button from "@material-ui/core/Button" |
| 13 | +import FormControlLabel from "@material-ui/core/FormControlLabel" |
| 14 | +import FormHelperText from "@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 |
| -const AppearanceSettingsPage: React.FC = () => { |
35 |
| - const xServices = useContext(XServiceContext) |
36 |
| - const [appearanceXService, appearanceSend] = useActor( |
37 |
| - xServices.appearanceXService, |
38 |
| - ) |
39 |
| - const [entitlementsState] = useActor(xServices.entitlementsXService) |
40 |
| - const appearance = appearanceXService.context.appearance |
41 |
| - const styles = useStyles() |
42 |
| - |
43 |
| - const isEntitled = |
44 |
| - entitlementsState.context.entitlements.features[FeatureNames.Appearance] |
45 |
| - .entitlement !== "not_entitled" |
| 17 | +import makeStyles from "@material-ui/core/styles/makeStyles" |
| 18 | +import Switch from "@material-ui/core/Switch" |
| 19 | +import TextField from "@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 |
| - const updateAppearance = ( |
| 25 | +export type AppearanceSettingsPageViewProps = { |
| 26 | + appearance: AppearanceConfig |
| 27 | + isEntitled: boolean |
| 28 | + updateAppearance: ( |
48 | 29 | newConfig: Partial<AppearanceConfig>,
|
49 | 30 | preview: boolean,
|
50 |
| - ) => { |
51 |
| - const newAppearance = { |
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 | +export const AppearanceSettingsPageView = ({ |
| 34 | + appearance, |
| 35 | + isEntitled, |
| 36 | + updateAppearance, |
| 37 | +}: AppearanceSettingsPageViewProps): JSX.Element => { |
| 38 | + const styles = useStyles() |
| 39 | + const theme = useTheme() |
| 40 | + const [t] = useTranslation("appearanceSettings") |
68 | 41 | const logoForm = 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 |
| - const theme = 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 |
| -export default AppearanceSettingsPage |
0 commit comments