mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
change up verbage and break out hook
This commit is contained in:
parent
35488c706f
commit
5ad17ee691
6 changed files with 46 additions and 41 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
} from "src/core/StashService";
|
||||
import { withoutTypename } from "src/utils/data";
|
||||
import { useConfigurationContext } from "src/hooks/Config";
|
||||
import { useAutoTagTrigger } from "src/hooks/useAutoTagTrigger";
|
||||
import { IdentifyDialog } from "../../Dialogs/IdentifyDialog/IdentifyDialog";
|
||||
import * as GQL from "src/core/generated-graphql";
|
||||
import { DirectorySelectionDialog } from "./DirectorySelectionDialog";
|
||||
|
|
@ -201,13 +202,10 @@ export const LibraryTasks: React.FC = () => {
|
|||
});
|
||||
}
|
||||
|
||||
function onAutoTagClick() {
|
||||
if (configuration?.interface.disableAutoTagWarning) {
|
||||
runAutoTag();
|
||||
return;
|
||||
}
|
||||
setDialogOpen({ autoTagAlert: true });
|
||||
}
|
||||
const onAutoTagClick = useAutoTagTrigger(
|
||||
() => runAutoTag(),
|
||||
() => setDialogOpen({ autoTagAlert: true })
|
||||
);
|
||||
|
||||
function renderScanDialog() {
|
||||
if (!dialogOpen.scan) {
|
||||
|
|
@ -484,8 +482,8 @@ export const LibraryTasks: React.FC = () => {
|
|||
/>
|
||||
<BooleanSetting
|
||||
id="disable_auto_tag_warning"
|
||||
headingID="config.tasks.auto_tag.skip_warning.heading"
|
||||
subHeadingID="config.tasks.auto_tag.skip_warning.description"
|
||||
headingID="config.tasks.auto_tag.disable_warning.heading"
|
||||
subHeadingID="config.tasks.auto_tag.disable_warning.description"
|
||||
checked={iface.disableAutoTagWarning ?? undefined}
|
||||
onChange={(v) => saveInterface({ disableAutoTagWarning: v })}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { FormattedMessage, useIntl } from "react-intl";
|
|||
import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
|
||||
import { useConfigureInterface } from "src/core/StashService";
|
||||
import { SettingStateContext } from "src/components/Settings/context";
|
||||
import { useToast } from "src/hooks/Toast";
|
||||
import { ModalComponent } from "./Modal";
|
||||
import { Icon } from "./Icon";
|
||||
|
||||
|
|
@ -34,30 +35,28 @@ export const AutoTagConfirmDialog: React.FC<IAutoTagConfirmDialog> = ({
|
|||
onCancel,
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const Toast = useToast();
|
||||
const [dontShowAgain, setDontShowAgain] = useState(false);
|
||||
const [configureInterface] = useConfigureInterface();
|
||||
// route through SettingsContext when available so the Settings panel's
|
||||
// local state reflects the change without a page refresh
|
||||
const settingsContext = useContext(SettingStateContext);
|
||||
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
setDontShowAgain(false);
|
||||
}
|
||||
}, [show]);
|
||||
// route through SettingsContext when available so the Settings panel's
|
||||
// local state reflects the change without a page refresh
|
||||
const settingsContext = useContext(SettingStateContext);
|
||||
|
||||
async function handleConfirm() {
|
||||
function handleConfirm() {
|
||||
if (dontShowAgain) {
|
||||
try {
|
||||
if (settingsContext) {
|
||||
settingsContext.saveInterface({ disableAutoTagWarning: true });
|
||||
} else {
|
||||
await configureInterface({
|
||||
variables: { input: { disableAutoTagWarning: true } },
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// preference persistence failure must not block the confirmed action
|
||||
if (settingsContext) {
|
||||
// context's saveInterface already surfaces errors via its own toast
|
||||
settingsContext.saveInterface({ disableAutoTagWarning: true });
|
||||
} else {
|
||||
configureInterface({
|
||||
variables: { input: { disableAutoTagWarning: true } },
|
||||
}).catch((e) => Toast.error(e));
|
||||
}
|
||||
}
|
||||
onConfirm();
|
||||
|
|
@ -88,4 +87,4 @@ export const AutoTagConfirmDialog: React.FC<IAutoTagConfirmDialog> = ({
|
|||
/>
|
||||
</ModalComponent>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { Button, Dropdown, Modal, SplitButton } from "react-bootstrap";
|
||||
import React, { useState } from "react";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { useConfigurationContext } from "src/hooks/Config";
|
||||
import { useAutoTagTrigger } from "src/hooks/useAutoTagTrigger";
|
||||
import { ImageInput } from "./ImageInput";
|
||||
import { AutoTagConfirmDialog } from "./AutoTagConfirmDialog";
|
||||
import cx from "classnames";
|
||||
|
|
@ -31,22 +31,13 @@ interface IProps {
|
|||
|
||||
export const DetailsEditNavbar: React.FC<IProps> = (props: IProps) => {
|
||||
const intl = useIntl();
|
||||
const { configuration } = useConfigurationContext();
|
||||
const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState<boolean>(false);
|
||||
const [isAutoTagAlertOpen, setIsAutoTagAlertOpen] = useState<boolean>(false);
|
||||
|
||||
const skipAutoTagWarning =
|
||||
configuration?.interface.disableAutoTagWarning ?? false;
|
||||
|
||||
function onAutoTagClick() {
|
||||
if (skipAutoTagWarning) {
|
||||
if (props.onAutoTag) {
|
||||
props.onAutoTag();
|
||||
}
|
||||
return;
|
||||
}
|
||||
setIsAutoTagAlertOpen(true);
|
||||
}
|
||||
const onAutoTagClick = useAutoTagTrigger(
|
||||
() => props.onAutoTag?.(),
|
||||
() => setIsAutoTagAlertOpen(true)
|
||||
);
|
||||
|
||||
function renderEditButton() {
|
||||
if (props.isNew) return;
|
||||
|
|
|
|||
|
|
@ -51,4 +51,4 @@ Performers or Tags that have Ignore Auto tag flag added to them will be skipped
|
|||
|
||||
### Skip the confirmation warning
|
||||
|
||||
A confirmation warning is shown before Auto tag runs. If you use Auto tag frequently you can bypass this warning by ticking the **Don't show this warning again** checkbox on the warning dialog, or by enabling **Settings → Tasks → Auto Tag → Skip auto tag warning**.
|
||||
A confirmation warning is shown before Auto tag runs. If you use Auto tag frequently you can bypass this warning by ticking the **Don't show this warning again** checkbox on the warning dialog, or by enabling **Settings → Tasks → Auto Tag → Disable auto tag warning**.
|
||||
|
|
|
|||
17
ui/v2.5/src/hooks/useAutoTagTrigger.ts
Normal file
17
ui/v2.5/src/hooks/useAutoTagTrigger.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { useConfigurationContext } from "./Config";
|
||||
|
||||
// Centralises the "skip warning" check so every entry point to auto tag
|
||||
// consults the same interface flag.
|
||||
export function useAutoTagTrigger(
|
||||
onRun: () => void,
|
||||
onOpenConfirm: () => void
|
||||
) {
|
||||
const { configuration } = useConfigurationContext();
|
||||
return () => {
|
||||
if (configuration?.interface.disableAutoTagWarning) {
|
||||
onRun();
|
||||
return;
|
||||
}
|
||||
onOpenConfirm();
|
||||
};
|
||||
}
|
||||
|
|
@ -510,9 +510,9 @@
|
|||
"auto_tag": {
|
||||
"auto_tagging_all_paths": "Auto tagging all paths",
|
||||
"auto_tagging_paths": "Auto tagging the following paths",
|
||||
"skip_warning": {
|
||||
"disable_warning": {
|
||||
"description": "Skip the confirmation warning shown before running auto tag.",
|
||||
"heading": "Skip auto tag warning"
|
||||
"heading": "Disable auto tag warning"
|
||||
}
|
||||
},
|
||||
"auto_tag_based_on_filenames": "Auto tag content based on file paths.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue