import { Box, Center, Checkbox, createStyles, Group, Paper, Stack, Text, Title, } from '@mantine/core'; import { IconBrandDocker, IconLayout, IconSearch } from '@tabler/icons'; import { ChangeEvent, Dispatch, SetStateAction, useState } from 'react'; import { useConfigContext } from '../../../config/provider'; import { useConfigStore } from '../../../config/store'; import { CustomizationSettingsType } from '../../../types/settings'; import { Logo } from '../../layout/Logo'; interface LayoutSelectorProps { defaultLayout: CustomizationSettingsType['layout'] | undefined; } // TODO: add translations export const LayoutSelector = ({ defaultLayout }: LayoutSelectorProps) => { const { classes } = useStyles(); const { name: configName } = useConfigContext(); const updateConfig = useConfigStore((x) => x.updateConfig); const [leftSidebar, setLeftSidebar] = useState(defaultLayout?.enabledLeftSidebar ?? true); const [rightSidebar, setRightSidebar] = useState(defaultLayout?.enabledRightSidebar ?? true); const [docker, setDocker] = useState(defaultLayout?.enabledDocker ?? false); const [ping, setPing] = useState(defaultLayout?.enabledPing ?? false); const [searchBar, setSearchBar] = useState(defaultLayout?.enabledSearchbar ?? false); if (!configName) return null; const handleChange = ( key: keyof CustomizationSettingsType['layout'], event: ChangeEvent, setState: Dispatch> ) => { const value = event.target.checked; setState(value); updateConfig(configName, (prev) => { const layout = prev.settings.customization.layout; layout[key] = value; return { ...prev, settings: { ...prev.settings, customization: { ...prev.settings.customization, layout, }, }, }; }); }; return ( Dashboard layout You can adjust the layout of the Dashboard to your preferences. The main are cannot be turned on or off {searchBar ? ( Search ) : null} {docker ? : null} {leftSidebar && (
Sidebar
)} Main Can be used for categories,
services and integrations
{rightSidebar && (
Sidebar
)}
handleChange('enabledLeftSidebar', ev, setLeftSidebar)} /> handleChange('enabledRightSidebar', ev, setRightSidebar)} /> handleChange('enabledSearchbar', ev, setSearchBar)} /> handleChange('enabledDocker', ev, setDocker)} /> handleChange('enabledPing', ev, setPing)} />
); }; const useStyles = createStyles((theme) => ({ main: { flexGrow: 1, }, box: { backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[1], borderRadius: theme.radius.md, }, }));