diff --git a/dashboard/components/content-editor/editor-mode-switch.tsx b/dashboard/components/content-editor/editor-mode-switch.tsx index b41a533..34b0e00 100644 --- a/dashboard/components/content-editor/editor-mode-switch.tsx +++ b/dashboard/components/content-editor/editor-mode-switch.tsx @@ -2,10 +2,14 @@ import { cn } from "@/lib/utils" -import type { ContentMode } from "./types" +import { + CONTENT_MODE_OPTIONS, + type ContentMode, +} from "./types" type EditorModeSwitchProps = { value: ContentMode + allowedModes?: ReadonlyArray disabled?: boolean onChange: (nextMode: ContentMode) => void } @@ -17,13 +21,20 @@ const MODE_OPTIONS: Array<{ value: ContentMode; label: string }> = [ export function EditorModeSwitch({ value, + allowedModes = CONTENT_MODE_OPTIONS, disabled = false, onChange, }: EditorModeSwitchProps) { + const options = MODE_OPTIONS.filter((option) => allowedModes.includes(option.value)) + + if (options.length <= 1) { + return null + } + return (
- {MODE_OPTIONS.map((option) => { + {options.map((option) => { const active = option.value === value return (