Add option to disable create from dropdown (#1814)

* Convert config hooks to common context
* Add option to disable creating from dropdown
This commit is contained in:
WithoutPants
2021-10-11 17:45:58 +11:00
committed by GitHub
parent 46ae4581b8
commit b5381ff071
24 changed files with 269 additions and 130 deletions

View File

@@ -4,6 +4,7 @@ import { useIntl } from "react-intl";
import { DurationInput, LoadingIndicator } from "src/components/Shared";
import { useConfiguration, useConfigureInterface } from "src/core/StashService";
import { useToast } from "src/hooks";
import * as GQL from "src/core/generated-graphql";
import { CheckboxGroup } from "./CheckboxGroup";
const allMenuItems = [
@@ -38,6 +39,10 @@ export const SettingsInterfacePanel: React.FC = () => {
const [language, setLanguage] = useState<string>("en");
const [handyKey, setHandyKey] = useState<string>();
const [funscriptOffset, setFunscriptOffset] = useState<number>(0);
const [
disableDropdownCreate,
setDisableDropdownCreate,
] = useState<GQL.ConfigDisableDropdownCreateInput>({});
const [updateInterfaceConfig] = useConfigureInterface({
menuItems: menuItemIds,
@@ -53,6 +58,7 @@ export const SettingsInterfacePanel: React.FC = () => {
slideshowDelay,
handyKey,
funscriptOffset,
disableDropdownCreate,
});
useEffect(() => {
@@ -70,6 +76,11 @@ export const SettingsInterfacePanel: React.FC = () => {
setSlideshowDelay(iCfg?.slideshowDelay ?? 5000);
setHandyKey(iCfg?.handyKey ?? "");
setFunscriptOffset(iCfg?.funscriptOffset ?? 0);
setDisableDropdownCreate({
performer: iCfg?.disabledDropdownCreate.performer,
studio: iCfg?.disabledDropdownCreate.studio,
tag: iCfg?.disabledDropdownCreate.tag,
});
}, [config]);
async function onSave() {
@@ -257,6 +268,64 @@ export const SettingsInterfacePanel: React.FC = () => {
</Form.Text>
</Form.Group>
<Form.Group>
<h5>{intl.formatMessage({ id: "config.ui.editing.heading" })}</h5>
<Form.Group>
<h6>
{intl.formatMessage({
id: "config.ui.editing.disable_dropdown_create.heading",
})}
</h6>
<Form.Check
id="disableDropdownCreate_performer"
checked={disableDropdownCreate.performer ?? false}
label={intl.formatMessage({
id: "performer",
})}
onChange={() => {
setDisableDropdownCreate({
...disableDropdownCreate,
performer: !disableDropdownCreate.performer ?? true,
});
}}
/>
<Form.Check
id="disableDropdownCreate_studio"
checked={disableDropdownCreate.studio ?? false}
label={intl.formatMessage({
id: "studio",
})}
onChange={() => {
setDisableDropdownCreate({
...disableDropdownCreate,
studio: !disableDropdownCreate.studio ?? true,
});
}}
/>
<Form.Check
id="disableDropdownCreate_tag"
checked={disableDropdownCreate.tag ?? false}
label={intl.formatMessage({
id: "tag",
})}
onChange={() => {
setDisableDropdownCreate({
...disableDropdownCreate,
tag: !disableDropdownCreate.tag ?? true,
});
}}
/>
<Form.Text className="text-muted">
{intl.formatMessage({
id: "config.ui.editing.disable_dropdown_create.description",
})}
</Form.Text>
</Form.Group>
</Form.Group>
<Form.Group>
<h5>{intl.formatMessage({ id: "config.ui.custom_css.heading" })}</h5>
<Form.Check