diff --git a/web/ui/mantine-ui/src/App.tsx b/web/ui/mantine-ui/src/App.tsx index 565f21045..c7189bfda 100644 --- a/web/ui/mantine-ui/src/App.tsx +++ b/web/ui/mantine-ui/src/App.tsx @@ -12,10 +12,14 @@ import { Box, Burger, Button, + Checkbox, + Fieldset, Group, MantineProvider, Menu, + Popover, Skeleton, + Stack, Text, Transition, createTheme, @@ -65,6 +69,7 @@ import { SettingsContext } from "./settings"; import { Notifications } from "@mantine/notifications"; import { useAppDispatch } from "./state/hooks"; import { updateSettings } from "./state/settingsSlice"; +import SettingsMenu from "./SettingsMenu"; const queryClient = new QueryClient(); @@ -294,36 +299,18 @@ function App() { - - - Prometheus{agentMode && " Agent"} + + + + Prometheus{agentMode && " Agent"} + + + {navLinks} + - - {navLinks} - - - {} - - - - - - - - } - > - Settings - - - + + + {navLinks} + + + + diff --git a/web/ui/mantine-ui/src/SettingsMenu.tsx b/web/ui/mantine-ui/src/SettingsMenu.tsx new file mode 100644 index 000000000..5546b820a --- /dev/null +++ b/web/ui/mantine-ui/src/SettingsMenu.tsx @@ -0,0 +1,112 @@ +import { Popover, ActionIcon, Fieldset, Checkbox, Stack } from "@mantine/core"; +import { IconSettings } from "@tabler/icons-react"; +import { FC } from "react"; +import { useAppDispatch, useAppSelector } from "./state/hooks"; +import { updateSettings } from "./state/settingsSlice"; + +const SettingsMenu: FC = () => { + const { + useLocalTime, + enableQueryHistory, + enableAutocomplete, + enableSyntaxHighlighting, + enableLinter, + showAnnotations, + } = useAppSelector((state) => state.settings); + const dispatch = useAppDispatch(); + + return ( + + + + + + + + +
+ + dispatch( + updateSettings({ useLocalTime: event.currentTarget.checked }) + ) + } + /> +
+ +
+ + + dispatch( + updateSettings({ + enableQueryHistory: event.currentTarget.checked, + }) + ) + } + /> + + dispatch( + updateSettings({ + enableAutocomplete: event.currentTarget.checked, + }) + ) + } + /> + + dispatch( + updateSettings({ + enableSyntaxHighlighting: event.currentTarget.checked, + }) + ) + } + /> + + dispatch( + updateSettings({ + enableLinter: event.currentTarget.checked, + }) + ) + } + /> + +
+ +
+ + dispatch( + updateSettings({ + showAnnotations: event.currentTarget.checked, + }) + ) + } + /> +
+
+
+
+ ); +}; + +export default SettingsMenu; diff --git a/web/ui/mantine-ui/src/state/settingsSlice.ts b/web/ui/mantine-ui/src/state/settingsSlice.ts index 9c979f558..199e63add 100644 --- a/web/ui/mantine-ui/src/state/settingsSlice.ts +++ b/web/ui/mantine-ui/src/state/settingsSlice.ts @@ -2,10 +2,22 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit"; interface Settings { pathPrefix: string; + useLocalTime: boolean; + enableQueryHistory: boolean; + enableAutocomplete: boolean; + enableSyntaxHighlighting: boolean; + enableLinter: boolean; + showAnnotations: boolean; } const initialState: Settings = { pathPrefix: "", + useLocalTime: false, + enableQueryHistory: false, + enableAutocomplete: true, + enableSyntaxHighlighting: true, + enableLinter: true, + showAnnotations: false, }; export const settingsSlice = createSlice({