mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add Settings menu, make menu links left-justified again
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
121d92209d
commit
796d1806da
|
@ -12,10 +12,14 @@ import {
|
||||||
Box,
|
Box,
|
||||||
Burger,
|
Burger,
|
||||||
Button,
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
Fieldset,
|
||||||
Group,
|
Group,
|
||||||
MantineProvider,
|
MantineProvider,
|
||||||
Menu,
|
Menu,
|
||||||
|
Popover,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
Transition,
|
Transition,
|
||||||
createTheme,
|
createTheme,
|
||||||
|
@ -65,6 +69,7 @@ import { SettingsContext } from "./settings";
|
||||||
import { Notifications } from "@mantine/notifications";
|
import { Notifications } from "@mantine/notifications";
|
||||||
import { useAppDispatch } from "./state/hooks";
|
import { useAppDispatch } from "./state/hooks";
|
||||||
import { updateSettings } from "./state/settingsSlice";
|
import { updateSettings } from "./state/settingsSlice";
|
||||||
|
import SettingsMenu from "./SettingsMenu";
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
|
@ -294,36 +299,18 @@ function App() {
|
||||||
<AppShell.Header bg="rgb(65, 73, 81)" c="#fff">
|
<AppShell.Header bg="rgb(65, 73, 81)" c="#fff">
|
||||||
<Group h="100%" px="md">
|
<Group h="100%" px="md">
|
||||||
<Group style={{ flex: 1 }} justify="space-between">
|
<Group style={{ flex: 1 }} justify="space-between">
|
||||||
<Group gap={10} w={150}>
|
<Group gap={65}>
|
||||||
<img src={PrometheusLogo} height={30} />
|
<Group gap={10}>
|
||||||
<Text fz={20}>Prometheus{agentMode && " Agent"}</Text>
|
<img src={PrometheusLogo} height={30} />
|
||||||
|
<Text fz={20}>Prometheus{agentMode && " Agent"}</Text>
|
||||||
|
</Group>
|
||||||
|
<Group gap={12} visibleFrom="sm">
|
||||||
|
{navLinks}
|
||||||
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<Group gap={12} visibleFrom="sm">
|
<Group visibleFrom="xs">
|
||||||
{navLinks}
|
<ThemeSelector />
|
||||||
</Group>
|
<SettingsMenu />
|
||||||
<Group w={180} justify="flex-end">
|
|
||||||
{<ThemeSelector />}
|
|
||||||
<Menu shadow="md" width={200}>
|
|
||||||
<Menu.Target>
|
|
||||||
<ActionIcon
|
|
||||||
// variant=""
|
|
||||||
color="gray"
|
|
||||||
aria-label="Settings"
|
|
||||||
size="md"
|
|
||||||
>
|
|
||||||
<IconSettings size={navLinkIconSize} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Menu.Target>
|
|
||||||
<Menu.Dropdown>
|
|
||||||
<Menu.Item
|
|
||||||
component={NavLink}
|
|
||||||
to="/"
|
|
||||||
leftSection={<IconAdjustments />}
|
|
||||||
>
|
|
||||||
Settings
|
|
||||||
</Menu.Item>
|
|
||||||
</Menu.Dropdown>
|
|
||||||
</Menu>
|
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<Burger
|
<Burger
|
||||||
|
@ -338,6 +325,10 @@ function App() {
|
||||||
|
|
||||||
<AppShell.Navbar py="md" px={4} bg="rgb(65, 73, 81)" c="#fff">
|
<AppShell.Navbar py="md" px={4} bg="rgb(65, 73, 81)" c="#fff">
|
||||||
{navLinks}
|
{navLinks}
|
||||||
|
<Group mt="md" hiddenFrom="xs" justify="center">
|
||||||
|
<ThemeSelector />
|
||||||
|
<SettingsMenu />
|
||||||
|
</Group>
|
||||||
</AppShell.Navbar>
|
</AppShell.Navbar>
|
||||||
|
|
||||||
<AppShell.Main>
|
<AppShell.Main>
|
||||||
|
|
112
web/ui/mantine-ui/src/SettingsMenu.tsx
Normal file
112
web/ui/mantine-ui/src/SettingsMenu.tsx
Normal file
|
@ -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 (
|
||||||
|
<Popover position="bottom" withArrow shadow="md">
|
||||||
|
<Popover.Target>
|
||||||
|
<ActionIcon
|
||||||
|
// variant=""
|
||||||
|
color="gray"
|
||||||
|
aria-label="Settings"
|
||||||
|
size={32}
|
||||||
|
>
|
||||||
|
<IconSettings size={20} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Popover.Target>
|
||||||
|
<Popover.Dropdown>
|
||||||
|
<Stack>
|
||||||
|
<Fieldset p="md" legend="Global settings">
|
||||||
|
<Checkbox
|
||||||
|
checked={useLocalTime}
|
||||||
|
label="Use local time"
|
||||||
|
onChange={(event) =>
|
||||||
|
dispatch(
|
||||||
|
updateSettings({ useLocalTime: event.currentTarget.checked })
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Fieldset>
|
||||||
|
|
||||||
|
<Fieldset p="md" legend="Query page settings">
|
||||||
|
<Stack>
|
||||||
|
<Checkbox
|
||||||
|
checked={enableQueryHistory}
|
||||||
|
label="Enable query history"
|
||||||
|
onChange={(event) =>
|
||||||
|
dispatch(
|
||||||
|
updateSettings({
|
||||||
|
enableQueryHistory: event.currentTarget.checked,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
checked={enableAutocomplete}
|
||||||
|
label="Enable autocomplete"
|
||||||
|
onChange={(event) =>
|
||||||
|
dispatch(
|
||||||
|
updateSettings({
|
||||||
|
enableAutocomplete: event.currentTarget.checked,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
checked={enableSyntaxHighlighting}
|
||||||
|
label="Enable syntax highlighting"
|
||||||
|
onChange={(event) =>
|
||||||
|
dispatch(
|
||||||
|
updateSettings({
|
||||||
|
enableSyntaxHighlighting: event.currentTarget.checked,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
checked={enableLinter}
|
||||||
|
label="Enable linter"
|
||||||
|
onChange={(event) =>
|
||||||
|
dispatch(
|
||||||
|
updateSettings({
|
||||||
|
enableLinter: event.currentTarget.checked,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Fieldset>
|
||||||
|
|
||||||
|
<Fieldset p="md" legend="Alerts page settings">
|
||||||
|
<Checkbox
|
||||||
|
checked={showAnnotations}
|
||||||
|
label="Show expanded annotations"
|
||||||
|
onChange={(event) =>
|
||||||
|
dispatch(
|
||||||
|
updateSettings({
|
||||||
|
showAnnotations: event.currentTarget.checked,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Fieldset>
|
||||||
|
</Stack>
|
||||||
|
</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SettingsMenu;
|
|
@ -2,10 +2,22 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
interface Settings {
|
interface Settings {
|
||||||
pathPrefix: string;
|
pathPrefix: string;
|
||||||
|
useLocalTime: boolean;
|
||||||
|
enableQueryHistory: boolean;
|
||||||
|
enableAutocomplete: boolean;
|
||||||
|
enableSyntaxHighlighting: boolean;
|
||||||
|
enableLinter: boolean;
|
||||||
|
showAnnotations: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: Settings = {
|
const initialState: Settings = {
|
||||||
pathPrefix: "",
|
pathPrefix: "",
|
||||||
|
useLocalTime: false,
|
||||||
|
enableQueryHistory: false,
|
||||||
|
enableAutocomplete: true,
|
||||||
|
enableSyntaxHighlighting: true,
|
||||||
|
enableLinter: true,
|
||||||
|
showAnnotations: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const settingsSlice = createSlice({
|
export const settingsSlice = createSlice({
|
||||||
|
|
Loading…
Reference in a new issue