New: (UI) Add clone indexer in info modal

pull/1851/head
Bogdan 1 year ago
parent 07b98f4137
commit c873b3ffac

@ -22,7 +22,7 @@ import AddIndexerModal from 'Indexer/Add/AddIndexerModal';
import EditIndexerModalConnector from 'Indexer/Edit/EditIndexerModalConnector';
import NoIndexer from 'Indexer/NoIndexer';
import { executeCommand } from 'Store/Actions/commandActions';
import { testAllIndexers } from 'Store/Actions/indexerActions';
import { cloneIndexer, testAllIndexers } from 'Store/Actions/indexerActions';
import {
setIndexerFilter,
setIndexerSort,
@ -98,6 +98,15 @@ const IndexerIndex = withScrollPosition((props: IndexerIndexProps) => {
setIsEditIndexerModalOpen(false);
}, [setIsEditIndexerModalOpen]);
const onCloneIndexerPress = useCallback(
(id: number) => {
dispatch(cloneIndexer({ id }));
setIsEditIndexerModalOpen(true);
},
[dispatch, setIsEditIndexerModalOpen]
);
const onAppIndexerSyncPress = useCallback(() => {
dispatch(
executeCommand({
@ -303,6 +312,7 @@ const IndexerIndex = withScrollPosition((props: IndexerIndexProps) => {
jumpToCharacter={jumpToCharacter}
isSelectMode={isSelectMode}
isSmallScreen={isSmallScreen}
onCloneIndexerPress={onCloneIndexerPress}
/>
<IndexerIndexFooter />

@ -27,10 +27,11 @@ interface IndexerIndexRowProps {
sortKey: string;
columns: Column[];
isSelectMode: boolean;
onCloneIndexerPress(id: number): void;
}
function IndexerIndexRow(props: IndexerIndexRowProps) {
const { indexerId, columns, isSelectMode } = props;
const { indexerId, columns, isSelectMode, onCloneIndexerPress } = props;
const { indexer, appProfile, status, longDateFormat, timeFormat } =
useSelector(createIndexerIndexItemSelector(props.indexerId));
@ -153,6 +154,7 @@ function IndexerIndexRow(props: IndexerIndexRowProps) {
<IndexerTitleLink
indexerId={indexerId}
indexerName={indexerName}
onCloneIndexerPress={onCloneIndexerPress}
/>
</VirtualTableRowCell>
);

@ -26,6 +26,7 @@ interface RowItemData {
sortKey: string;
columns: Column[];
isSelectMode: boolean;
onCloneIndexerPress(id: number): void;
}
interface IndexerIndexTableProps {
@ -37,6 +38,7 @@ interface IndexerIndexTableProps {
scrollerRef: RefObject<HTMLElement>;
isSelectMode: boolean;
isSmallScreen: boolean;
onCloneIndexerPress(id: number): void;
}
const columnsSelector = createSelector(
@ -49,7 +51,7 @@ const Row: React.FC<ListChildComponentProps<RowItemData>> = ({
style,
data,
}) => {
const { items, sortKey, columns, isSelectMode } = data;
const { items, sortKey, columns, isSelectMode, onCloneIndexerPress } = data;
if (index >= items.length) {
return null;
@ -71,6 +73,7 @@ const Row: React.FC<ListChildComponentProps<RowItemData>> = ({
sortKey={sortKey}
columns={columns}
isSelectMode={isSelectMode}
onCloneIndexerPress={onCloneIndexerPress}
/>
</div>
);
@ -89,6 +92,7 @@ function IndexerIndexTable(props: IndexerIndexTableProps) {
isSelectMode,
isSmallScreen,
scrollerRef,
onCloneIndexerPress,
} = props;
const columns = useSelector(columnsSelector);
@ -198,6 +202,7 @@ function IndexerIndexTable(props: IndexerIndexTableProps) {
sortKey,
columns,
isSelectMode,
onCloneIndexerPress,
}}
>
{Row}

@ -7,10 +7,11 @@ import styles from './IndexerTitleLink.css';
interface IndexerTitleLinkProps {
indexerName: string;
indexerId: number;
onCloneIndexerPress(id: number): void;
}
function IndexerTitleLink(props: IndexerTitleLinkProps) {
const { indexerName, indexerId } = props;
const { indexerName, indexerId, onCloneIndexerPress } = props;
const [isIndexerInfoModalOpen, setIsIndexerInfoModalOpen] = useState(false);
@ -32,6 +33,7 @@ function IndexerTitleLink(props: IndexerTitleLinkProps) {
indexerId={indexerId}
isOpen={isIndexerInfoModalOpen}
onModalClose={onIndexerInfoModalClose}
onCloneIndexerPress={onCloneIndexerPress}
/>
</div>
);

@ -7,16 +7,18 @@ interface IndexerInfoModalProps {
isOpen: boolean;
indexerId: number;
onModalClose(): void;
onCloneIndexerPress(id: number): void;
}
function IndexerInfoModal(props: IndexerInfoModalProps) {
const { isOpen, onModalClose, indexerId } = props;
const { isOpen, indexerId, onModalClose, onCloneIndexerPress } = props;
return (
<Modal size={sizes.MEDIUM} isOpen={isOpen} onModalClose={onModalClose}>
<IndexerInfoModalContent
indexerId={indexerId}
onModalClose={onModalClose}
onCloneIndexerPress={onCloneIndexerPress}
/>
</Modal>
);

@ -41,12 +41,13 @@ function createIndexerInfoItemSelector(indexerId: number) {
interface IndexerInfoModalContentProps {
indexerId: number;
onModalClose(): void;
onCloneIndexerPress(id: number): void;
}
function IndexerInfoModalContent(props: IndexerInfoModalContentProps) {
const { indexer } = useSelector(
createIndexerInfoItemSelector(props.indexerId)
);
const { indexerId, onCloneIndexerPress } = props;
const { indexer } = useSelector(createIndexerInfoItemSelector(indexerId));
const {
id,
@ -92,6 +93,11 @@ function IndexerInfoModalContent(props: IndexerInfoModalContentProps) {
onModalClose();
}, [setIsDeleteIndexerModalOpen, onModalClose]);
const onCloneIndexerPressWrapper = useCallback(() => {
onCloneIndexerPress(id);
onModalClose();
}, [id, onCloneIndexerPress, onModalClose]);
return (
<ModalContent onModalClose={onModalClose}>
<ModalHeader>{`${name}`}</ModalHeader>
@ -304,6 +310,9 @@ function IndexerInfoModalContent(props: IndexerInfoModalContentProps) {
>
{translate('Delete')}
</Button>
<Button onPress={onCloneIndexerPressWrapper}>
{translate('Clone')}
</Button>
<Button onPress={onEditIndexerPress}>{translate('Edit')}</Button>
<Button onPress={onModalClose}>{translate('Close')}</Button>
</ModalFooter>

@ -108,6 +108,7 @@
"ClearHistory": "Clear History",
"ClearHistoryMessageText": "Are you sure you want to clear all Prowlarr history?",
"ClientPriority": "Client Priority",
"Clone": "Clone",
"CloneProfile": "Clone Profile",
"Close": "Close",
"CloseCurrentModal": "Close Current Modal",

Loading…
Cancel
Save