From ce9020a3e161908aa8003cfebd5986e6340d130d Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Mon, 19 Oct 2026 15:59:00 +0200 Subject: [PATCH] Removed widget header button action source from HTML page layout (#16339) * Removed widget header button action source from HTML page layout * Additional fixes nsd License headers fix --- .../app/core/services/dashboard-utils.service.ts | 5 ++++- .../dashboard-page/dashboard-page.component.html | 1 + .../dashboard-page/edit-widget.component.ts | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/core/services/dashboard-utils.service.ts b/ui-ngx/src/app/core/services/dashboard-utils.service.ts index 43e7754e58..a121cddf28 100644 --- a/ui-ngx/src/app/core/services/dashboard-utils.service.ts +++ b/ui-ngx/src/app/core/services/dashboard-utils.service.ts @@ -45,6 +45,7 @@ import { TargetDevice, TargetDeviceType, Widget, + widgetActionSources, WidgetConfig, WidgetConfigMode, WidgetSize, @@ -690,11 +691,13 @@ export class DashboardUtilsService { }; // Stable per state: an unchanged page keeps its rendered instance, a changed one is re-rendered. const widgetId = htmlPageWidgetId(stateId); + const actions = {...layout.gridSettings?.htmlPageConfig?.actions}; + delete actions[widgetActionSources.headerButton.value]; const config = mergeDeep({}, htmlPageDefaultConfig, { settings: layout.gridSettings?.htmlPageConfig?.settings || mergeDeep({} as HtmlContainerWidgetSettings, htmlContainerDefaultSettings), - actions: layout.gridSettings?.htmlPageConfig?.actions + actions } ); result.widget = { diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html index 614fb2ab21..c798ac713f 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.html @@ -511,6 +511,7 @@ [widgetLayout]="editingWidgetLayout" [showLayoutConfig]="showLayoutConfigInEdit(editingLayoutCtx)" [isDefaultBreakpoint]="editingLayoutCtx?.breakpoint === 'default'" + [isHtmlPage]="isHtml" (revertWidgetConfig)="onRevertWidgetEdit()" (applyWidgetConfig)="saveWidget()"> diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.ts index 01771c5a7a..f241b66d6e 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.ts @@ -1,5 +1,6 @@ // SPDX-FileCopyrightText: Copyright The ThingsBoard Authors -// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc. +// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; @@ -7,7 +8,7 @@ import { AppState } from '@core/core.state'; import { MatDialog } from '@angular/material/dialog'; import { Dashboard, WidgetLayout } from '@shared/models/dashboard.models'; import { IAliasController, IStateController } from '@core/api/widget-api.models'; -import { Widget, WidgetConfigMode } from '@shared/models/widget.models'; +import { Widget, widgetActionSources, WidgetConfigMode } from '@shared/models/widget.models'; import { WidgetComponentService } from '@home/components/widget/widget-component.service'; import { WidgetConfigComponentData } from '../../models/widget-component.models'; import { isDefined, isDefinedAndNotNull } from '@core/utils'; @@ -53,6 +54,10 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan @coerceBoolean() isDefaultBreakpoint= true; + @Input() + @coerceBoolean() + isHtmlPage = false; + @Output() applyWidgetConfig = new EventEmitter(); @@ -94,7 +99,7 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan for (const propName of Object.keys(changes)) { const change = changes[propName]; if (!change.firstChange && change.currentValue !== change.previousValue) { - if (['widget', 'widgetLayout'].includes(propName)) { + if (['widget', 'widgetLayout', 'isHtmlPage'].includes(propName)) { reloadConfig = true; } } @@ -135,7 +140,10 @@ export class EditWidgetComponent extends PageComponent implements OnInit, OnChan widgetInfo.typeLatestDataKeySettingsForm : (widgetInfo.latestDataKeySettingsForm || []); const typeParameters = widgetInfo.typeParameters; const dataKeySettingsFunction: DataKeySettingsFunction = typeParameters?.dataKeySettingsFunction; - const actionSources = widgetInfo.actionSources; + const actionSources = {...widgetInfo.actionSources}; + if (this.isHtmlPage) { + delete actionSources[widgetActionSources.headerButton.value]; + } const isDataEnabled = isDefined(widgetInfo.typeParameters) ? !widgetInfo.typeParameters.useCustomDatasources : true; this.widgetConfig = {