From fa0edec74ba1829a398f9a98236fd3a296ba853a Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Thu, 2 May 2019 23:40:49 -0400 Subject: [PATCH] Fix up Unknown widget to work again Store module Type in common settings to enable this Simplify the function params to be more inline with existing ones, vs being unique --- cfg/common_settings.go | 2 ++ maker/widget_maker.go | 2 +- modules/unknown/widget.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cfg/common_settings.go b/cfg/common_settings.go index 342fcd41..25ec723a 100644 --- a/cfg/common_settings.go +++ b/cfg/common_settings.go @@ -27,6 +27,7 @@ type Colors struct { type Module struct { Name string + Type string } type Position struct { @@ -82,6 +83,7 @@ func NewCommonSettingsFromModule(name, defaultTitle string, moduleConfig *config Module: Module{ Name: name, + Type: moduleConfig.UString("type", name), }, Position: Position{ diff --git a/maker/widget_maker.go b/maker/widget_maker.go index 723dc79f..521559a1 100644 --- a/maker/widget_maker.go +++ b/maker/widget_maker.go @@ -201,7 +201,7 @@ func MakeWidget( widget = zendesk.NewWidget(app, settings) default: settings := unknown.NewSettingsFromYAML(widgetName, moduleConfig, globalConfig) - widget = unknown.NewWidget(app, widgetName, settings) + widget = unknown.NewWidget(app, settings) } return widget diff --git a/modules/unknown/widget.go b/modules/unknown/widget.go index 777e3b3c..6493c6c1 100644 --- a/modules/unknown/widget.go +++ b/modules/unknown/widget.go @@ -14,7 +14,7 @@ type Widget struct { settings *Settings } -func NewWidget(app *tview.Application, name string, settings *Settings) *Widget { +func NewWidget(app *tview.Application, settings *Settings) *Widget { widget := Widget{ TextWidget: wtf.NewTextWidget(app, settings.common, false), @@ -31,7 +31,7 @@ func (widget *Widget) Refresh() { widget.app.QueueUpdateDraw(func() { widget.View.Clear() - content := fmt.Sprintf("Widget %s does not exist", widget.CommonSettings.Title) + content := fmt.Sprintf("Widget %s and/or type %s does not exist", widget.Name(), widget.CommonSettings.Module.Type) widget.View.SetText(content) }) }