Let workflows merge or discard their own tasks
This commit is contained in:
@@ -176,6 +176,8 @@ struct WorkflowEditor: View {
|
||||
@ViewState private var loaded: WorkflowDefinition?
|
||||
@ViewState private var name = ""
|
||||
@ViewState private var description = ""
|
||||
@ViewState private var autoMerge = false
|
||||
@ViewState private var autoDiscard = false
|
||||
@ViewState private var failure = ""
|
||||
@ViewState private var saving = false
|
||||
|
||||
@@ -206,6 +208,14 @@ struct WorkflowEditor: View {
|
||||
TextField("Description", text: $description, axis: .vertical)
|
||||
.modifier(FieldStyle())
|
||||
.padding(.top, 8)
|
||||
Toggle("Merge its tasks when they're ready", isOn: $autoMerge)
|
||||
.toggleStyle(.checkbox)
|
||||
.tint(Palette.accent)
|
||||
.padding(.top, 8)
|
||||
Toggle("Discard its tasks when they suggest it", isOn: $autoDiscard)
|
||||
.toggleStyle(.checkbox)
|
||||
.tint(Palette.accent)
|
||||
.padding(.top, 4)
|
||||
if !root.stageNames().isEmpty {
|
||||
BoxDiagramView(source: stepDiagram(root))
|
||||
.padding(.top, 12)
|
||||
@@ -244,7 +254,7 @@ struct WorkflowEditor: View {
|
||||
}
|
||||
|
||||
private var current: WorkflowDefinition? {
|
||||
root.map { WorkflowDefinition(description: description.isEmpty ? nil : description, steps: $0.children.map(\.step)) }
|
||||
root.map { WorkflowDefinition(description: description.isEmpty ? nil : description, autoMerge: autoMerge ? true : nil, autoDiscard: autoDiscard ? true : nil, steps: $0.children.map(\.step)) }
|
||||
}
|
||||
|
||||
private var target: String {
|
||||
@@ -266,6 +276,8 @@ struct WorkflowEditor: View {
|
||||
let def = try await store.api.client.getWorkflow(path: .init(name: original)).ok.body.json
|
||||
name = original
|
||||
description = def.description ?? ""
|
||||
autoMerge = def.autoMerge ?? false
|
||||
autoDiscard = def.autoDiscard ?? false
|
||||
root = StepNode(kind: .order, children: def.steps.map { StepNode($0) })
|
||||
loaded = current
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user