mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
Merge 11a2289fdf into 01a7583364
This commit is contained in:
commit
c1a360597a
7 changed files with 92 additions and 5 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";
|
||||
|
|
@ -195,6 +196,12 @@ export const LibraryTasks: React.FC = () => {
|
|||
});
|
||||
}
|
||||
|
||||
const onAutoTagClick = useAutoTagTrigger(
|
||||
() => runAutoTag(),
|
||||
() => setDialogOpen({ autoTagAlert: true }),
|
||||
ui.disableAutoTagWarning
|
||||
);
|
||||
|
||||
function renderScanDialog() {
|
||||
if (!dialogOpen.scan) {
|
||||
return;
|
||||
|
|
@ -449,7 +456,7 @@ export const LibraryTasks: React.FC = () => {
|
|||
variant="secondary"
|
||||
type="submit"
|
||||
className="mr-2"
|
||||
onClick={() => setDialogOpen({ autoTagAlert: true })}
|
||||
onClick={onAutoTagClick}
|
||||
>
|
||||
<FormattedMessage id="actions.auto_tag" />…
|
||||
</Button>
|
||||
|
|
@ -468,6 +475,13 @@ export const LibraryTasks: React.FC = () => {
|
|||
options={autoTagOptions}
|
||||
setOptions={onSetAutoTagOptions}
|
||||
/>
|
||||
<BooleanSetting
|
||||
id="disable_auto_tag_warning"
|
||||
headingID="config.tasks.auto_tag.disable_warning.heading"
|
||||
subHeadingID="config.tasks.auto_tag.disable_warning.description"
|
||||
checked={ui.disableAutoTagWarning ?? undefined}
|
||||
onChange={(v) => saveUI({ disableAutoTagWarning: v })}
|
||||
/>
|
||||
</SettingGroup>
|
||||
</SettingSection>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import React from "react";
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { Form } from "react-bootstrap";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
|
||||
import { useConfigureUISetting } 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";
|
||||
|
||||
|
|
@ -31,6 +35,29 @@ export const AutoTagConfirmDialog: React.FC<IAutoTagConfirmDialog> = ({
|
|||
onCancel,
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const Toast = useToast();
|
||||
const [dontShowAgain, setDontShowAgain] = useState(false);
|
||||
const [saveUISetting] = useConfigureUISetting();
|
||||
const settingsContext = useContext(SettingStateContext);
|
||||
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
setDontShowAgain(false);
|
||||
}
|
||||
}, [show]);
|
||||
|
||||
function handleConfirm() {
|
||||
if (dontShowAgain) {
|
||||
if (settingsContext) {
|
||||
settingsContext.saveUI({ disableAutoTagWarning: true });
|
||||
} else {
|
||||
saveUISetting({
|
||||
variables: { key: "disableAutoTagWarning", value: true },
|
||||
}).catch((e: unknown) => Toast.error(e));
|
||||
}
|
||||
}
|
||||
onConfirm();
|
||||
}
|
||||
|
||||
return (
|
||||
<ModalComponent
|
||||
|
|
@ -40,13 +67,21 @@ export const AutoTagConfirmDialog: React.FC<IAutoTagConfirmDialog> = ({
|
|||
accept={{
|
||||
text: intl.formatMessage({ id: "actions.confirm" }),
|
||||
variant: "danger",
|
||||
onClick: onConfirm,
|
||||
onClick: handleConfirm,
|
||||
}}
|
||||
cancel={{
|
||||
onClick: onCancel,
|
||||
}}
|
||||
>
|
||||
<AutoTagWarning />
|
||||
<Form.Check
|
||||
id="auto-tag-dont-show-again"
|
||||
checked={dontShowAgain}
|
||||
onChange={(e) => setDontShowAgain(e.currentTarget.checked)}
|
||||
label={intl.formatMessage({
|
||||
id: "dialogs.dont_show_again",
|
||||
})}
|
||||
/>
|
||||
</ModalComponent>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { Button, Dropdown, Modal, SplitButton } from "react-bootstrap";
|
||||
import React, { useState } from "react";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { useAutoTagTrigger } from "src/hooks/useAutoTagTrigger";
|
||||
import { ImageInput } from "./ImageInput";
|
||||
import { AutoTagConfirmDialog } from "./AutoTagConfirmDialog";
|
||||
import cx from "classnames";
|
||||
|
|
@ -33,6 +34,11 @@ export const DetailsEditNavbar: React.FC<IProps> = (props: IProps) => {
|
|||
const [isDeleteAlertOpen, setIsDeleteAlertOpen] = useState<boolean>(false);
|
||||
const [isAutoTagAlertOpen, setIsAutoTagAlertOpen] = useState<boolean>(false);
|
||||
|
||||
const onAutoTagClick = useAutoTagTrigger(
|
||||
() => props.onAutoTag?.(),
|
||||
() => setIsAutoTagAlertOpen(true)
|
||||
);
|
||||
|
||||
function renderEditButton() {
|
||||
if (props.isNew) return;
|
||||
return (
|
||||
|
|
@ -116,7 +122,7 @@ export const DetailsEditNavbar: React.FC<IProps> = (props: IProps) => {
|
|||
<Button
|
||||
variant="secondary"
|
||||
disabled={props.autoTagDisabled}
|
||||
onClick={() => setIsAutoTagAlertOpen(true)}
|
||||
onClick={onAutoTagClick}
|
||||
>
|
||||
<FormattedMessage id="actions.auto_tag" />…
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ export interface IUIConfig {
|
|||
|
||||
taskDefaults?: Record<string, {}>;
|
||||
|
||||
// if true the auto tag confirmation warning is skipped
|
||||
disableAutoTagWarning?: boolean;
|
||||
|
||||
defaultFilters?: DefaultFilters;
|
||||
|
||||
taggerConfig?: ITaggerConfig;
|
||||
|
|
|
|||
|
|
@ -48,3 +48,7 @@ Performers or Tags that have Ignore Auto tag flag added to them will be skipped
|
|||
- **Auto tag:** You can run the Auto tag task on your entire library from the Tasks page.
|
||||
- **Selective auto tag:** You can run the Auto tag task on specific directories from the Tasks page.
|
||||
- **Individual pages:** You can run Auto tag tasks for specific Performers, Studios, and Tags from their respective pages.
|
||||
|
||||
### Disable the confirmation warning
|
||||
|
||||
A confirmation warning is shown before the auto tag task runs. If you use auto tag frequently, you can disable 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**.
|
||||
|
|
|
|||
20
ui/v2.5/src/hooks/useAutoTagTrigger.ts
Normal file
20
ui/v2.5/src/hooks/useAutoTagTrigger.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useCallback } from "react";
|
||||
import { IUIConfig } from "src/core/config";
|
||||
import { useConfigurationContext } from "./Config";
|
||||
|
||||
export function useAutoTagTrigger(
|
||||
onRun: () => void,
|
||||
onOpenConfirm: () => void,
|
||||
override?: boolean | null
|
||||
) {
|
||||
const { configuration } = useConfigurationContext();
|
||||
const ui = configuration?.ui as IUIConfig | undefined;
|
||||
const disabled = override ?? ui?.disableAutoTagWarning ?? false;
|
||||
return useCallback(() => {
|
||||
if (disabled) {
|
||||
onRun();
|
||||
return;
|
||||
}
|
||||
onOpenConfirm();
|
||||
}, [disabled, onRun, onOpenConfirm]);
|
||||
}
|
||||
|
|
@ -509,7 +509,11 @@
|
|||
"anonymising_database": "Anonymising database",
|
||||
"auto_tag": {
|
||||
"auto_tagging_all_paths": "Auto tagging all paths",
|
||||
"auto_tagging_paths": "Auto tagging the following paths"
|
||||
"auto_tagging_paths": "Auto tagging the following paths",
|
||||
"disable_warning": {
|
||||
"description": "Disable the confirmation warning shown before running auto tag.",
|
||||
"heading": "Disable auto tag warning"
|
||||
}
|
||||
},
|
||||
"auto_tag_based_on_filenames": "Auto tag content based on file paths.",
|
||||
"auto_tag_confirm": "This will attempt to match your content against existing metadata.",
|
||||
|
|
@ -1002,6 +1006,7 @@
|
|||
"delete_object_desc": "Are you sure you want to delete {count, plural, one {this {singularEntity}} other {these {pluralEntity}}}?",
|
||||
"delete_object_overflow": "…and {count} other {count, plural, one {{singularEntity}} other {{pluralEntity}}}.",
|
||||
"delete_object_title": "Delete {count, plural, one {{singularEntity}} other {{pluralEntity}}}",
|
||||
"dont_show_again": "Don't show this warning again",
|
||||
"dont_show_until_updated": "Don't show until next update",
|
||||
"edit_entity_title": "Edit {count, plural, one {{singularEntity}} other {{pluralEntity}}}",
|
||||
"edit_entity_count_title": "Edit {count} {count, plural, one {{singularEntity}} other {{pluralEntity}}}",
|
||||
|
|
|
|||
Loading…
Reference in a new issue