Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
Use camelcase for javascript plugin state
Browse files Browse the repository at this point in the history
Signed-off-by: vikram yadav <vyadav@pivotal.io>
  • Loading branch information
vikram yadav committed Apr 1, 2021
1 parent c80b24b commit f123c1d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/2244-xtreme-vikram-yadav
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Share partial octant state with plugins
2 changes: 1 addition & 1 deletion pkg/action/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
// of the new current namespace.
RequestSetNamespace = "action.octant.dev/setNamespace"

// RequestSteFilter is the action for when the filters are updated in Octant.
// RequestSetFilter is the action for when the filters are updated in Octant.
// The ActionRequest.Payload for this action contains an array of key/values representing
// the filters.
RequestSetFilter = "action.octant.dev/setFilter"
Expand Down
5 changes: 3 additions & 2 deletions pkg/plugin/dashboard/dashboard.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/plugin/javascript.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (t *jsPlugin) Content(ctx context.Context, contentPath string) (component.C

t.loop.RunOnLoop(func(vm *goja.Runtime) {
clientID := ocontext.WebsocketClientIDFrom(ctx)
ostate := ocontext.PluginStateFrom(ctx)
oState := ocontext.PluginStateFrom(ctx)

handler, err := vm.RunString("_concretePlugin.contentHandler")
if err != nil {
Expand All @@ -259,7 +259,7 @@ func (t *jsPlugin) Content(ctx context.Context, contentPath string) (component.C
if err := obj.Set("clientID", vm.ToValue(clientID)); err != nil {
errCh <- fmt.Errorf("unable to set clientID: %w", err)
}
if err := obj.Set("ostate", vm.ToValue(ostate)); err != nil {
if err := obj.Set("oState", vm.ToValue(oState)); err != nil {
errCh <- fmt.Errorf("unable to set octant state: %w", err)
}

Expand Down Expand Up @@ -462,7 +462,7 @@ func (t *jsPlugin) HandleAction(ctx context.Context, actionPath string, payload

t.loop.RunOnLoop(func(vm *goja.Runtime) {
clientID := ocontext.WebsocketClientIDFrom(ctx)
ostate := ocontext.PluginStateFrom(ctx)
oState := ocontext.PluginStateFrom(ctx)

handler, err := vm.RunString("_concretePlugin.actionHandler")
if err != nil {
Expand Down Expand Up @@ -492,7 +492,7 @@ func (t *jsPlugin) HandleAction(ctx context.Context, actionPath string, payload
errCh <- fmt.Errorf("unable to set clientID: %w", err)
return
}
if err := obj.Set("ostate", vm.ToValue(ostate)); err != nil {
if err := obj.Set("oState", vm.ToValue(oState)); err != nil {
errCh <- fmt.Errorf("unable to set octant state: %w", err)
}

Expand Down Expand Up @@ -579,7 +579,7 @@ func (t *jsPlugin) objectRequestCall(ctx context.Context, handlerName string, ob

t.loop.RunOnLoop(func(vm *goja.Runtime) {
clientID := ocontext.WebsocketClientIDFrom(ctx)
ostate := ocontext.PluginStateFrom(ctx)
oState := ocontext.PluginStateFrom(ctx)

handler, err := vm.RunString(fmt.Sprintf("_concretePlugin.%s", handlerName))
if err != nil {
Expand All @@ -602,7 +602,7 @@ func (t *jsPlugin) objectRequestCall(ctx context.Context, handlerName string, ob
errCh <- fmt.Errorf("unable to set clientID: %w", err)
return
}
if err := obj.Set("ostate", vm.ToValue(ostate)); err != nil {
if err := obj.Set("oState", vm.ToValue(oState)); err != nil {
errCh <- fmt.Errorf("unable to set octant state: %w", err)
}
s, err := cHandler(t.pluginClass, obj)
Expand Down

0 comments on commit f123c1d

Please sign in to comment.