From 3cc4de8abc771c2fd9b838973f1e9a96388daa9e Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Thu, 24 Jul 2025 22:35:35 +0800 Subject: [PATCH] refactor: change database schemas --- internal/certificate/service.go | 2 +- internal/domain/certificate.go | 18 +- internal/domain/workflow.go | 10 +- internal/domain/workflow_log.go | 4 +- internal/domain/workflow_output.go | 4 +- internal/domain/workflow_run.go | 2 +- internal/repository/certificate.go | 26 +- internal/repository/statistics.go | 4 +- internal/repository/workflow.go | 8 +- internal/repository/workflow_log.go | 10 +- internal/repository/workflow_output.go | 8 +- internal/repository/workflow_run.go | 8 +- internal/workflow/event.go | 6 +- .../workflow/node-processor/apply_node.go | 6 +- .../workflow/node-processor/upload_node.go | 4 +- internal/workflow/service.go | 6 +- migrations/1753272000_v0.4.0_migrate.go | 633 ++++++++++++++---- .../certificate/CertificateDetail.tsx | 2 +- .../components/workflow/WorkflowRunDetail.tsx | 2 +- ui/src/components/workflow/WorkflowRuns.tsx | 8 +- ui/src/components/workflow/node/StartNode.tsx | 6 +- .../workflow/node/StartNodeConfigForm.tsx | 10 +- ui/src/domain/certificate.ts | 10 +- ui/src/domain/workflow.ts | 6 +- ui/src/domain/workflowRun.ts | 4 +- ui/src/i18n/locales/en/nls.certificate.json | 2 +- ui/src/i18n/locales/en/nls.workflow.json | 2 +- .../i18n/locales/en/nls.workflow.nodes.json | 2 +- ui/src/i18n/locales/en/nls.workflow.runs.json | 2 +- ui/src/i18n/locales/zh/nls.certificate.json | 4 +- ui/src/i18n/locales/zh/nls.workflow.json | 2 +- .../i18n/locales/zh/nls.workflow.nodes.json | 2 +- ui/src/i18n/locales/zh/nls.workflow.runs.json | 2 +- ui/src/pages/certificates/CertificateList.tsx | 18 +- ui/src/pages/dashboard/Dashboard.tsx | 4 +- ui/src/pages/workflows/WorkflowList.tsx | 4 +- ui/src/repository/certificate.ts | 8 +- ui/src/repository/workflowLog.ts | 2 +- ui/src/repository/workflowRun.ts | 4 +- 39 files changed, 638 insertions(+), 227 deletions(-) diff --git a/internal/certificate/service.go b/internal/certificate/service.go index 9d66741f2..4df15799c 100644 --- a/internal/certificate/service.go +++ b/internal/certificate/service.go @@ -54,7 +54,7 @@ func (s *CertificateService) InitSchedule(ctx context.Context) error { if settingsContent != nil && settingsContent.ExpiredCertificatesMaxDaysRetention != 0 { ret, err := s.certificateRepo.DeleteWhere( context.Background(), - dbx.NewExp(fmt.Sprintf("expireAtDATETIME('now')"), - dbx.NewExp("expireAtDATETIME('now')"), + dbx.NewExp("validityNotAfter DATETIME('now') and expireAt < DATETIME('now', '+20 days') AND deleted = ''"). + NewQuery("SELECT COUNT(*) AS total FROM certificate WHERE validityNotAfter > DATETIME('now') and validityNotAfter < DATETIME('now', '+20 days') AND deleted = ''"). One(&certExpireSoonTotal); err != nil { return nil, err } @@ -43,7 +43,7 @@ func (r *StatisticsRepository) Get(ctx context.Context) (*domain.Statistics, err Total int `db:"total"` }{} if err := app.GetDB(). - NewQuery("SELECT COUNT(*) AS total FROM certificate WHERE expireAt < DATETIME('now') AND deleted = ''"). + NewQuery("SELECT COUNT(*) AS total FROM certificate WHERE validityNotAfter < DATETIME('now') AND deleted = ''"). One(&certExpiredTotal); err != nil { return nil, err } diff --git a/internal/repository/workflow.go b/internal/repository/workflow.go index 3367644be..a5c32a8b5 100644 --- a/internal/repository/workflow.go +++ b/internal/repository/workflow.go @@ -18,13 +18,13 @@ func NewWorkflowRepository() *WorkflowRepository { return &WorkflowRepository{} } -func (r *WorkflowRepository) ListEnabledAuto(ctx context.Context) ([]*domain.Workflow, error) { +func (r *WorkflowRepository) ListEnabledScheduled(ctx context.Context) ([]*domain.Workflow, error) { records, err := app.GetApp().FindRecordsByFilter( domain.CollectionNameWorkflow, "enabled={:enabled} && trigger={:trigger}", "-created", 0, 0, - dbx.Params{"enabled": true, "trigger": string(domain.WorkflowTriggerTypeAuto)}, + dbx.Params{"enabled": true, "trigger": string(domain.WorkflowTriggerTypeScheduled)}, ) if err != nil { return nil, err @@ -82,7 +82,7 @@ func (r *WorkflowRepository) Save(ctx context.Context, workflow *domain.Workflow record.Set("content", workflow.Content) record.Set("draft", workflow.Draft) record.Set("hasDraft", workflow.HasDraft) - record.Set("lastRunId", workflow.LastRunId) + record.Set("lastRunRef", workflow.LastRunId) record.Set("lastRunStatus", string(workflow.LastRunStatus)) record.Set("lastRunTime", workflow.LastRunTime) if err := app.GetApp().Save(record); err != nil { @@ -124,7 +124,7 @@ func (r *WorkflowRepository) castRecordToModel(record *core.Record) (*domain.Wor Content: content, Draft: draft, HasDraft: record.GetBool("hasDraft"), - LastRunId: record.GetString("lastRunId"), + LastRunId: record.GetString("lastRunRef"), LastRunStatus: domain.WorkflowRunStatusType(record.GetString("lastRunStatus")), LastRunTime: record.GetDateTime("lastRunTime").Time(), } diff --git a/internal/repository/workflow_log.go b/internal/repository/workflow_log.go index 295c8a98c..948326a67 100644 --- a/internal/repository/workflow_log.go +++ b/internal/repository/workflow_log.go @@ -21,7 +21,7 @@ func NewWorkflowLogRepository() *WorkflowLogRepository { func (r *WorkflowLogRepository) ListByWorkflowRunId(ctx context.Context, workflowRunId string) ([]*domain.WorkflowLog, error) { records, err := app.GetApp().FindRecordsByFilter( domain.CollectionNameWorkflowLog, - "runId={:runId}", + "runRef={:runId}", "timestamp", 0, 0, dbx.Params{"runId": workflowRunId}, @@ -62,8 +62,8 @@ func (r *WorkflowLogRepository) Save(ctx context.Context, workflowLog *domain.Wo } } - record.Set("workflowId", workflowLog.WorkflowId) - record.Set("runId", workflowLog.RunId) + record.Set("workflowRef", workflowLog.WorkflowId) + record.Set("runRef", workflowLog.RunId) record.Set("nodeId", workflowLog.NodeId) record.Set("nodeName", workflowLog.NodeName) record.Set("timestamp", workflowLog.Timestamp) @@ -99,8 +99,8 @@ func (r *WorkflowLogRepository) castRecordToModel(record *core.Record) (*domain. CreatedAt: record.GetDateTime("created").Time(), UpdatedAt: record.GetDateTime("updated").Time(), }, - WorkflowId: record.GetString("workflowId"), - RunId: record.GetString("runId"), + WorkflowId: record.GetString("workflowRef"), + RunId: record.GetString("runRef"), NodeId: record.GetString("nodeId"), NodeName: record.GetString("nodeName"), Timestamp: int64(record.GetInt("timestamp")), diff --git a/internal/repository/workflow_output.go b/internal/repository/workflow_output.go index 5b8b72fb9..88ff9ea73 100644 --- a/internal/repository/workflow_output.go +++ b/internal/repository/workflow_output.go @@ -123,8 +123,8 @@ func (r *WorkflowOutputRepository) castRecordToModel(record *core.Record) (*doma CreatedAt: record.GetDateTime("created").Time(), UpdatedAt: record.GetDateTime("updated").Time(), }, - WorkflowId: record.GetString("workflowId"), - RunId: record.GetString("runId"), + WorkflowId: record.GetString("workflowRef"), + RunId: record.GetString("runRef"), NodeId: record.GetString("nodeId"), Node: node, Outputs: outputs, @@ -148,8 +148,8 @@ func (r *WorkflowOutputRepository) saveRecord(workflowOutput *domain.WorkflowOut return record, err } } - record.Set("workflowId", workflowOutput.WorkflowId) - record.Set("runId", workflowOutput.RunId) + record.Set("workflowRef", workflowOutput.WorkflowId) + record.Set("runRef", workflowOutput.RunId) record.Set("nodeId", workflowOutput.NodeId) record.Set("node", workflowOutput.Node) record.Set("outputs", workflowOutput.Outputs) diff --git a/internal/repository/workflow_run.go b/internal/repository/workflow_run.go index 01051be95..d128e9bcd 100644 --- a/internal/repository/workflow_run.go +++ b/internal/repository/workflow_run.go @@ -50,7 +50,7 @@ func (r *WorkflowRunRepository) Save(ctx context.Context, workflowRun *domain.Wo } err = app.GetApp().RunInTransaction(func(txApp core.App) error { - record.Set("workflowId", workflowRun.WorkflowId) + record.Set("workflowRef", workflowRun.WorkflowId) record.Set("trigger", string(workflowRun.Trigger)) record.Set("status", string(workflowRun.Status)) record.Set("startedAt", workflowRun.StartedAt) @@ -70,7 +70,7 @@ func (r *WorkflowRunRepository) Save(ctx context.Context, workflowRun *domain.Wo workflowRecord, err := txApp.FindRecordById(domain.CollectionNameWorkflow, workflowRun.WorkflowId) if err != nil { return err - } else if workflowRun.Id == workflowRecord.GetString("lastRunId") { + } else if workflowRun.Id == workflowRecord.GetString("lastRunRef") { workflowRecord.IgnoreUnchangedFields(true) workflowRecord.Set("lastRunStatus", record.GetString("status")) err = txApp.Save(workflowRecord) @@ -79,7 +79,7 @@ func (r *WorkflowRunRepository) Save(ctx context.Context, workflowRun *domain.Wo } } else if workflowRecord.GetDateTime("lastRunTime").Time().IsZero() || workflowRun.StartedAt.After(workflowRecord.GetDateTime("lastRunTime").Time()) { workflowRecord.IgnoreUnchangedFields(true) - workflowRecord.Set("lastRunId", record.Id) + workflowRecord.Set("lastRunRef", record.Id) workflowRecord.Set("lastRunStatus", record.GetString("status")) workflowRecord.Set("lastRunTime", record.GetString("startedAt")) err = txApp.Save(workflowRecord) @@ -136,7 +136,7 @@ func (r *WorkflowRunRepository) castRecordToModel(record *core.Record) (*domain. CreatedAt: record.GetDateTime("created").Time(), UpdatedAt: record.GetDateTime("updated").Time(), }, - WorkflowId: record.GetString("workflowId"), + WorkflowId: record.GetString("workflowRef"), Status: domain.WorkflowRunStatusType(record.GetString("status")), Trigger: domain.WorkflowTriggerType(record.GetString("trigger")), StartedAt: record.GetDateTime("startedAt").Time(), diff --git a/internal/workflow/event.go b/internal/workflow/event.go index 9451377c9..a8a04e47c 100644 --- a/internal/workflow/event.go +++ b/internal/workflow/event.go @@ -57,8 +57,8 @@ func onWorkflowRecordCreateOrUpdate(ctx context.Context, record *core.Record) er enabled := record.GetBool("enabled") trigger := record.GetString("trigger") - // 如果是手动触发或未启用,移除定时任务 - if !enabled || trigger == string(domain.WorkflowTriggerTypeManual) { + // 如果非定时触发或未启用,移除定时任务 + if !enabled || trigger != string(domain.WorkflowTriggerTypeScheduled) { scheduler.Remove(fmt.Sprintf("workflow#%s", workflowId)) return nil } @@ -68,7 +68,7 @@ func onWorkflowRecordCreateOrUpdate(ctx context.Context, record *core.Record) er workflowSrv := NewWorkflowService(repository.NewWorkflowRepository(), repository.NewWorkflowRunRepository(), repository.NewSettingsRepository()) workflowSrv.StartRun(ctx, &dtos.WorkflowStartRunReq{ WorkflowId: workflowId, - RunTrigger: domain.WorkflowTriggerTypeAuto, + RunTrigger: domain.WorkflowTriggerTypeScheduled, }) }) if err != nil { diff --git a/internal/workflow/node-processor/apply_node.go b/internal/workflow/node-processor/apply_node.go index 7f174b154..2878daee9 100644 --- a/internal/workflow/node-processor/apply_node.go +++ b/internal/workflow/node-processor/apply_node.go @@ -79,7 +79,7 @@ func (n *applyNode) Process(ctx context.Context) error { } certificate := &domain.Certificate{ - Source: domain.CertificateSourceTypeWorkflow, + Source: domain.CertificateSourceTypeRequest, Certificate: applyResult.FullChainCertificate, PrivateKey: applyResult.PrivateKey, IssuerCertificate: applyResult.IssuerCertificate, @@ -115,7 +115,7 @@ func (n *applyNode) Process(ctx context.Context) error { // 记录中间结果 n.outputs[outputKeyForNodeSkipped] = strconv.FormatBool(false) n.outputs[outputKeyForCertificateValidity] = strconv.FormatBool(true) - n.outputs[outputKeyForCertificateDaysLeft] = strconv.FormatInt(int64(time.Until(certificate.ExpireAt).Hours()/24), 10) + n.outputs[outputKeyForCertificateDaysLeft] = strconv.FormatInt(int64(time.Until(certificate.ValidityNotAfter).Hours()/24), 10) n.logger.Info("application completed") return nil @@ -158,7 +158,7 @@ func (n *applyNode) checkCanSkip(ctx context.Context, lastOutput *domain.Workflo lastCertificate, _ := n.certRepo.GetByWorkflowRunIdAndNodeId(ctx, lastOutput.RunId, lastOutput.NodeId) if lastCertificate != nil { renewalInterval := time.Duration(thisNodeCfg.SkipBeforeExpiryDays) * time.Hour * 24 - expirationTime := time.Until(lastCertificate.ExpireAt) + expirationTime := time.Until(lastCertificate.ValidityNotAfter) if expirationTime > renewalInterval { daysLeft := int(expirationTime.Hours() / 24) // TODO: 优化此处逻辑,[checkCanSkip] 方法不应该修改中间结果,违背单一职责 diff --git a/internal/workflow/node-processor/upload_node.go b/internal/workflow/node-processor/upload_node.go index be28241c0..3112d0806 100644 --- a/internal/workflow/node-processor/upload_node.go +++ b/internal/workflow/node-processor/upload_node.go @@ -74,7 +74,7 @@ func (n *uploadNode) Process(ctx context.Context) error { // 记录中间结果 n.outputs[outputKeyForNodeSkipped] = strconv.FormatBool(false) n.outputs[outputKeyForCertificateValidity] = strconv.FormatBool(true) - n.outputs[outputKeyForCertificateDaysLeft] = strconv.FormatInt(int64(time.Until(certificate.ExpireAt).Hours()/24), 10) + n.outputs[outputKeyForCertificateDaysLeft] = strconv.FormatInt(int64(time.Until(certificate.ValidityNotAfter).Hours()/24), 10) n.logger.Info("uploading completed") return nil @@ -95,7 +95,7 @@ func (n *uploadNode) checkCanSkip(ctx context.Context, lastOutput *domain.Workfl lastCertificate, _ := n.certRepo.GetByWorkflowRunIdAndNodeId(ctx, lastOutput.RunId, lastOutput.NodeId) if lastCertificate != nil { - daysLeft := int(time.Until(lastCertificate.ExpireAt).Hours() / 24) + daysLeft := int(time.Until(lastCertificate.ValidityNotAfter).Hours() / 24) n.outputs[outputKeyForCertificateValidity] = strconv.FormatBool(daysLeft > 0) n.outputs[outputKeyForCertificateDaysLeft] = strconv.FormatInt(int64(daysLeft), 10) diff --git a/internal/workflow/service.go b/internal/workflow/service.go index ac10ede9f..c90a2cb9a 100644 --- a/internal/workflow/service.go +++ b/internal/workflow/service.go @@ -16,7 +16,7 @@ import ( ) type workflowRepository interface { - ListEnabledAuto(ctx context.Context) ([]*domain.Workflow, error) + ListEnabledScheduled(ctx context.Context) ([]*domain.Workflow, error) GetById(ctx context.Context, id string) (*domain.Workflow, error) Save(ctx context.Context, workflow *domain.Workflow) (*domain.Workflow, error) } @@ -80,7 +80,7 @@ func (s *WorkflowService) InitSchedule(ctx context.Context) error { // 工作流 { - workflows, err := s.workflowRepo.ListEnabledAuto(ctx) + workflows, err := s.workflowRepo.ListEnabledScheduled(ctx) if err != nil { return err } @@ -91,7 +91,7 @@ func (s *WorkflowService) InitSchedule(ctx context.Context) error { err := app.GetScheduler().Add(fmt.Sprintf("workflow#%s", workflow.Id), workflow.TriggerCron, func() { s.StartRun(ctx, &dtos.WorkflowStartRunReq{ WorkflowId: workflow.Id, - RunTrigger: domain.WorkflowTriggerTypeAuto, + RunTrigger: domain.WorkflowTriggerTypeScheduled, }) }) if err != nil { diff --git a/migrations/1753272000_v0.4.0_migrate.go b/migrations/1753272000_v0.4.0_migrate.go index f6b8fe4a1..4523c8ae5 100644 --- a/migrations/1753272000_v0.4.0_migrate.go +++ b/migrations/1753272000_v0.4.0_migrate.go @@ -1,6 +1,8 @@ package migrations import ( + "encoding/json" + "github.com/pocketbase/pocketbase/core" m "github.com/pocketbase/pocketbase/migrations" ) @@ -10,72 +12,203 @@ func init() { tracer := NewTracer("v0.4.0") tracer.Printf("go ...") - // update collection `workflow_logs` + // update collection `access` { - collection, err := app.FindCollectionByNameOrId("pbc_1682296116") + collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e") if err != nil { return err + } else if collection != nil { + records, err := app.FindAllRecords(collection) + if err != nil { + return err + } + + for _, record := range records { + changed := false + + provider := record.GetString("provider") + config := make(map[string]any) + if err := record.UnmarshalJSONField("config", &config); err != nil { + return err + } + + switch provider { + case "discordbot", "mattermost", "slackbot": + if _, ok := config["defaultChannelId"]; ok { + config["channelId"] = config["defaultChannelId"] + delete(config, "defaultChannelId") + record.Set("config", config) + changed = true + } + + case "email": + if _, ok := config["defaultSenderAddress"]; ok { + config["senderAddress"] = config["defaultSenderAddress"] + delete(config, "defaultSenderAddress") + record.Set("config", config) + changed = true + } + if _, ok := config["defaultSenderName"]; ok { + config["senderName"] = config["defaultSenderName"] + delete(config, "defaultSenderName") + record.Set("config", config) + changed = true + } + if _, ok := config["defaultReceiverAddress"]; ok { + config["receiverAddress"] = config["defaultReceiverAddress"] + delete(config, "defaultReceiverAddress") + record.Set("config", config) + changed = true + } + + case "telegrambot": + if _, ok := config["defaultChatId"]; ok { + config["chatId"] = config["defaultChatId"] + delete(config, "defaultChatId") + record.Set("config", config) + changed = true + } + + case "webhook": + if _, ok := config["defaultDataForDeployment"]; ok { + config["dataForDeployment"] = config["defaultDataForDeployment"] + delete(config, "defaultDataForDeployment") + record.Set("config", config) + changed = true + } + if _, ok := config["defaultDataForNotification"]; ok { + config["dataForNotification"] = config["defaultDataForNotification"] + delete(config, "defaultDataForNotification") + record.Set("config", config) + changed = true + } + } + + if changed { + if err := app.Save(record); err != nil { + return err + } + + tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name) + } + } } + } - field := collection.Fields.GetByName("level") - if field != nil && field.Type() == "text" { - // add temp field `levelTmp` - if err := collection.Fields.AddMarshaledJSONAt(7, []byte(`{ + // update collection `certificate` + { + collection, err := app.FindCollectionByNameOrId("4szxr9x43tpj6np") + if err != nil { + return err + } else if collection != nil { + if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{ "hidden": false, - "id": "number760395071", - "max": null, - "min": null, - "name": "levelTmp", - "onlyInt": false, + "id": "by9hetqi", + "maxSelect": 1, + "name": "source", "presentable": false, "required": false, "system": false, - "type": "number" + "type": "select", + "values": [ + "request", + "upload" + ] }`)); err != nil { return err } - if err := app.Save(collection); err != nil { - return err - } - // copy `level` to `levelTmp` - if _, err := app.DB().NewQuery("UPDATE workflow_logs SET levelTmp = -4 WHERE level = 'DEBUG'").Execute(); err != nil { - return err - } - if _, err := app.DB().NewQuery("UPDATE workflow_logs SET levelTmp = 4 WHERE level = 'WARN'").Execute(); err != nil { - return err - } - if _, err := app.DB().NewQuery("UPDATE workflow_logs SET levelTmp = 8 WHERE level = 'ERROR'").Execute(); err != nil { - return err - } - if _, err := app.DB().NewQuery("UPDATE workflow_logs SET levelTmp = 0 WHERE levelTmp IS NULL").Execute(); err != nil { - return err - } - - // remove old field `level` - collection.Fields.RemoveById(field.GetId()) - if err := app.Save(collection); err != nil { - println(err) - return err - } - - // rename field `levelTmp` to `level` - if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{ + if err := collection.Fields.AddMarshaledJSONAt(9, []byte(`{ "hidden": false, - "id": "number760395071", - "max": null, - "min": null, - "name": "level", - "onlyInt": false, + "id": "v40aqzpd", + "max": "", + "min": "", + "name": "validityNotBefore", "presentable": false, "required": false, "system": false, - "type": "number" + "type": "date" }`)); err != nil { return err } + + if err := collection.Fields.AddMarshaledJSONAt(10, []byte(`{ + "hidden": false, + "id": "zgpdby2k", + "max": "", + "min": "", + "name": "validityNotAfter", + "presentable": false, + "required": false, + "system": false, + "type": "date" + }`)); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(15, []byte(`{ + "cascadeDelete": false, + "collectionId": "tovyif5ax6j62ur", + "hidden": false, + "id": "uvqfamb1", + "maxSelect": 1, + "minSelect": 0, + "name": "workflowRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(16, []byte(`{ + "cascadeDelete": false, + "collectionId": "qjp8lygssgwyqyz", + "hidden": false, + "id": "relation3917999135", + "maxSelect": 1, + "minSelect": 0, + "name": "workflowRunRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(17, []byte(`{ + "cascadeDelete": false, + "collectionId": "bqnxb95f2cooowp", + "hidden": false, + "id": "2ohlr0yd", + "maxSelect": 1, + "minSelect": 0, + "name": "workflowOutputRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := json.Unmarshal([]byte(`{ + "indexes": [ + "CREATE INDEX `+"`"+`idx_Jx8TXzDCmw`+"`"+` ON `+"`"+`certificate`+"`"+` (`+"`"+`workflowRef`+"`"+`)", + "CREATE INDEX `+"`"+`idx_2cRXqNDyyp`+"`"+` ON `+"`"+`certificate`+"`"+` (`+"`"+`workflowRunRef`+"`"+`)", + "CREATE INDEX `+"`"+`idx_kcKpgAZapk`+"`"+` ON `+"`"+`certificate`+"`"+` (`+"`"+`workflowNodeId`+"`"+`)" + ] + }`), &collection); err != nil { + return err + } + if err := app.Save(collection); err != nil { - println(err) + return err + } + + if _, err := app.DB().NewQuery("UPDATE certificate SET source = 'request' WHERE source = 'workflow'").Execute(); err != nil { return err } @@ -83,86 +216,360 @@ func init() { } } - // update collection `access` + // update collection `workflow` { - collection, err := app.FindCollectionByNameOrId("4yzbv8urny5ja1e") + collection, err := app.FindCollectionByNameOrId("tovyif5ax6j62ur") if err != nil { return err - } - - records, err := app.FindAllRecords(collection) - if err != nil { - return err - } - - for _, record := range records { - changed := false - - provider := record.GetString("provider") - config := make(map[string]any) - if err := record.UnmarshalJSONField("config", &config); err != nil { + } else if collection != nil { + if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{ + "hidden": false, + "id": "vqoajwjq", + "maxSelect": 1, + "name": "trigger", + "presentable": false, + "required": false, + "system": false, + "type": "select", + "values": [ + "manual", + "scheduled" + ] + }`)); err != nil { return err } - switch provider { - case "discordbot", "mattermost", "slackbot": - if _, ok := config["defaultChannelId"]; ok { - config["channelId"] = config["defaultChannelId"] - delete(config, "defaultChannelId") - record.Set("config", config) - changed = true - } - - case "email": - if _, ok := config["defaultSenderAddress"]; ok { - config["senderAddress"] = config["defaultSenderAddress"] - delete(config, "defaultSenderAddress") - record.Set("config", config) - changed = true - } - if _, ok := config["defaultSenderName"]; ok { - config["senderName"] = config["defaultSenderName"] - delete(config, "defaultSenderName") - record.Set("config", config) - changed = true - } - if _, ok := config["defaultReceiverAddress"]; ok { - config["receiverAddress"] = config["defaultReceiverAddress"] - delete(config, "defaultReceiverAddress") - record.Set("config", config) - changed = true - } - - case "telegrambot": - if _, ok := config["defaultChatId"]; ok { - config["chatId"] = config["defaultChatId"] - delete(config, "defaultChatId") - record.Set("config", config) - changed = true - } - - case "webhook": - if _, ok := config["defaultDataForDeployment"]; ok { - config["dataForDeployment"] = config["defaultDataForDeployment"] - delete(config, "defaultDataForDeployment") - record.Set("config", config) - changed = true - } - if _, ok := config["defaultDataForNotification"]; ok { - config["dataForNotification"] = config["defaultDataForNotification"] - delete(config, "defaultDataForNotification") - record.Set("config", config) - changed = true - } + if err := collection.Fields.AddMarshaledJSONAt(9, []byte(`{ + "cascadeDelete": false, + "collectionId": "qjp8lygssgwyqyz", + "hidden": false, + "id": "a23wkj9x", + "maxSelect": 1, + "minSelect": 0, + "name": "lastRunRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err } - if changed { - if err := app.Save(record); err != nil { + if err := app.Save(collection); err != nil { + return err + } + + if _, err := app.DB().NewQuery("UPDATE workflow SET trigger = 'scheduled' WHERE trigger = 'auto'").Execute(); err != nil { + return err + } + + tracer.Printf("collection '%s' updated", collection.Name) + + records, err := app.FindAllRecords(collection) + if err != nil { + return err + } else { + for _, record := range records { + changed := false + + draft := make(map[string]any) + if err := record.UnmarshalJSONField("draft", &draft); err == nil { + if _, ok := draft["config"]; ok { + config := draft["config"].(map[string]any) + if _, ok := config["trigger"]; ok { + trigger := config["trigger"].(string) + if trigger == "auto" { + config["trigger"] = "scheduled" + record.Set("draft", draft) + changed = true + } + } + } + } + + content := make(map[string]any) + if err := record.UnmarshalJSONField("content", &content); err == nil { + if _, ok := content["config"]; ok { + config := content["config"].(map[string]any) + if _, ok := config["trigger"]; ok { + trigger := config["trigger"].(string) + if trigger == "auto" { + config["trigger"] = "scheduled" + record.Set("content", content) + changed = true + } + } + } + } + + if changed { + if err := app.Save(record); err != nil { + return err + } + + tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name) + } + } + } + } + } + + // update collection `workflow_run` + { + collection, err := app.FindCollectionByNameOrId("qjp8lygssgwyqyz") + if err != nil { + return err + } else if collection != nil { + if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{ + "cascadeDelete": true, + "collectionId": "tovyif5ax6j62ur", + "hidden": false, + "id": "m8xfsyyy", + "maxSelect": 1, + "minSelect": 0, + "name": "workflowRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{ + "hidden": false, + "id": "jlroa3fk", + "maxSelect": 1, + "name": "trigger", + "presentable": false, + "required": false, + "system": false, + "type": "select", + "values": [ + "manual", + "scheduled" + ] + }`)); err != nil { + return err + } + + if err := json.Unmarshal([]byte(`{ + "indexes": [ + "CREATE INDEX `+"`"+`idx_7ZpfjTFsD2`+"`"+` ON `+"`"+`workflow_run`+"`"+` (`+"`"+`workflowRef`+"`"+`)" + ] + }`), &collection); err != nil { + return err + } + + if err := app.Save(collection); err != nil { + return err + } + + if _, err := app.DB().NewQuery("UPDATE workflow_run SET trigger = 'scheduled' WHERE trigger = 'auto'").Execute(); err != nil { + return err + } + + tracer.Printf("collection '%s' updated", collection.Name) + + records, err := app.FindAllRecords(collection) + if err != nil { + return err + } else { + for _, record := range records { + changed := false + + detail := make(map[string]any) + if err := record.UnmarshalJSONField("detail", &detail); err == nil { + if _, ok := detail["config"]; ok { + config := detail["config"].(map[string]any) + if _, ok := config["trigger"]; ok { + trigger := config["trigger"].(string) + if trigger == "auto" { + config["trigger"] = "scheduled" + record.Set("detail", detail) + changed = true + } + } + } + } + + if changed { + if err := app.Save(record); err != nil { + return err + } + + tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name) + } + } + } + } + } + + // update collection `workflow_output` + { + collection, err := app.FindCollectionByNameOrId("bqnxb95f2cooowp") + if err != nil { + return err + } else if collection != nil { + if err := json.Unmarshal([]byte(`{ + "indexes": [ + "CREATE INDEX `+"`"+`idx_BYoQPsz4my`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`workflowRef`+"`"+`)", + "CREATE INDEX `+"`"+`idx_O9zxLETuxJ`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`runRef`+"`"+`)", + "CREATE INDEX `+"`"+`idx_luac8Ul34G`+"`"+` ON `+"`"+`workflow_output`+"`"+` (`+"`"+`nodeId`+"`"+`)" + ] + }`), &collection); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{ + "cascadeDelete": true, + "collectionId": "tovyif5ax6j62ur", + "hidden": false, + "id": "jka88auc", + "maxSelect": 1, + "minSelect": 0, + "name": "workflowRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{ + "cascadeDelete": true, + "collectionId": "qjp8lygssgwyqyz", + "hidden": false, + "id": "relation821863227", + "maxSelect": 1, + "minSelect": 0, + "name": "runRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := app.Save(collection); err != nil { + return err + } + + tracer.Printf("collection '%s' updated", collection.Name) + } + } + + // update collection `workflow_logs` + { + collection, err := app.FindCollectionByNameOrId("pbc_1682296116") + if err != nil { + return err + } else if collection != nil { + if field := collection.Fields.GetByName("level"); field != nil && field.Type() == "text" { + if _, err := app.DB().NewQuery("UPDATE workflow_logs SET level = -4 WHERE level = 'DEBUG'").Execute(); err != nil { + return err + } + if _, err := app.DB().NewQuery("UPDATE workflow_logs SET level = 0 WHERE level = 'INFO'").Execute(); err != nil { + return err + } + if _, err := app.DB().NewQuery("UPDATE workflow_logs SET level = 4 WHERE level = 'WARN'").Execute(); err != nil { + return err + } + if _, err := app.DB().NewQuery("UPDATE workflow_logs SET level = 8 WHERE level = 'ERROR'").Execute(); err != nil { return err } - tracer.Printf("record #%s in collection '%s' updated", record.Id, collection.Name) + if err := collection.Fields.AddMarshaledJSONAt(7, []byte(`{ + "hidden": false, + "id": "number760395071", + "max": null, + "min": null, + "name": "levelTmp", + "onlyInt": false, + "presentable": false, + "required": false, + "system": false, + "type": "number" + }`)); err != nil { + return err + } + if err := app.Save(collection); err != nil { + return err + } + + collection.Fields.RemoveById(field.GetId()) + if err := app.Save(collection); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{ + "hidden": false, + "id": "number760395071", + "max": null, + "min": null, + "name": "level", + "onlyInt": false, + "presentable": false, + "required": false, + "system": false, + "type": "number" + }`)); err != nil { + return err + } + if err := app.Save(collection); err != nil { + return err + } } + + if err := collection.Fields.AddMarshaledJSONAt(1, []byte(`{ + "cascadeDelete": true, + "collectionId": "tovyif5ax6j62ur", + "hidden": false, + "id": "relation3371272342", + "maxSelect": 1, + "minSelect": 0, + "name": "workflowRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := collection.Fields.AddMarshaledJSONAt(2, []byte(`{ + "cascadeDelete": true, + "collectionId": "qjp8lygssgwyqyz", + "hidden": false, + "id": "relation821863227", + "maxSelect": 1, + "minSelect": 0, + "name": "runRef", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }`)); err != nil { + return err + } + + if err := json.Unmarshal([]byte(`{ + "indexes": [ + "CREATE INDEX `+"`"+`idx_IOlpy6XuJ2`+"`"+` ON `+"`"+`workflow_logs`+"`"+` (`+"`"+`workflowRef`+"`"+`)", + "CREATE INDEX `+"`"+`idx_qVlTb2yl7v`+"`"+` ON `+"`"+`workflow_logs`+"`"+` (`+"`"+`runRef`+"`"+`)", + "CREATE INDEX `+"`"+`idx_UL4tdCXNlA`+"`"+` ON `+"`"+`workflow_logs`+"`"+` (`+"`"+`nodeId`+"`"+`)" + ] + }`), &collection); err != nil { + return err + } + + if err := app.Save(collection); err != nil { + return err + } + + tracer.Printf("collection '%s' updated", collection.Name) } } diff --git a/ui/src/components/certificate/CertificateDetail.tsx b/ui/src/components/certificate/CertificateDetail.tsx index a016eef19..0d2ef75cb 100644 --- a/ui/src/components/certificate/CertificateDetail.tsx +++ b/ui/src/components/certificate/CertificateDetail.tsx @@ -45,7 +45,7 @@ const CertificateDetail = ({ data, ...props }: CertificateDetailProps) => { diff --git a/ui/src/components/workflow/WorkflowRunDetail.tsx b/ui/src/components/workflow/WorkflowRunDetail.tsx index e517c761b..87bbef859 100644 --- a/ui/src/components/workflow/WorkflowRunDetail.tsx +++ b/ui/src/components/workflow/WorkflowRunDetail.tsx @@ -239,7 +239,7 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin style={{ color: "inherit" }} bordered={false} defaultActiveKey={listData.map((group) => group.id)} - expandIcon={({ isActive }) => } + expandIcon={({ isActive }) => } items={listData.map((group) => { return { key: group.id, diff --git a/ui/src/components/workflow/WorkflowRuns.tsx b/ui/src/components/workflow/WorkflowRuns.tsx index bdf256edc..72892bc57 100644 --- a/ui/src/components/workflow/WorkflowRuns.tsx +++ b/ui/src/components/workflow/WorkflowRuns.tsx @@ -64,8 +64,8 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => { title: t("workflow_run.props.trigger"), ellipsis: true, render: (_, record) => { - if (record.trigger === WORKFLOW_TRIGGERS.AUTO) { - return t("workflow_run.props.trigger.auto"); + if (record.trigger === WORKFLOW_TRIGGERS.SCHEDULED) { + return t("workflow_run.props.trigger.scheduled"); } else if (record.trigger === WORKFLOW_TRIGGERS.MANUAL) { return t("workflow_run.props.trigger.manual"); } @@ -203,6 +203,10 @@ const WorkflowRuns = ({ className, style, workflowId }: WorkflowRunsProps) => { return [...prev]; }); + if (cb.record.id === detailDrawerProps.data?.id) { + setDetailRecord({ ...detailDrawerProps.data, ...cb.record }); + } + if (cb.record.status !== WORKFLOW_RUN_STATUSES.PENDING && cb.record.status !== WORKFLOW_RUN_STATUSES.RUNNING) { unsubscribeWorkflowRun(item.id); } diff --git a/ui/src/components/workflow/node/StartNode.tsx b/ui/src/components/workflow/node/StartNode.tsx index 45ac116ca..ff5eeebbe 100644 --- a/ui/src/components/workflow/node/StartNode.tsx +++ b/ui/src/components/workflow/node/StartNode.tsx @@ -40,14 +40,14 @@ const StartNode = ({ node, disabled }: StartNodeProps) => { return (
- {config.trigger === WORKFLOW_TRIGGERS.AUTO - ? t("workflow.props.trigger.auto") + {config.trigger === WORKFLOW_TRIGGERS.SCHEDULED + ? t("workflow.props.trigger.scheduled") : config.trigger === WORKFLOW_TRIGGERS.MANUAL ? t("workflow.props.trigger.manual") : "\u00A0"} - {config.trigger === WORKFLOW_TRIGGERS.AUTO ? config.triggerCron : ""} + {config.trigger === WORKFLOW_TRIGGERS.SCHEDULED ? config.triggerCron : ""}
); diff --git a/ui/src/components/workflow/node/StartNodeConfigForm.tsx b/ui/src/components/workflow/node/StartNodeConfigForm.tsx index 3f098a9eb..900bfc63a 100644 --- a/ui/src/components/workflow/node/StartNodeConfigForm.tsx +++ b/ui/src/components/workflow/node/StartNodeConfigForm.tsx @@ -40,7 +40,7 @@ const StartNodeConfigForm = forwardRef { - if (fieldTrigger !== WORKFLOW_TRIGGERS.AUTO) return true; + if (fieldTrigger !== WORKFLOW_TRIGGERS.SCHEDULED) return true; return validCronExpression(v!); }, t("workflow_node.start.form.trigger_cron.errmsg.invalid")), }); @@ -58,7 +58,7 @@ const StartNodeConfigForm = forwardRef { - if (value === WORKFLOW_TRIGGERS.AUTO) { + if (value === WORKFLOW_TRIGGERS.SCHEDULED) { formInst.setFieldValue("triggerCron", formProps.initialValues?.triggerCron || initFormModel().triggerCron); } else { formInst.setFieldValue("triggerCron", undefined); @@ -89,7 +89,7 @@ const StartNodeConfigForm = forwardRef handleTriggerChange(e.target.value)}> - {t("workflow_node.start.form.trigger.option.auto.label")} + {t("workflow_node.start.form.trigger.option.scheduled.label")} {t("workflow_node.start.form.trigger.option.manual.label")} @@ -97,7 +97,7 @@ const StartNodeConfigForm = forwardRef
- + } /> diff --git a/ui/src/domain/certificate.ts b/ui/src/domain/certificate.ts index c4bc8710b..36987ba76 100644 --- a/ui/src/domain/certificate.ts +++ b/ui/src/domain/certificate.ts @@ -8,16 +8,16 @@ export interface CertificateModel extends BaseModel { privateKey: string; issuerOrg: string; keyAlgorithm: string; - effectAt: ISO8601String; - expireAt: ISO8601String; - workflowId: string; + validityNotBefore: ISO8601String; + validityNotAfter: ISO8601String; + workflowRef: string; expand?: { - workflowId?: WorkflowModel; // TODO: ugly, maybe to use an alias? + workflowRef?: WorkflowModel; }; } export const CERTIFICATE_SOURCES = Object.freeze({ - WORKFLOW: "workflow", + REQUEST: "request", UPLOAD: "upload", } as const); diff --git a/ui/src/domain/workflow.ts b/ui/src/domain/workflow.ts index c9367747f..ac2e2b19d 100644 --- a/ui/src/domain/workflow.ts +++ b/ui/src/domain/workflow.ts @@ -13,13 +13,13 @@ export interface WorkflowModel extends BaseModel { content?: WorkflowNode; draft?: WorkflowNode; hasDraft?: boolean; - lastRunId?: string; + lastRunRef?: string; lastRunStatus?: string; lastRunTime?: string; } export const WORKFLOW_TRIGGERS = Object.freeze({ - AUTO: "auto", + SCHEDULED: "scheduled", MANUAL: "manual", } as const); @@ -135,7 +135,7 @@ export type WorkflowNodeConfigForStart = { export const defaultNodeConfigForStart = (): Partial => { return { - trigger: WORKFLOW_TRIGGERS.AUTO, + trigger: WORKFLOW_TRIGGERS.SCHEDULED, triggerCron: "0 0 * * *", }; }; diff --git a/ui/src/domain/workflowRun.ts b/ui/src/domain/workflowRun.ts index 6df4a4062..bd118e480 100644 --- a/ui/src/domain/workflowRun.ts +++ b/ui/src/domain/workflowRun.ts @@ -1,14 +1,14 @@ import { type WorkflowModel } from "./workflow"; export interface WorkflowRunModel extends BaseModel { - workflowId: string; + workflowRef: string; status: string; trigger: string; startedAt: ISO8601String; endedAt: ISO8601String; error?: string; expand?: { - workflowId?: WorkflowModel; // TODO: ugly, maybe to use an alias? + workflowRef?: WorkflowModel; }; } diff --git a/ui/src/i18n/locales/en/nls.certificate.json b/ui/src/i18n/locales/en/nls.certificate.json index 7f83da5ec..24588ba70 100644 --- a/ui/src/i18n/locales/en/nls.certificate.json +++ b/ui/src/i18n/locales/en/nls.certificate.json @@ -26,7 +26,7 @@ "certificate.props.validity.filter.expired": "Expired", "certificate.props.brand": "Brand", "certificate.props.source": "Source", - "certificate.props.source.workflow": "Workflow", + "certificate.props.source.request": "Request", "certificate.props.source.upload": "Upload", "certificate.props.certificate": "Certificate chain", "certificate.props.private_key": "Private key", diff --git a/ui/src/i18n/locales/en/nls.workflow.json b/ui/src/i18n/locales/en/nls.workflow.json index 1f9130c4b..426a58f09 100644 --- a/ui/src/i18n/locales/en/nls.workflow.json +++ b/ui/src/i18n/locales/en/nls.workflow.json @@ -36,7 +36,7 @@ "workflow.props.name": "Name", "workflow.props.description": "Description", "workflow.props.trigger": "Trigger", - "workflow.props.trigger.auto": "Scheduled", + "workflow.props.trigger.scheduled": "Scheduled", "workflow.props.trigger.manual": "Manual", "workflow.props.last_run_at": "Last run at", "workflow.props.state": "Active", diff --git a/ui/src/i18n/locales/en/nls.workflow.nodes.json b/ui/src/i18n/locales/en/nls.workflow.nodes.json index 200e1a48a..8f586007a 100644 --- a/ui/src/i18n/locales/en/nls.workflow.nodes.json +++ b/ui/src/i18n/locales/en/nls.workflow.nodes.json @@ -15,7 +15,7 @@ "workflow_node.start.default_name": "Start", "workflow_node.start.form.trigger.label": "Trigger", "workflow_node.start.form.trigger.placeholder": "Please select trigger", - "workflow_node.start.form.trigger.option.auto.label": "Scheduled", + "workflow_node.start.form.trigger.option.scheduled.label": "Scheduled", "workflow_node.start.form.trigger.option.manual.label": "Manual", "workflow_node.start.form.trigger_cron.label": "Cron expression", "workflow_node.start.form.trigger_cron.placeholder": "Please enter cron expression", diff --git a/ui/src/i18n/locales/en/nls.workflow.runs.json b/ui/src/i18n/locales/en/nls.workflow.runs.json index 8223cee36..1c9a05eb4 100644 --- a/ui/src/i18n/locales/en/nls.workflow.runs.json +++ b/ui/src/i18n/locales/en/nls.workflow.runs.json @@ -20,7 +20,7 @@ "workflow_run.props.status.failed": "Failed", "workflow_run.props.status.canceled": "Canceled", "workflow_run.props.trigger": "Trigger", - "workflow_run.props.trigger.auto": "Timing", + "workflow_run.props.trigger.scheduled": "Scheduled", "workflow_run.props.trigger.manual": "Manual", "workflow_run.props.started_at": "Started at", "workflow_run.props.ended_at": "Ended at", diff --git a/ui/src/i18n/locales/zh/nls.certificate.json b/ui/src/i18n/locales/zh/nls.certificate.json index 55dc77359..6ea7260a3 100644 --- a/ui/src/i18n/locales/zh/nls.certificate.json +++ b/ui/src/i18n/locales/zh/nls.certificate.json @@ -26,8 +26,8 @@ "certificate.props.validity.filter.expired": "已过期", "certificate.props.brand": "证书品牌", "certificate.props.source": "来源", - "certificate.props.source.workflow": "工作流", - "certificate.props.source.upload": "用户上传", + "certificate.props.source.request": "申请", + "certificate.props.source.upload": "上传", "certificate.props.certificate": "证书内容", "certificate.props.private_key": "私钥内容", "certificate.props.serial_number": "证书序列号", diff --git a/ui/src/i18n/locales/zh/nls.workflow.json b/ui/src/i18n/locales/zh/nls.workflow.json index ff5e103c5..ca74474b9 100644 --- a/ui/src/i18n/locales/zh/nls.workflow.json +++ b/ui/src/i18n/locales/zh/nls.workflow.json @@ -36,7 +36,7 @@ "workflow.props.name": "名称", "workflow.props.description": "描述", "workflow.props.trigger": "触发方式", - "workflow.props.trigger.auto": "定时", + "workflow.props.trigger.scheduled": "定时", "workflow.props.trigger.manual": "手动", "workflow.props.last_run_at": "最近执行时间", "workflow.props.state": "启用", diff --git a/ui/src/i18n/locales/zh/nls.workflow.nodes.json b/ui/src/i18n/locales/zh/nls.workflow.nodes.json index 572ca55df..e13f02070 100644 --- a/ui/src/i18n/locales/zh/nls.workflow.nodes.json +++ b/ui/src/i18n/locales/zh/nls.workflow.nodes.json @@ -15,7 +15,7 @@ "workflow_node.start.default_name": "开始", "workflow_node.start.form.trigger.label": "触发方式", "workflow_node.start.form.trigger.placeholder": "请选择触发方式", - "workflow_node.start.form.trigger.option.auto.label": "定时触发", + "workflow_node.start.form.trigger.option.scheduled.label": "定时触发", "workflow_node.start.form.trigger.option.manual.label": "手动触发", "workflow_node.start.form.trigger_cron.label": "Cron 表达式", "workflow_node.start.form.trigger_cron.placeholder": "请输入 Cron 表达式", diff --git a/ui/src/i18n/locales/zh/nls.workflow.runs.json b/ui/src/i18n/locales/zh/nls.workflow.runs.json index bbe3e8565..af5ba358c 100644 --- a/ui/src/i18n/locales/zh/nls.workflow.runs.json +++ b/ui/src/i18n/locales/zh/nls.workflow.runs.json @@ -20,7 +20,7 @@ "workflow_run.props.status.failed": "已失败", "workflow_run.props.status.canceled": "已取消", "workflow_run.props.trigger": "执行方式", - "workflow_run.props.trigger.auto": "定时执行", + "workflow_run.props.trigger.scheduled": "定时执行", "workflow_run.props.trigger.manual": "手动执行", "workflow_run.props.started_at": "开始时间", "workflow_run.props.ended_at": "完成时间", diff --git a/ui/src/pages/certificates/CertificateList.tsx b/ui/src/pages/certificates/CertificateList.tsx index 8ebe45b0e..85af2c5ac 100644 --- a/ui/src/pages/certificates/CertificateList.tsx +++ b/ui/src/pages/certificates/CertificateList.tsx @@ -49,14 +49,14 @@ const CertificateList = () => { render: (_, record) => {record.subjectAltNames}, }, { - key: "expiry", + key: "validity", title: t("certificate.props.validity"), sorter: true, - sortOrder: sorter.columnKey === "expiry" ? sorter.order : undefined, + sortOrder: sorter.columnKey === "validity" ? sorter.order : undefined, render: (_, record) => { - const total = dayjs(record.expireAt).diff(dayjs(record.created), "d") + 1; - const isExpired = dayjs().isAfter(dayjs(record.expireAt)); - const leftHours = dayjs(record.expireAt).diff(dayjs(), "h"); + const total = dayjs(record.validityNotAfter).diff(dayjs(record.created), "d") + 1; + const isExpired = dayjs().isAfter(dayjs(record.validityNotAfter)); + const leftHours = dayjs(record.validityNotAfter).diff(dayjs(), "h"); const leftDays = Math.round(leftHours / 24); return ( @@ -83,7 +83,7 @@ const CertificateList = () => { )} - {t("certificate.props.validity.expiration", { date: dayjs(record.expireAt).format("YYYY-MM-DD") })} + {t("certificate.props.validity.expiration", { date: dayjs(record.validityNotAfter).format("YYYY-MM-DD") })} ); @@ -103,7 +103,7 @@ const CertificateList = () => { key: "source", title: t("certificate.props.source"), render: (_, record) => { - const workflowId = record.workflowId; + const workflowId = record.workflowRef; return (
{t(`certificate.props.source.${record.source}`)} @@ -117,7 +117,7 @@ const CertificateList = () => { } }} > - {record.expand?.workflowId?.name ?? {t(`#${workflowId}`)}} + {record.expand?.workflowRef?.name ?? {t(`#${workflowId}`)}}
); @@ -218,7 +218,7 @@ const CertificateList = () => { () => { const { columnKey: sorterKey, order: sorterOrder } = sorter; let sort: string | undefined; - sort = sorterKey === "expiry" ? "expireAt" : ""; + sort = sorterKey === "validity" ? "validityNotAfter" : ""; sort = sort && (sorterOrder === "ascend" ? `${sort}` : sorterOrder === "descend" ? `-${sort}` : undefined); return listCertificates({ diff --git a/ui/src/pages/dashboard/Dashboard.tsx b/ui/src/pages/dashboard/Dashboard.tsx index 5ec5e0edd..bcb893d2c 100644 --- a/ui/src/pages/dashboard/Dashboard.tsx +++ b/ui/src/pages/dashboard/Dashboard.tsx @@ -245,7 +245,7 @@ const WorkflowRunHistoryTable = ({ className, style }: { className?: string; sty key: "name", title: t("workflow.props.name"), render: (_, record) => { - const workflow = record.expand?.workflowId; + const workflow = record.expand?.workflowRef; return (
- {workflow?.name ?? {t(`#${record.workflowId}`)}} + {workflow?.name ?? {t(`#${record.workflowRef}`)}}
); diff --git a/ui/src/pages/workflows/WorkflowList.tsx b/ui/src/pages/workflows/WorkflowList.tsx index 06023d6c7..9f9e93f46 100644 --- a/ui/src/pages/workflows/WorkflowList.tsx +++ b/ui/src/pages/workflows/WorkflowList.tsx @@ -64,10 +64,10 @@ const WorkflowList = () => { return "-"; } else if (trigger === WORKFLOW_TRIGGERS.MANUAL) { return {t("workflow.props.trigger.manual")}; - } else if (trigger === WORKFLOW_TRIGGERS.AUTO) { + } else if (trigger === WORKFLOW_TRIGGERS.SCHEDULED) { return (
- {t("workflow.props.trigger.auto")} + {t("workflow.props.trigger.scheduled")} {record.triggerCron || "\u00A0"}
); diff --git a/ui/src/repository/certificate.ts b/ui/src/repository/certificate.ts index db099bd79..92ad852b1 100644 --- a/ui/src/repository/certificate.ts +++ b/ui/src/repository/certificate.ts @@ -19,9 +19,9 @@ export const list = async (request: ListRequest) => { filters.push(pb.filter("(subjectAltNames~{:keyword} || serialNumber={:keyword})", { keyword: request.keyword })); } if (request.state === "expireSoon") { - filters.push(pb.filter("expireAt<{:expiredAt} && expireAt>@now", { expiredAt: dayjs().add(20, "d").toDate() })); + filters.push(pb.filter("validityNotAfter<{:expiredAt} && validityNotAfter>@now", { expiredAt: dayjs().add(20, "d").toDate() })); } else if (request.state === "expired") { - filters.push(pb.filter("expireAt<={:expiredAt}", { expiredAt: new Date() })); + filters.push(pb.filter("validityNotAfter<={:expiredAt}", { expiredAt: new Date() })); } const sort = request.sort || "-created"; @@ -30,7 +30,7 @@ export const list = async (request: ListRequest) => { const perPage = request.perPage || 10; return pb.collection(COLLECTION_NAME_CERTIFICATE).getList(page, perPage, { - expand: "workflowId", + expand: "workflowRef", filter: filters.join(" && "), sort: sort, requestKey: null, @@ -42,7 +42,7 @@ export const listByWorkflowRunId = async (workflowRunId: string) => { const list = await pb.collection(COLLECTION_NAME_CERTIFICATE).getFullList({ batch: 65535, - filter: pb.filter("workflowRunId={:workflowRunId}", { workflowRunId: workflowRunId }), + filter: pb.filter("workflowRunRef={:workflowRunId}", { workflowRunId }), sort: "created", requestKey: null, }); diff --git a/ui/src/repository/workflowLog.ts b/ui/src/repository/workflowLog.ts index 683b4b034..4a972f903 100644 --- a/ui/src/repository/workflowLog.ts +++ b/ui/src/repository/workflowLog.ts @@ -7,7 +7,7 @@ export const listByWorkflowRunId = async (workflowRunId: string) => { const list = await pb.collection(COLLECTION_NAME_WORKFLOW_LOG).getFullList({ batch: 65535, - filter: pb.filter("runId={:runId}", { runId: workflowRunId }), + filter: pb.filter("runRef={:workflowRunId}", { workflowRunId }), sort: "timestamp", requestKey: null, }); diff --git a/ui/src/repository/workflowRun.ts b/ui/src/repository/workflowRun.ts index 22c698029..2fdc011f2 100644 --- a/ui/src/repository/workflowRun.ts +++ b/ui/src/repository/workflowRun.ts @@ -16,7 +16,7 @@ export const list = async (request: ListRequest) => { const filters: string[] = []; if (request.workflowId) { - filters.push(pb.filter("workflowId={:workflowId}", { workflowId: request.workflowId })); + filters.push(pb.filter("workflowRef={:workflowId}", { workflowId: request.workflowId })); } const page = request.page || 1; @@ -25,7 +25,7 @@ export const list = async (request: ListRequest) => { filter: filters.join(" && "), sort: "-created", requestKey: null, - expand: request.expand ? "workflowId" : undefined, + expand: request.expand ? "workflowRef" : undefined, }); };