mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-06 13:02:23 -07:00
New: Add individual edit to Manage Custom Formats
(cherry picked from commit e006b405323c276eb5b7f2dd97b97c80394a6930)
This commit is contained in:
parent
030300c896
commit
3c258d6e5a
5 changed files with 89 additions and 3 deletions
|
@ -3,6 +3,7 @@ import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { clearPendingChanges } from 'Store/Actions/baseActions';
|
import { clearPendingChanges } from 'Store/Actions/baseActions';
|
||||||
import EditCustomFormatModal from './EditCustomFormatModal';
|
import EditCustomFormatModal from './EditCustomFormatModal';
|
||||||
|
import EditCustomFormatModalContentConnector from './EditCustomFormatModalContentConnector';
|
||||||
|
|
||||||
function mapStateToProps() {
|
function mapStateToProps() {
|
||||||
return {};
|
return {};
|
||||||
|
@ -36,6 +37,7 @@ class EditCustomFormatModalConnector extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCustomFormatModalConnector.propTypes = {
|
EditCustomFormatModalConnector.propTypes = {
|
||||||
|
...EditCustomFormatModalContentConnector.propTypes,
|
||||||
onModalClose: PropTypes.func.isRequired,
|
onModalClose: PropTypes.func.isRequired,
|
||||||
clearPendingChanges: PropTypes.func.isRequired
|
clearPendingChanges: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,6 +47,11 @@ const COLUMNS = [
|
||||||
isSortable: true,
|
isSortable: true,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'actions',
|
||||||
|
label: '',
|
||||||
|
isVisible: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
interface ManageCustomFormatsModalContentProps {
|
interface ManageCustomFormatsModalContentProps {
|
||||||
|
|
|
@ -4,3 +4,9 @@
|
||||||
|
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
composes: cell from '~Components/Table/Cells/TableRowCell.css';
|
||||||
|
|
||||||
|
width: 40px;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// This file is automatically generated.
|
// This file is automatically generated.
|
||||||
// Please do not change this file!
|
// Please do not change this file!
|
||||||
interface CssExports {
|
interface CssExports {
|
||||||
|
'actions': string;
|
||||||
'includeCustomFormatWhenRenaming': string;
|
'includeCustomFormatWhenRenaming': string;
|
||||||
'name': string;
|
'name': string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
import IconButton from 'Components/Link/IconButton';
|
||||||
|
import ConfirmModal from 'Components/Modal/ConfirmModal';
|
||||||
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
||||||
import TableSelectCell from 'Components/Table/Cells/TableSelectCell';
|
import TableSelectCell from 'Components/Table/Cells/TableSelectCell';
|
||||||
import Column from 'Components/Table/Column';
|
import Column from 'Components/Table/Column';
|
||||||
import TableRow from 'Components/Table/TableRow';
|
import TableRow from 'Components/Table/TableRow';
|
||||||
|
import { icons } from 'Helpers/Props';
|
||||||
|
import { deleteCustomFormat } from 'Store/Actions/settingsActions';
|
||||||
import { SelectStateInputProps } from 'typings/props';
|
import { SelectStateInputProps } from 'typings/props';
|
||||||
import translate from 'Utilities/String/translate';
|
import translate from 'Utilities/String/translate';
|
||||||
|
import EditCustomFormatModalConnector from '../EditCustomFormatModalConnector';
|
||||||
import styles from './ManageCustomFormatsModalRow.css';
|
import styles from './ManageCustomFormatsModalRow.css';
|
||||||
|
|
||||||
interface ManageCustomFormatsModalRowProps {
|
interface ManageCustomFormatsModalRowProps {
|
||||||
|
@ -16,6 +24,15 @@ interface ManageCustomFormatsModalRowProps {
|
||||||
onSelectedChange(result: SelectStateInputProps): void;
|
onSelectedChange(result: SelectStateInputProps): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDeletingSelector() {
|
||||||
|
return createSelector(
|
||||||
|
(state: AppState) => state.settings.customFormats.isDeleting,
|
||||||
|
(isDeleting) => {
|
||||||
|
return isDeleting;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function ManageCustomFormatsModalRow(props: ManageCustomFormatsModalRowProps) {
|
function ManageCustomFormatsModalRow(props: ManageCustomFormatsModalRowProps) {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
|
@ -25,7 +42,16 @@ function ManageCustomFormatsModalRow(props: ManageCustomFormatsModalRowProps) {
|
||||||
onSelectedChange,
|
onSelectedChange,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const onSelectedChangeWrapper = useCallback(
|
const dispatch = useDispatch();
|
||||||
|
const isDeleting = useSelector(isDeletingSelector());
|
||||||
|
|
||||||
|
const [isEditCustomFormatModalOpen, setIsEditCustomFormatModalOpen] =
|
||||||
|
useState(false);
|
||||||
|
|
||||||
|
const [isDeleteCustomFormatModalOpen, setIsDeleteCustomFormatModalOpen] =
|
||||||
|
useState(false);
|
||||||
|
|
||||||
|
const handlelectedChange = useCallback(
|
||||||
(result: SelectStateInputProps) => {
|
(result: SelectStateInputProps) => {
|
||||||
onSelectedChange({
|
onSelectedChange({
|
||||||
...result,
|
...result,
|
||||||
|
@ -34,12 +60,33 @@ function ManageCustomFormatsModalRow(props: ManageCustomFormatsModalRowProps) {
|
||||||
[onSelectedChange]
|
[onSelectedChange]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleEditCustomFormatModalOpen = useCallback(() => {
|
||||||
|
setIsEditCustomFormatModalOpen(true);
|
||||||
|
}, [setIsEditCustomFormatModalOpen]);
|
||||||
|
|
||||||
|
const handleEditCustomFormatModalClose = useCallback(() => {
|
||||||
|
setIsEditCustomFormatModalOpen(false);
|
||||||
|
}, [setIsEditCustomFormatModalOpen]);
|
||||||
|
|
||||||
|
const handleDeleteCustomFormatPress = useCallback(() => {
|
||||||
|
setIsEditCustomFormatModalOpen(false);
|
||||||
|
setIsDeleteCustomFormatModalOpen(true);
|
||||||
|
}, [setIsEditCustomFormatModalOpen, setIsDeleteCustomFormatModalOpen]);
|
||||||
|
|
||||||
|
const handleDeleteCustomFormatModalClose = useCallback(() => {
|
||||||
|
setIsDeleteCustomFormatModalOpen(false);
|
||||||
|
}, [setIsDeleteCustomFormatModalOpen]);
|
||||||
|
|
||||||
|
const handleConfirmDeleteCustomFormat = useCallback(() => {
|
||||||
|
dispatch(deleteCustomFormat({ id }));
|
||||||
|
}, [id, dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableSelectCell
|
<TableSelectCell
|
||||||
id={id}
|
id={id}
|
||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
onSelectedChange={onSelectedChangeWrapper}
|
onSelectedChange={handlelectedChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TableRowCell className={styles.name}>{name}</TableRowCell>
|
<TableRowCell className={styles.name}>{name}</TableRowCell>
|
||||||
|
@ -47,6 +94,31 @@ function ManageCustomFormatsModalRow(props: ManageCustomFormatsModalRowProps) {
|
||||||
<TableRowCell className={styles.includeCustomFormatWhenRenaming}>
|
<TableRowCell className={styles.includeCustomFormatWhenRenaming}>
|
||||||
{includeCustomFormatWhenRenaming ? translate('Yes') : translate('No')}
|
{includeCustomFormatWhenRenaming ? translate('Yes') : translate('No')}
|
||||||
</TableRowCell>
|
</TableRowCell>
|
||||||
|
|
||||||
|
<TableRowCell className={styles.actions}>
|
||||||
|
<IconButton
|
||||||
|
name={icons.EDIT}
|
||||||
|
onPress={handleEditCustomFormatModalOpen}
|
||||||
|
/>
|
||||||
|
</TableRowCell>
|
||||||
|
|
||||||
|
<EditCustomFormatModalConnector
|
||||||
|
id={id}
|
||||||
|
isOpen={isEditCustomFormatModalOpen}
|
||||||
|
onModalClose={handleEditCustomFormatModalClose}
|
||||||
|
onDeleteCustomFormatPress={handleDeleteCustomFormatPress}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ConfirmModal
|
||||||
|
isOpen={isDeleteCustomFormatModalOpen}
|
||||||
|
kind="danger"
|
||||||
|
title={translate('DeleteCustomFormat')}
|
||||||
|
message={translate('DeleteCustomFormatMessageText', { name })}
|
||||||
|
confirmLabel={translate('Delete')}
|
||||||
|
isSpinning={isDeleting}
|
||||||
|
onConfirm={handleConfirmDeleteCustomFormat}
|
||||||
|
onCancel={handleDeleteCustomFormatModalClose}
|
||||||
|
/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue