From cca18eefa410f0518a579614a6851ba41fb8f7e8 Mon Sep 17 00:00:00 2001 From: "Myles J." Date: Mon, 3 Feb 2025 22:50:18 +0000 Subject: [PATCH] Proposal: Add ability to hide widgets via config (#1864) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 👋 Hello, I'm not sure if this warranted an Issue first but it seemed small enough to just raise a PR. I'm happy to add something to the documentation as well if you agree with the proposal. There are some widgets that I'd rather not be displayed in the sidebar - at the moment these are default widgets for which I cannot see any existing means of omitting them via configuration. I'm proposing a `display:hidden` field on the widget settings such that I can configure the following: ```json { "defwidget@ai": { "display:hidden": true } } ``` I'm considering this option to be distinct from any means of outright "disabling" the widget - that is to say that I've not chosen to filter the widgets from the configuration because I'm not fully aware of the project goals. Where for example I imagine that it might be useful to be able to interact with a widget or it's config via the CLI or shortcut regardless of visibility? example --- frontend/app/workspace/workspace.tsx | 9 ++++++++- frontend/types/gotypes.d.ts | 1 + pkg/wconfig/settingsconfig.go | 15 ++++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/frontend/app/workspace/workspace.tsx b/frontend/app/workspace/workspace.tsx index 626191581..e20e6f98d 100644 --- a/frontend/app/workspace/workspace.tsx +++ b/frontend/app/workspace/workspace.tsx @@ -78,7 +78,14 @@ async function handleWidgetSelect(widget: WidgetConfigType) { const Widget = memo(({ widget }: { widget: WidgetConfigType }) => { return ( -
handleWidgetSelect(widget)} title={widget.description || widget.label}> +
handleWidgetSelect(widget)} + title={widget.description || widget.label} + style={{ + display: widget["display:hidden"] ? "none" : "inherit", + }} + >
diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 400e86935..b4e6d62d6 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -1224,6 +1224,7 @@ declare global { // wconfig.WidgetConfigType type WidgetConfigType = { "display:order"?: number; + "display:hidden"?: boolean; icon?: string; color?: string; label?: string; diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 8383b5282..bb8589918 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -582,13 +582,14 @@ func SetConnectionsConfigValue(connName string, toMerge waveobj.MetaMapType) err } type WidgetConfigType struct { - DisplayOrder float64 `json:"display:order,omitempty"` - Icon string `json:"icon,omitempty"` - Color string `json:"color,omitempty"` - Label string `json:"label,omitempty"` - Description string `json:"description,omitempty"` - Magnified bool `json:"magnified,omitempty"` - BlockDef waveobj.BlockDef `json:"blockdef"` + DisplayOrder float64 `json:"display:order,omitempty"` + DisplayHidden bool `json:"display:hidden,omitempty"` + Icon string `json:"icon,omitempty"` + Color string `json:"color,omitempty"` + Label string `json:"label,omitempty"` + Description string `json:"description,omitempty"` + Magnified bool `json:"magnified,omitempty"` + BlockDef waveobj.BlockDef `json:"blockdef"` } type MimeTypeConfigType struct {