diff options
author | JayZed <[email protected]> | 2024-07-24 13:09:30 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-24 13:09:30 -0400 |
commit | b304f6f1efecdfa5b258138029b54460267e8032 (patch) | |
tree | 52d181bbba2ad6870b1a084b8cb434b045b5bdd0 /frontend/src | |
parent | c852458b8c6a732b75832eb6ea72cc531a94d553 (diff) | |
download | bazarr-b304f6f1efecdfa5b258138029b54460267e8032.tar.gz bazarr-b304f6f1efecdfa5b258138029b54460267e8032.zip |
Added new feature: Tag-Based Automatic Language Profile Selectionv1.4.4-beta.25
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/components/forms/ProfileEditForm.module.scss | 8 | ||||
-rw-r--r-- | frontend/src/components/forms/ProfileEditForm.tsx | 31 | ||||
-rw-r--r-- | frontend/src/pages/Settings/Languages/index.tsx | 22 | ||||
-rw-r--r-- | frontend/src/pages/Settings/Languages/table.tsx | 5 | ||||
-rw-r--r-- | frontend/src/types/api.d.ts | 1 |
5 files changed, 64 insertions, 3 deletions
diff --git a/frontend/src/components/forms/ProfileEditForm.module.scss b/frontend/src/components/forms/ProfileEditForm.module.scss index d98b850ff..3d4a8e177 100644 --- a/frontend/src/components/forms/ProfileEditForm.module.scss +++ b/frontend/src/components/forms/ProfileEditForm.module.scss @@ -3,3 +3,11 @@ padding: 0; } } + +.evenly { + flex-wrap: wrap; + + & > div { + flex: 1; + } +} diff --git a/frontend/src/components/forms/ProfileEditForm.tsx b/frontend/src/components/forms/ProfileEditForm.tsx index 75e2f9df7..267951fcb 100644 --- a/frontend/src/components/forms/ProfileEditForm.tsx +++ b/frontend/src/components/forms/ProfileEditForm.tsx @@ -3,6 +3,7 @@ import { Accordion, Button, Checkbox, + Flex, Select, Stack, Switch, @@ -72,9 +73,16 @@ const ProfileEditForm: FunctionComponent<Props> = ({ (value) => value.length > 0, "Must have a name", ), + tag: FormUtils.validation((value) => { + if (!value) { + return true; + } + + return /^[a-z_0-9-]+$/.test(value); + }, "Only lowercase alphanumeric characters, underscores (_) and hyphens (-) are allowed"), items: FormUtils.validation( (value) => value.length > 0, - "Must contain at lease 1 language", + "Must contain at least 1 language", ), }, }); @@ -265,7 +273,24 @@ const ProfileEditForm: FunctionComponent<Props> = ({ })} > <Stack> - <TextInput label="Name" {...form.getInputProps("name")}></TextInput> + <Flex + direction={{ base: "column", sm: "row" }} + gap="sm" + className={styles.evenly} + > + <TextInput label="Name" {...form.getInputProps("name")}></TextInput> + <TextInput + label="Tag" + {...form.getInputProps("tag")} + onBlur={() => + form.setFieldValue( + "tag", + (prev) => + prev?.toLowerCase().trim().replace(/\s+/g, "_") ?? undefined, + ) + } + ></TextInput> + </Flex> <Accordion multiple chevronPosition="right" @@ -274,7 +299,6 @@ const ProfileEditForm: FunctionComponent<Props> = ({ > <Accordion.Item value="Languages"> <Stack> - {form.errors.items} <SimpleTable columns={columns} data={form.values.items} @@ -282,6 +306,7 @@ const ProfileEditForm: FunctionComponent<Props> = ({ <Button fullWidth onClick={addItem}> Add Language </Button> + <Text c="var(--mantine-color-error)">{form.errors.items}</Text> <Selector clearable label="Cutoff" diff --git a/frontend/src/pages/Settings/Languages/index.tsx b/frontend/src/pages/Settings/Languages/index.tsx index 9fe562920..6a5b5309b 100644 --- a/frontend/src/pages/Settings/Languages/index.tsx +++ b/frontend/src/pages/Settings/Languages/index.tsx @@ -115,6 +115,28 @@ const SettingsLanguagesView: FunctionComponent = () => { <Section header="Languages Profile"> <Table></Table> </Section> + <Section header="Tag-Based Automatic Language Profile Selection Settings"> + <Message> + If enabled, Bazarr will look at the names of all tags of a Series from + Sonarr (or a Movie from Radarr) to find a matching Bazarr language + profile tag. It will use as the language profile the FIRST tag from + Sonarr/Radarr that matches the tag of a Bazarr language profile + EXACTLY. If mutiple tags match, there is no guarantee as to which one + will be used, so choose your tag names carefully. Also, if you update + the tag names in Sonarr/Radarr, Bazarr will detect this and repeat the + matching process for the affected shows. However, if a show's only + matching tag is removed from Sonarr/Radarr, Bazarr will NOT remove the + show's existing language profile, but keep it, as is. + </Message> + <Check + label="Series" + settingKey="settings-general-serie_tag_enabled" + ></Check> + <Check + label="Movies" + settingKey="settings-general-movie_tag_enabled" + ></Check> + </Section> <Section header="Default Settings"> <Check label="Series" diff --git a/frontend/src/pages/Settings/Languages/table.tsx b/frontend/src/pages/Settings/Languages/table.tsx index c32300628..03971a5cc 100644 --- a/frontend/src/pages/Settings/Languages/table.tsx +++ b/frontend/src/pages/Settings/Languages/table.tsx @@ -66,6 +66,10 @@ const Table: FunctionComponent = () => { accessorKey: "name", }, { + header: "Tag", + accessorKey: "tag", + }, + { header: "Languages", accessorKey: "items", cell: ({ @@ -178,6 +182,7 @@ const Table: FunctionComponent = () => { const profile = { profileId: nextProfileId, name: "", + tag: undefined, items: [], cutoff: null, mustContain: [], diff --git a/frontend/src/types/api.d.ts b/frontend/src/types/api.d.ts index 069be3029..e8bd4483e 100644 --- a/frontend/src/types/api.d.ts +++ b/frontend/src/types/api.d.ts @@ -40,6 +40,7 @@ declare namespace Language { mustContain: string[]; mustNotContain: string[]; originalFormat: boolean | null; + tag: string | undefined; } } |