diff --git a/go/vt/workflow/long_polling_test.go b/go/vt/workflow/long_polling_test.go index 53da9f4731..3bb4e16e40 100644 --- a/go/vt/workflow/long_polling_test.go +++ b/go/vt/workflow/long_polling_test.go @@ -68,7 +68,8 @@ func TestLongPolling(t *testing.T) { if err != nil { t.Fatalf("/poll/1 reading failed: %v", err) } - if string(tree) != `{"nodes":[{"name":"name","path":"/uuid1","children":[],"lastChanged":143,"actions":null}]}` { + if !strings.Contains(string(tree), `"name":"name"`) || + !strings.Contains(string(tree), `"path":"/uuid1"`) { t.Errorf("unexpected first result: %v", string(tree)) } diff --git a/go/vt/workflow/node.go b/go/vt/workflow/node.go index 9a950ecb3a..61703d2db4 100644 --- a/go/vt/workflow/node.go +++ b/go/vt/workflow/node.go @@ -27,47 +27,56 @@ import ( type NodeDisplay int const ( + // NodeDisplayUnknown is an unknown value and should never be set. + NodeDisplayUnknown NodeDisplay = 0 + // NodeDisplayIndeterminate is a progress bar that doesn't have // a current value, but just shows movement. - NodeDisplayIndeterminate NodeDisplay = 0 + NodeDisplayIndeterminate NodeDisplay = 1 // NodeDisplayDeterminate is a progress bar driven by the // Progress field. - NodeDisplayDeterminate NodeDisplay = 1 + NodeDisplayDeterminate NodeDisplay = 2 // NodeDisplayNone shows no progress bar or status. - NodeDisplayNone NodeDisplay = 2 + NodeDisplayNone NodeDisplay = 3 ) // ActionState constants need to match node.ts.ActionState. type ActionState int const ( + // ActionStateUnknown is an unknown value and should never be set. + ActionStateUnknown ActionState = 0 + // ActionStateEnabled is for when the action is enabled. - ActionStateEnabled ActionState = 0 + ActionStateEnabled ActionState = 1 // ActionStateDisabled is for when the action is disabled. - ActionStateDisabled ActionState = 1 + ActionStateDisabled ActionState = 2 ) // ActionStyle constants need to match node.ts.ActionStyle. type ActionStyle int const ( + // ActionStyleUnknown is an unknown value and should never be set. + ActionStyleUnknown ActionStyle = 0 + // ActionStyleNormal will just trigger the action. - ActionStyleNormal ActionStyle = 0 + ActionStyleNormal ActionStyle = 1 // ActionStyleWarning will display a warning dialog to confirm // action with Action.Message. - ActionStyleWarning ActionStyle = 1 + ActionStyleWarning ActionStyle = 2 // ActionStyleWaiting highlights to the user that the process // is waiting on the execution of the action. - ActionStyleWaiting ActionStyle = 2 + ActionStyleWaiting ActionStyle = 3 // ActionStyleTriggered is a state where the button is greyed // out and cannot be pressed. - ActionStyleTriggered ActionStyle = 3 + ActionStyleTriggered ActionStyle = 4 ) // Node is the UI representation of a Workflow toplevel object, or of @@ -102,24 +111,24 @@ type Node struct { Name string `json:"name"` Path string `json:"path"` - Children []*Node `json:"children"` + Children []*Node `json:"children,omitempty"` LastChanged int64 `json:"lastChanged"` - Progress int `json:"progress,omitempty"` - ProgressMessage string `json:"progressMsg,omitempty"` - State workflowpb.WorkflowState `json:"state,omitempty"` + Progress int `json:"progress"` + ProgressMessage string `json:"progressMsg"` + State workflowpb.WorkflowState `json:"state"` Display NodeDisplay `json:"display,omitempty"` - Message string `json:"message,omitempty"` - Log string `json:"log,omitempty"` - Disabled bool `json:"disabled,omitempty"` + Message string `json:"message"` + Log string `json:"log"` + Disabled bool `json:"disabled"` Actions []*Action `json:"actions"` } // Action must match node.ts Action. type Action struct { - Name string `json:"name,omitempty"` + Name string `json:"name"` State ActionState `json:"state,omitempty"` Style ActionStyle `json:"style,omitempty"` - Message string `json:"message,omitempty"` + Message string `json:"message"` } // Update is the data structure we send on the websocket or on the diff --git a/go/vt/workflow/node_test.go b/go/vt/workflow/node_test.go index c85b3e4818..ac6d37b958 100644 --- a/go/vt/workflow/node_test.go +++ b/go/vt/workflow/node_test.go @@ -73,7 +73,7 @@ func TestNodeManagerWithRoot(t *testing.T) { result, ok = <-notifications if !ok || !strings.Contains(string(result), `"name":"name2"`) || - !strings.Contains(string(result), `"children":[]`) || // FIXME(alainjobart) this should be true, we're not changing the children. + strings.Contains(string(result), `"children":[]`) || strings.Contains(string(result), `"fullUpdate":true`) { t.Errorf("unexpected notification: %v %v", ok, string(result)) } diff --git a/go/vt/workflow/websocket_test.go b/go/vt/workflow/websocket_test.go index a24f58aaf6..6d6972fc5c 100644 --- a/go/vt/workflow/websocket_test.go +++ b/go/vt/workflow/websocket_test.go @@ -61,7 +61,8 @@ func TestWebSocket(t *testing.T) { if err != nil { t.Fatalf("WebSocket first read failed: %v", err) } - if string(tree) != `{"nodes":[{"name":"name","path":"/uuid1","children":[],"lastChanged":143,"actions":null}]}` { + if !strings.Contains(string(tree), `"name":"name"`) || + !strings.Contains(string(tree), `"path":"/uuid1"`) { t.Errorf("unexpected first result: %v", string(tree)) } diff --git a/web/vtctld2/app/index.html b/web/vtctld2/app/index.html index 70e442cd3f..0147162f14 100644 --- a/web/vtctld2/app/index.html +++ b/web/vtctld2/app/index.html @@ -28,5 +28,5 @@