From a10b78a79ce836bfbd5b40e9021c30dfef64a23e Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 12 Dec 2024 19:32:57 +0800 Subject: [PATCH] feat: optimize action pages Signed-off-by: Innei --- .../src/modules/action/action-card.tsx | 34 +++++--- .../src/modules/action/action-setting.tsx | 26 +++--- .../src/modules/action/feed-filter.tsx | 25 +++--- .../src/modules/action/target-action-list.tsx | 87 ++++++++++--------- .../modules/user/ProfileButton.desktop.tsx | 4 +- .../components/src/ui/select/responsive.tsx | 9 +- 6 files changed, 104 insertions(+), 81 deletions(-) diff --git a/apps/renderer/src/modules/action/action-card.tsx b/apps/renderer/src/modules/action/action-card.tsx index f01274eaf..f7df679d7 100644 --- a/apps/renderer/src/modules/action/action-card.tsx +++ b/apps/renderer/src/modules/action/action-card.tsx @@ -1,7 +1,8 @@ -import { Button } from "@follow/components/ui/button/index.js" import { Card, CardContent, CardHeader } from "@follow/components/ui/card/index.jsx" import { Input } from "@follow/components/ui/input/index.js" import { Switch } from "@follow/components/ui/switch/index.jsx" +import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.js" +import clsx from "clsx" import { useTranslation } from "react-i18next" import { actionActions, useActionByIndex } from "~/store/action" @@ -10,12 +11,29 @@ import { FeedFilter } from "./feed-filter" import { TargetActionList } from "./target-action-list" export const ActionCard = ({ index }: { index: number }) => { + const { t } = useTranslation("common") return ( - + + + { + actionActions.removeByIndex(index) + }} + > + + {t("words.delete")} + + {t("words.delete")} + - + @@ -31,15 +49,7 @@ const ActionCardToolbar = ({ index }: { index: number }) => { const onChange = actionActions.updateByIndex.bind(null, index) return ( -
- +

{t("actions.action_card.name")}

+
-
- -
- + +
) } diff --git a/apps/renderer/src/modules/action/feed-filter.tsx b/apps/renderer/src/modules/action/feed-filter.tsx index 71cb35a2e..118465715 100644 --- a/apps/renderer/src/modules/action/feed-filter.tsx +++ b/apps/renderer/src/modules/action/feed-filter.tsx @@ -74,9 +74,9 @@ export const FeedFilter = ({ index }: { index: number }) => { const onChange = actionActions.updateByIndex.bind(null, index) return ( -
+

{t("actions.action_card.when_feeds_match")}

-
+
0 ? "filter" : "all"} onValueChange={(value) => { @@ -99,7 +99,7 @@ export const FeedFilter = ({ index }: { index: number }) => {
{condition.length > 0 && ( -
+
@@ -131,6 +131,7 @@ export const FeedFilter = ({ index }: { index: number }) => { > {t("actions.action_card.field")} change("field", value as ActionFeedField)} @@ -168,6 +169,7 @@ export const FeedFilter = ({ index }: { index: number }) => { /> )} + { @@ -274,6 +276,7 @@ const OperationTableCell = ({ > {t("actions.action_card.operator")} onValueChange?.(value as ActionOperation)} @@ -302,19 +305,19 @@ const ActionTableCell = ({ const { t } = useTranslation("settings") return ( <> - - - - + + + + ) } diff --git a/apps/renderer/src/modules/action/target-action-list.tsx b/apps/renderer/src/modules/action/target-action-list.tsx index dd3202296..04fccffc5 100644 --- a/apps/renderer/src/modules/action/target-action-list.tsx +++ b/apps/renderer/src/modules/action/target-action-list.tsx @@ -1,4 +1,4 @@ -import { Button } from "@follow/components/ui/button/index.js" +import { ActionButton, Button } from "@follow/components/ui/button/index.js" import { Divider } from "@follow/components/ui/divider/index.js" import { Input } from "@follow/components/ui/input/index.js" import { ResponsiveSelect } from "@follow/components/ui/select/responsive.js" @@ -11,7 +11,6 @@ import { TableRow, } from "@follow/components/ui/table/index.jsx" import type { ActionModel, SupportedLanguages } from "@follow/models/types" -import { cn } from "@follow/utils/utils" import { Fragment, useMemo } from "react" import { useTranslation } from "react-i18next" @@ -64,16 +63,16 @@ const AddTableRow = ({ onClick, disabled }: { onClick?: () => void; disabled?: b onClick={onClick} disabled={disabled} > - {t("actions.action_card.add")} + {t("actions.action_card.add")} ) } const DeleteTableCell = ({ disabled, onClick }: { disabled?: boolean; onClick?: () => void }) => ( - + ) @@ -117,6 +116,7 @@ export const TargetActionList = ({ index }: { index: number }) => { config: () => ( { onChange((data) => { @@ -124,7 +124,7 @@ export const TargetActionList = ({ index }: { index: number }) => { }) }} items={TransitionOptions} - triggerClassName="w-fit max-w-44" + triggerClassName="w-fit max-w-44 text-sm" /> ), configInline: true, @@ -195,12 +195,12 @@ export const TargetActionList = ({ index }: { index: number }) => { }, config: () => ( <> -
+
- {t("actions.action_card.from")} {t("actions.action_card.to")} + @@ -212,18 +212,6 @@ export const TargetActionList = ({ index }: { index: number }) => { } return ( - { - onChange((data) => { - if (data.result.rewriteRules?.length === 1) { - delete data.result.rewriteRules - } else { - data.result.rewriteRules?.splice(rewriteIdx, 1) - } - }) - }} - /> { onChange={(e) => change("to", e.target.value)} /> + { + onChange((data) => { + if (data.result.rewriteRules?.length === 1) { + delete data.result.rewriteRules + } else { + data.result.rewriteRules?.splice(rewriteIdx, 1) + } + }) + }} + /> ) })} @@ -276,6 +276,17 @@ export const TargetActionList = ({ index }: { index: number }) => { {webhooks?.map((webhook, rewriteIdx) => { return (
+ { + onChange((data) => { + data.result.webhooks![rewriteIdx] = e.target.value + }) + }} + /> { @@ -288,17 +299,6 @@ export const TargetActionList = ({ index }: { index: number }) => { }) }} /> - { - onChange((data) => { - data.result.webhooks![rewriteIdx] = e.target.value - }) - }} - />
) })} @@ -342,16 +342,16 @@ export const TargetActionList = ({ index }: { index: number }) => { ) return ( -
+

{t("actions.action_card.then_do")}

-
+
- + + + - + {notEnabledActions.map((action) => { return ( { -
+
{enabledActions .filter((action) => action.enabled) .map((action, index) => { return ( -
+
{action.title} {action.configInline && action.config && action.config()} - { onChange((data) => { action.onRemove(data) }) }} - /> + > + +
{!action.configInline && action.config && action.config()} {index !== enabledActions.length - 1 && } diff --git a/apps/renderer/src/modules/user/ProfileButton.desktop.tsx b/apps/renderer/src/modules/user/ProfileButton.desktop.tsx index a9b722b66..c20aed7e1 100644 --- a/apps/renderer/src/modules/user/ProfileButton.desktop.tsx +++ b/apps/renderer/src/modules/user/ProfileButton.desktop.tsx @@ -143,7 +143,7 @@ export const ProfileButton: FC = memo((props) => { - {/* NOTE: The shortcut needs to be grouped, but there is only one currently, so no separator line has been added. */} + {!zenModeSetting && ( = memo((props) => { > {t("words.actions")} + + { diff --git a/packages/components/src/ui/select/responsive.tsx b/packages/components/src/ui/select/responsive.tsx index 7d3bbcda2..b7cb4b4ce 100644 --- a/packages/components/src/ui/select/responsive.tsx +++ b/packages/components/src/ui/select/responsive.tsx @@ -13,7 +13,7 @@ export interface ResponsiveSelectProps { defaultValue?: string value?: string onValueChange?: (value: string) => void - + placeholder?: string items: ResponsiveSelectItem[] renderValue?: (value: string) => React.ReactNode renderItem?: (item: ResponsiveSelectItem) => React.ReactNode @@ -34,6 +34,7 @@ export const ResponsiveSelect = ({ size = "default", triggerClassName, contentClassName, + placeholder, }: ResponsiveSelectProps) => { const [valueInner] = useControlled(value, defaultValue ?? "", onValueChange) @@ -67,7 +68,11 @@ export const ResponsiveSelect = ({ triggerClassName, )} > - {renderValue?.(valueInner) ?? valueToLabelMap[valueInner]} + + {(renderValue?.(valueInner) ?? valueToLabelMap[valueInner]) || ( + {placeholder} + )} +