|
1 | 1 | import React from "react"; |
2 | | -import { OnloadArgs } from "roamjs-components/types"; |
3 | | -import { Label, NumericInput, Checkbox } from "@blueprintjs/core"; |
| 2 | +import { Label } from "@blueprintjs/core"; |
4 | 3 | import Description from "roamjs-components/components/Description"; |
5 | | -import { getSettings } from "~/utils/parseResultSettings"; |
6 | | -import { DEFAULT_PAGE_SIZE_KEY, HIDE_METADATA_KEY } from "~/data/userSettings"; |
7 | 4 | import DefaultFilters from "./DefaultFilters"; |
8 | | -import QueryPagesPanel from "./QueryPagesPanel"; |
9 | | -import { setSetting } from "~/utils/extensionSettings"; |
| 5 | +import { |
| 6 | + PersonalFlagPanel, |
| 7 | + PersonalNumberPanel, |
| 8 | + PersonalMultiTextPanel, |
| 9 | +} from "./components/BlockPropSettingPanels"; |
10 | 10 |
|
11 | | -const QuerySettings = ({ |
12 | | - extensionAPI, |
13 | | -}: { |
14 | | - extensionAPI: OnloadArgs["extensionAPI"]; |
15 | | -}) => { |
16 | | - const { globalPageSize, hideMetadata } = getSettings(extensionAPI); |
| 11 | +const QuerySettings = () => { |
17 | 12 | return ( |
18 | 13 | <div className="flex flex-col gap-4 p-1"> |
19 | | - <Checkbox |
20 | | - defaultChecked={hideMetadata} |
21 | | - onChange={(e) => { |
22 | | - const target = e.target as HTMLInputElement; |
23 | | - void setSetting<boolean>(HIDE_METADATA_KEY, target.checked); |
24 | | - }} |
25 | | - labelElement={ |
26 | | - <> |
27 | | - Hide Query Metadata |
28 | | - <Description |
29 | | - description={ |
30 | | - "Hide the Roam blocks that are used to power each query" |
31 | | - } |
32 | | - /> |
33 | | - </> |
34 | | - } |
| 14 | + <PersonalFlagPanel |
| 15 | + title="Hide Query Metadata" |
| 16 | + description="Hide the Roam blocks that are used to power each query" |
| 17 | + settingKeys={["Query", "Hide Query Metadata"]} |
| 18 | + defaultValue={false} |
| 19 | + /> |
| 20 | + <PersonalNumberPanel |
| 21 | + title="Default Page Size" |
| 22 | + description="The default page size used for query results" |
| 23 | + settingKeys={["Query", "Default Page Size"]} |
| 24 | + defaultValue={10} |
| 25 | + min={1} |
| 26 | + /> |
| 27 | + <PersonalMultiTextPanel |
| 28 | + title="Query Pages" |
| 29 | + description="The title formats of pages that you would like to serve as pages that generate queries" |
| 30 | + settingKeys={["Query", "Query Pages"]} |
| 31 | + defaultValue={[]} |
35 | 32 | /> |
36 | | - <Label> |
37 | | - Default Page Size |
38 | | - <Description |
39 | | - description={"The default page size used for query results"} |
40 | | - /> |
41 | | - <NumericInput |
42 | | - defaultValue={globalPageSize.toString()} |
43 | | - onValueChange={(value) => |
44 | | - void extensionAPI.settings.set(DEFAULT_PAGE_SIZE_KEY, value) |
45 | | - } |
46 | | - /> |
47 | | - </Label> |
48 | | - <Label> |
49 | | - Query Pages |
50 | | - <Description |
51 | | - description={ |
52 | | - "The title formats of pages that you would like to serve as pages that generate queries" |
53 | | - } |
54 | | - /> |
55 | | - <QueryPagesPanel extensionAPI={extensionAPI} /> |
56 | | - </Label> |
57 | 33 | <Label> |
58 | 34 | Default Filters |
59 | 35 | <Description |
60 | 36 | description={ |
61 | 37 | "Any filters that should be applied to your results by default" |
62 | 38 | } |
63 | 39 | /> |
64 | | - <DefaultFilters extensionAPI={extensionAPI} /> |
| 40 | + <DefaultFilters /> |
65 | 41 | </Label> |
66 | 42 | </div> |
67 | 43 | ); |
|
0 commit comments