From 2b95bb31fc4ceb4e974e4d603b91628b3302394c Mon Sep 17 00:00:00 2001 From: Harshith Mohan Date: Wed, 25 Oct 2023 11:27:38 +0530 Subject: [PATCH] Update actions modal --- src/components/Dialogs/ActionsModal.tsx | 71 +++++++++++-------------- src/components/Panels/ModalPanel.tsx | 9 ++-- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/components/Dialogs/ActionsModal.tsx b/src/components/Dialogs/ActionsModal.tsx index 833081c13..af734fb4f 100644 --- a/src/components/Dialogs/ActionsModal.tsx +++ b/src/components/Dialogs/ActionsModal.tsx @@ -1,6 +1,5 @@ import React, { useMemo, useState } from 'react'; -import AnimateHeight from 'react-animate-height'; -import { mdiInformationOutline, mdiPlayCircleOutline } from '@mdi/js'; +import { mdiPlayCircleOutline } from '@mdi/js'; import { Icon } from '@mdi/react'; import cx from 'classnames'; import { map } from 'lodash'; @@ -17,10 +16,10 @@ const actions = { import: { title: 'Import', data: [ + 'run-import', 'remove-missing-files-mylist', 'remove-missing-files', 'import-new-files', - 'run-import', ], }, anidb: { @@ -89,7 +88,7 @@ type Props = { const Action = ({ actionKey }: { actionKey: string }) => { const [runActionTrigger] = useRunActionMutation(); - const runAction = async (name: string, action) => { + const runAction = async (name: string, action: string) => { try { await runActionTrigger(action); toast.success(`Running action "${name}"`); @@ -100,33 +99,20 @@ const Action = ({ actionKey }: { actionKey: string }) => { } }; - const [showInfo, setShowInfo] = useState(false); - const action = useMemo(() => quickActions[actionKey], [actionKey]); - const { functionName, info, name } = action; + const { functionName, name } = action; return ( - -
+ +
{name} -
- - -
+ +
+
+ {quickActions[actionKey].info}
- -
- {/* Icon size reduces if not put in a div */} -
- -
- {info} -
-
); }; @@ -138,23 +124,28 @@ function ActionsModal({ onClose, show }: Props) { -
-
- {map(actions, (value, key) => ( -
setActiveTab(key)} - > - {value.title} -
- ))} +
+
+
Actions
+
+ {map(actions, (value, key) => ( +
setActiveTab(key)} + > + {value.title} +
+ ))} +
-
- {actions[activeTab].data.map(key => )} +
+
+ {actions[activeTab].data.map((key: string) => )} +
diff --git a/src/components/Panels/ModalPanel.tsx b/src/components/Panels/ModalPanel.tsx index b05f91a29..c985cdf6b 100644 --- a/src/components/Panels/ModalPanel.tsx +++ b/src/components/Panels/ModalPanel.tsx @@ -5,9 +5,10 @@ import cx from 'classnames'; type Props = { children: React.ReactNode; show: boolean; - title: React.ReactNode; + title?: React.ReactNode; size?: 'sm' | 'md' | 'lg'; className?: string; + noPadding?: boolean; onRequestClose?: () => void; onAfterOpen?: () => void; }; @@ -22,6 +23,7 @@ function ModalPanel(props: Props) { const { children, className, + noPadding, onAfterOpen, onRequestClose, show, @@ -44,13 +46,14 @@ function ModalPanel(props: Props) {
e.stopPropagation()} > -
{title}
+ {title &&
{title}
}
{children}