mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 13:39:53 +00:00
chore: remove unused code
This commit is contained in:
parent
b6203e57ed
commit
ef9ddd27a5
@ -29,8 +29,8 @@ import (
|
|||||||
/*
|
/*
|
||||||
提供商类型常量值。
|
提供商类型常量值。
|
||||||
|
|
||||||
注意:如果追加新的枚举值,请保持以 ASCII 排序。
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new enum, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
*/
|
*/
|
||||||
const (
|
const (
|
||||||
configTypeACMEHttpReq = "acmehttpreq"
|
configTypeACMEHttpReq = "acmehttpreq"
|
||||||
|
@ -15,8 +15,8 @@ import (
|
|||||||
/*
|
/*
|
||||||
提供商部署目标常量值。
|
提供商部署目标常量值。
|
||||||
|
|
||||||
注意:如果追加新的枚举值,请保持以 ASCII 排序。
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
NOTICE: If you add new enum, please keep ASCII order.
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
*/
|
*/
|
||||||
const (
|
const (
|
||||||
targetAliyunALB = "aliyun-alb"
|
targetAliyunALB = "aliyun-alb"
|
||||||
|
@ -33,10 +33,13 @@ import (
|
|||||||
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
"github.com/usual2970/certimate/internal/pkg/utils/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: 该方法目前未实际使用,将在后续迭代中替换
|
|
||||||
func createDeployer(target string, accessConfig string, deployConfig map[string]any) (deployer.Deployer, deployer.Logger, error) {
|
func createDeployer(target string, accessConfig string, deployConfig map[string]any) (deployer.Deployer, deployer.Logger, error) {
|
||||||
logger := deployer.NewDefaultLogger()
|
logger := deployer.NewDefaultLogger()
|
||||||
|
|
||||||
|
/*
|
||||||
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
|
*/
|
||||||
switch target {
|
switch target {
|
||||||
case targetAliyunALB, targetAliyunCDN, targetAliyunCLB, targetAliyunDCDN, targetAliyunNLB, targetAliyunOSS:
|
case targetAliyunALB, targetAliyunCDN, targetAliyunCLB, targetAliyunDCDN, targetAliyunNLB, targetAliyunOSS:
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func createNotifier(channel string, channelConfig map[string]any) (notifier.Notifier, error) {
|
func createNotifier(channel string, channelConfig map[string]any) (notifier.Notifier, error) {
|
||||||
|
/*
|
||||||
|
注意:如果追加新的常量值,请保持以 ASCII 排序。
|
||||||
|
NOTICE: If you add new constant, please keep ASCII order.
|
||||||
|
*/
|
||||||
switch channel {
|
switch channel {
|
||||||
|
case domain.NotifyChannelBark:
|
||||||
|
return providerBark.New(&providerBark.BarkNotifierConfig{
|
||||||
|
DeviceKey: maps.GetValueAsString(channelConfig, "deviceKey"),
|
||||||
|
ServerUrl: maps.GetValueAsString(channelConfig, "serverUrl"),
|
||||||
|
})
|
||||||
|
|
||||||
|
case domain.NotifyChannelDingtalk:
|
||||||
|
return providerDingTalk.New(&providerDingTalk.DingTalkNotifierConfig{
|
||||||
|
AccessToken: maps.GetValueAsString(channelConfig, "accessToken"),
|
||||||
|
Secret: maps.GetValueAsString(channelConfig, "secret"),
|
||||||
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelEmail:
|
case domain.NotifyChannelEmail:
|
||||||
return providerEmail.New(&providerEmail.EmailNotifierConfig{
|
return providerEmail.New(&providerEmail.EmailNotifierConfig{
|
||||||
SmtpHost: maps.GetValueAsString(channelConfig, "smtpHost"),
|
SmtpHost: maps.GetValueAsString(channelConfig, "smtpHost"),
|
||||||
@ -28,38 +44,26 @@ func createNotifier(channel string, channelConfig map[string]any) (notifier.Noti
|
|||||||
ReceiverAddress: maps.GetValueAsString(channelConfig, "receiverAddress"),
|
ReceiverAddress: maps.GetValueAsString(channelConfig, "receiverAddress"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelWebhook:
|
|
||||||
return providerWebhook.New(&providerWebhook.WebhookNotifierConfig{
|
|
||||||
Url: maps.GetValueAsString(channelConfig, "url"),
|
|
||||||
})
|
|
||||||
|
|
||||||
case domain.NotifyChannelDingtalk:
|
|
||||||
return providerDingTalk.New(&providerDingTalk.DingTalkNotifierConfig{
|
|
||||||
AccessToken: maps.GetValueAsString(channelConfig, "accessToken"),
|
|
||||||
Secret: maps.GetValueAsString(channelConfig, "secret"),
|
|
||||||
})
|
|
||||||
|
|
||||||
case domain.NotifyChannelLark:
|
case domain.NotifyChannelLark:
|
||||||
return providerLark.New(&providerLark.LarkNotifierConfig{
|
return providerLark.New(&providerLark.LarkNotifierConfig{
|
||||||
WebhookUrl: maps.GetValueAsString(channelConfig, "webhookUrl"),
|
WebhookUrl: maps.GetValueAsString(channelConfig, "webhookUrl"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
case domain.NotifyChannelServerChan:
|
||||||
|
return providerServerChan.New(&providerServerChan.ServerChanNotifierConfig{
|
||||||
|
Url: maps.GetValueAsString(channelConfig, "url"),
|
||||||
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelTelegram:
|
case domain.NotifyChannelTelegram:
|
||||||
return providerTelegram.New(&providerTelegram.TelegramNotifierConfig{
|
return providerTelegram.New(&providerTelegram.TelegramNotifierConfig{
|
||||||
ApiToken: maps.GetValueAsString(channelConfig, "apiToken"),
|
ApiToken: maps.GetValueAsString(channelConfig, "apiToken"),
|
||||||
ChatId: maps.GetValueAsInt64(channelConfig, "chatId"),
|
ChatId: maps.GetValueAsInt64(channelConfig, "chatId"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelServerChan:
|
case domain.NotifyChannelWebhook:
|
||||||
return providerServerChan.New(&providerServerChan.ServerChanNotifierConfig{
|
return providerWebhook.New(&providerWebhook.WebhookNotifierConfig{
|
||||||
Url: maps.GetValueAsString(channelConfig, "url"),
|
Url: maps.GetValueAsString(channelConfig, "url"),
|
||||||
})
|
})
|
||||||
|
|
||||||
case domain.NotifyChannelBark:
|
|
||||||
return providerBark.New(&providerBark.BarkNotifierConfig{
|
|
||||||
DeviceKey: maps.GetValueAsString(channelConfig, "deviceKey"),
|
|
||||||
ServerUrl: maps.GetValueAsString(channelConfig, "serverUrl"),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("unsupported notifier channel: %s", channelConfig)
|
return nil, fmt.Errorf("unsupported notifier channel: %s", channelConfig)
|
||||||
|
@ -13,7 +13,21 @@ module.exports = {
|
|||||||
parser: "@typescript-eslint/parser",
|
parser: "@typescript-eslint/parser",
|
||||||
plugins: ["react-refresh"],
|
plugins: ["react-refresh"],
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-explicit-any": "warn",
|
"@typescript-eslint/no-explicit-any": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
ignoreRestArgs: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
argsIgnorePattern: "^_",
|
||||||
|
caughtErrorsIgnorePattern: "^_",
|
||||||
|
destructuredArrayIgnorePattern: "^_",
|
||||||
|
varsIgnorePattern: "^_",
|
||||||
|
},
|
||||||
|
],
|
||||||
"react-refresh/only-export-components": [
|
"react-refresh/only-export-components": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
|
97
ui/package-lock.json
generated
97
ui/package-lock.json
generated
@ -19,9 +19,6 @@
|
|||||||
"@radix-ui/react-scroll-area": "^1.1.0",
|
"@radix-ui/react-scroll-area": "^1.1.0",
|
||||||
"@radix-ui/react-select": "^2.1.1",
|
"@radix-ui/react-select": "^2.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.0",
|
"@radix-ui/react-slot": "^1.1.0",
|
||||||
"@radix-ui/react-switch": "^1.1.0",
|
|
||||||
"@radix-ui/react-toast": "^1.2.1",
|
|
||||||
"@radix-ui/react-tooltip": "^1.1.2",
|
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
"ahooks": "^3.8.4",
|
"ahooks": "^3.8.4",
|
||||||
"antd": "^5.22.2",
|
"antd": "^5.22.2",
|
||||||
@ -3547,100 +3544,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@radix-ui/react-switch": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-switch/-/react-switch-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-OBzy5WAj641k0AOSpKQtreDMe+isX0MQJ1IVyF03ucdF3DunOnROVrjWs8zsXUxC3zfZ6JL9HFVCUlMghz9dJw==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/primitive": "1.1.0",
|
|
||||||
"@radix-ui/react-compose-refs": "1.1.0",
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
||||||
"@radix-ui/react-use-previous": "1.1.0",
|
|
||||||
"@radix-ui/react-use-size": "1.1.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-toast": {
|
|
||||||
"version": "1.2.1",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-toast/-/react-toast-1.2.1.tgz",
|
|
||||||
"integrity": "sha512-5trl7piMXcZiCq7MW6r8YYmu0bK5qDpTWz+FdEPdKyft2UixkspheYbjbrLXVN5NGKHFbOP7lm8eD0biiSqZqg==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/primitive": "1.1.0",
|
|
||||||
"@radix-ui/react-collection": "1.1.0",
|
|
||||||
"@radix-ui/react-compose-refs": "1.1.0",
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-dismissable-layer": "1.1.0",
|
|
||||||
"@radix-ui/react-portal": "1.1.1",
|
|
||||||
"@radix-ui/react-presence": "1.1.0",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0",
|
|
||||||
"@radix-ui/react-use-callback-ref": "1.1.0",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
||||||
"@radix-ui/react-use-layout-effect": "1.1.0",
|
|
||||||
"@radix-ui/react-visually-hidden": "1.1.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-tooltip": {
|
|
||||||
"version": "1.1.2",
|
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-tooltip/-/react-tooltip-1.1.2.tgz",
|
|
||||||
"integrity": "sha512-9XRsLwe6Yb9B/tlnYCPVUd/TFS4J7HuOZW345DCeC6vKIxQGMZdx21RK4VoZauPD5frgkXTYVS5y90L+3YBn4w==",
|
|
||||||
"dependencies": {
|
|
||||||
"@radix-ui/primitive": "1.1.0",
|
|
||||||
"@radix-ui/react-compose-refs": "1.1.0",
|
|
||||||
"@radix-ui/react-context": "1.1.0",
|
|
||||||
"@radix-ui/react-dismissable-layer": "1.1.0",
|
|
||||||
"@radix-ui/react-id": "1.1.0",
|
|
||||||
"@radix-ui/react-popper": "1.2.0",
|
|
||||||
"@radix-ui/react-portal": "1.1.1",
|
|
||||||
"@radix-ui/react-presence": "1.1.0",
|
|
||||||
"@radix-ui/react-primitive": "2.0.0",
|
|
||||||
"@radix-ui/react-slot": "1.1.0",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
||||||
"@radix-ui/react-visually-hidden": "1.1.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-use-callback-ref": {
|
"node_modules/@radix-ui/react-use-callback-ref": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmmirror.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.0.tgz",
|
"resolved": "https://registry.npmmirror.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.0.tgz",
|
||||||
|
@ -21,9 +21,6 @@
|
|||||||
"@radix-ui/react-scroll-area": "^1.1.0",
|
"@radix-ui/react-scroll-area": "^1.1.0",
|
||||||
"@radix-ui/react-select": "^2.1.1",
|
"@radix-ui/react-select": "^2.1.1",
|
||||||
"@radix-ui/react-slot": "^1.1.0",
|
"@radix-ui/react-slot": "^1.1.0",
|
||||||
"@radix-ui/react-switch": "^1.1.0",
|
|
||||||
"@radix-ui/react-toast": "^1.2.1",
|
|
||||||
"@radix-ui/react-tooltip": "^1.1.2",
|
|
||||||
"@tanstack/react-table": "^8.20.5",
|
"@tanstack/react-table": "^8.20.5",
|
||||||
"ahooks": "^3.8.4",
|
"ahooks": "^3.8.4",
|
||||||
"antd": "^5.22.2",
|
"antd": "^5.22.2",
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.Root>, React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>>(
|
|
||||||
({ className, ...props }, ref) => (
|
|
||||||
<SwitchPrimitives.Root
|
|
||||||
className={cn(
|
|
||||||
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
ref={ref}
|
|
||||||
>
|
|
||||||
<SwitchPrimitives.Thumb
|
|
||||||
className={cn(
|
|
||||||
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</SwitchPrimitives.Root>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
||||||
|
|
||||||
export { Switch };
|
|
@ -1,93 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import * as ToastPrimitives from "@radix-ui/react-toast";
|
|
||||||
import { X } from "lucide-react";
|
|
||||||
import { cva, type VariantProps } from "class-variance-authority";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const ToastProvider = ToastPrimitives.Provider;
|
|
||||||
|
|
||||||
const ToastViewport = React.forwardRef<React.ElementRef<typeof ToastPrimitives.Viewport>, React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>>(
|
|
||||||
({ className, ...props }, ref) => (
|
|
||||||
<ToastPrimitives.Viewport
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
||||||
|
|
||||||
const toastVariants = cva(
|
|
||||||
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default: "border bg-background text-foreground",
|
|
||||||
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const Toast = React.forwardRef<
|
|
||||||
React.ElementRef<typeof ToastPrimitives.Root>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> & VariantProps<typeof toastVariants>
|
|
||||||
>(({ className, variant, ...props }, ref) => {
|
|
||||||
return <ToastPrimitives.Root ref={ref} className={cn(toastVariants({ variant }), className)} {...props} />;
|
|
||||||
});
|
|
||||||
Toast.displayName = ToastPrimitives.Root.displayName;
|
|
||||||
|
|
||||||
const ToastAction = React.forwardRef<React.ElementRef<typeof ToastPrimitives.Action>, React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>>(
|
|
||||||
({ className, ...props }, ref) => (
|
|
||||||
<ToastPrimitives.Action
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
||||||
|
|
||||||
const ToastClose = React.forwardRef<React.ElementRef<typeof ToastPrimitives.Close>, React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>>(
|
|
||||||
({ className, ...props }, ref) => (
|
|
||||||
<ToastPrimitives.Close
|
|
||||||
ref={ref}
|
|
||||||
className={cn(
|
|
||||||
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
toast-close=""
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<X className="h-4 w-4" />
|
|
||||||
</ToastPrimitives.Close>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
||||||
|
|
||||||
const ToastTitle = React.forwardRef<React.ElementRef<typeof ToastPrimitives.Title>, React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>>(
|
|
||||||
({ className, ...props }, ref) => <ToastPrimitives.Title ref={ref} className={cn("text-sm font-semibold", className)} {...props} />
|
|
||||||
);
|
|
||||||
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
||||||
|
|
||||||
const ToastDescription = React.forwardRef<
|
|
||||||
React.ElementRef<typeof ToastPrimitives.Description>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
|
|
||||||
>(({ className, ...props }, ref) => <ToastPrimitives.Description ref={ref} className={cn("text-sm opacity-90", className)} {...props} />);
|
|
||||||
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
||||||
|
|
||||||
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
||||||
|
|
||||||
type ToastActionElement = React.ReactElement<typeof ToastAction>;
|
|
||||||
|
|
||||||
export { type ToastProps, type ToastActionElement, ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction };
|
|
@ -1,24 +0,0 @@
|
|||||||
import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport } from "@/components/ui/toast";
|
|
||||||
import { useToast } from "@/components/ui/use-toast";
|
|
||||||
|
|
||||||
export function Toaster() {
|
|
||||||
const { toasts } = useToast();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ToastProvider>
|
|
||||||
{toasts.map(function ({ id, title, description, action, ...props }) {
|
|
||||||
return (
|
|
||||||
<Toast key={id} {...props}>
|
|
||||||
<div className="grid gap-1">
|
|
||||||
{title && <ToastTitle>{title}</ToastTitle>}
|
|
||||||
{description && <ToastDescription>{description}</ToastDescription>}
|
|
||||||
</div>
|
|
||||||
{action}
|
|
||||||
<ToastClose />
|
|
||||||
</Toast>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
<ToastViewport />
|
|
||||||
</ToastProvider>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
||||||
|
|
||||||
import { cn } from "./utils";
|
|
||||||
|
|
||||||
const TooltipProvider = TooltipPrimitive.Provider;
|
|
||||||
|
|
||||||
const Tooltip = TooltipPrimitive.Root;
|
|
||||||
|
|
||||||
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
||||||
|
|
||||||
const TooltipContent = React.forwardRef<React.ElementRef<typeof TooltipPrimitive.Content>, React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>>(
|
|
||||||
({ className, sideOffset = 4, ...props }, ref) => (
|
|
||||||
<TooltipPrimitive.Content
|
|
||||||
ref={ref}
|
|
||||||
sideOffset={sideOffset}
|
|
||||||
className={cn(
|
|
||||||
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
);
|
|
||||||
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
||||||
|
|
||||||
type TooltipFastProps = TooltipPrimitive.TooltipContentProps &
|
|
||||||
TooltipPrimitive.TooltipProps &
|
|
||||||
React.RefAttributes<HTMLDivElement> & {
|
|
||||||
contentView?: JSX.Element;
|
|
||||||
};
|
|
||||||
|
|
||||||
const TooltipLink = React.forwardRef((props: React.PropsWithChildren, forwardedRef: React.ForwardedRef<HTMLAnchorElement>) => (
|
|
||||||
<a {...props} ref={forwardedRef}>
|
|
||||||
{props.children}
|
|
||||||
</a>
|
|
||||||
));
|
|
||||||
|
|
||||||
function TooltipFast({ children, contentView, open, defaultOpen, onOpenChange, ...props }: TooltipFastProps) {
|
|
||||||
return (
|
|
||||||
<TooltipProvider>
|
|
||||||
<Tooltip open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>
|
|
||||||
<TooltipPrimitive.Trigger asChild>
|
|
||||||
<TooltipLink>{children}</TooltipLink>
|
|
||||||
</TooltipPrimitive.Trigger>
|
|
||||||
<TooltipContent side="top" align="center" {...props}>
|
|
||||||
{contentView}
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
</TooltipProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, TooltipFast };
|
|
@ -1,187 +0,0 @@
|
|||||||
// Inspired by react-hot-toast library
|
|
||||||
import * as React from "react";
|
|
||||||
|
|
||||||
import type { ToastActionElement, ToastProps } from "@/components/ui/toast";
|
|
||||||
|
|
||||||
const TOAST_LIMIT = 1;
|
|
||||||
const TOAST_REMOVE_DELAY = 1000000;
|
|
||||||
|
|
||||||
type ToasterToast = ToastProps & {
|
|
||||||
id: string;
|
|
||||||
title?: React.ReactNode;
|
|
||||||
description?: React.ReactNode;
|
|
||||||
action?: ToastActionElement;
|
|
||||||
};
|
|
||||||
|
|
||||||
const actionTypes = {
|
|
||||||
ADD_TOAST: "ADD_TOAST",
|
|
||||||
UPDATE_TOAST: "UPDATE_TOAST",
|
|
||||||
DISMISS_TOAST: "DISMISS_TOAST",
|
|
||||||
REMOVE_TOAST: "REMOVE_TOAST",
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
function genId() {
|
|
||||||
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
||||||
return count.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActionType = typeof actionTypes;
|
|
||||||
|
|
||||||
type Action =
|
|
||||||
| {
|
|
||||||
type: ActionType["ADD_TOAST"];
|
|
||||||
toast: ToasterToast;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: ActionType["UPDATE_TOAST"];
|
|
||||||
toast: Partial<ToasterToast>;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: ActionType["DISMISS_TOAST"];
|
|
||||||
toastId?: ToasterToast["id"];
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: ActionType["REMOVE_TOAST"];
|
|
||||||
toastId?: ToasterToast["id"];
|
|
||||||
};
|
|
||||||
|
|
||||||
interface State {
|
|
||||||
toasts: ToasterToast[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
||||||
|
|
||||||
const addToRemoveQueue = (toastId: string) => {
|
|
||||||
if (toastTimeouts.has(toastId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const timeout = setTimeout(() => {
|
|
||||||
toastTimeouts.delete(toastId);
|
|
||||||
dispatch({
|
|
||||||
type: "REMOVE_TOAST",
|
|
||||||
toastId: toastId,
|
|
||||||
});
|
|
||||||
}, TOAST_REMOVE_DELAY);
|
|
||||||
|
|
||||||
toastTimeouts.set(toastId, timeout);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const reducer = (state: State, action: Action): State => {
|
|
||||||
switch (action.type) {
|
|
||||||
case "ADD_TOAST":
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
||||||
};
|
|
||||||
|
|
||||||
case "UPDATE_TOAST":
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toasts: state.toasts.map((t) => (t.id === action.toast.id ? { ...t, ...action.toast } : t)),
|
|
||||||
};
|
|
||||||
|
|
||||||
case "DISMISS_TOAST": {
|
|
||||||
const { toastId } = action;
|
|
||||||
|
|
||||||
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
||||||
// but I'll keep it here for simplicity
|
|
||||||
if (toastId) {
|
|
||||||
addToRemoveQueue(toastId);
|
|
||||||
} else {
|
|
||||||
state.toasts.forEach((toast) => {
|
|
||||||
addToRemoveQueue(toast.id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toasts: state.toasts.map((t) =>
|
|
||||||
t.id === toastId || toastId === undefined
|
|
||||||
? {
|
|
||||||
...t,
|
|
||||||
open: false,
|
|
||||||
}
|
|
||||||
: t
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
case "REMOVE_TOAST":
|
|
||||||
if (action.toastId === undefined) {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toasts: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const listeners: Array<(state: State) => void> = [];
|
|
||||||
|
|
||||||
let memoryState: State = { toasts: [] };
|
|
||||||
|
|
||||||
function dispatch(action: Action) {
|
|
||||||
memoryState = reducer(memoryState, action);
|
|
||||||
listeners.forEach((listener) => {
|
|
||||||
listener(memoryState);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
type Toast = Omit<ToasterToast, "id">;
|
|
||||||
|
|
||||||
function toast({ ...props }: Toast) {
|
|
||||||
const id = genId();
|
|
||||||
|
|
||||||
const update = (props: ToasterToast) =>
|
|
||||||
dispatch({
|
|
||||||
type: "UPDATE_TOAST",
|
|
||||||
toast: { ...props, id },
|
|
||||||
});
|
|
||||||
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
||||||
|
|
||||||
dispatch({
|
|
||||||
type: "ADD_TOAST",
|
|
||||||
toast: {
|
|
||||||
...props,
|
|
||||||
id,
|
|
||||||
open: true,
|
|
||||||
onOpenChange: (open) => {
|
|
||||||
if (!open) dismiss();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: id,
|
|
||||||
dismiss,
|
|
||||||
update,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function useToast() {
|
|
||||||
const [state, setState] = React.useState<State>(memoryState);
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
listeners.push(setState);
|
|
||||||
return () => {
|
|
||||||
const index = listeners.indexOf(setState);
|
|
||||||
if (index > -1) {
|
|
||||||
listeners.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [state]);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
toast,
|
|
||||||
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export { useToast, toast };
|
|
@ -1,6 +1,7 @@
|
|||||||
import { memo, useEffect } from "react";
|
import { memo, useEffect } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Switch, Tooltip } from "antd";
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { ChevronsUpDown, Plus, CircleHelp } from "lucide-react";
|
import { ChevronsUpDown, Plus, CircleHelp } from "lucide-react";
|
||||||
@ -17,8 +18,6 @@ import StringList from "@/components/certimate/StringList";
|
|||||||
import { accessProvidersMap } from "@/domain/access";
|
import { accessProvidersMap } from "@/domain/access";
|
||||||
import { useAccessStore } from "@/stores/access";
|
import { useAccessStore } from "@/stores/access";
|
||||||
import { useContactStore } from "@/stores/contact";
|
import { useContactStore } from "@/stores/contact";
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
import { TooltipFast } from "@/components/ui/tooltip";
|
|
||||||
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
|
||||||
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
@ -304,9 +303,8 @@ const ApplyForm = ({ data }: ApplyFormProps) => {
|
|||||||
<FormLabel>
|
<FormLabel>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<span className="mr-1">{t("domain.application.form.disable_follow_cname.label")} </span>
|
<span className="mr-1">{t("domain.application.form.disable_follow_cname.label")} </span>
|
||||||
<TooltipFast
|
<Tooltip
|
||||||
className="max-w-[20rem]"
|
title={
|
||||||
contentView={
|
|
||||||
<p>
|
<p>
|
||||||
{t("domain.application.form.disable_follow_cname.tips")}
|
{t("domain.application.form.disable_follow_cname.tips")}
|
||||||
<a
|
<a
|
||||||
@ -320,14 +318,14 @@ const ApplyForm = ({ data }: ApplyFormProps) => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<CircleHelp size={14} />
|
<CircleHelp size={14} />
|
||||||
</TooltipFast>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<div>
|
<div>
|
||||||
<Switch
|
<Switch
|
||||||
defaultChecked={field.value}
|
defaultChecked={field.value}
|
||||||
onCheckedChange={(value) => {
|
onChange={(value) => {
|
||||||
form.setValue(field.name, value);
|
form.setValue(field.name, value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -52,7 +52,7 @@ const ConsoleLayout = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout className="min-h-screen" hasSider>
|
<Layout className="min-h-screen" hasSider>
|
||||||
<Layout.Sider className="max-md:hidden max-md:static fixed top-0 left-0 h-full z-[9]" width="256px" theme="light">
|
<Layout.Sider className="max-md:hidden max-md:static fixed top-0 left-0 h-full z-[20]" width="256px" theme="light">
|
||||||
<div className="flex flex-col items-center justify-between w-full h-full overflow-hidden">
|
<div className="flex flex-col items-center justify-between w-full h-full overflow-hidden">
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<SiderMenu />
|
<SiderMenu />
|
||||||
@ -64,7 +64,7 @@ const ConsoleLayout = () => {
|
|||||||
</Layout.Sider>
|
</Layout.Sider>
|
||||||
|
|
||||||
<Layout className="pl-[256px] max-md:pl-0">
|
<Layout className="pl-[256px] max-md:pl-0">
|
||||||
<Layout.Header className="sticky top-0 left-0 right-0 p-0 z-[8] shadow-sm" style={{ background: themeToken.colorBgContainer }}>
|
<Layout.Header className="sticky top-0 left-0 right-0 p-0 z-[19] shadow-sm" style={{ background: themeToken.colorBgContainer }}>
|
||||||
<div className="flex items-center justify-between size-full px-4 overflow-hidden">
|
<div className="flex items-center justify-between size-full px-4 overflow-hidden">
|
||||||
<div className="flex items-center gap-4 size-full">
|
<div className="flex items-center gap-4 size-full">
|
||||||
<Button className="md:hidden" icon={<MenuIcon />} size="large" onClick={handleSiderOpen} />
|
<Button className="md:hidden" icon={<MenuIcon />} size="large" onClick={handleSiderOpen} />
|
||||||
@ -100,9 +100,7 @@ const ConsoleLayout = () => {
|
|||||||
</Layout.Header>
|
</Layout.Header>
|
||||||
|
|
||||||
<Layout.Content style={{ overflow: "initial" }}>
|
<Layout.Content style={{ overflow: "initial" }}>
|
||||||
<div className="p-4">
|
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
|
||||||
</Layout.Content>
|
</Layout.Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -159,7 +159,7 @@ const AccessList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="p-4">
|
||||||
{ModelContextHolder}
|
{ModelContextHolder}
|
||||||
{NotificationContextHolder}
|
{NotificationContextHolder}
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ const AccessList = () => {
|
|||||||
rowKey={(record: AccessModel) => record.id}
|
rowKey={(record: AccessModel) => record.id}
|
||||||
scroll={{ x: "max(100%, 960px)" }}
|
scroll={{ x: "max(100%, 960px)" }}
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ const CertificateList = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="p-4">
|
||||||
{NotificationContextHolder}
|
{NotificationContextHolder}
|
||||||
|
|
||||||
<PageHeader title={t("certificate.page.title")} />
|
<PageHeader title={t("certificate.page.title")} />
|
||||||
@ -233,7 +233,7 @@ const CertificateList = () => {
|
|||||||
rowKey={(record: CertificateModel) => record.id}
|
rowKey={(record: CertificateModel) => record.id}
|
||||||
scroll={{ x: "max(100%, 960px)" }}
|
scroll={{ x: "max(100%, 960px)" }}
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ const Dashboard = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="p-4">
|
||||||
{NotificationContextHolder}
|
{NotificationContextHolder}
|
||||||
|
|
||||||
<PageHeader title={t("dashboard.page.title")} />
|
<PageHeader title={t("dashboard.page.title")} />
|
||||||
@ -116,7 +116,7 @@ const Dashboard = () => {
|
|||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
<div>TODO: {t("dashboard.latest_workflow_run")}</div>
|
<div>TODO: {t("dashboard.latest_workflow_run")}</div>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const Settings = () => {
|
|||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="p-4">
|
||||||
<PageHeader title={t("settings.page.title")} />
|
<PageHeader title={t("settings.page.title")} />
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
@ -73,7 +73,7 @@ const Settings = () => {
|
|||||||
>
|
>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Card>
|
</Card>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
import { run } from "@/api/workflow";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { message, notification, Switch } from "antd";
|
||||||
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { ArrowLeft as ArrowLeftIcon } from "lucide-react";
|
||||||
|
|
||||||
import Show from "@/components/Show";
|
import Show from "@/components/Show";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
import { Toaster } from "@/components/ui/toaster";
|
|
||||||
import { useToast } from "@/components/ui/use-toast";
|
|
||||||
import End from "@/components/workflow/End";
|
import End from "@/components/workflow/End";
|
||||||
import NodeRender from "@/components/workflow/NodeRender";
|
import NodeRender from "@/components/workflow/NodeRender";
|
||||||
import WorkflowBaseInfoEditDialog from "@/components/workflow/WorkflowBaseInfoEditDialog";
|
import WorkflowBaseInfoEditDialog from "@/components/workflow/WorkflowBaseInfoEditDialog";
|
||||||
import WorkflowLog from "@/components/workflow/WorkflowLog";
|
import WorkflowLog from "@/components/workflow/WorkflowLog";
|
||||||
|
|
||||||
import { cn } from "@/components/ui/utils";
|
|
||||||
import WorkflowProvider from "@/components/workflow/WorkflowProvider";
|
import WorkflowProvider from "@/components/workflow/WorkflowProvider";
|
||||||
|
import { cn } from "@/components/ui/utils";
|
||||||
import { allNodesValidated, WorkflowNode } from "@/domain/workflow";
|
import { allNodesValidated, WorkflowNode } from "@/domain/workflow";
|
||||||
import { getErrMsg } from "@/utils/error";
|
|
||||||
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
import { useWorkflowStore, WorkflowState } from "@/stores/workflow";
|
||||||
import { ArrowLeft } from "lucide-react";
|
import { run as runWorkflow } from "@/api/workflow";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
||||||
|
|
||||||
import { useShallow } from "zustand/shallow";
|
|
||||||
|
|
||||||
const selectState = (state: WorkflowState) => ({
|
const selectState = (state: WorkflowState) => ({
|
||||||
workflow: state.workflow,
|
workflow: state.workflow,
|
||||||
@ -30,11 +25,18 @@ const selectState = (state: WorkflowState) => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const WorkflowDetail = () => {
|
const WorkflowDetail = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [messageApi, MessageContextHolder] = message.useMessage();
|
||||||
|
const [_, NotificationContextHolder] = notification.useNotification();
|
||||||
|
|
||||||
// 3. 使用正确的选择器和 shallow 比较
|
// 3. 使用正确的选择器和 shallow 比较
|
||||||
const { workflow, init, switchEnable, save } = useWorkflowStore(useShallow(selectState));
|
const { workflow, init, switchEnable, save } = useWorkflowStore(useShallow(selectState));
|
||||||
|
|
||||||
// 从 url 中获取 workflowId
|
// 从 url 中获取 workflowId
|
||||||
const [searchParams] = useSearchParams();
|
|
||||||
const [locId, setLocId] = useState<string>("");
|
const [locId, setLocId] = useState<string>("");
|
||||||
const id = searchParams.get("id");
|
const id = searchParams.get("id");
|
||||||
|
|
||||||
@ -49,12 +51,6 @@ const WorkflowDetail = () => {
|
|||||||
}
|
}
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const { toast } = useToast();
|
|
||||||
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const elements = useMemo(() => {
|
const elements = useMemo(() => {
|
||||||
let current = workflow.draft as WorkflowNode;
|
let current = workflow.draft as WorkflowNode;
|
||||||
|
|
||||||
@ -78,11 +74,7 @@ const WorkflowDetail = () => {
|
|||||||
|
|
||||||
const handleEnableChange = () => {
|
const handleEnableChange = () => {
|
||||||
if (!workflow.enabled && !allNodesValidated(workflow.draft as WorkflowNode)) {
|
if (!workflow.enabled && !allNodesValidated(workflow.draft as WorkflowNode)) {
|
||||||
toast({
|
messageApi.warning(t("workflow.detail.action.save.failed.uncompleted"));
|
||||||
title: t("workflow.detail.action.save.failed"),
|
|
||||||
description: t("workflow.detail.action.save.failed.uncompleted"),
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switchEnable();
|
switchEnable();
|
||||||
@ -93,11 +85,7 @@ const WorkflowDetail = () => {
|
|||||||
|
|
||||||
const handleWorkflowSaveClick = () => {
|
const handleWorkflowSaveClick = () => {
|
||||||
if (!allNodesValidated(workflow.draft as WorkflowNode)) {
|
if (!allNodesValidated(workflow.draft as WorkflowNode)) {
|
||||||
toast({
|
messageApi.warning(t("workflow.detail.action.save.failed.uncompleted"));
|
||||||
title: t("workflow.detail.action.save.failed"),
|
|
||||||
description: t("workflow.detail.action.save.failed.uncompleted"),
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
save();
|
save();
|
||||||
@ -119,30 +107,23 @@ const WorkflowDetail = () => {
|
|||||||
}
|
}
|
||||||
setRunning(true);
|
setRunning(true);
|
||||||
try {
|
try {
|
||||||
await run(workflow.id as string);
|
await runWorkflow(workflow.id as string);
|
||||||
toast({
|
messageApi.success(t("workflow.detail.action.run.success"));
|
||||||
title: t("workflow.detail.action.run.success"),
|
|
||||||
description: t("workflow.detail.action.run.success"),
|
|
||||||
variant: "default",
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast({
|
messageApi.warning(t("workflow.detail.action.run.failed"));
|
||||||
title: t("workflow.detail.action.run.failed"),
|
|
||||||
description: getErrMsg(e),
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
setRunning(false);
|
setRunning(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div>
|
||||||
|
{MessageContextHolder}
|
||||||
|
{NotificationContextHolder}
|
||||||
|
|
||||||
<WorkflowProvider>
|
<WorkflowProvider>
|
||||||
<Toaster />
|
<div className="h-16 sticky top-0 left-0 z-[1]` shadow-md bg-muted/40 flex justify-between items-center">
|
||||||
<ScrollArea className="h-[100vh] w-full relative bg-background">
|
|
||||||
<div className="h-16 sticky top-0 left-0 z-20 shadow-md bg-muted/40 flex justify-between items-center">
|
|
||||||
<div className="px-5 text-stone-700 dark:text-stone-200 flex items-center space-x-2">
|
<div className="px-5 text-stone-700 dark:text-stone-200 flex items-center space-x-2">
|
||||||
<ArrowLeft className="cursor-pointer" onClick={handleBackClick} />
|
<ArrowLeftIcon className="cursor-pointer" onClick={handleBackClick} />
|
||||||
<WorkflowBaseInfoEditDialog
|
<WorkflowBaseInfoEditDialog
|
||||||
trigger={
|
trigger={
|
||||||
<div className="flex flex-col space-y-1 cursor-pointer items-start">
|
<div className="flex flex-col space-y-1 cursor-pointer items-start">
|
||||||
@ -190,24 +171,25 @@ const WorkflowDetail = () => {
|
|||||||
</Show>
|
</Show>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Switch className="dark:data-[state=unchecked]:bg-stone-400" checked={workflow.enabled ?? false} onCheckedChange={handleEnableChange} />
|
<Switch checked={workflow.enabled ?? false} onChange={handleEnableChange} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Show when={tab === "workflow"}>
|
<Show when={tab === "workflow"}>
|
||||||
<div className=" flex flex-col items-center mt-8">{elements}</div>
|
<div className="p-4">
|
||||||
|
<div className="flex flex-col items-center p-4 bg-background">{elements}</div>
|
||||||
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={!!locId && tab === "history"}>
|
<Show when={!!locId && tab === "history"}>
|
||||||
<div className=" flex flex-col items-center mt-8">
|
<div className="p-4">
|
||||||
|
<div className="flex flex-col items-center p-4 bg-background">
|
||||||
<WorkflowLog />
|
<WorkflowLog />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<ScrollBar orientation="vertical" />
|
|
||||||
<ScrollBar orientation="horizontal" />
|
|
||||||
</ScrollArea>
|
|
||||||
</WorkflowProvider>
|
</WorkflowProvider>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ const WorkflowList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="p-4">
|
||||||
{ModelContextHolder}
|
{ModelContextHolder}
|
||||||
{NotificationContextHolder}
|
{NotificationContextHolder}
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ const WorkflowList = () => {
|
|||||||
rowKey={(record: WorkflowModel) => record.id}
|
rowKey={(record: WorkflowModel) => record.id}
|
||||||
scroll={{ x: "max(100%, 960px)" }}
|
scroll={{ x: "max(100%, 960px)" }}
|
||||||
/>
|
/>
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user