Identify: Options to skip multiple results and single name performers (#3707)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Flashy78
2023-07-10 21:37:00 -07:00
committed by GitHub
parent ff22577ce0
commit cbdd4d3cbf
19 changed files with 581 additions and 136 deletions

View File

@@ -1,10 +1,11 @@
import React from "react";
import { Form } from "react-bootstrap";
import { Col, Form, Row } from "react-bootstrap";
import * as GQL from "src/core/generated-graphql";
import { FormattedMessage, useIntl } from "react-intl";
import { IScraperSource } from "./constants";
import { FieldOptionsList } from "./FieldOptions";
import { ThreeStateBoolean } from "./ThreeStateBoolean";
import { TagSelect } from "src/components/Shared/Select";
interface IOptionsEditor {
options: GQL.IdentifyMetadataOptionsInput;
@@ -35,8 +36,76 @@ export const OptionsEditor: React.FC<IOptionsEditor> = ({
indeterminateClassname: "text-muted",
};
function maybeRenderMultipleMatchesTag() {
if (!options.skipMultipleMatches) {
return;
}
return (
<Form.Group controlId="match_tags" className="ml-3 mt-1 mb-0" as={Row}>
<Form.Label
column
sm={{ span: 4, offset: 1 }}
title={intl.formatMessage({
id: "config.tasks.identify.tag_skipped_matches_tooltip",
})}
>
<FormattedMessage id="config.tasks.identify.tag_skipped_matches" />
</Form.Label>
<Col sm>
<TagSelect
onSelect={(tags) =>
setOptions({
skipMultipleMatchTag: tags[0]?.id,
})
}
ids={
options.skipMultipleMatchTag ? [options.skipMultipleMatchTag] : []
}
noSelectionString="Select/create tag..."
/>
</Col>
</Form.Group>
);
}
function maybeRenderPerformersTag() {
if (!options.skipSingleNamePerformers) {
return;
}
return (
<Form.Group controlId="match_tags" className="ml-3 mt-1 mb-0" as={Row}>
<Form.Label
column
sm={{ span: 4, offset: 1 }}
title={intl.formatMessage({
id: "config.tasks.identify.tag_skipped_performer_tooltip",
})}
>
<FormattedMessage id="config.tasks.identify.tag_skipped_performers" />
</Form.Label>
<Col sm>
<TagSelect
onSelect={(tags) =>
setOptions({
skipSingleNamePerformerTag: tags[0]?.id,
})
}
ids={
options.skipSingleNamePerformerTag
? [options.skipSingleNamePerformerTag]
: []
}
noSelectionString="Select/create tag..."
/>
</Col>
</Form.Group>
);
}
return (
<Form.Group>
<Form.Group className="mb-0">
<Form.Group>
<h5>
<FormattedMessage
@@ -52,7 +121,7 @@ export const OptionsEditor: React.FC<IOptionsEditor> = ({
</Form.Text>
)}
</Form.Group>
<Form.Group>
<Form.Group className="mb-0">
<ThreeStateBoolean
id="include-male-performers"
value={
@@ -104,6 +173,50 @@ export const OptionsEditor: React.FC<IOptionsEditor> = ({
{...checkboxProps}
/>
</Form.Group>
<ThreeStateBoolean
id="skip-multiple-match"
value={
options.skipMultipleMatches === null
? undefined
: options.skipMultipleMatches
}
setValue={(v) =>
setOptions({
skipMultipleMatches: v,
})
}
label={intl.formatMessage({
id: "config.tasks.identify.skip_multiple_matches",
})}
defaultValue={defaultOptions?.skipMultipleMatches ?? undefined}
tooltip={intl.formatMessage({
id: "config.tasks.identify.skip_multiple_matches_tooltip",
})}
{...checkboxProps}
/>
{maybeRenderMultipleMatchesTag()}
<ThreeStateBoolean
id="skip-single-name-performers"
value={
options.skipSingleNamePerformers === null
? undefined
: options.skipSingleNamePerformers
}
setValue={(v) =>
setOptions({
skipSingleNamePerformers: v,
})
}
label={intl.formatMessage({
id: "config.tasks.identify.skip_single_name_performers",
})}
defaultValue={defaultOptions?.skipSingleNamePerformers ?? undefined}
tooltip={intl.formatMessage({
id: "config.tasks.identify.skip_single_name_performers_tooltip",
})}
{...checkboxProps}
/>
{maybeRenderPerformersTag()}
<FieldOptionsList
fieldOptions={options.fieldOptions ?? undefined}