Fixed: Selection of last added custom filter

Plus some translations and typos
This commit is contained in:
Bogdan 2024-02-23 05:30:37 +02:00 committed by Mark McDowall
parent b34e0f8259
commit 1f97679868
3 changed files with 17 additions and 9 deletions

View File

@ -1,3 +1,4 @@
import { maxBy } from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import FormInputGroup from 'Components/Form/FormInputGroup'; import FormInputGroup from 'Components/Form/FormInputGroup';
@ -8,6 +9,7 @@ import ModalContent from 'Components/Modal/ModalContent';
import ModalFooter from 'Components/Modal/ModalFooter'; import ModalFooter from 'Components/Modal/ModalFooter';
import ModalHeader from 'Components/Modal/ModalHeader'; import ModalHeader from 'Components/Modal/ModalHeader';
import { inputTypes } from 'Helpers/Props'; import { inputTypes } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
import FilterBuilderRow from './FilterBuilderRow'; import FilterBuilderRow from './FilterBuilderRow';
import styles from './FilterBuilderModalContent.css'; import styles from './FilterBuilderModalContent.css';
@ -49,7 +51,7 @@ class FilterBuilderModalContent extends Component {
if (id) { if (id) {
dispatchSetFilter({ selectedFilterKey: id }); dispatchSetFilter({ selectedFilterKey: id });
} else { } else {
const last = customFilters[customFilters.length -1]; const last = maxBy(customFilters, 'id');
dispatchSetFilter({ selectedFilterKey: last.id }); dispatchSetFilter({ selectedFilterKey: last.id });
} }
@ -107,7 +109,7 @@ class FilterBuilderModalContent extends Component {
this.setState({ this.setState({
labelErrors: [ labelErrors: [
{ {
message: 'Label is required' message: translate('LabelIsRequired')
} }
] ]
}); });
@ -145,13 +147,13 @@ class FilterBuilderModalContent extends Component {
return ( return (
<ModalContent onModalClose={onModalClose}> <ModalContent onModalClose={onModalClose}>
<ModalHeader> <ModalHeader>
Custom Filter {translate('CustomFilter')}
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
<div className={styles.labelContainer}> <div className={styles.labelContainer}>
<div className={styles.label}> <div className={styles.label}>
Label {translate('Label')}
</div> </div>
<div className={styles.labelInputContainer}> <div className={styles.labelInputContainer}>
@ -165,7 +167,9 @@ class FilterBuilderModalContent extends Component {
</div> </div>
</div> </div>
<div className={styles.label}>Filters</div> <div className={styles.label}>
{translate('Filters')}
</div>
<div className={styles.rows}> <div className={styles.rows}>
{ {
@ -192,7 +196,7 @@ class FilterBuilderModalContent extends Component {
<ModalFooter> <ModalFooter>
<Button onPress={onCancelPress}> <Button onPress={onCancelPress}>
Cancel {translate('Cancel')}
</Button> </Button>
<SpinnerErrorButton <SpinnerErrorButton
@ -200,7 +204,7 @@ class FilterBuilderModalContent extends Component {
error={saveError} error={saveError}
onPress={this.onSaveFilterPress} onPress={this.onSaveFilterPress}
> >
Save {translate('Save')}
</SpinnerErrorButton> </SpinnerErrorButton>
</ModalFooter> </ModalFooter>
</ModalContent> </ModalContent>

View File

@ -37,8 +37,8 @@ class CustomFilter extends Component {
dispatchSetFilter dispatchSetFilter
} = this.props; } = this.props;
// Assume that delete and then unmounting means the delete was successful. // Assume that delete and then unmounting means the deletion was successful.
// Moving this check to a ancestor would be more accurate, but would have // Moving this check to an ancestor would be more accurate, but would have
// more boilerplate. // more boilerplate.
if (this.state.isDeleting && id === selectedFilterKey) { if (this.state.isDeleting && id === selectedFilterKey) {
dispatchSetFilter({ selectedFilterKey: 'all' }); dispatchSetFilter({ selectedFilterKey: 'all' });

View File

@ -266,6 +266,7 @@
"CreateGroup": "Create Group", "CreateGroup": "Create Group",
"CurrentlyInstalled": "Currently Installed", "CurrentlyInstalled": "Currently Installed",
"Custom": "Custom", "Custom": "Custom",
"CustomFilter": "Custom Filter",
"CustomFilters": "Custom Filters", "CustomFilters": "Custom Filters",
"CustomFormat": "Custom Format", "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.", "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", "FilterNotInNext": "not in the next",
"FilterSeriesPlaceholder": "Filter series", "FilterSeriesPlaceholder": "Filter series",
"FilterStartsWith": "starts with", "FilterStartsWith": "starts with",
"Filters": "Filters",
"FinaleTooltip": "Series or season finale", "FinaleTooltip": "Series or season finale",
"FirstDayOfWeek": "First Day of Week", "FirstDayOfWeek": "First Day of Week",
"Fixed": "Fixed", "Fixed": "Fixed",
@ -1026,6 +1028,8 @@
"KeyboardShortcutsFocusSearchBox": "Focus Search Box", "KeyboardShortcutsFocusSearchBox": "Focus Search Box",
"KeyboardShortcutsOpenModal": "Open This Modal", "KeyboardShortcutsOpenModal": "Open This Modal",
"KeyboardShortcutsSaveSettings": "Save Settings", "KeyboardShortcutsSaveSettings": "Save Settings",
"Label": "Label",
"LabelIsRequired": "Label is required",
"Language": "Language", "Language": "Language",
"Languages": "Languages", "Languages": "Languages",
"LanguagesLoadError": "Unable to load languages", "LanguagesLoadError": "Unable to load languages",