Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Stack } from "components/Stack/Stack"
import { useFormik } from "formik"
import { useTheme } from "@mui/styles"
import Link from "@mui/material/Link"
import { colors } from "theme/colors"

export type AppearanceSettingsPageViewProps = {
appearance: UpdateAppearanceConfig
Expand Down Expand Up @@ -53,7 +54,8 @@ export const AppearanceSettingsPageView = ({
initialValues: {
message: appearance.service_banner.message,
enabled: appearance.service_banner.enabled,
background_color: appearance.service_banner.background_color,
background_color:
appearance.service_banner.background_color ?? colors.blue[7],
},
onSubmit: (values) =>
updateAppearance(
Expand Down
23 changes: 8 additions & 15 deletions site/src/xServices/appearance/appearanceXService.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { displaySuccess } from "components/GlobalSnackbar/utils"
import { displayError, displaySuccess } from "components/GlobalSnackbar/utils"
import { assign, createMachine } from "xstate"
import * as API from "../../api/api"
import { AppearanceConfig } from "../../api/typesGenerated"
import { getErrorMessage } from "api/errors"

export type AppearanceContext = {
appearance?: AppearanceConfig
getAppearanceError?: unknown
setAppearanceError?: unknown
preview: boolean
}

Expand Down Expand Up @@ -39,11 +39,7 @@ export const appearanceMachine = createMachine(
idle: {
on: {
SET_PREVIEW_APPEARANCE: {
actions: [
"clearGetAppearanceError",
"clearSetAppearanceError",
"assignPreviewAppearance",
],
actions: ["clearGetAppearanceError", "assignPreviewAppearance"],
},
SAVE_APPEARANCE: "savingAppearance",
},
Expand All @@ -64,7 +60,6 @@ export const appearanceMachine = createMachine(
},
},
savingAppearance: {
entry: "clearSetAppearanceError",
invoke: {
id: "setAppearance",
src: "setAppearance",
Expand All @@ -74,7 +69,11 @@ export const appearanceMachine = createMachine(
},
onError: {
target: "idle",
actions: ["assignSetAppearanceError"],
actions: (_, error) => {
displayError(
getErrorMessage(error, "Failed to update appearance settings."),
)
},
},
},
},
Expand All @@ -99,12 +98,6 @@ export const appearanceMachine = createMachine(
clearGetAppearanceError: assign({
getAppearanceError: (_) => undefined,
}),
assignSetAppearanceError: assign({
setAppearanceError: (_, event) => event.data,
}),
clearSetAppearanceError: assign({
setAppearanceError: (_) => undefined,
}),
},
services: {
getAppearance: async () => {
Expand Down