Merge remote-tracking branch 'origin/dev' into release/desktop/0.8.0
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { LoadingWithIcon } from "@follow/components/ui/loading/index.jsx"
|
||||
import * as ScrollArea from "@follow/components/ui/scroll-area/ScrollArea.js"
|
||||
import {
|
||||
useActionRules,
|
||||
useIsActionDataDirty,
|
||||
usePrefetchActions,
|
||||
useUpdateActionsMutation,
|
||||
} from "@follow/store/action/hooks"
|
||||
import type { ActionItem } from "@follow/store/action/store"
|
||||
import { actionActions } from "@follow/store/action/store"
|
||||
import { nextFrame } from "@follow/utils"
|
||||
import { JsonObfuscatedCodec } from "@follow/utils/json-codec"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
import { m } from "motion/react"
|
||||
import { useEffect } from "react"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { unstable_usePrompt } from "react-router"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { MenuItemText, useShowContextMenu } from "~/atoms/context-menu"
|
||||
import { HeaderActionButton, HeaderActionGroup } from "~/components/ui/button/HeaderActionButton"
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -23,9 +28,16 @@ import {
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "~/components/ui/dropdown-menu/dropdown-menu.js"
|
||||
import { useDialog } from "~/components/ui/modal/stacked/hooks"
|
||||
import { useContextMenu } from "~/hooks/common/useContextMenu"
|
||||
import { copyToClipboard, readFromClipboard } from "~/lib/clipboard"
|
||||
import { downloadJsonFile, selectJsonFile } from "~/lib/export"
|
||||
import { RuleCard } from "~/modules/action/rule-card"
|
||||
import {
|
||||
buildActionSummary,
|
||||
buildConditionSummary,
|
||||
getRuleDisplayName,
|
||||
} from "~/modules/action/rule-summary"
|
||||
|
||||
import { useSetSubViewRightView } from "../app-layout/subview/hooks"
|
||||
import { generateExportFilename } from "./utils"
|
||||
@@ -37,12 +49,12 @@ const EmptyActionPlaceholder = () => {
|
||||
<div className="relative flex min-h-96 w-full items-center justify-center">
|
||||
<div className="flex flex-col items-center gap-6 text-center">
|
||||
{/* Simple icon */}
|
||||
<div className="flex size-16 items-center justify-center rounded-2xl bg-fill-quaternary">
|
||||
<i className="i-mgc-magic-2-cute-re size-8 text-text-secondary" />
|
||||
<div className="flex size-14 items-center justify-center rounded-lg border border-fill-secondary bg-fill-quinary">
|
||||
<i className="i-mgc-magic-2-cute-re size-7 text-text-secondary" />
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<h2 className="text-xl font-semibold text-text">
|
||||
<h2 className="text-lg font-semibold text-text">
|
||||
{t("actions.action_card.empty.title")}
|
||||
</h2>
|
||||
<p className="max-w-sm text-sm text-text-secondary">
|
||||
@@ -51,7 +63,7 @@ const EmptyActionPlaceholder = () => {
|
||||
</div>
|
||||
</div>
|
||||
<m.div
|
||||
className="absolute -top-6 right-20"
|
||||
className="fixed right-20 top-12 z-[1000]"
|
||||
animate={{
|
||||
x: [0, 8, 0],
|
||||
y: [0, -4, 0],
|
||||
@@ -63,9 +75,9 @@ const EmptyActionPlaceholder = () => {
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-2 text-text-tertiary">
|
||||
<div className="flex items-center gap-2 text-text-secondary">
|
||||
<span className="text-sm font-medium">{t("actions.action_card.empty.start")}</span>
|
||||
<i className="i-mgc-arrow-right-up-cute-re size-6" />
|
||||
<i className="i-mgc-arrow-right-up-cute-re size-5" />
|
||||
</div>
|
||||
</m.div>
|
||||
</div>
|
||||
@@ -74,9 +86,22 @@ const EmptyActionPlaceholder = () => {
|
||||
|
||||
export const ActionSetting = () => {
|
||||
const actions = useActionRules()
|
||||
const { t } = useTranslation("settings")
|
||||
|
||||
const [selectedRuleIndex, setSelectedRuleIndex] = useState(0)
|
||||
const actionQuery = usePrefetchActions()
|
||||
|
||||
useEffect(() => {
|
||||
if (actions.length === 0) {
|
||||
setSelectedRuleIndex(0)
|
||||
return
|
||||
}
|
||||
|
||||
if (selectedRuleIndex > actions.length - 1) {
|
||||
setSelectedRuleIndex(actions.length - 1)
|
||||
}
|
||||
}, [actions.length, selectedRuleIndex])
|
||||
|
||||
if (actionQuery.isPending) {
|
||||
return (
|
||||
<LoadingWithIcon
|
||||
@@ -89,47 +114,66 @@ export const ActionSetting = () => {
|
||||
|
||||
const hasActions = actions.length > 0
|
||||
|
||||
const handleCreateRule = () => {
|
||||
const nextIndex = actions.length
|
||||
actionActions.addRule((number) => t("actions.actionName", { number }))
|
||||
setSelectedRuleIndex(nextIndex)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6">
|
||||
<ActionButtonGroup />
|
||||
<>
|
||||
<ActionButtonGroup onCreateRule={handleCreateRule} />
|
||||
<ShareImportSection />
|
||||
{hasActions ? (
|
||||
<div className="flex flex-col gap-6 @container">
|
||||
{actions.map((_, actionIdx) => {
|
||||
return <RuleCard key={actionIdx} index={actionIdx} />
|
||||
})}
|
||||
<div className="flex min-h-0 w-full flex-1 flex-col @[960px]:absolute @[960px]:inset-x-0 @[960px]:bottom-0 @[960px]:top-12">
|
||||
<div className="hidden h-full flex-1 @[960px]:flex @[960px]:h-0 @[960px]:overflow-hidden @[960px]:rounded-lg @[960px]:border @[960px]:border-fill-secondary">
|
||||
<RuleList
|
||||
selectedIndex={selectedRuleIndex}
|
||||
onSelect={setSelectedRuleIndex}
|
||||
onDelete={(deletedIndex) => {
|
||||
// Adjust selectedRuleIndex when a rule is deleted
|
||||
if (deletedIndex === selectedRuleIndex) {
|
||||
// If deleting the selected rule, select the previous one or 0
|
||||
setSelectedRuleIndex(Math.max(0, deletedIndex - 1))
|
||||
} else if (deletedIndex < selectedRuleIndex) {
|
||||
// If deleting a rule before the selected one, shift the index down
|
||||
setSelectedRuleIndex(selectedRuleIndex - 1)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className="flex flex-1 border-l border-fill-secondary">
|
||||
<RuleCard index={selectedRuleIndex} mode="detail" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-3 @[960px]:hidden">
|
||||
{actions.map((_, actionIdx) => (
|
||||
<RuleCard
|
||||
key={actionIdx}
|
||||
index={actionIdx}
|
||||
mode="compact"
|
||||
defaultOpen={actionIdx === selectedRuleIndex}
|
||||
onOpenChange={(open) => {
|
||||
if (open) {
|
||||
setSelectedRuleIndex(actionIdx)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyActionPlaceholder />
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const ActionButtonGroup = () => {
|
||||
const queryClient = useQueryClient()
|
||||
const actionLength = useActionRules((actions) => actions.length)
|
||||
const isDirty = useIsActionDataDirty()
|
||||
const ShareImportSection = () => {
|
||||
const { t } = useTranslation("settings")
|
||||
unstable_usePrompt({
|
||||
message: t("actions.navigate.prompt"),
|
||||
when: ({ currentLocation, nextLocation }) =>
|
||||
isDirty && currentLocation.pathname !== nextLocation.pathname,
|
||||
})
|
||||
const actionLength = useActionRules((actions) => actions.length)
|
||||
const hasActions = actionLength > 0
|
||||
|
||||
const mutation = useUpdateActionsMutation({
|
||||
onSuccess: () => {
|
||||
// apply new action settings
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["entries"],
|
||||
})
|
||||
toast(t("actions.saveSuccess"))
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(error)
|
||||
},
|
||||
})
|
||||
|
||||
const handleExport = () => {
|
||||
const handleExport = useCallback(() => {
|
||||
try {
|
||||
const jsonData = actionActions.exportRules()
|
||||
const filename = generateExportFilename()
|
||||
@@ -138,9 +182,9 @@ const ActionButtonGroup = () => {
|
||||
} catch {
|
||||
toast.error("Failed to export action rules")
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleImport = async () => {
|
||||
const handleImport = useCallback(async () => {
|
||||
try {
|
||||
const jsonData = await selectJsonFile()
|
||||
const result = actionActions.importRules(jsonData)
|
||||
@@ -152,28 +196,26 @@ const ActionButtonGroup = () => {
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message === "No file selected") {
|
||||
// User cancelled file selection, don't show error
|
||||
return
|
||||
}
|
||||
toast.error("Failed to import action rules")
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const foloPrefix = "folo:actions#"
|
||||
const handleCopyToClipboard = async () => {
|
||||
const handleCopyToClipboard = useCallback(async () => {
|
||||
try {
|
||||
const jsonData = actionActions.exportRules()
|
||||
const codecData = JsonObfuscatedCodec.encode(jsonData)
|
||||
|
||||
await copyToClipboard(`${foloPrefix}${codecData}`)
|
||||
toast.success("Action rules copied to clipboard")
|
||||
} catch (error) {
|
||||
toast.error("Failed to copy action rules to clipboard")
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
}, [foloPrefix])
|
||||
|
||||
const handleImportFromClipboard = async () => {
|
||||
const handleImportFromClipboard = useCallback(async () => {
|
||||
try {
|
||||
const clipboardData = await readFromClipboard()
|
||||
if (!clipboardData.startsWith(foloPrefix)) {
|
||||
@@ -181,9 +223,7 @@ const ActionButtonGroup = () => {
|
||||
return
|
||||
}
|
||||
const codecData = clipboardData.slice(foloPrefix.length)
|
||||
|
||||
const jsonData = JsonObfuscatedCodec.decode(codecData)
|
||||
|
||||
const result = actionActions.importRules(jsonData)
|
||||
|
||||
if (result.success) {
|
||||
@@ -199,19 +239,201 @@ const ActionButtonGroup = () => {
|
||||
}
|
||||
console.error(error)
|
||||
}
|
||||
}, [foloPrefix])
|
||||
|
||||
return (
|
||||
<div className="mb-4 flex justify-end">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
buttonClassName="size-9 p-0"
|
||||
aria-label={
|
||||
hasActions
|
||||
? t("actions.action_card.summary.share")
|
||||
: t("actions.action_card.summary.import")
|
||||
}
|
||||
>
|
||||
<i
|
||||
className={cn(
|
||||
"size-4",
|
||||
hasActions ? "i-mgc-share-forward-cute-re" : "i-mgc-file-import-cute-re",
|
||||
)}
|
||||
/>
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-56">
|
||||
<DropdownMenuItem onClick={handleExport} disabled={!hasActions}>
|
||||
<i className="i-mgc-download-2-cute-re mr-3 size-4" />
|
||||
{t("actions.action_card.summary.export")}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleImport}>
|
||||
<i className="i-mgc-file-upload-cute-re mr-3 size-4" />
|
||||
{t("actions.action_card.summary.import_file")}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onClick={handleCopyToClipboard} disabled={!hasActions}>
|
||||
<i className="i-mgc-copy-2-cute-re mr-3 size-4" />
|
||||
{t("actions.action_card.summary.copy")}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleImportFromClipboard}>
|
||||
<i className="i-mgc-paste-cute-re mr-3 size-4" />
|
||||
{t("actions.action_card.summary.import_clipboard")}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const RuleList = ({
|
||||
selectedIndex,
|
||||
onSelect,
|
||||
onDelete,
|
||||
}: {
|
||||
selectedIndex: number
|
||||
onSelect: (index: number) => void
|
||||
onDelete: (index: number) => void
|
||||
}) => {
|
||||
const rules = useActionRules()
|
||||
const { t } = useTranslation("settings")
|
||||
const ruleCount = useActionRules((s) => s.length)
|
||||
const mutation = useUpdateActionsMutation()
|
||||
const { ask } = useDialog()
|
||||
const showContextMenu = useShowContextMenu()
|
||||
|
||||
const handleDeleteRule = useCallback(
|
||||
(index: number) => {
|
||||
if (ruleCount === 1) {
|
||||
ask({
|
||||
title: t("actions.action_card.summary.delete_title"),
|
||||
variant: "danger",
|
||||
message: t("actions.action_card.summary.delete_message"),
|
||||
onConfirm: () => {
|
||||
actionActions.deleteRule(index)
|
||||
onDelete(index)
|
||||
nextFrame(() => {
|
||||
mutation.mutate()
|
||||
})
|
||||
},
|
||||
})
|
||||
} else {
|
||||
actionActions.deleteRule(index)
|
||||
onDelete(index)
|
||||
}
|
||||
},
|
||||
[ruleCount, ask, t, mutation, onDelete],
|
||||
)
|
||||
|
||||
if (rules.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-[260px] shrink-0 flex-col">
|
||||
<ScrollArea.ScrollArea rootClassName="h-full" viewportClassName="h-full">
|
||||
<div className="flex flex-col">
|
||||
{rules.map((rule, index) => (
|
||||
<RuleListItem
|
||||
key={rule.index ?? index}
|
||||
rule={rule}
|
||||
index={index}
|
||||
isActive={index === selectedIndex}
|
||||
onSelect={onSelect}
|
||||
handleDelete={handleDeleteRule}
|
||||
showContextMenu={showContextMenu}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</ScrollArea.ScrollArea>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const RuleListItem = ({
|
||||
rule,
|
||||
index,
|
||||
isActive,
|
||||
onSelect,
|
||||
handleDelete,
|
||||
showContextMenu,
|
||||
}: {
|
||||
rule: ActionItem
|
||||
index: number
|
||||
isActive: boolean
|
||||
onSelect: (index: number) => void
|
||||
handleDelete: (index: number) => void
|
||||
showContextMenu: ReturnType<typeof useShowContextMenu>
|
||||
}) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const displayName = getRuleDisplayName(rule, index, t)
|
||||
const whenSummary = buildConditionSummary(rule, t)
|
||||
const actionSummary = buildActionSummary(rule, t)
|
||||
|
||||
const contextMenuProps = useContextMenu({
|
||||
onContextMenu: async (e) => {
|
||||
e.preventDefault()
|
||||
await showContextMenu(
|
||||
[
|
||||
new MenuItemText({
|
||||
label: t("actions.action_card.summary.delete"),
|
||||
icon: <i className="i-mgc-delete-2-cute-re" />,
|
||||
click: () => handleDelete(index),
|
||||
}),
|
||||
],
|
||||
e,
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onSelect(index)}
|
||||
{...contextMenuProps}
|
||||
className={cn(
|
||||
"flex flex-col gap-1 border-b border-fill-tertiary px-4 py-3 text-left transition-all last:border-b-0",
|
||||
isActive ? "bg-fill-quaternary" : "hover:bg-fill-quinary",
|
||||
)}
|
||||
>
|
||||
<span className="text-sm font-medium text-text">{displayName}</span>
|
||||
<span className="line-clamp-2 text-xs text-text-secondary">{whenSummary}</span>
|
||||
<span className="line-clamp-1 text-xs text-text-secondary">{actionSummary}</span>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
const ActionButtonGroup = ({ onCreateRule }: { onCreateRule: () => void }) => {
|
||||
const queryClient = useQueryClient()
|
||||
const actionLength = useActionRules((actions) => actions.length)
|
||||
const isDirty = useIsActionDataDirty()
|
||||
const { t } = useTranslation("settings")
|
||||
unstable_usePrompt({
|
||||
message: t("actions.navigate.prompt"),
|
||||
when: ({ currentLocation, nextLocation }) =>
|
||||
isDirty && currentLocation.pathname !== nextLocation.pathname,
|
||||
})
|
||||
|
||||
const mutation = useUpdateActionsMutation({
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["entries"],
|
||||
})
|
||||
toast(t("actions.saveSuccess"))
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(error)
|
||||
},
|
||||
})
|
||||
|
||||
const hasActions = actionLength > 0
|
||||
|
||||
const setRightView = useSetSubViewRightView()
|
||||
useEffect(() => {
|
||||
setRightView(
|
||||
<HeaderActionGroup>
|
||||
<HeaderActionButton
|
||||
variant="primary"
|
||||
icon="i-mingcute-add-line"
|
||||
onClick={() => actionActions.addRule((number) => t("actions.actionName", { number }))}
|
||||
>
|
||||
<HeaderActionButton variant="primary" icon="i-mingcute-add-line" onClick={onCreateRule}>
|
||||
{t("actions.newRule")}
|
||||
</HeaderActionButton>
|
||||
|
||||
@@ -231,70 +453,7 @@ const ActionButtonGroup = () => {
|
||||
return () => {
|
||||
setRightView(null)
|
||||
}
|
||||
}, [setRightView, actionLength, hasActions, isDirty, mutation, t])
|
||||
}, [setRightView, actionLength, hasActions, isDirty, mutation, onCreateRule, t])
|
||||
|
||||
return (
|
||||
<div className="mb-6 flex w-full items-center justify-end p-4 lg:justify-between">
|
||||
{/* Left side - Simple status */}
|
||||
<div className="hidden lg:block">
|
||||
<h3 className="text-lg font-medium text-text">
|
||||
{hasActions ? `${actionLength} Rules` : "No Rules"}
|
||||
</h3>
|
||||
<p className="text-sm text-text-secondary">
|
||||
{hasActions ? "Active automation rules" : "Create your first automation rule"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Right side - Action buttons */}
|
||||
<div className="flex items-center gap-2">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="sm">
|
||||
{hasActions ? (
|
||||
<i className="i-mgc-share-forward-cute-re mr-2 size-4" />
|
||||
) : (
|
||||
<i className="i-mgc-file-import-cute-re mr-2 size-4" />
|
||||
)}
|
||||
{hasActions ? "Share" : "Import"}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-56">
|
||||
<DropdownMenuItem onClick={handleExport} disabled={!hasActions}>
|
||||
<i className="i-mgc-download-2-cute-re mr-3 size-4" />
|
||||
Export to File
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleImport}>
|
||||
<i className="i-mgc-file-upload-cute-re mr-3 size-4" />
|
||||
Import from File
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onClick={handleCopyToClipboard} disabled={!hasActions}>
|
||||
<i className="i-mgc-copy-2-cute-re mr-3 size-4" />
|
||||
Copy to Clipboard
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleImportFromClipboard}>
|
||||
<i className="i-mgc-paste-cute-re mr-3 size-4" />
|
||||
Import from Clipboard
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
<Button
|
||||
variant={actionLength === 0 ? "primary" : "outline"}
|
||||
size="sm"
|
||||
onClick={() => actionActions.addRule((number) => t("actions.actionName", { number }))}
|
||||
>
|
||||
<i className="i-mingcute-add-line mr-2 size-4" />
|
||||
{t("actions.newRule")}
|
||||
</Button>
|
||||
|
||||
{hasActions && (
|
||||
<Button onClick={() => mutation.mutate()} size="sm" disabled={!isDirty}>
|
||||
<i className="i-mgc-check-circle-cute-re mr-2 size-4" />
|
||||
{t("actions.save")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -1,77 +1,181 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { Input } from "@follow/components/ui/input/index.js"
|
||||
import * as ScrollArea from "@follow/components/ui/scroll-area/ScrollArea.js"
|
||||
import { Switch } from "@follow/components/ui/switch/index.jsx"
|
||||
import { useActionRule, useActionRules, useUpdateActionsMutation } from "@follow/store/action/hooks"
|
||||
import { actionActions } from "@follow/store/action/store"
|
||||
import { nextFrame } from "@follow/utils"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useDialog } from "~/components/ui/modal/stacked/hooks"
|
||||
|
||||
import { buildActionSummary, buildConditionSummary, getRuleDisplayName } from "./rule-summary"
|
||||
import { ThenSection } from "./then-section"
|
||||
import { WhenSection } from "./when-section"
|
||||
|
||||
export const RuleCard = ({ index }: { index: number }) => {
|
||||
type RuleCardProps = {
|
||||
index: number
|
||||
mode?: "detail" | "compact"
|
||||
defaultOpen?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}
|
||||
|
||||
export const RuleCard = ({
|
||||
index,
|
||||
mode = "detail",
|
||||
defaultOpen = false,
|
||||
onOpenChange,
|
||||
}: RuleCardProps) => {
|
||||
if (mode === "compact") {
|
||||
return <CompactRuleCard index={index} defaultOpen={defaultOpen} onOpenChange={onOpenChange} />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="group/card-root relative flex flex-col gap-4 rounded-2xl border bg-material-ultra-thin p-4 shadow-sm md:p-6">
|
||||
<RuleCardToolbar index={index} />
|
||||
<div className="grid grid-cols-1 gap-x-8 gap-y-6 @[800px]:grid-cols-2">
|
||||
<WhenSection index={index} />
|
||||
<ThenSection index={index} />
|
||||
<div className="group/rule flex size-full flex-col @container">
|
||||
<div className="shrink-0 border-b border-fill-tertiary px-5 py-4">
|
||||
<RuleCardToolbar index={index} />
|
||||
</div>
|
||||
<ScrollArea.ScrollArea rootClassName="flex-1" viewportClassName="h-full">
|
||||
<div className="p-5">
|
||||
<RuleCardContent index={index} />
|
||||
</div>
|
||||
</ScrollArea.ScrollArea>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const RuleCardContent = ({ index }: { index: number }) => {
|
||||
return (
|
||||
<div className="flex flex-col gap-6 @[900px]:grid @[900px]:grid-cols-2 @[900px]:items-start @[900px]:gap-6">
|
||||
<WhenSection index={index} />
|
||||
<ThenSection index={index} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const CompactRuleCard = ({
|
||||
index,
|
||||
defaultOpen,
|
||||
onOpenChange,
|
||||
}: {
|
||||
index: number
|
||||
defaultOpen: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const rule = useActionRule(index)
|
||||
const disabled = useActionRule(index, (a) => a.result.disabled)
|
||||
const [open, setOpen] = useState(defaultOpen)
|
||||
|
||||
useEffect(() => {
|
||||
setOpen(defaultOpen)
|
||||
}, [defaultOpen])
|
||||
|
||||
const toggle = () => {
|
||||
setOpen((prev) => {
|
||||
const next = !prev
|
||||
onOpenChange?.(next)
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
const displayName = getRuleDisplayName(rule, index, t)
|
||||
const whenSummary = buildConditionSummary(rule, t)
|
||||
const actionSummary = buildActionSummary(rule, t)
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden rounded-lg border border-fill-secondary bg-transparent">
|
||||
<button
|
||||
type="button"
|
||||
onClick={toggle}
|
||||
className="flex w-full items-start justify-between gap-3 px-4 py-3 text-left transition-colors hover:bg-fill-quinary"
|
||||
>
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-semibold text-text">{displayName}</span>
|
||||
<span className="line-clamp-1 text-xs text-text-tertiary">{whenSummary}</span>
|
||||
<span className="line-clamp-1 text-xs text-text-tertiary">{actionSummary}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{disabled && (
|
||||
<span className="rounded-md border border-fill-secondary bg-fill-quaternary px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-text-secondary">
|
||||
{t("actions.action_card.summary.disabled")}
|
||||
</span>
|
||||
)}
|
||||
<i
|
||||
className={cn(
|
||||
"size-4 text-text-tertiary transition-transform",
|
||||
open ? "i-mingcute-arrow-up-line" : "i-mingcute-arrow-down-line",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</button>
|
||||
{open ? (
|
||||
<div className="space-y-4 border-t border-fill-tertiary bg-transparent p-4">
|
||||
<RuleCardToolbar index={index} />
|
||||
<RuleCardContent index={index} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const RuleCardToolbar = ({ index }: { index: number }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const name = useActionRule(index, (a) => a.name)
|
||||
const disabled = useActionRule(index, (a) => a.result.disabled)
|
||||
|
||||
const ruleCount = useActionRules((s) => s.length)
|
||||
const mutation = useUpdateActionsMutation()
|
||||
|
||||
const { ask } = useDialog()
|
||||
|
||||
const handleDelete = () => {
|
||||
if (ruleCount === 1) {
|
||||
ask({
|
||||
title: t("actions.action_card.summary.delete_title"),
|
||||
variant: "danger",
|
||||
message: t("actions.action_card.summary.delete_message"),
|
||||
onConfirm: () => {
|
||||
actionActions.deleteRule(index)
|
||||
nextFrame(() => {
|
||||
mutation.mutate()
|
||||
})
|
||||
},
|
||||
})
|
||||
} else {
|
||||
actionActions.deleteRule(index)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full items-center gap-3">
|
||||
<div className={"flex w-full flex-wrap items-center gap-3"}>
|
||||
<Input
|
||||
value={name}
|
||||
className="h-9 max-w-64 bg-transparent px-2 text-lg font-semibold shadow-none ring-0 focus-visible:ring-0"
|
||||
placeholder={t("actions.action_card.name")}
|
||||
className="h-9 min-w-[160px] flex-1 bg-transparent px-3 text-base font-semibold shadow-none ring-0 focus-visible:ring-0"
|
||||
onChange={(e) => {
|
||||
actionActions.patchRule(index, { name: e.target.value })
|
||||
}}
|
||||
/>
|
||||
<div className="grow" />
|
||||
|
||||
<Switch
|
||||
checked={!disabled}
|
||||
onCheckedChange={(checked) => {
|
||||
actionActions.patchRule(index, {
|
||||
result: { disabled: !checked },
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<div className="absolute right-0 top-0 opacity-0 transition-opacity duration-200 group-hover/card-root:opacity-100">
|
||||
<button
|
||||
className="center flex size-8 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background"
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (ruleCount === 1) {
|
||||
ask({
|
||||
title: "Delete Rule",
|
||||
variant: "danger",
|
||||
message: "Are you sure you want to delete this rule? This action cannot be undone.",
|
||||
onConfirm: () => {
|
||||
actionActions.deleteRule(index)
|
||||
nextFrame(() => {
|
||||
mutation.mutate()
|
||||
})
|
||||
},
|
||||
})
|
||||
} else {
|
||||
actionActions.deleteRule(index)
|
||||
}
|
||||
<div className="flex items-center gap-3">
|
||||
<Switch
|
||||
checked={!disabled}
|
||||
onCheckedChange={(checked) => {
|
||||
actionActions.patchRule(index, {
|
||||
result: { disabled: !checked },
|
||||
})
|
||||
}}
|
||||
aria-label={t("actions.action_card.summary.toggle")}
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
aria-label={t("actions.action_card.summary.delete")}
|
||||
buttonClassName="size-8 p-0"
|
||||
onClick={handleDelete}
|
||||
>
|
||||
<i className="i-mgc-close-cute-re" />
|
||||
</button>
|
||||
<i className="i-mgc-delete-2-cute-re" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import { filterFieldOptions, filterOperatorOptions } from "@follow/store/action/constant"
|
||||
import type { ActionItem } from "@follow/store/action/store"
|
||||
import type { TFunction } from "i18next"
|
||||
|
||||
import { availableActionMap } from "./constants"
|
||||
|
||||
const fieldLabelMap = new Map(filterFieldOptions.map((option) => [option.value, option.label]))
|
||||
const operatorLabelMap = new Map(
|
||||
filterOperatorOptions.map((option) => [option.value, option.label]),
|
||||
)
|
||||
|
||||
export const getRuleDisplayName = (
|
||||
rule: ActionItem | undefined,
|
||||
index: number,
|
||||
t: TFunction<"settings">,
|
||||
) => {
|
||||
const fallback = t("actions.actionName", { number: index + 1 })
|
||||
if (!rule) return fallback
|
||||
const trimmedName = rule.name?.trim()
|
||||
return trimmedName && trimmedName.length > 0 ? trimmedName : fallback
|
||||
}
|
||||
|
||||
export const buildConditionSummary = (rule: ActionItem | undefined, t: TFunction<"settings">) => {
|
||||
if (!rule || rule.condition.length === 0) {
|
||||
return t("actions.action_card.all")
|
||||
}
|
||||
|
||||
const andSeparator = ` ${t("actions.action_card.and")} `
|
||||
const orSeparator = ` ${t("actions.action_card.or")} `
|
||||
|
||||
const groups = rule.condition
|
||||
.map((group) => {
|
||||
const groupParts = group
|
||||
.map((condition) => {
|
||||
const fieldLabelKey = condition.field ? fieldLabelMap.get(condition.field) : undefined
|
||||
const operatorLabelKey = condition.operator
|
||||
? operatorLabelMap.get(condition.operator)
|
||||
: undefined
|
||||
const fieldLabel = fieldLabelKey ? t(fieldLabelKey) : undefined
|
||||
const operatorLabel = operatorLabelKey ? t(operatorLabelKey) : undefined
|
||||
const { value } = condition
|
||||
|
||||
const valueText =
|
||||
typeof value === "number"
|
||||
? value.toString()
|
||||
: typeof value === "string" && value.trim().length > 0
|
||||
? value
|
||||
: undefined
|
||||
|
||||
const parts = [fieldLabel, operatorLabel, valueText].filter(Boolean)
|
||||
return parts.join(" ")
|
||||
})
|
||||
.filter((part) => part.length > 0)
|
||||
|
||||
return groupParts.join(andSeparator)
|
||||
})
|
||||
.filter((group) => group.length > 0)
|
||||
|
||||
if (groups.length === 0) {
|
||||
return t("actions.action_card.all")
|
||||
}
|
||||
|
||||
return groups.join(orSeparator)
|
||||
}
|
||||
|
||||
export const buildActionSummary = (rule: ActionItem | undefined, t: TFunction<"settings">) => {
|
||||
if (!rule) {
|
||||
return t("actions.action_card.summary.no_actions")
|
||||
}
|
||||
|
||||
if (rule.result?.disabled) {
|
||||
return t("actions.action_card.summary.disabled")
|
||||
}
|
||||
|
||||
const labels = Object.values(availableActionMap)
|
||||
.filter((action) => {
|
||||
const value = rule.result?.[action.value as keyof typeof rule.result]
|
||||
if (Array.isArray(value)) {
|
||||
return value.length > 0
|
||||
}
|
||||
|
||||
if (typeof value === "object" && value !== null) {
|
||||
return Object.keys(value).length > 0
|
||||
}
|
||||
|
||||
return Boolean(value)
|
||||
})
|
||||
.map((action) => t(action.label))
|
||||
|
||||
if (labels.length === 0) {
|
||||
return t("actions.action_card.summary.no_actions")
|
||||
}
|
||||
|
||||
return labels.join(" + ")
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
import { ActionButton, Button } from "@follow/components/ui/button/index.js"
|
||||
import { Divider } from "@follow/components/ui/divider/index.js"
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { Input } from "@follow/components/ui/input/index.js"
|
||||
import type { ActionAction } from "@follow/store/action/constant"
|
||||
import { useActionRule } from "@follow/store/action/hooks"
|
||||
import { actionActions } from "@follow/store/action/store"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
import type { ActionId } from "@follow-app/client-sdk"
|
||||
import { merge } from "es-toolkit/compat"
|
||||
import type { ReactNode } from "react"
|
||||
import { Fragment, useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
@@ -19,7 +20,12 @@ import {
|
||||
import { useSettingModal } from "../settings/modal/useSettingModal"
|
||||
import { availableActionMap } from "./constants"
|
||||
|
||||
export const ThenSection = ({ index }: { index: number }) => {
|
||||
type ThenSectionProps = {
|
||||
index: number
|
||||
variant?: "detail" | "compact"
|
||||
}
|
||||
|
||||
export const ThenSection = ({ index, variant: _variant = "detail" }: ThenSectionProps) => {
|
||||
const { t } = useTranslation("settings")
|
||||
const result = useActionRule(index, (a) => a.result)
|
||||
|
||||
@@ -33,28 +39,26 @@ export const ThenSection = ({ index }: { index: number }) => {
|
||||
const extendedAvailableActionMap: Record<
|
||||
ActionId,
|
||||
ActionAction & {
|
||||
config?: () => React.ReactNode
|
||||
config?: () => ReactNode
|
||||
}
|
||||
> = merge(availableActionMap, {
|
||||
rewriteRules: {
|
||||
config: () => (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-col gap-3">
|
||||
{!rewriteRules || rewriteRules.length === 0 ? (
|
||||
<div className="flex items-center justify-between rounded-lg border border-dashed p-3">
|
||||
<span className="text-muted-foreground text-sm">Add rewrite rules</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.addRewriteRule(index)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-add-cute-re" />
|
||||
</Button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className="flex items-center justify-between rounded-lg bg-fill-quaternary px-4 py-3 text-xs text-text-tertiary transition-colors hover:bg-fill-tertiary hover:text-text disabled:opacity-50"
|
||||
onClick={() => {
|
||||
actionActions.addRewriteRule(index)
|
||||
}}
|
||||
>
|
||||
<span>{t("actions.action_card.rewrite_rules")}</span>
|
||||
<i className="i-mgc-add-cute-re" />
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<div className="flex flex-col gap-3">
|
||||
{rewriteRules.map((rule, rewriteIdx) => {
|
||||
const change = (key: "from" | "to", value: string) => {
|
||||
actionActions.updateRewriteRule({
|
||||
@@ -65,112 +69,116 @@ export const ThenSection = ({ index }: { index: number }) => {
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div key={rewriteIdx} className="group/rewrite-item flex items-end gap-2">
|
||||
<div className="w-full">
|
||||
<label className="text-muted-foreground text-sm">
|
||||
<div
|
||||
key={rewriteIdx}
|
||||
className="flex flex-col gap-3 rounded-lg bg-fill-quaternary p-4"
|
||||
>
|
||||
<div className="grid gap-3 @[520px]:grid-cols-2">
|
||||
<label className="text-xs font-medium uppercase tracking-wide text-text-secondary">
|
||||
{t("actions.action_card.from")}
|
||||
<Input
|
||||
disabled={disabled}
|
||||
value={rule.from}
|
||||
className="mt-2 h-9"
|
||||
onChange={(event) => change("from", event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<Input
|
||||
disabled={disabled}
|
||||
value={rule.from}
|
||||
className="h-8"
|
||||
onChange={(e) => change("from", e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<label className="text-muted-foreground text-sm">
|
||||
<label className="text-xs font-medium uppercase tracking-wide text-text-secondary">
|
||||
{t("actions.action_card.to")}
|
||||
<Input
|
||||
disabled={disabled}
|
||||
value={rule.to}
|
||||
className="mt-2 h-9"
|
||||
onChange={(event) => change("to", event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<Input
|
||||
disabled={disabled}
|
||||
value={rule.to}
|
||||
className="h-8"
|
||||
onChange={(e) => change("to", e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-1 text-text-secondary">
|
||||
<ActionButton
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<IconButton
|
||||
icon="i-mgc-add-cute-re"
|
||||
ariaLabel={t("actions.action_card.add")}
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.addRewriteRule(index)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-add-cute-re" />
|
||||
</ActionButton>
|
||||
<ActionButton
|
||||
/>
|
||||
<IconButton
|
||||
icon="i-mgc-delete-2-cute-re"
|
||||
className="hover:text-red"
|
||||
ariaLabel={t("actions.action_card.summary.delete")}
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.deleteRewriteRule(index, rewriteIdx)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-delete-2-cute-re" />
|
||||
</ActionButton>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
webhooks: {
|
||||
config: () => (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex flex-col gap-3">
|
||||
{!webhooks || webhooks.length === 0 ? (
|
||||
<div className="flex items-center justify-between rounded-lg border border-dashed p-3">
|
||||
<span className="text-muted-foreground text-sm">Add webhooks</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.addWebhook(index)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-add-cute-re" />
|
||||
</Button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
className="flex items-center justify-between rounded-lg bg-fill-quaternary px-4 py-3 text-xs text-text-tertiary transition-colors hover:bg-fill-tertiary hover:text-text disabled:opacity-50"
|
||||
onClick={() => {
|
||||
actionActions.addWebhook(index)
|
||||
}}
|
||||
>
|
||||
<span>{t("actions.action_card.webhooks")}</span>
|
||||
<i className="i-mgc-add-cute-re" />
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<div className="flex flex-col gap-3">
|
||||
{webhooks.map((webhook, webhookIdx) => {
|
||||
return (
|
||||
<div key={webhookIdx} className="flex items-center gap-2">
|
||||
<div
|
||||
key={webhookIdx}
|
||||
className="flex flex-col gap-2 rounded-lg bg-fill-quaternary p-4"
|
||||
>
|
||||
<Input
|
||||
disabled={disabled}
|
||||
value={webhook}
|
||||
className="h-8"
|
||||
className="h-9"
|
||||
placeholder="https://"
|
||||
onChange={(e) => {
|
||||
onChange={(event) => {
|
||||
actionActions.updateWebhook({
|
||||
index,
|
||||
webhookIndex: webhookIdx,
|
||||
value: e.target.value,
|
||||
value: event.target.value,
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<div className="flex gap-1 text-text-secondary">
|
||||
<ActionButton
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<IconButton
|
||||
icon="i-mgc-add-cute-re"
|
||||
ariaLabel={t("actions.action_card.add")}
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.addWebhook(index)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-add-cute-re" />
|
||||
</ActionButton>
|
||||
<ActionButton
|
||||
/>
|
||||
<IconButton
|
||||
icon="i-mgc-delete-2-cute-re"
|
||||
className="hover:text-red"
|
||||
ariaLabel={t("actions.action_card.summary.delete")}
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.deleteWebhook(index, webhookIdx)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-delete-2-cute-re" />
|
||||
</ActionButton>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
@@ -178,89 +186,204 @@ export const ThenSection = ({ index }: { index: number }) => {
|
||||
})
|
||||
return Object.values(extendedAvailableActionMap)
|
||||
}, [disabled, index, rewriteRules, t, webhooks])
|
||||
const enabledActions = useMemo(
|
||||
() => availableActions.filter((action) => !!result?.[action.value]),
|
||||
[availableActions, result],
|
||||
)
|
||||
|
||||
const enabledActions = useMemo(() => {
|
||||
if (!result) return []
|
||||
|
||||
// Get the order of actions from the result object (insertion order)
|
||||
const resultKeys = Object.keys(result).filter((key) => result[key as ActionId])
|
||||
|
||||
// Sort availableActions based on the order in result object
|
||||
return resultKeys
|
||||
.map((key) => availableActions.find((action) => action.value === key))
|
||||
.filter((action): action is NonNullable<typeof action> => !!action)
|
||||
}, [availableActions, result])
|
||||
const notEnabledActions = useMemo(
|
||||
() => availableActions.filter((action) => !result?.[action.value]),
|
||||
[availableActions, result],
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<h2 className="text-lg font-semibold">{t("actions.action_card.then_do")}</h2>
|
||||
<div className="flex flex-col gap-2 pl-2">
|
||||
{enabledActions.map((action, i) => {
|
||||
return (
|
||||
<Fragment key={action.label}>
|
||||
<div className="group/action relative flex flex-col gap-2 py-2">
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<i className={action.iconClassname} />
|
||||
<span className="shrink grow truncate font-medium">{t(action.label)}</span>
|
||||
{action.prefixElement && <div className="ml-2">{action.prefixElement}</div>}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{action.settingsPath && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
settingModalPresent(action.settingsPath)
|
||||
}}
|
||||
>
|
||||
{t("actions.action_card.settings")}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
buttonClassName="opacity-0 group-hover/action:opacity-100"
|
||||
disabled={disabled}
|
||||
<section className="flex flex-col gap-4">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wide text-text-secondary">
|
||||
{t("actions.action_card.then_do")}
|
||||
</span>
|
||||
{enabledActions.length > 0 && (
|
||||
<span className="text-xs text-text-secondary">
|
||||
{t("actions.action_card.summary.action_count", { count: enabledActions.length })}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="relative flex flex-col">
|
||||
{enabledActions.length === 0 ? (
|
||||
<div className="flex flex-col items-center gap-3 rounded-lg bg-fill-quaternary px-4 py-6">
|
||||
<span className="text-xs text-text-secondary">
|
||||
{t("actions.action_card.summary.no_actions")}
|
||||
</span>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild disabled={disabled}>
|
||||
<Button variant="outline" size="sm" buttonClassName="border-dashed">
|
||||
<i className="i-mgc-add-cute-re mr-2" />
|
||||
{t("actions.action_card.add")}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-60">
|
||||
{notEnabledActions.map((action) => {
|
||||
return (
|
||||
<DropdownMenuItem
|
||||
key={action.label}
|
||||
onClick={() => {
|
||||
actionActions.deleteRuleAction(index, action.value)
|
||||
if (action.onEnable) {
|
||||
action.onEnable(index)
|
||||
} else {
|
||||
actionActions.patchRule(index, { result: { [action.value]: true } })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-close-cute-re" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{action.config && <div className="pl-6">{action.config()}</div>}
|
||||
</div>
|
||||
{i !== enabledActions.length - 1 && <Divider className="my-1" />}
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild disabled={disabled}>
|
||||
<Button variant="outline" buttonClassName="mt-2 w-full">
|
||||
<i className="i-mgc-add-cute-re mr-2" />
|
||||
{t("actions.action_card.add")}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56">
|
||||
{notEnabledActions.map((action) => {
|
||||
<div className="flex items-center gap-2">
|
||||
<i className={action.iconClassname} />
|
||||
{t(action.label)}
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
)
|
||||
})}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{enabledActions.map((action, actionIndex) => {
|
||||
const isLast = actionIndex === enabledActions.length - 1
|
||||
return (
|
||||
<DropdownMenuItem
|
||||
key={action.label}
|
||||
onClick={() => {
|
||||
if (action.onEnable) {
|
||||
action.onEnable(index)
|
||||
} else {
|
||||
actionActions.patchRule(index, { result: { [action.value]: true } })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<i className={action.iconClassname} />
|
||||
{t(action.label)}
|
||||
<Fragment key={action.label}>
|
||||
<div className="relative flex gap-4">
|
||||
{/* Connection line and icon */}
|
||||
<div className="relative flex flex-col items-center pt-0.5">
|
||||
<div className="flex size-9 shrink-0 items-center justify-center rounded-full bg-material-ultra-thick text-text shadow-sm">
|
||||
<i className={cn(action.iconClassname, "text-base")} />
|
||||
</div>
|
||||
{!isLast && (
|
||||
<div className="absolute left-1/2 top-9 h-[calc(100%+0.75rem)] w-0.5 -translate-x-1/2 bg-gradient-to-b from-fill-secondary to-transparent" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action content */}
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-3 pb-6 pt-0.5">
|
||||
<div className="flex items-center gap-4">
|
||||
{/* Label */}
|
||||
<span className="flex h-9 items-center text-sm font-medium text-text">
|
||||
{t(action.label)}
|
||||
</span>
|
||||
|
||||
{/* Spacer */}
|
||||
<div className="flex-1" />
|
||||
|
||||
{/* Value selector or prefix element */}
|
||||
{action.prefixElement && (
|
||||
<div className="text-xs">{action.prefixElement}</div>
|
||||
)}
|
||||
|
||||
{/* Settings button */}
|
||||
{action.settingsPath && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
buttonClassName="rounded-lg"
|
||||
onClick={() => {
|
||||
settingModalPresent(action.settingsPath)
|
||||
}}
|
||||
>
|
||||
{t("actions.action_card.settings")}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Delete button */}
|
||||
<IconButton
|
||||
icon="i-mgc-delete-2-cute-re"
|
||||
ariaLabel={t("actions.action_card.summary.delete")}
|
||||
disabled={disabled}
|
||||
className="hover:text-red"
|
||||
onClick={() => {
|
||||
actionActions.deleteRuleAction(index, action.value)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{action.config && (
|
||||
<div className="rounded-lg bg-fill-quinary p-4">{action.config()}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<div className="relative flex gap-4">
|
||||
<div className="size-9 shrink-0" />
|
||||
<div className="pb-2">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild disabled={disabled}>
|
||||
<Button variant="outline" size="sm" buttonClassName="border-dashed">
|
||||
<i className="i-mgc-add-cute-re mr-2" />
|
||||
{t("actions.action_card.add")}
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" className="w-60">
|
||||
{notEnabledActions.map((action) => {
|
||||
return (
|
||||
<DropdownMenuItem
|
||||
key={action.label}
|
||||
onClick={() => {
|
||||
if (action.onEnable) {
|
||||
action.onEnable(index)
|
||||
} else {
|
||||
actionActions.patchRule(index, { result: { [action.value]: true } })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<i className={action.iconClassname} />
|
||||
{t(action.label)}
|
||||
</div>
|
||||
</DropdownMenuItem>
|
||||
)
|
||||
})}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const IconButton = ({
|
||||
icon,
|
||||
onClick,
|
||||
ariaLabel,
|
||||
disabled,
|
||||
className,
|
||||
}: {
|
||||
icon: string
|
||||
onClick: () => void
|
||||
ariaLabel: string
|
||||
disabled?: boolean
|
||||
className?: string
|
||||
}) => {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={ariaLabel}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"flex size-6 items-center justify-center rounded-md text-text-secondary transition-colors hover:bg-fill-quaternary hover:text-text disabled:opacity-50",
|
||||
className,
|
||||
)}
|
||||
onClick={onClick}
|
||||
>
|
||||
<i className={icon} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { Input } from "@follow/components/ui/input/index.js"
|
||||
import { RadioGroup, RadioGroupItem } from "@follow/components/ui/radio-group/motion.js"
|
||||
import { SegmentGroup, SegmentItem } from "@follow/components/ui/segment/index.js"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
@@ -18,48 +18,50 @@ import { useTranslation } from "react-i18next"
|
||||
|
||||
import { ViewSelectContent } from "~/modules/feed/view-select-content"
|
||||
|
||||
export const WhenSection = ({ index }: { index: number }) => {
|
||||
type WhenSectionProps = {
|
||||
index: number
|
||||
}
|
||||
|
||||
export const WhenSection = ({ index }: WhenSectionProps) => {
|
||||
const { t } = useTranslation("settings")
|
||||
|
||||
const disabled = useActionRule(index, (a) => a.result.disabled)
|
||||
const condition = useActionRule(index, (a) => a.condition)
|
||||
|
||||
const mode = condition.length > 0 ? "filter" : "all"
|
||||
|
||||
const handleModeChange = (value: "all" | "filter") => {
|
||||
if (value === "all" && condition.length > 0) {
|
||||
actionActions.toggleRuleFilter(index)
|
||||
}
|
||||
|
||||
if (value === "filter" && condition.length === 0) {
|
||||
actionActions.toggleRuleFilter(index)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<h2 className="text-lg font-semibold">{t("actions.action_card.when_feeds_match")}</h2>
|
||||
<div className="pl-2">
|
||||
<RadioGroup
|
||||
value={condition.length > 0 ? "filter" : "all"}
|
||||
onValueChange={(value) => {
|
||||
actionActions.patchRule(index, {
|
||||
condition: value === "all" ? [] : [[{}]],
|
||||
})
|
||||
}}
|
||||
className="flex gap-8"
|
||||
<section className="flex flex-col gap-4">
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<span className="text-xs font-semibold uppercase tracking-wide text-text-secondary">
|
||||
{t("actions.action_card.when_feeds_match")}
|
||||
</span>
|
||||
<SegmentGroup
|
||||
value={mode}
|
||||
onValueChanged={(value) => handleModeChange(value as "all" | "filter")}
|
||||
>
|
||||
<RadioGroupItem
|
||||
labelClassName="text-sm"
|
||||
disabled={disabled}
|
||||
label={t("actions.action_card.all")}
|
||||
value="all"
|
||||
/>
|
||||
<RadioGroupItem
|
||||
labelClassName="text-sm"
|
||||
disabled={disabled}
|
||||
label={t("actions.action_card.custom_filters")}
|
||||
value="filter"
|
||||
/>
|
||||
</RadioGroup>
|
||||
<SegmentItem value="all" label={t("actions.action_card.all")} />
|
||||
<SegmentItem value="filter" label={t("actions.action_card.custom_filters")} />
|
||||
</SegmentGroup>
|
||||
</div>
|
||||
|
||||
{condition.length > 0 && (
|
||||
<div className="flex flex-col gap-4 pl-2 pt-4">
|
||||
{mode === "filter" && (
|
||||
<div className="flex flex-col gap-4">
|
||||
{condition.map((orConditions, orConditionIdx) => {
|
||||
return (
|
||||
<Fragment key={orConditionIdx}>
|
||||
<div className="group/or relative flex flex-col gap-2 rounded-lg border p-2 pl-6 @[500px]:p-4">
|
||||
<div className="absolute left-3 top-9 h-[calc(100%-4.5rem)] w-px bg-border" />
|
||||
{orConditions.map((condition, conditionIdx) => {
|
||||
<div className="flex flex-col gap-3 rounded-lg border border-dashed border-border bg-transparent p-4">
|
||||
{orConditions.map((item, conditionIdx) => {
|
||||
const actionConditionIndex = {
|
||||
ruleIndex: index,
|
||||
groupIndex: orConditionIdx,
|
||||
@@ -71,51 +73,52 @@ export const WhenSection = ({ index }: { index: number }) => {
|
||||
[key]: value,
|
||||
})
|
||||
}
|
||||
|
||||
const type =
|
||||
filterFieldOptions.find((option) => option.value === condition.field)?.type ||
|
||||
filterFieldOptions.find((option) => option.value === item.field)?.type ||
|
||||
"text"
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2" key={conditionIdx}>
|
||||
<div className="group/condition-item relative flex items-center gap-2">
|
||||
<div className="absolute -left-3.5 top-1/2 h-px w-3 -translate-y-1/2 bg-border" />
|
||||
<div className="absolute -left-3.5 top-1/2 size-1.5 -translate-y-1/2 rounded-full border bg-background" />
|
||||
<div key={conditionIdx} className="flex flex-col gap-2">
|
||||
<div className="flex flex-col gap-2 rounded-lg border border-fill-secondary bg-transparent p-3 @[800px]:flex-row @[800px]:items-center">
|
||||
<ResponsiveSelect
|
||||
placeholder="Select Field"
|
||||
disabled={disabled}
|
||||
value={condition.field}
|
||||
value={item.field}
|
||||
onValueChange={(value) => change("field", value as ActionFeedField)}
|
||||
items={filterFieldOptions.map((option) => ({
|
||||
...option,
|
||||
label: t(option.label),
|
||||
}))}
|
||||
triggerClassName="h-8"
|
||||
triggerClassName="h-9 min-w-[160px] @[800px]:flex-1"
|
||||
/>
|
||||
<OperationSelect
|
||||
type={type}
|
||||
disabled={disabled}
|
||||
value={condition.operator}
|
||||
value={item.operator}
|
||||
onValueChange={(value) => change("operator", value)}
|
||||
/>
|
||||
<ValueInput
|
||||
type={type}
|
||||
value={condition.value}
|
||||
value={item.value}
|
||||
onChange={(value) => change("value", value)}
|
||||
disabled={disabled}
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
buttonClassName="opacity-0 group-hover/condition-item:opacity-100"
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t("actions.action_card.summary.delete")}
|
||||
className="flex size-9 shrink-0 items-center justify-center self-end rounded-lg border border-fill-secondary bg-transparent text-text-secondary transition-colors hover:border-fill hover:bg-fill-quinary hover:text-text disabled:opacity-50 @[800px]:self-center"
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.deleteConditionItem(actionConditionIndex)
|
||||
}}
|
||||
>
|
||||
<i className="i-mgc-delete-2-cute-re" />
|
||||
</Button>
|
||||
</button>
|
||||
</div>
|
||||
{conditionIdx !== orConditions.length - 1 && (
|
||||
<div className="flex items-center pl-2">
|
||||
<span className="text-muted-foreground text-sm">
|
||||
<div className="flex items-center text-xs text-text-secondary">
|
||||
<span className="rounded-md border border-border bg-material-medium px-2 py-0.5 font-bold uppercase tracking-wide">
|
||||
{t("actions.action_card.and")}
|
||||
</span>
|
||||
</div>
|
||||
@@ -125,7 +128,8 @@ export const WhenSection = ({ index }: { index: number }) => {
|
||||
})}
|
||||
<Button
|
||||
variant="outline"
|
||||
buttonClassName="mt-2"
|
||||
size="sm"
|
||||
buttonClassName="w-fit border-dashed border-border "
|
||||
disabled={disabled}
|
||||
onClick={() => {
|
||||
actionActions.addConditionItem({
|
||||
@@ -139,9 +143,8 @@ export const WhenSection = ({ index }: { index: number }) => {
|
||||
</Button>
|
||||
</div>
|
||||
{orConditionIdx !== condition.length - 1 && (
|
||||
<div className="relative flex h-8 w-full items-center justify-center">
|
||||
<div className="absolute left-0 top-1/2 h-px w-full bg-border" />
|
||||
<span className="text-muted-foreground z-[1] bg-background px-2 text-sm">
|
||||
<div className="flex items-center justify-center">
|
||||
<span className="rounded-md border border-border bg-material-medium px-3 py-1 text-xs font-semibold uppercase tracking-wide text-text-secondary">
|
||||
{t("actions.action_card.or")}
|
||||
</span>
|
||||
</div>
|
||||
@@ -151,6 +154,8 @@ export const WhenSection = ({ index }: { index: number }) => {
|
||||
})}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
buttonClassName="w-fit border-dashed border-border "
|
||||
onClick={() => {
|
||||
actionActions.addConditionGroup({ ruleIndex: index })
|
||||
}}
|
||||
@@ -161,7 +166,7 @@ export const WhenSection = ({ index }: { index: number }) => {
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -192,9 +197,9 @@ const OperationSelect = ({
|
||||
placeholder="Select Operation"
|
||||
disabled={disabled}
|
||||
value={value}
|
||||
onValueChange={(value) => onValueChange?.(value as ActionOperation)}
|
||||
onValueChange={(nextValue) => onValueChange?.(nextValue as ActionOperation)}
|
||||
items={options}
|
||||
triggerClassName="h-8"
|
||||
triggerClassName="h-9 min-w-[150px]"
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -215,7 +220,7 @@ const ValueInput = ({
|
||||
return (
|
||||
<Select
|
||||
disabled={disabled}
|
||||
onValueChange={(value) => onChange(value)}
|
||||
onValueChange={(nextValue) => onChange(nextValue)}
|
||||
value={value as string | undefined}
|
||||
>
|
||||
<CommonSelectTrigger />
|
||||
@@ -230,7 +235,7 @@ const ValueInput = ({
|
||||
return (
|
||||
<Select
|
||||
disabled={disabled}
|
||||
onValueChange={(value) => onChange(value)}
|
||||
onValueChange={(nextValue) => onChange(nextValue)}
|
||||
value={value as string | undefined}
|
||||
>
|
||||
<CommonSelectTrigger />
|
||||
@@ -247,8 +252,8 @@ const ValueInput = ({
|
||||
disabled={disabled}
|
||||
type="number"
|
||||
value={value}
|
||||
className="h-8"
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="h-9"
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -257,8 +262,8 @@ const ValueInput = ({
|
||||
<Input
|
||||
disabled={disabled}
|
||||
value={value as string | undefined}
|
||||
className="h-8"
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className="h-9"
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -266,7 +271,7 @@ const ValueInput = ({
|
||||
}
|
||||
|
||||
const CommonSelectTrigger = () => (
|
||||
<SelectTrigger className="h-8">
|
||||
<SelectTrigger className="h-9 min-w-[150px]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
)
|
||||
|
||||
@@ -10,9 +10,9 @@ export function Component() {
|
||||
useSubViewTitle("words.actions")
|
||||
|
||||
return (
|
||||
<div className="flex size-full flex-col px-6 py-8">
|
||||
<div className="-mt-6 flex size-full min-h-[calc(100vh-8rem)] flex-col px-6">
|
||||
{/* Simple Header */}
|
||||
<div className="mx-auto mb-8 max-w-6xl text-center">
|
||||
<div className="mx-auto max-w-6xl text-center">
|
||||
<h1 className="mb-4 text-3xl font-bold text-text">{t("words.actions")}</h1>
|
||||
|
||||
{/* Documentation Link */}
|
||||
@@ -28,7 +28,7 @@ export function Component() {
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="mx-auto w-full max-w-6xl">
|
||||
<div className="relative mx-auto flex min-h-0 w-full max-w-6xl flex-1 flex-col @container">
|
||||
<ActionSetting />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -64,6 +64,23 @@
|
||||
"actions.action_card.silence": "Silence",
|
||||
"actions.action_card.source_content": "View Source Content",
|
||||
"actions.action_card.star": "Star",
|
||||
"actions.action_card.summary.action_count": "{{count}} actions enabled",
|
||||
"actions.action_card.summary.active": "Active",
|
||||
"actions.action_card.summary.copy": "Copy to Clipboard",
|
||||
"actions.action_card.summary.delete": "Delete",
|
||||
"actions.action_card.summary.delete_message": "Are you sure you want to delete this rule? This action cannot be undone.",
|
||||
"actions.action_card.summary.delete_title": "Delete Rule",
|
||||
"actions.action_card.summary.disabled": "Disabled",
|
||||
"actions.action_card.summary.empty": "No rules yet",
|
||||
"actions.action_card.summary.export": "Export to File",
|
||||
"actions.action_card.summary.helper": "Automate your workflow with precise triggers and actions.",
|
||||
"actions.action_card.summary.import": "Import",
|
||||
"actions.action_card.summary.import_clipboard": "Import from Clipboard",
|
||||
"actions.action_card.summary.import_file": "Import from File",
|
||||
"actions.action_card.summary.no_actions": "No actions configured yet",
|
||||
"actions.action_card.summary.rule_count": "{{count}} rules",
|
||||
"actions.action_card.summary.share": "Share",
|
||||
"actions.action_card.summary.toggle": "Toggle rule status",
|
||||
"actions.action_card.then_do": "Then Do…",
|
||||
"actions.action_card.to": "To",
|
||||
"actions.action_card.translate_into": "Translate",
|
||||
|
||||
@@ -64,6 +64,23 @@
|
||||
"actions.action_card.silence": "サイレント",
|
||||
"actions.action_card.source_content": "ソースコンテンツを表示する",
|
||||
"actions.action_card.star": "スター",
|
||||
"actions.action_card.summary.action_count": "有効なアクション {{count}} 件",
|
||||
"actions.action_card.summary.active": "有効",
|
||||
"actions.action_card.summary.copy": "クリップボードにコピー",
|
||||
"actions.action_card.summary.delete": "削除",
|
||||
"actions.action_card.summary.delete_message": "このルールを削除してもよろしいですか?この操作は元に戻せません。",
|
||||
"actions.action_card.summary.delete_title": "ルールを削除",
|
||||
"actions.action_card.summary.disabled": "無効",
|
||||
"actions.action_card.summary.empty": "ルールはまだありません",
|
||||
"actions.action_card.summary.export": "ファイルにエクスポート",
|
||||
"actions.action_card.summary.helper": "条件とアクションを組み合わせてワークフローを自動化しましょう。",
|
||||
"actions.action_card.summary.import": "インポート",
|
||||
"actions.action_card.summary.import_clipboard": "クリップボードからインポート",
|
||||
"actions.action_card.summary.import_file": "ファイルからインポート",
|
||||
"actions.action_card.summary.no_actions": "アクションはまだ設定されていません",
|
||||
"actions.action_card.summary.rule_count": "ルール {{count}} 件",
|
||||
"actions.action_card.summary.share": "共有",
|
||||
"actions.action_card.summary.toggle": "ルールの有効・無効を切り替える",
|
||||
"actions.action_card.then_do": "次に行う…",
|
||||
"actions.action_card.to": "へ",
|
||||
"actions.action_card.translate_into": "翻訳する",
|
||||
|
||||
@@ -64,6 +64,23 @@
|
||||
"actions.action_card.silence": "静音",
|
||||
"actions.action_card.source_content": "查看原始内容",
|
||||
"actions.action_card.star": "收藏",
|
||||
"actions.action_card.summary.action_count": "已启用 {{count}} 个动作",
|
||||
"actions.action_card.summary.active": "启用",
|
||||
"actions.action_card.summary.copy": "复制到剪贴板",
|
||||
"actions.action_card.summary.delete": "删除",
|
||||
"actions.action_card.summary.delete_message": "确定要删除此规则吗?该操作无法撤销。",
|
||||
"actions.action_card.summary.delete_title": "删除规则",
|
||||
"actions.action_card.summary.disabled": "已禁用",
|
||||
"actions.action_card.summary.empty": "暂时还没有规则",
|
||||
"actions.action_card.summary.export": "导出到文件",
|
||||
"actions.action_card.summary.helper": "用精准的触发条件和动作自动化你的工作流。",
|
||||
"actions.action_card.summary.import": "导入",
|
||||
"actions.action_card.summary.import_clipboard": "从剪贴板导入",
|
||||
"actions.action_card.summary.import_file": "从文件导入",
|
||||
"actions.action_card.summary.no_actions": "尚未配置任何动作",
|
||||
"actions.action_card.summary.rule_count": "{{count}} 条规则",
|
||||
"actions.action_card.summary.share": "分享",
|
||||
"actions.action_card.summary.toggle": "切换规则状态",
|
||||
"actions.action_card.then_do": "执行动作",
|
||||
"actions.action_card.to": "到",
|
||||
"actions.action_card.translate_into": "翻译成",
|
||||
|
||||
@@ -61,6 +61,23 @@
|
||||
"actions.action_card.silence": "靜音",
|
||||
"actions.action_card.source_content": "瀏覽原始内容",
|
||||
"actions.action_card.star": "收藏",
|
||||
"actions.action_card.summary.action_count": "已啟用 {{count}} 個動作",
|
||||
"actions.action_card.summary.active": "啟用中",
|
||||
"actions.action_card.summary.copy": "複製到剪貼簿",
|
||||
"actions.action_card.summary.delete": "刪除",
|
||||
"actions.action_card.summary.delete_message": "確定要刪除此規則嗎?此操作無法復原。",
|
||||
"actions.action_card.summary.delete_title": "刪除規則",
|
||||
"actions.action_card.summary.disabled": "已停用",
|
||||
"actions.action_card.summary.empty": "尚未建立任何規則",
|
||||
"actions.action_card.summary.export": "匯出成檔案",
|
||||
"actions.action_card.summary.helper": "透過精準的條件與動作,自動化你的工作流程。",
|
||||
"actions.action_card.summary.import": "匯入",
|
||||
"actions.action_card.summary.import_clipboard": "從剪貼簿匯入",
|
||||
"actions.action_card.summary.import_file": "從檔案匯入",
|
||||
"actions.action_card.summary.no_actions": "尚未設定任何動作",
|
||||
"actions.action_card.summary.rule_count": "{{count}} 條規則",
|
||||
"actions.action_card.summary.share": "分享",
|
||||
"actions.action_card.summary.toggle": "切換規則狀態",
|
||||
"actions.action_card.then_do": "然後執行…",
|
||||
"actions.action_card.to": "到",
|
||||
"actions.action_card.translate_into": "翻譯成",
|
||||
|
||||
Reference in New Issue
Block a user