2024-12-13 03:50:05 -08:00
|
|
|
import {
|
|
|
|
Popover,
|
|
|
|
ActionIcon,
|
|
|
|
Fieldset,
|
|
|
|
Checkbox,
|
|
|
|
Stack,
|
|
|
|
Group,
|
|
|
|
NumberInput,
|
|
|
|
} from "@mantine/core";
|
2024-03-14 04:07:13 -07:00
|
|
|
import { IconSettings } from "@tabler/icons-react";
|
|
|
|
import { FC } from "react";
|
2024-07-15 13:19:47 -07:00
|
|
|
import { useAppDispatch } from "../state/hooks";
|
|
|
|
import { updateSettings, useSettings } from "../state/settingsSlice";
|
2024-09-13 05:43:05 -07:00
|
|
|
import { actionIconStyle } from "../styles";
|
2024-03-14 04:07:13 -07:00
|
|
|
|
|
|
|
const SettingsMenu: FC = () => {
|
|
|
|
const {
|
|
|
|
useLocalTime,
|
|
|
|
enableQueryHistory,
|
|
|
|
enableAutocomplete,
|
|
|
|
enableSyntaxHighlighting,
|
|
|
|
enableLinter,
|
|
|
|
showAnnotations,
|
2024-12-13 03:50:05 -08:00
|
|
|
ruleGroupsPerPage,
|
|
|
|
alertGroupsPerPage,
|
2024-07-15 13:19:47 -07:00
|
|
|
} = useSettings();
|
2024-03-14 04:07:13 -07:00
|
|
|
const dispatch = useAppDispatch();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Popover position="bottom" withArrow shadow="md">
|
|
|
|
<Popover.Target>
|
2024-09-09 09:55:32 -07:00
|
|
|
<ActionIcon
|
|
|
|
color="gray"
|
|
|
|
title="Settings"
|
|
|
|
aria-label="Settings"
|
|
|
|
size={32}
|
|
|
|
>
|
2024-09-13 05:43:05 -07:00
|
|
|
<IconSettings style={actionIconStyle} />
|
2024-03-14 04:07:13 -07:00
|
|
|
</ActionIcon>
|
|
|
|
</Popover.Target>
|
|
|
|
<Popover.Dropdown>
|
2024-12-13 03:50:05 -08:00
|
|
|
<Group align="flex-start">
|
|
|
|
<Stack>
|
|
|
|
<Fieldset p="md" legend="Global settings">
|
2024-03-14 04:07:13 -07:00
|
|
|
<Checkbox
|
2024-12-13 03:50:05 -08:00
|
|
|
checked={useLocalTime}
|
|
|
|
label="Use local time"
|
2024-03-14 04:07:13 -07:00
|
|
|
onChange={(event) =>
|
|
|
|
dispatch(
|
|
|
|
updateSettings({
|
2024-12-13 03:50:05 -08:00
|
|
|
useLocalTime: event.currentTarget.checked,
|
2024-03-14 04:07:13 -07:00
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
2024-12-13 03:50:05 -08:00
|
|
|
</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>
|
|
|
|
</Stack>
|
|
|
|
|
|
|
|
<Stack>
|
|
|
|
<Fieldset p="md" legend="Alerts page settings">
|
2024-03-14 04:07:13 -07:00
|
|
|
<Checkbox
|
2024-12-13 03:50:05 -08:00
|
|
|
checked={showAnnotations}
|
|
|
|
label="Show expanded annotations"
|
2024-03-14 04:07:13 -07:00
|
|
|
onChange={(event) =>
|
|
|
|
dispatch(
|
|
|
|
updateSettings({
|
2024-12-13 03:50:05 -08:00
|
|
|
showAnnotations: event.currentTarget.checked,
|
2024-03-14 04:07:13 -07:00
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
/>
|
2024-12-13 03:50:05 -08:00
|
|
|
</Fieldset>
|
|
|
|
<Fieldset p="md" legend="Alerts page settings">
|
|
|
|
<NumberInput
|
|
|
|
min={1}
|
|
|
|
allowDecimal={false}
|
|
|
|
label="Alert groups per page"
|
|
|
|
value={alertGroupsPerPage}
|
|
|
|
onChange={(value) => {
|
|
|
|
if (typeof value !== "number") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-03-14 04:07:13 -07:00
|
|
|
dispatch(
|
|
|
|
updateSettings({
|
2024-12-13 03:50:05 -08:00
|
|
|
alertGroupsPerPage: value,
|
2024-03-14 04:07:13 -07:00
|
|
|
})
|
2024-12-13 03:50:05 -08:00
|
|
|
);
|
|
|
|
}}
|
2024-03-14 04:07:13 -07:00
|
|
|
/>
|
2024-12-13 03:50:05 -08:00
|
|
|
</Fieldset>
|
|
|
|
<Fieldset p="md" legend="Rules page settings">
|
|
|
|
<NumberInput
|
|
|
|
min={1}
|
|
|
|
allowDecimal={false}
|
|
|
|
label="Rule groups per page"
|
|
|
|
value={ruleGroupsPerPage}
|
|
|
|
onChange={(value) => {
|
|
|
|
if (typeof value !== "number") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-03-14 04:07:13 -07:00
|
|
|
dispatch(
|
|
|
|
updateSettings({
|
2024-12-13 03:50:05 -08:00
|
|
|
ruleGroupsPerPage: value,
|
2024-03-14 04:07:13 -07:00
|
|
|
})
|
2024-12-13 03:50:05 -08:00
|
|
|
);
|
|
|
|
}}
|
2024-03-14 04:07:13 -07:00
|
|
|
/>
|
2024-12-13 03:50:05 -08:00
|
|
|
</Fieldset>
|
|
|
|
</Stack>
|
|
|
|
</Group>
|
2024-03-14 04:07:13 -07:00
|
|
|
</Popover.Dropdown>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SettingsMenu;
|