From 1f97679868012b70beecc553557e96e6c8bc80e3 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 23 Feb 2024 05:30:37 +0200 Subject: [PATCH] Fixed: Selection of last added custom filter Plus some translations and typos --- .../Builder/FilterBuilderModalContent.js | 18 +++++++++++------- .../Filter/CustomFilters/CustomFilter.js | 4 ++-- src/NzbDrone.Core/Localization/Core/en.json | 4 ++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js index d718aab0c..0c4a31657 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js @@ -1,3 +1,4 @@ +import { maxBy } from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import FormInputGroup from 'Components/Form/FormInputGroup'; @@ -8,6 +9,7 @@ import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import FilterBuilderRow from './FilterBuilderRow'; import styles from './FilterBuilderModalContent.css'; @@ -49,7 +51,7 @@ class FilterBuilderModalContent extends Component { if (id) { dispatchSetFilter({ selectedFilterKey: id }); } else { - const last = customFilters[customFilters.length -1]; + const last = maxBy(customFilters, 'id'); dispatchSetFilter({ selectedFilterKey: last.id }); } @@ -107,7 +109,7 @@ class FilterBuilderModalContent extends Component { this.setState({ labelErrors: [ { - message: 'Label is required' + message: translate('LabelIsRequired') } ] }); @@ -145,13 +147,13 @@ class FilterBuilderModalContent extends Component { return ( - Custom Filter + {translate('CustomFilter')}
- Label + {translate('Label')}
@@ -165,7 +167,9 @@ class FilterBuilderModalContent extends Component {
-
Filters
+
+ {translate('Filters')} +
{ @@ -192,7 +196,7 @@ class FilterBuilderModalContent extends Component { - Save + {translate('Save')} diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js index 7407f729a..9f378d5a2 100644 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js @@ -37,8 +37,8 @@ class CustomFilter extends Component { dispatchSetFilter } = this.props; - // Assume that delete and then unmounting means the delete was successful. - // Moving this check to a ancestor would be more accurate, but would have + // Assume that delete and then unmounting means the deletion was successful. + // Moving this check to an ancestor would be more accurate, but would have // more boilerplate. if (this.state.isDeleting && id === selectedFilterKey) { dispatchSetFilter({ selectedFilterKey: 'all' }); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 8bc21c8e8..e7f80c263 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -266,6 +266,7 @@ "CreateGroup": "Create Group", "CurrentlyInstalled": "Currently Installed", "Custom": "Custom", + "CustomFilter": "Custom Filter", "CustomFilters": "Custom Filters", "CustomFormat": "Custom Format", "CustomFormatHelpText": "{appName} scores each release using the sum of scores for matching custom formats. If a new release would improve the score, at the same or better quality, then {appName} will grab it.", @@ -696,6 +697,7 @@ "FilterNotInNext": "not in the next", "FilterSeriesPlaceholder": "Filter series", "FilterStartsWith": "starts with", + "Filters": "Filters", "FinaleTooltip": "Series or season finale", "FirstDayOfWeek": "First Day of Week", "Fixed": "Fixed", @@ -1026,6 +1028,8 @@ "KeyboardShortcutsFocusSearchBox": "Focus Search Box", "KeyboardShortcutsOpenModal": "Open This Modal", "KeyboardShortcutsSaveSettings": "Save Settings", + "Label": "Label", + "LabelIsRequired": "Label is required", "Language": "Language", "Languages": "Languages", "LanguagesLoadError": "Unable to load languages",