mirror of https://github.com/usual2970/certimate
improve data display
parent
9132d47f4d
commit
8901f5d40e
|
@ -27,7 +27,7 @@ import DeployToLocal from "./DeployToLocal";
|
||||||
import DeployToSSH from "./DeployToSSH";
|
import DeployToSSH from "./DeployToSSH";
|
||||||
import DeployToWebhook from "./DeployToWebhook";
|
import DeployToWebhook from "./DeployToWebhook";
|
||||||
import DeployToKubernetesSecret from "./DeployToKubernetesSecret";
|
import DeployToKubernetesSecret from "./DeployToKubernetesSecret";
|
||||||
import DeployToVolcengineLive from "./DeployToVolcengineLive"
|
import DeployToVolcengineLive from "./DeployToVolcengineLive";
|
||||||
import { deployTargetsMap, type DeployConfig } from "@/domain/domain";
|
import { deployTargetsMap, type DeployConfig } from "@/domain/domain";
|
||||||
import { accessProvidersMap } from "@/domain/access";
|
import { accessProvidersMap } from "@/domain/access";
|
||||||
import { useConfigContext } from "@/providers/config";
|
import { useConfigContext } from "@/providers/config";
|
||||||
|
|
|
@ -0,0 +1,327 @@
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import { useToast } from "@/components/ui/use-toast";
|
||||||
|
import { getErrMessage } from "@/lib/error";
|
||||||
|
import { NotifyChannelEmail, NotifyChannels } from "@/domain/settings";
|
||||||
|
import { useNotifyContext } from "@/providers/notify";
|
||||||
|
import { update } from "@/repository/settings";
|
||||||
|
import Show from "@/components/Show";
|
||||||
|
import { notifyTest } from "@/api/notify";
|
||||||
|
|
||||||
|
type MailSetting = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
data: NotifyChannelEmail;
|
||||||
|
};
|
||||||
|
|
||||||
|
const Mail = () => {
|
||||||
|
const { config, setChannels } = useNotifyContext();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [changed, setChanged] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [mail, setmail] = useState<MailSetting>({
|
||||||
|
id: config.id ?? "",
|
||||||
|
name: "notifyChannels",
|
||||||
|
data: {
|
||||||
|
senderAddress: "",
|
||||||
|
receiverAddresses: "",
|
||||||
|
smtpHostAddr: "",
|
||||||
|
smtpHostPort: "25",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const [originMail, setoriginMail] = useState<MailSetting>({
|
||||||
|
id: config.id ?? "",
|
||||||
|
name: "notifyChannels",
|
||||||
|
data: {
|
||||||
|
senderAddress: "",
|
||||||
|
receiverAddresses: "",
|
||||||
|
smtpHostAddr: "",
|
||||||
|
smtpHostPort: "25",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setChanged(false);
|
||||||
|
}, [config]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const data = getDetailMail();
|
||||||
|
setoriginMail({
|
||||||
|
id: config.id ?? "",
|
||||||
|
name: "mail",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}, [config]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const data = getDetailMail();
|
||||||
|
setmail({
|
||||||
|
id: config.id ?? "",
|
||||||
|
name: "mail",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}, [config]);
|
||||||
|
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const getDetailMail = () => {
|
||||||
|
const df: NotifyChannelMail = {
|
||||||
|
senderAddress: "",
|
||||||
|
receiverAddresses: "",
|
||||||
|
smtpHostAddr: "",
|
||||||
|
smtpHostPort: "25",
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
enabled: false,
|
||||||
|
};
|
||||||
|
if (!config.content) {
|
||||||
|
return df;
|
||||||
|
}
|
||||||
|
const chanels = config.content as NotifyChannels;
|
||||||
|
if (!chanels.mail) {
|
||||||
|
return df;
|
||||||
|
}
|
||||||
|
|
||||||
|
return chanels.mail as NotifyChannelMail;
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkChanged = (data: NotifyChannelMail) => {
|
||||||
|
if (
|
||||||
|
data.senderAddress !== originMail.data.senderAddress ||
|
||||||
|
data.receiverAddresses !== originMail.data.receiverAddresses ||
|
||||||
|
data.smtpHostAddr !== originMail.data.smtpHostAddr ||
|
||||||
|
data.smtpHostPort !== originMail.data.smtpHostPort ||
|
||||||
|
data.username !== originMail.data.username ||
|
||||||
|
data.password !== originMail.data.password
|
||||||
|
) {
|
||||||
|
setChanged(true);
|
||||||
|
} else {
|
||||||
|
setChanged(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSaveClick = async () => {
|
||||||
|
try {
|
||||||
|
const resp = await update({
|
||||||
|
...config,
|
||||||
|
name: "notifyChannels",
|
||||||
|
content: {
|
||||||
|
...config.content,
|
||||||
|
mail: {
|
||||||
|
...mail.data,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
setChannels(resp);
|
||||||
|
toast({
|
||||||
|
title: t("common.save.succeeded.message"),
|
||||||
|
description: t("settings.notification.config.saved.message"),
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
const msg = getErrMessage(e);
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: t("common.save.failed.message"),
|
||||||
|
description: `${t("settings.notification.config.failed.message")}: ${msg}`,
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePushTestClick = async () => {
|
||||||
|
try {
|
||||||
|
await notifyTest("mail");
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: t("settings.notification.config.push.test.message.success.message"),
|
||||||
|
description: t("settings.notification.config.push.test.message.success.message"),
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
const msg = getErrMessage(e);
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: t("settings.notification.config.push.test.message.failed.message"),
|
||||||
|
description: `${t("settings.notification.config.push.test.message.failed.message")}: ${msg}`,
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSwitchChange = async () => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
enabled: !mail.data.enabled,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
setmail(newData);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const resp = await update({
|
||||||
|
...config,
|
||||||
|
name: "notifyChannels",
|
||||||
|
content: {
|
||||||
|
...config.content,
|
||||||
|
mail: {
|
||||||
|
...newData.data,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
setChannels(resp);
|
||||||
|
} catch (e) {
|
||||||
|
const msg = getErrMessage(e);
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: t("common.save.failed.message"),
|
||||||
|
description: `${t("settings.notification.config.failed.message")}: ${msg}`,
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Input
|
||||||
|
placeholder={t("settings.notification.mail.sender_address.placeholder")}
|
||||||
|
value={mail.data.senderAddress}
|
||||||
|
onChange={(e) => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
senderAddress: e.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
checkChanged(newData.data);
|
||||||
|
setmail(newData);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder={t("settings.notification.mail.receiver_address.placeholder")}
|
||||||
|
className="mt-2"
|
||||||
|
value={mail.data.receiverAddresses}
|
||||||
|
onChange={(e) => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
receiverAddresses: e.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
checkChanged(newData.data);
|
||||||
|
setmail(newData);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder={t("settings.notification.mail.smtp_host.placeholder")}
|
||||||
|
className="mt-2"
|
||||||
|
value={mail.data.smtpHostAddr}
|
||||||
|
onChange={(e) => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
smtpHostAddr: e.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
checkChanged(newData.data);
|
||||||
|
setmail(newData);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder={t("settings.notification.mail.smtp_port.placeholder")}
|
||||||
|
className="mt-2"
|
||||||
|
value={mail.data.smtpHostPort}
|
||||||
|
onChange={(e) => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
smtpHostPort: e.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
checkChanged(newData.data);
|
||||||
|
setmail(newData);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder={t("settings.notification.mail.username.placeholder")}
|
||||||
|
className="mt-2"
|
||||||
|
value={mail.data.username}
|
||||||
|
onChange={(e) => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
username: e.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
checkChanged(newData.data);
|
||||||
|
setmail(newData);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder={t("settings.notification.mail.password.placeholder")}
|
||||||
|
className="mt-2"
|
||||||
|
value={mail.data.password}
|
||||||
|
onChange={(e) => {
|
||||||
|
const newData = {
|
||||||
|
...mail,
|
||||||
|
data: {
|
||||||
|
...mail.data,
|
||||||
|
password: e.target.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
checkChanged(newData.data);
|
||||||
|
setmail(newData);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="flex items-center space-x-1 mt-2">
|
||||||
|
<Switch id="airplane-mode" checked={mail.data.enabled} onCheckedChange={handleSwitchChange} />
|
||||||
|
<Label htmlFor="airplane-mode">{t("settings.notification.config.enable")}</Label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-end mt-2">
|
||||||
|
<Show when={changed}>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
handleSaveClick();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("common.save")}
|
||||||
|
</Button>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
<Show when={!changed && mail.id != ""}>
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() => {
|
||||||
|
handlePushTestClick();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("settings.notification.config.push.test.message")}
|
||||||
|
</Button>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Mail;
|
||||||
|
|
|
@ -24,12 +24,12 @@ const CustomAlertDialog = ({ open, title, description, confirm, onOpenChange }:
|
||||||
return (
|
return (
|
||||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader className="dark:text-stone-200">
|
||||||
<AlertDialogTitle>{title}</AlertDialogTitle>
|
<AlertDialogTitle>{title}</AlertDialogTitle>
|
||||||
<AlertDialogDescription>{description}</AlertDialogDescription>
|
<AlertDialogDescription>{description}</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t("common.cancel")}</AlertDialogCancel>
|
<AlertDialogCancel className="dark:text-stone-200">{t("common.cancel")}</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
confirm && confirm();
|
confirm && confirm();
|
||||||
|
|
|
@ -3,20 +3,23 @@ import { ColumnDef, flexRender, getCoreRowModel, getPaginationRowModel, Paginati
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
interface DataTableProps<TData, TValue> {
|
interface DataTableProps<TData extends { id: string }, TValue> {
|
||||||
columns: ColumnDef<TData, TValue>[];
|
columns: ColumnDef<TData, TValue>[];
|
||||||
data: TData[];
|
data: TData[];
|
||||||
pageCount: number;
|
pageCount: number;
|
||||||
onPageChange?: (pageIndex: number, pageSize?: number) => Promise<void>;
|
onPageChange?: (pageIndex: number, pageSize?: number) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DataTable<TData, TValue>({ columns, data, onPageChange, pageCount }: DataTableProps<TData, TValue>) {
|
export function DataTable<TData extends { id: string }, TValue>({ columns, data, onPageChange, pageCount }: DataTableProps<TData, TValue>) {
|
||||||
const [{ pageIndex, pageSize }, setPagination] = useState<PaginationState>({
|
const [{ pageIndex, pageSize }, setPagination] = useState<PaginationState>({
|
||||||
pageIndex: 0,
|
pageIndex: 0,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const pagination = {
|
const pagination = {
|
||||||
pageIndex,
|
pageIndex,
|
||||||
pageSize,
|
pageSize,
|
||||||
|
@ -39,13 +42,17 @@ export function DataTable<TData, TValue>({ columns, data, onPageChange, pageCoun
|
||||||
onPageChange?.(pageIndex, pageSize);
|
onPageChange?.(pageIndex, pageSize);
|
||||||
}, [pageIndex]);
|
}, [pageIndex]);
|
||||||
|
|
||||||
|
const handleRowClick = (id: string) => {
|
||||||
|
navigate(`/workflow/detail?id=${id}`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="rounded-md">
|
<div className="rounded-md">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
<TableRow key={headerGroup.id} className="border-muted-foreground">
|
<TableRow key={headerGroup.id} className="dark:border-muted-foreground">
|
||||||
{headerGroup.headers.map((header) => {
|
{headerGroup.headers.map((header) => {
|
||||||
return <TableHead key={header.id}>{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}</TableHead>;
|
return <TableHead key={header.id}>{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}</TableHead>;
|
||||||
})}
|
})}
|
||||||
|
@ -55,7 +62,15 @@ export function DataTable<TData, TValue>({ columns, data, onPageChange, pageCoun
|
||||||
<TableBody className="dark:text-stone-200">
|
<TableBody className="dark:text-stone-200">
|
||||||
{table.getRowModel().rows?.length ? (
|
{table.getRowModel().rows?.length ? (
|
||||||
table.getRowModel().rows.map((row) => (
|
table.getRowModel().rows.map((row) => (
|
||||||
<TableRow key={row.id} data-state={row.getIsSelected() && "selected"} className="border-muted-foreground">
|
<TableRow
|
||||||
|
key={row.id}
|
||||||
|
data-state={row.getIsSelected() && "selected"}
|
||||||
|
className="dark:border-muted-foreground"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
handleRowClick(row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
{row.getVisibleCells().map((cell) => (
|
{row.getVisibleCells().map((cell) => (
|
||||||
<TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell>
|
<TableCell key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</TableCell>
|
||||||
))}
|
))}
|
||||||
|
@ -84,4 +99,3 @@ export function DataTable<TData, TValue>({ columns, data, onPageChange, pageCoun
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "
|
||||||
import { Input } from "../ui/input";
|
import { Input } from "../ui/input";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useState } from "react";
|
import { memo, useState } from "react";
|
||||||
|
|
||||||
type WorkflowNameEditDialogProps = {
|
type WorkflowNameEditDialogProps = {
|
||||||
trigger: React.ReactNode;
|
trigger: React.ReactNode;
|
||||||
|
@ -28,10 +28,6 @@ const WorkflowNameBaseInfoDialog = ({ trigger }: WorkflowNameEditDialogProps) =>
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof formSchema>>({
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
|
||||||
name: workflow.name,
|
|
||||||
description: workflow.description,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -72,7 +68,14 @@ const WorkflowNameBaseInfoDialog = ({ trigger }: WorkflowNameEditDialogProps) =>
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>名称</FormLabel>
|
<FormLabel>名称</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="请输入流程名称" {...field} />
|
<Input
|
||||||
|
placeholder="请输入流程名称"
|
||||||
|
{...field}
|
||||||
|
defaultValue={workflow.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
form.setValue("name", e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
@ -87,7 +90,14 @@ const WorkflowNameBaseInfoDialog = ({ trigger }: WorkflowNameEditDialogProps) =>
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>说明</FormLabel>
|
<FormLabel>说明</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="请输入流程说明" {...field} />
|
<Input
|
||||||
|
placeholder="请输入流程说明"
|
||||||
|
{...field}
|
||||||
|
defaultValue={workflow.description}
|
||||||
|
onChange={(e) => {
|
||||||
|
form.setValue("description", e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
@ -107,4 +117,4 @@ const WorkflowNameBaseInfoDialog = ({ trigger }: WorkflowNameEditDialogProps) =>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default WorkflowNameBaseInfoDialog;
|
export default memo(WorkflowNameBaseInfoDialog);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import i18n from "@/i18n";
|
||||||
import { deployTargets, KVType } from "./domain";
|
import { deployTargets, KVType } from "./domain";
|
||||||
|
|
||||||
export type Workflow = {
|
export type Workflow = {
|
||||||
id?: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -125,6 +125,7 @@ export const initWorkflow = (): Workflow => {
|
||||||
root.next = newWorkflowNode(WorkflowNodeType.Notify, {});
|
root.next = newWorkflowNode(WorkflowNodeType.Notify, {});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
id: "",
|
||||||
name: i18n.t("workflow.default.name"),
|
name: i18n.t("workflow.default.name"),
|
||||||
type: "auto",
|
type: "auto",
|
||||||
crontab: "0 0 * * *",
|
crontab: "0 0 * * *",
|
||||||
|
|
|
@ -90,6 +90,9 @@ const Workflow = () => {
|
||||||
onCheckedChange={() => {
|
onCheckedChange={() => {
|
||||||
handleCheckedChange(row.original.id ?? "");
|
handleCheckedChange(row.original.id ?? "");
|
||||||
}}
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -127,7 +130,8 @@ const Workflow = () => {
|
||||||
<DropdownMenuContent align="end">
|
<DropdownMenuContent align="end">
|
||||||
<DropdownMenuLabel>操作</DropdownMenuLabel>
|
<DropdownMenuLabel>操作</DropdownMenuLabel>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
navigate(`/workflow/detail?id=${workflow.id}`);
|
navigate(`/workflow/detail?id=${workflow.id}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -135,7 +139,8 @@ const Workflow = () => {
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="text-red-500"
|
className="text-red-500"
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
handleDeleteClick(workflow.id ?? "");
|
handleDeleteClick(workflow.id ?? "");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -31,20 +31,20 @@ export type WorkflowState = {
|
||||||
|
|
||||||
export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
||||||
workflow: {
|
workflow: {
|
||||||
id: "root",
|
id: "",
|
||||||
name: "placeholder",
|
name: "placeholder",
|
||||||
type: WorkflowNodeType.Start,
|
type: WorkflowNodeType.Start,
|
||||||
},
|
},
|
||||||
initialized: false,
|
initialized: false,
|
||||||
init: async (id?: string) => {
|
init: async (id?: string) => {
|
||||||
let data = {
|
let data = {
|
||||||
|
id: "",
|
||||||
name: "placeholder",
|
name: "placeholder",
|
||||||
type: "auto",
|
type: "auto",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
data = initWorkflow();
|
data = initWorkflow();
|
||||||
data = await save(data);
|
|
||||||
} else {
|
} else {
|
||||||
data = await getWrokflow(id);
|
data = await getWrokflow(id);
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,15 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setBaseInfo: async (name: string, description: string) => {
|
setBaseInfo: async (name: string, description: string) => {
|
||||||
const resp = await save({
|
const data: Record<string, string | boolean | WorkflowNode> = {
|
||||||
id: (get().workflow.id as string) ?? "",
|
id: (get().workflow.id as string) ?? "",
|
||||||
name: name,
|
name: name,
|
||||||
description: description,
|
description: description,
|
||||||
});
|
};
|
||||||
|
if (!data.id) {
|
||||||
|
data.draft = get().workflow.draft as WorkflowNode;
|
||||||
|
}
|
||||||
|
const resp = await save(data);
|
||||||
set((state: WorkflowState) => {
|
set((state: WorkflowState) => {
|
||||||
return {
|
return {
|
||||||
workflow: {
|
workflow: {
|
||||||
|
@ -201,3 +205,4 @@ export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
||||||
return getWorkflowOutputBeforeId(get().workflow.draft as WorkflowNode, id, type);
|
return getWorkflowOutputBeforeId(get().workflow.draft as WorkflowNode, id, type);
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue