refactor(ui): refactor accesses state using zustand store

This commit is contained in:
Fu Diwei
2024-12-11 19:55:50 +08:00
parent b744363736
commit bb3009a124
48 changed files with 359 additions and 404 deletions

View File

@@ -1,4 +1,5 @@
import { z } from "zod";
import { type BaseModel } from "pocketbase";
type AccessUsages = "apply" | "deploy" | "all";
@@ -59,8 +60,7 @@ export const accessTypeFormSchema = z.union(
{ message: "access.authorization.form.type.placeholder" }
);
export type Access = {
id: string;
export interface AccessModel extends BaseModel {
name: string;
configType: string;
usage: AccessUsages;
@@ -83,10 +83,7 @@ export type Access = {
| KubernetesConfig
| VolcengineConfig
| ByteplusConfig;
deleted?: string;
created?: string;
updated?: string;
};
}
export type AliyunConfig = {
accessKeyId: string;

View File

@@ -1,7 +1,8 @@
import { Workflow } from "./workflow";
import { type BaseModel } from "pocketbase";
export type Certificate = {
id: string;
import { WorkflowModel } from "./workflow";
export interface CertificateModel extends BaseModel {
san: string;
certificate: string;
privateKey: string;
@@ -12,10 +13,7 @@ export type Certificate = {
expireAt: string;
workflow: string;
nodeId: string;
created: string;
updated: string;
expand: {
workflow?: Workflow;
workflow?: WorkflowModel;
};
};
}

View File

@@ -56,16 +56,6 @@ export type ApplyConfig = {
disableFollowCNAME?: boolean;
};
export type Statistic = {
certificateTotal: number;
certificateExpired: number;
certificateExpireSoon: number;
workflowTotal: number;
workflowEnabled: number;
workflowDisabled: number;
};
export type DeployTarget = {
type: string;
provider: string;

View File

@@ -1,6 +1,6 @@
import { type BaseModel } from "pocketbase";
export interface Settings<T> extends BaseModel {
export interface SettingsModel<T> extends BaseModel {
name: string;
content: T;
}

View File

@@ -0,0 +1,8 @@
export type Statistics = {
certificateTotal: number;
certificateExpired: number;
certificateExpireSoon: number;
workflowTotal: number;
workflowEnabled: number;
workflowDisabled: number;
};

View File

@@ -1,5 +1,6 @@
import { produce } from "immer";
import { nanoid } from "nanoid";
import { type BaseModel } from "pocketbase";
import i18n from "@/i18n";
import { deployTargets, KVType } from "./domain";
@@ -27,8 +28,7 @@ export type WorkflowOutput = {
error: string;
};
export type Workflow = {
id: string;
export interface WorkflowModel extends BaseModel {
name: string;
description?: string;
type: string;
@@ -37,9 +37,7 @@ export type Workflow = {
draft?: WorkflowNode;
enabled?: boolean;
hasDraft?: boolean;
created?: string;
updated?: string;
};
}
export enum WorkflowNodeType {
Start = "start",
@@ -131,7 +129,7 @@ type NewWorkflowNodeOptions = {
providerType?: string;
};
export const initWorkflow = (): Workflow => {
export const initWorkflow = (): WorkflowModel => {
// 开始节点
const rs = newWorkflowNode(WorkflowNodeType.Start, {});
let root = rs;