-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.jsx
73 lines (68 loc) · 2.24 KB
/
Settings.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const React = require("react");
const {
SwitchItem,
TextInput,
ButtonItem,
} = require("@vizality/components/settings");
const { Button } = require("@vizality/components");
module.exports = class Settings extends React.Component {
render() {
const { getSetting, toggleSetting, updateSetting } = this.props;
return (
<div>
<TextInput
note="Text to replace your token with"
defaultValue={getSetting("tokenReplacer", "[REDACTED]")}
onChange={(val) => updateSetting("tokenReplacer", val)}
>
Token Replacer
</TextInput>
<TextInput
note="Custom formatting! Check out the github repo for more info."
defaultValue={getSetting(
"evalFormat",
"⏱️ Took {time}{n}🔍 Typeof {type}{n}{output}"
)}
onChange={(val) => updateSetting("evalFormat", val)}
>
Output Formatting
</TextInput>
<TextInput
note="Amount of messages to cache for auto completion"
defaultValue={getSetting("autoCompleteAmount", 25)}
onChange={(val) =>
updateSetting("autoCompleteAmount", isNaN(val) ? 25 : Number(val))
}
disabled={!getSetting("autoCompleteToggle")}
>
Auto Complete
</TextInput>
<SwitchItem
note="Turns auto complete on or off."
value={getSetting("autoCompleteToggle", true)}
onChange={() => toggleSetting("autoCompleteToggle")}
>
Auto Complete
</SwitchItem>
<SwitchItem
note="For the users who are inexpirenced. I'm not sure why you'd want this, but it's here just in case."
value={getSetting("safeEval", false)}
onChange={() => toggleSetting("safeEval")}
>
Basic/Safe Evaluate
</SwitchItem>
<ButtonItem
note="Clear all of the auto complete cache, just in case."
disabled={!getSetting("autoCompleteToggle")}
button="Clear Data"
color={Button.Colors.RED}
onClick={() =>
(vizality.api.commands.commands["eval"].messages = [])
}
>
Clear Auto Complete Cache
</ButtonItem>
</div>
);
}
};