100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Migrate Material UI confirm dialogs (showOkCancelDialog) with Vaadin components (#2998)
Martin Peeterse9e0133a0417
diff --git a/ui/app/manager/src/pages/page-alarms.ts b/ui/app/manager/src/pages/page-alarms.tsindex ff0ea19b7..7268526ec 100644--- a/ui/app/manager/src/pages/page-alarms.ts+++ b/ui/app/manager/src/pages/page-alarms.ts@@ -20,7 +20,7 @@ import {getAlarmsRoute} from "../routes";import {when} from "lit/directives/when.js";import {until} from "lit/directives/until.js";import {guard} from "lit/directives/guard.js";-import {OrMwcDialog, showDialog, showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {OrAssetTreeRequestSelectionEvent, OrAssetTreeSelectionEvent} from "@openremote/or-asset-tree";import {OrMwcTable,@@ -31,6 +31,7 @@ import "../components/alarms/or-alarms-table";import {OrVaadinSelect} from "@openremote/or-vaadin-components/or-vaadin-select";import moment from "moment";import {OrVaadinButton} from "@openremote/or-vaadin-components/or-vaadin-button";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";export interface PageAlarmsConfig {initialFilter?: string;@@ -569,21 +570,25 @@ export class PageAlarms extends Page<AppStateKeyed> {}private _deleteAlarm(alarm: SentAlarm) {- showOkCancelDialog(i18next.t("alarm.deleteAlarm"), i18next.t("alarm.deleteAlarmConfirm", {alarm: alarm.title}), i18next.t("delete"))- .then((ok) => {- if (ok) {- this.doDelete(alarm.id);- }- });+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.doDelete(alarm.id)}>+ ${getConfirmDialogContent("error", "alarm.deleteAlarm", "alarm.deleteAlarmConfirm", "delete", "cancel")}+ </or-vaadin-confirm-dialog>+ `);}private _deleteAlarms() {- showOkCancelDialog(i18next.t("alarm.deleteAlarms"), i18next.t("alarm.deleteAlarmsConfirm", {count: this._selectedIds.length}), i18next.t("delete"))- .then((ok) => {- if (ok) {- this.doMultipleDelete(this._selectedIds);- }- });+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.doMultipleDelete(this._selectedIds)}>+ ${getConfirmDialogContent(+ "error",+ "alarm.deleteAlarms",+ html`<or-translate value="alarm.deleteAlarmsConfirm" .options="${{ count: this._selectedIds.length }}"></or-translate>`,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}private doDelete(alarmId: any) {diff --git a/ui/app/manager/src/pages/page-assets.ts b/ui/app/manager/src/pages/page-assets.tsindex b83e2721a..d15a1e4bd 100644--- a/ui/app/manager/src/pages/page-assets.ts+++ b/ui/app/manager/src/pages/page-assets.ts@@ -23,12 +23,13 @@ import {import manager, {DefaultBoxShadow, DefaultColor5, Util} from "@openremote/core";import {AppStateKeyed, Page, PageProvider, router} from "@openremote/or-app";import {createSlice, Store, createSelector} from "@reduxjs/toolkit";-import {DialogAction, OrMwcDialog, showDialog, showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {DialogAction, OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {i18next} from "@openremote/or-translate"import {Asset, AssetEventCause, WellknownAssets} from "@openremote/model";import "@openremote/or-json-forms";import {getAlarmsRoute, getAssetsRoute, getUsersRoute} from "../routes";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";export interface PageAssetsConfig {viewer?: ViewerConfig;@@ -403,12 +404,11 @@ export class PageAssets extends Page<AssetsStateKeyed> {protected _confirmContinue(action: () => void) {if (this._viewer.isModified()) {- showOkCancelDialog(i18next.t("loseChanges"), i18next.t("confirmContinueAssetModified"), i18next.t("discard"))- .then((ok) => {- if (ok) {- action();- }- });+ showConfirmDialog(this.shadowRoot, html`+ <or-vaadin-confirm-dialog @confirm=${() => action()}>+ ${getConfirmDialogContent("error", "loseChanges", "confirmContinueAssetModified", "discard", "cancel")}+ </or-vaadin-confirm-dialog>+ `);} else {action();}diff --git a/ui/app/manager/src/pages/page-gateway-tunnel.ts b/ui/app/manager/src/pages/page-gateway-tunnel.tsindex a33748088..3c148eabf 100644--- a/ui/app/manager/src/pages/page-gateway-tunnel.ts+++ b/ui/app/manager/src/pages/page-gateway-tunnel.ts@@ -10,11 +10,12 @@ import {DefaultColor3, manager} from "@openremote/core";import {Asset, AssetQuery, GatewayTunnelInfo, GatewayTunnelInfoType} from "@openremote/model";import {TableColumn, TableRow} from "@openremote/or-mwc-components/or-mwc-table";import {getAssetsRoute} from "../routes";-import {OrMwcDialog, showDialog, showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";import moment from "moment";import {OrVaadinComboBox} from "@openremote/or-vaadin-components/or-vaadin-combo-box";import {OrVaadinSelect} from "@openremote/or-vaadin-components/or-vaadin-select";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";export function pageGatewayTunnelProvider(store: Store<AppStateKeyed>): PageProvider<AppStateKeyed> {return {@@ -226,25 +227,24 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {*/protected _onStopTunnelClick(ev: Event, tunnel: GatewayTunnelInfo) {ev.stopPropagation();- showOkCancelDialog(- i18next.t("areYouSure"),- i18next.t("gatewayTunnels.stopWarning"),- i18next.t("gatewayTunnels.stop")- ).then((ok: boolean) => {- if (ok) {- this._stopTunnel(tunnel).then(success => {- if (success) {- showSnackbar(undefined, "gatewayTunnels.closeSuccessful");- } else {- showSnackbar(undefined, "errorOccurred");- }- }).catch(_error => {+ const onOk = () => {+ this._stopTunnel(tunnel).then(success => {+ if (success) {+ showSnackbar(undefined, "gatewayTunnels.closeSuccessful");+ } else {showSnackbar(undefined, "errorOccurred");- }).finally(() => {- this._fetchTunnelsTask.run();- });- }- });+ }+ }).catch(_error => {+ showSnackbar(undefined, "errorOccurred");+ }).finally(() => {+ this._fetchTunnelsTask.run();+ });+ }+ showConfirmDialog(this.shadowRoot, html`+ <or-vaadin-confirm-dialog @confirm=${() => onOk()}>+ ${getConfirmDialogContent("error", "areYouSure", "gatewayTunnels.stopWarning", "gatewayTunnels.stop", "cancel")}+ </or-vaadin-confirm-dialog>+ `);}/**diff --git a/ui/app/manager/src/pages/page-provisioning.ts b/ui/app/manager/src/pages/page-provisioning.tsindex b1158a9b7..f25e6765e 100644--- a/ui/app/manager/src/pages/page-provisioning.ts+++ b/ui/app/manager/src/pages/page-provisioning.ts@@ -9,11 +9,11 @@ import {ClientRole, ProvisioningConfig, X509ProvisioningData} from "@openremote/import {i18next} from "@openremote/or-translate";import {OrIcon} from "@openremote/or-icon";import {InputType, OrInputChangedEvent} from "@openremote/or-mwc-components/or-mwc-input";-import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";import {GenericAxiosResponse} from "@openremote/rest";import {OrVaadinSelect} from "@openremote/or-vaadin-components/or-vaadin-select";import {OrVaadinMultiSelectComboBox} from "@openremote/or-vaadin-components/or-vaadin-multi-select-combo-box";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";const tableStyle = require("@material/data-table/dist/mdc.data-table.css");@@ -343,12 +343,11 @@ export class PageProvisioning extends Page<AppStateKeyed> {}protected _deleteConfig(config: ProvisioningConfig<any, any>) {- showOkCancelDialog(i18next.t("delete"), i18next.t("deleteProvisioningConfigConfirm"), i18next.t("delete"))- .then((ok) => {- if (ok) {- this._doDelete(config);- }- });+ showConfirmDialog(this.shadowRoot, html`+ <or-vaadin-confirm-dialog @confirm=${() => this._doDelete(config)}>+ ${getConfirmDialogContent("error", "delete", "deleteProvisioningConfigConfirm", "delete", "cancel")}+ </or-vaadin-confirm-dialog>+ `);}protected _doDelete(config: ProvisioningConfig<any, any>) {diff --git a/ui/app/manager/src/pages/page-roles.ts b/ui/app/manager/src/pages/page-roles.tsindex 4c7f66f12..3ae9392ae 100644--- a/ui/app/manager/src/pages/page-roles.ts+++ b/ui/app/manager/src/pages/page-roles.ts@@ -15,8 +15,8 @@ import {AppStateKeyed} from "@openremote/or-app";import { ClientRole, Role } from "@openremote/model";import { i18next } from "@openremote/or-translate";import { OrIcon } from "@openremote/or-icon";-import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {OrVaadinTextField} from "@openremote/or-vaadin-components/or-vaadin-text-field";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";const tableStyle = require("@material/data-table/dist/mdc.data-table.css");@@ -296,12 +296,17 @@ export class PageRoles extends Page<AppStateKeyed> {}private _deleteRole(role, rowIndex) {- showOkCancelDialog(i18next.t("deleteRole"), i18next.t("deleteRoleConfirm", { roleName: role.name }), i18next.t("delete"))- .then((ok) => {- if (ok) {- this.doDelete(role, rowIndex);- }- });+ showConfirmDialog(this.shadowRoot, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.doDelete(role, rowIndex)}>+ ${getConfirmDialogContent(+ "error",+ "deleteRole",+ html`<or-translate value="deleteRoleConfirm" .options=${{roleName: role.name}}></or-translate>`,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}private doDelete(role, rowIndex) {diff --git a/ui/app/manager/src/pages/page-users.ts b/ui/app/manager/src/pages/page-users.tsindex 4bde9f3ed..ece55a473 100644--- a/ui/app/manager/src/pages/page-users.ts+++ b/ui/app/manager/src/pages/page-users.ts@@ -7,7 +7,7 @@ import {Store} from "@reduxjs/toolkit";import {AppStateKeyed, Page, PageProvider, router} from "@openremote/or-app";import {ClientRole, Credential, Role, User, UserAssetLink, UserQuery, UserSession} from "@openremote/model";import {i18next} from "@openremote/or-translate";-import {OrMwcDialog, showDialog, showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";import {GenericAxiosResponse, isAxiosError} from "@openremote/rest";import {OrAssetTreeRequestSelectionEvent, OrAssetTreeSelectionEvent} from "@openremote/or-asset-tree";@@ -21,6 +21,7 @@ import {OrVaadinPasswordField} from "@openremote/or-vaadin-components/or-vaadin-import {OrVaadinMultiSelectComboBox} from "@openremote/or-vaadin-components/or-vaadin-multi-select-combo-box";import {OrVaadinCheckbox} from "@openremote/or-vaadin-components/or-vaadin-checkbox";import {OrVaadinTextField} from "@openremote/or-vaadin-components/or-vaadin-text-field";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";const tableStyle = require("@material/data-table/dist/mdc.data-table.css");@@ -441,12 +442,17 @@ export class PageUsers extends Page<AppStateKeyed> {}private _deleteUser(user) {- showOkCancelDialog(i18next.t("deleteUser"), i18next.t("deleteUserConfirm", { userName: user.username }), i18next.t("delete"))- .then((ok) => {- if (ok) {- this.doDelete(user);- }- });+ showConfirmDialog(this.shadowRoot, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.doDelete(user)}>+ ${getConfirmDialogContent(+ "error",+ "deleteUser",+ html`<or-translate value="deleteUserConfirm" .options=${{userName: user.username}}></or-translate>`,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}private doDelete(user) {diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.jsonindex 9970c338b..1fe2b1269 100644--- a/ui/app/shared/locales/en/or.json+++ b/ui/app/shared/locales/en/or.json@@ -106,10 +106,10 @@"close": "Close","active": "Active","deleteRulesets": "Delete rule(s)",- "deleteRulesetsConfirm": "Are you sure you want to delete the selected rule(s)? {{ruleNames}}",+ "deleteRulesetsConfirm": "Are you sure you want to delete the selected rule(s)?","deleteRulesetsFailed": "Failed to delete one or more requested rules","deleteRulesetGroups": "Delete group(s)",- "deleteRulesetGroupsConfirm": "Are you sure you want to delete the selected group(s)? {{groupNames}}",+ "deleteRulesetGroupsConfirm": "Are you sure you want to delete the selected group(s)?","saveRulesetFailed": "Failed to save rule","confirmContinueRulesetModified": "Rule has been modified, discard changes?","rulesLegacyJavaScriptWarning": "JavaScript rules are legacy and can only be viewed or deleted.",@@ -141,7 +141,7 @@"status": "Status","name": "Name","deleteAssets": "Delete asset(s)",- "deleteAssetsConfirm": "Delete asset(s) and all descendant assets?\n- {{assetNames}}",+ "deleteAssetsConfirm": "Delete asset(s) and all descendant assets?","deleteAssetsFailed": "Failed to delete requested asset(s)","ok": "OK","cancel": "Cancel",diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.jsonindex c8d1891f4..e37d78901 100644--- a/ui/app/shared/locales/nl/or.json+++ b/ui/app/shared/locales/nl/or.json@@ -104,10 +104,10 @@"close": "Sluiten","active": "Actief","deleteRulesets": "Regels verwijderen",- "deleteRulesetsConfirm": "Weet je zeker dat je de volgende regels wil verwijderen? {{ruleNames}}",+ "deleteRulesetsConfirm": "Weet je zeker dat je de volgende regels wil verwijderen?","deleteRulesetsFailed": "Het verwijderen van een of meerdere regels is niet gelukt","deleteRulesetGroups": "Groepen verwijderen",- "deleteRulesetGroupsConfirm": "Weet je zeker dat je de volgende groepen wilt verwijderen? {{groupNames}}",+ "deleteRulesetGroupsConfirm": "Weet je zeker dat je de volgende groepen wilt verwijderen?","saveRulesetFailed": "Het opslaan van de regel is niet gelukt","confirmContinueRulesetModified": "De regel is aangepast, wijzigingen weggooien?","when": "Als",@@ -136,7 +136,7 @@"status": "Status","name": "Naam","deleteAssets": "Verwijder assets",- "deleteAssetsConfirm": "Verwijder alle asset(s) en onderliggende assets?\n- {{assetNames}}",+ "deleteAssetsConfirm": "Verwijder alle asset(s) en onderliggende assets?","deleteAssetsFailed": "Verwijderen van de asset(s) is niet gelukt","ok": "OK","cancel": "Annuleren",diff --git a/ui/app/shared/locales/pl/or.json b/ui/app/shared/locales/pl/or.jsonindex 2708cdbad..081e00a9e 100644--- a/ui/app/shared/locales/pl/or.json+++ b/ui/app/shared/locales/pl/or.json@@ -107,10 +107,10 @@"active": "Aktywny","update": "Aktualizuj","deleteRulesets": "Usuń regułę/reguły",- "deleteRulesetsConfirm": "Czy na pewno chcesz usunąć wybrane reguły? {{ruleNames}}",+ "deleteRulesetsConfirm": "Czy na pewno chcesz usunąć wybrane reguły?","deleteRulesetsFailed": "Nie udało się usunąć jednej lub więcej żądanych reguł","deleteRulesetGroups": "Usuń grupę/grupy",- "deleteRulesetGroupsConfirm": "Czy na pewno chcesz usunąć wybrane grupy? {{groupNames}}",+ "deleteRulesetGroupsConfirm": "Czy na pewno chcesz usunąć wybrane grupy?","saveRulesetFailed": "Nie udało się zapisać reguły","confirmContinueRulesetModified": "Reguła została zmodyfikowana, odrzucić zmiany?","when": "Kiedy",@@ -139,7 +139,7 @@"status": "Status","name": "Nazwa","deleteAssets": "Usuń zasób / zasoby",- "deleteAssetsConfirm": "Usunąć zasób / zasoby i wszystkie podrzędne zasoby?\n- {{assetNames}}",+ "deleteAssetsConfirm": "Usunąć zasób / zasoby i wszystkie podrzędne zasoby?","deleteAssetsFailed": "Nie udało się usunąć żądanego zasobu/zasobów","ok": "OK","cancel": "Anuluj",diff --git a/ui/app/shared/locales/uk/or.json b/ui/app/shared/locales/uk/or.jsonindex 17c36ccd2..4c414a9e7 100644--- a/ui/app/shared/locales/uk/or.json+++ b/ui/app/shared/locales/uk/or.json@@ -82,7 +82,7 @@"close": "Закрити","active": "Активний","deleteRulesets": "Видалити правило(а)",- "deleteRulesetsConfirm": "Ви впевнені, що хочете видалити вибрані правила? {{ruleNames}}",+ "deleteRulesetsConfirm": "Ви впевнені, що хочете видалити вибрані правила?","deleteRulesetsFailed": "Не вдалося видалити одне або декілька запитаних правил","saveRulesetFailed": "Не вдалося зберегти правило","confirmContinueRulesetModified": "Правило було змінено, скасувати зміни?",@@ -110,7 +110,7 @@"status": "Статус","name": "Назва","deleteAssets": "Видалити актив(и)",- "deleteAssetsConfirm": "Видалити актив(и) та всі дочірні активи?\n- {{assetNames}}",+ "deleteAssetsConfirm": "Видалити актив(и) та всі дочірні активи?","deleteAssetsFailed": "Не вдалося видалити запитані активи","ok": "ОК","cancel": "Скасувати",diff --git a/ui/app/storybook/docs/components/or-vaadin-confirm-dialog.mdx b/ui/app/storybook/docs/components/or-vaadin-confirm-dialog.mdxnew file mode 100644index 000000000..13ad43406--- /dev/null+++ b/ui/app/storybook/docs/components/or-vaadin-confirm-dialog.mdx@@ -0,0 +1,27 @@+{/*+ * Copyright 2026, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+*/}++import { Meta } from '@storybook/addon-docs/blocks';+import * as ComponentStory from "../../../../component/or-vaadin-components/stories/or-vaadin-confirm-dialog.stories"; // stories need relative imports+import {ComponentDocs} from "../../util/componentdocs.mdx";++<Meta title="Components/Dialog (confirm)" />++<ComponentDocs story={ComponentStory} options={{displayName: "Confirm Dialog"}} elementsjson={ComponentStory.customElements} />diff --git a/ui/component/or-app/src/index.ts b/ui/component/or-app/src/index.tsindex 61d176450..06432c778 100644--- a/ui/component/or-app/src/index.ts+++ b/ui/component/or-app/src/index.ts@@ -9,7 +9,8 @@ import {updateMetadata} from "pwa-helpers/metadata";import {i18next} from "@openremote/or-translate"import manager, {BasicLoginResult, DefaultColor2, DefaultColor3, DefaultColor4, Manager, normaliseConfig, ORError, OREvent, Util} from "@openremote/core";import {DEFAULT_LANGUAGES, HeaderConfig} from "./or-header";-import {OrMwcDialog, showDialog, showErrorDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {showErrorDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";import {OrMwcSnackbar, showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";import {AnyAction, Store, Unsubscribe} from "@reduxjs/toolkit";import {AppStateKeyed, setOffline, setVisibility, updatePage, updateRealm} from "./app";@@ -233,25 +234,25 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {this.doAppConfigInit();if (!this.appConfig) {- showErrorDialog("appError.noConfig", document.body);+ showErrorDialog(document.body, "appError.noConfig");console.error("No AppConfig supplied");return;}if (!this._config) {- showErrorDialog("appError.noConfig", document.body);+ showErrorDialog(document.body, "appError.noConfig");console.error("No default AppConfig or realm specific config provided so cannot render");return;}if (!this._store) {- showErrorDialog("appError.noReduxStore", document.body);+ showErrorDialog(document.body, "appError.noReduxStore");console.error("No Redux store supplied");return;}if (!this.appConfig.pages || Object.keys(this.appConfig.pages).length === 0) {- showErrorDialog("appError.noPages", document.body);+ showErrorDialog(document.body, "appError.noPages");console.error("No page providers");return;}@@ -307,7 +308,7 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {}router.resolve();} else {- showErrorDialog(manager.isError ? "managerError." + manager.error : "");+ showErrorDialog(this.shadowRoot!, manager.isError ? "managerError." + manager.error : "");}});}@@ -465,7 +466,7 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {this.requestUpdate();} catch (e) {console.error(e);- showErrorDialog("errorOccurred", document.body);+ showErrorDialog(document.body, "errorOccurred");}}diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.tsindex e32a2da7a..ddcaf75fa 100644--- a/ui/component/or-asset-tree/src/index.ts+++ b/ui/component/or-asset-tree/src/index.ts@@ -23,6 +23,7 @@ import {type OrVaadinTextField} from "@openremote/or-vaadin-components/or-vaadinimport {type OrVaadinButton} from "@openremote/or-vaadin-components/or-vaadin-button";import {comboBoxRenderer, ComboBoxLitRenderer, OrVaadinComboBox} from "@openremote/or-vaadin-components/or-vaadin-combo-box";import {createMenuBarItem, MenuBarItem} from "@openremote/or-vaadin-components/or-vaadin-menu-bar";+import {getConfirmDialogContent, showConfirmDialog, showErrorDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";import "@openremote/or-icon";import {Asset,@@ -53,7 +54,7 @@ import {ListItem} from "@openremote/or-mwc-components/or-mwc-list";import "@openremote/or-mwc-components/or-mwc-list";import {i18next} from "@openremote/or-translate";import "@openremote/or-mwc-components/or-mwc-dialog";-import {OrMwcDialog, showDialog, showErrorDialog, showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {OrAddAssetDialog, OrAddChangedEvent} from "./or-add-asset-dialog";import "./or-add-asset-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";@@ -1474,7 +1475,7 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {});} catch (e) {console.error("Failed to copy asset", e);- showErrorDialog("Failed to copy asset");+ showErrorDialog(this.shadowRoot!, "Failed to copy asset");}}@@ -1660,22 +1661,30 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {}).then((response) => {this._onDeselectClicked();if (response.status !== 204) {- showErrorDialog(i18next.t("deleteAssetsFailed"));+ showErrorDialog(this.shadowRoot!, "deleteAssetsFailed");}}).catch((reason) => {- showErrorDialog(i18next.t("deleteAssetsFailed"));+ showErrorDialog(this.shadowRoot!, "deleteAssetsFailed");}).finally(() => {this.disabled = false;});};// Confirm deletion request- showOkCancelDialog(i18next.t("deleteAssets"), i18next.t("deleteAssetsConfirm", { assetNames: assetNames.join(",\n- ") }), i18next.t("delete"))- .then((ok) => {- if (ok) {- doDelete();- }- });+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => doDelete()}>+ ${getConfirmDialogContent(+ "error",+ "deleteAssets",+ html`+ <or-translate value="deleteAssetsConfirm"></or-translate>+ <ul>${assetNames.map(n => html`<li>${n}</li>`)}</ul>+ `,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}protected _canAdd(): boolean {diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex 9a8a741e9..326a00046 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -13,7 +13,7 @@ import "@openremote/or-chart";import "@openremote/or-mwc-components/or-mwc-table";import "@openremote/or-components/or-panel";import "@openremote/or-mwc-components/or-mwc-dialog";-import {showOkCancelDialog, showOkDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import "@openremote/or-mwc-components/or-mwc-list";import {OrTranslate, translate} from "@openremote/or-translate";import {InputType, OrInputChangedEvent, OrMwcInput} from "@openremote/or-mwc-components/or-mwc-input";@@ -53,6 +53,7 @@ import {when} from "lit/directives/when.js";import {ifDefined} from "lit/directives/if-defined.js";import {OrVaadinCheckbox} from "@openremote/or-vaadin-components/or-vaadin-checkbox";import {OrVaadinInput} from "@openremote/or-vaadin-components/or-vaadin-input";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";export interface PanelConfig {type: "info" | "setup" | "history" | "group" | "linkedUsers" | "alarm.linkedAlarms";@@ -748,6 +749,7 @@ function getPanelContent(id: string, assetInfo: AssetInfo, hostElement: LitElemeconst newlySelectedAttributes = [...selectedAttributes];+ // TODO: Replace with or-vaadin-dialog, see https://github.com/openremote/openremote/issues/2594showOkCancelDialog(i18next.t("addRemoveAttributes"),html`@@ -1543,7 +1545,11 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem&& !this._saveInProgress) // And save isn't in progressif (reloadAsset && this.editMode && this._assetInfo?.modified) {// Asset has changed whilst we're editing it so inform the user and reload- await showOkDialog("assetModified", i18next.t("assetModifiedMustRefresh"));+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog>+ ${getConfirmDialogContent("error tertiary", "assetModified", "assetModifiedMustRefresh", "ok")}+ </or-vaadin-confirm-dialog>+ `)}if (reloadAsset) {diff --git a/ui/component/or-dashboard-builder/src/index.ts b/ui/component/or-dashboard-builder/src/index.tsindex e334206e0..167d3d12f 100644--- a/ui/component/or-dashboard-builder/src/index.ts+++ b/ui/component/or-dashboard-builder/src/index.ts@@ -35,8 +35,7 @@ import {ListItem} from "@openremote/or-mwc-components/or-mwc-list";import {OrMwcTabItem} from "@openremote/or-mwc-components/or-mwc-tabs";import "@openremote/or-mwc-components/or-mwc-tabs";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";-import {i18next, translate} from "@openremote/or-translate";-import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {i18next, translate} from "@openremote/or-translate";import {DashboardKeyEmitter} from "./or-dashboard-keyhandler";import {OrDashboardPreview} from "./or-dashboard-preview";import {WidgetManifest} from "./util/or-widget";@@ -53,6 +52,7 @@ import {TableWidget} from "./widgets/table-widget";import {GatewayWidget} from "./widgets/gateway-widget";import {BarChartWidget} from "./widgets/barchart-widget";import {OrVaadinTextField} from "@openremote/or-vaadin-components/or-vaadin-text-field";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";// language=CSSconst styling = css`@@ -330,7 +330,13 @@ export class OrDashboardBuilder extends translate(i18next)(LitElement) {this.keyEmitter.addListener('delete', (_e: KeyboardEvent) => {if(this.selectedWidgetId) {const selectedWidget = this.selectedDashboard?.template?.widgets?.find(w => w.id == this.selectedWidgetId);- if(selectedWidget) { showOkCancelDialog(i18next.t('areYouSure'), i18next.t('dashboard.deleteWidgetWarning'), i18next.t('delete')).then((ok: boolean) => { if(ok) { this.deleteWidget(selectedWidget); }}); }+ if(selectedWidget) {+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.deleteWidget(selectedWidget)}>+ ${getConfirmDialogContent("error", "areYouSure", "dashboard.deleteWidgetWarning", "delete", "cancel")}+ </or-vaadin-confirm-dialog>+ `);+ }}});this.keyEmitter.addListener('deselect', (_e: KeyboardEvent) => { this.deselectWidget(); });@@ -729,9 +735,13 @@ export class OrDashboardBuilder extends translate(i18next)(LitElement) {<span id="title" title="${selectedWidget?.displayName}">${selectedWidget?.displayName}</span></div><div id="sidebar-widget-headeractions">- <or-vaadin-button theme="icon" @click=${() => showOkCancelDialog(i18next.t('areYouSure'), i18next.t('dashboard.deleteWidgetWarning'), i18next.t('delete')).then((ok: boolean) => {- if(ok) { this.deleteWidget(selectedWidget!); }- })}>+ <or-vaadin-button theme="icon" @click=${() => {+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.deleteWidget(selectedWidget!)}>+ ${getConfirmDialogContent("error", "areYouSure", "dashboard.deleteWidgetWarning", "delete", "cancel")}+ </or-vaadin-confirm-dialog>+ `)+ }}><or-icon icon="delete"></or-icon></or-vaadin-button><or-vaadin-button theme="icon" @click=${() => this.deselectWidget()}>diff --git a/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts b/ui/component/or-dashboard-builder/src/or-dashboard-tree.tsindex ece187148..9cfb91f13 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts@@ -24,13 +24,13 @@ import {style} from './style';import {Dashboard} from '@openremote/model';import manager, {Util} from '@openremote/core';import {ListItem} from '@openremote/or-mwc-components/or-mwc-list';-import {showOkCancelDialog} from '@openremote/or-mwc-components/or-mwc-dialog';import {i18next, translate} from '@openremote/or-translate';import {showSnackbar} from '@openremote/or-mwc-components/or-mwc-snackbar';import {style as OrAssetTreeStyle} from '@openremote/or-asset-tree';import {DashboardService, DashboardSizeOption} from './service/dashboard-service';import {isAxiosError} from '@openremote/rest';import {when} from "lit/directives/when.js";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";// language=cssconst treeStyling = css`@@ -159,11 +159,7 @@ export class OrDashboardTree extends translate(i18next)(LitElement) {protected duplicateDashboard(dashboard: Dashboard) {if (dashboard?.id !== null) {if(this.hasChanged) {- this.showDiscardChangesModal().then(ok => {- if(ok) {- this._doDuplicateDashboard(dashboard);- }- })+ this.showDiscardChangesModal(() => this._doDuplicateDashboard(dashboard));} else {this._doDuplicateDashboard(dashboard);}@@ -215,17 +211,19 @@ export class OrDashboardTree extends translate(i18next)(LitElement) {protected onDashboardClick(dashboardId: string) {if (dashboardId !== this.selected?.id) {if (this.hasChanged) {- this.showDiscardChangesModal().then(ok => {- if(ok) this.selectDashboard(dashboardId);- })+ this.showDiscardChangesModal(() => this.selectDashboard(dashboardId))} else {this.selectDashboard(dashboardId);}}}- protected showDiscardChangesModal(): Promise<boolean> {- return showOkCancelDialog(i18next.t('areYouSure'), i18next.t('confirmContinueDashboardModified'), i18next.t('discard'));+ protected showDiscardChangesModal(onconfirm: () => void): void {+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => onconfirm()}>+ ${getConfirmDialogContent("error", "areYouSure", "confirmContinueDashboardModified", "discard", "cancel")}+ </or-vaadin-confirm-dialog>+ `);}// Element render method@@ -252,9 +250,17 @@ export class OrDashboardTree extends translate(i18next)(LitElement) {</or-vaadin-button><or-vaadin-button theme="icon" title=${i18next.t("delete")} @click=${() => {if (this.selected != null) {- showOkCancelDialog(i18next.t('areYouSure'), i18next.t('dashboard.deletePermanentWarning', {dashboard: this.selected.displayName}), i18next.t('delete')).then((ok: boolean) => {- if (ok) this.deleteDashboard(this.selected!);- });+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => this.deleteDashboard(this.selected!)}>+ ${getConfirmDialogContent(+ "error",+ "areYouSure",+ html`<or-translate value="dashboard.deletePermanentWarning" .options=${{dashboard: this.selected.displayName}}></or-translate>`,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}}}><or-icon icon="delete"></or-icon>diff --git a/ui/component/or-rules/src/index.ts b/ui/component/or-rules/src/index.tsindex 57510f2d8..77d5137c2 100644--- a/ui/component/or-rules/src/index.ts+++ b/ui/component/or-rules/src/index.ts@@ -52,6 +52,7 @@ import {} from "@openremote/model";import "@openremote/or-translate";import "@openremote/or-mwc-components/or-mwc-drawer";+import "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";import "./or-rule-viewer";import "./or-rule-group-viewer";import "./or-rule-tree";@@ -59,7 +60,7 @@ import "./flow-viewer/flow-viewer";import {OrRuleViewer} from "./or-rule-viewer";import {RecurrenceOption} from "./json-viewer/or-rule-then-otherwise";import type {ValueInputProviderGenerator} from "@openremote/or-mwc-components/or-mwc-input";-import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";import {OrRuleTree, RuleTreeNode} from "./or-rule-tree";import {OrTreeDragEvent} from "@openremote/or-tree-menu";@@ -906,8 +907,11 @@ export class OrRules extends translate(i18next)(LitElement) {protected _confirmContinue(action: (ok: boolean) => void) {if (this._viewer?.modified) {- showOkCancelDialog(i18next.t("loseChanges"), i18next.t("confirmContinueRulesetModified"), i18next.t("discard"))- .then((ok) => action(ok));+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @cancel=${() => action(false)} @confirm=${() => action(true)}>+ ${getConfirmDialogContent("error", "loseChanges", "confirmContinueRulesetModified", "discard", "cancel")}+ </or-vaadin-confirm-dialog>+ `);} else {action(true);}diff --git a/ui/component/or-rules/src/or-rule-tree.ts b/ui/component/or-rules/src/or-rule-tree.tsindex e1f85f31c..a111a1bd4 100644--- a/ui/component/or-rules/src/or-rule-tree.ts+++ b/ui/component/or-rules/src/or-rule-tree.ts@@ -25,7 +25,6 @@ import {css, html, PropertyValues, TemplateResult} from "lit";import manager, {Util} from "@openremote/core";import {i18next} from "@openremote/or-translate";import {InputType, OrInputChangedEvent} from "@openremote/or-mwc-components/or-mwc-input";-import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {OrRules,OrRulesAddEvent,@@ -41,6 +40,7 @@ import {} from "./index";import {ifDefined} from "lit/directives/if-defined.js";import {when} from "lit/directives/when.js";+import {getConfirmDialogContent, showConfirmDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";const styling = css`.iconfill-gray {@@ -285,13 +285,23 @@ export class OrRuleTree extends OrTreeMenu {// If only groups are selected without any rules, prompt "delete groups" dialog.if(selectedRuleNodes.length === 0 && groupNodes.length > 0) {- showOkCancelDialog(i18next.t("deleteRulesetGroups"), i18next.t("deleteRulesetGroupsConfirm", { groupNames: groupNames }), i18next.t("delete"))- .then((ok) => {- if(ok) {- this.deselectAllNodes();- this.nodes = this.nodes.filter(n => !groupNames.includes(n.label));- }- })+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => {+ this.deselectAllNodes();+ this.nodes = this.nodes.filter(n => !groupNames.includes(n.label));+ }}>+ ${getConfirmDialogContent(+ "error",+ "deleteRulesetGroups",+ html`+ <or-translate value="deleteRulesetGroupsConfirm"></or-translate>+ <ul>${groupNames.map(n => html`<li>${n}</li>`)}</ul>+ `,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `)return;}@@ -300,18 +310,26 @@ export class OrRuleTree extends OrTreeMenu {.then((detail) => {if (detail.allow) {const names = selectedRules.map(r => r.name);- showOkCancelDialog(i18next.t("deleteRulesets"), i18next.t("deleteRulesetsConfirm", { ruleNames: names }), i18next.t("delete"))- .then((ok) => {- if (ok) {- this.deselectAllNodes();- this._deleteRulesets(selectedRules)- .catch(e => console.error(e))- .finally(() => {- this.nodes = this.nodes.filter(n => !groupNames.includes(n.label));- this.refresh()- });- }- });+ showConfirmDialog(this.shadowRoot!, html`+ <or-vaadin-confirm-dialog @confirm=${() => {+ this.deselectAllNodes();+ this._deleteRulesets(selectedRules).catch(e => console.error(e)).finally(() => {+ this.nodes = this.nodes.filter(n => !groupNames.includes(n.label));+ this.refresh()+ });+ }}>+ ${getConfirmDialogContent(+ "error",+ "deleteRulesets",+ html`+ <or-translate value="deleteRulesetsConfirm"></or-translate>+ <ul>${names.map(n => html`<li>${n}</li>`)}</ul>+ `,+ "delete",+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}});}diff --git a/ui/component/or-rules/src/or-rule-viewer.ts b/ui/component/or-rules/src/or-rule-viewer.tsindex f1427dfb0..250024b70 100644--- a/ui/component/or-rules/src/or-rule-viewer.ts+++ b/ui/component/or-rules/src/or-rule-viewer.ts@@ -36,11 +36,11 @@ import "./flow-viewer/components/flow-editor";import "@openremote/or-scheduler";import {i18next, translate} from "@openremote/or-translate"import {GenericAxiosResponse} from "@openremote/rest";-import {showErrorDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {project} from "./flow-viewer/components/flow-editor";import { INTUITIVE_NOT_APPLICABLE, OrSchedulerChangedEvent, RRulePartKeys } from "@openremote/or-scheduler";import {when} from "lit/directives/when.js";import {OrVaadinButton} from "@openremote/or-vaadin-components/or-vaadin-button";+import {showErrorDialog} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";const DISABLED_RRULE_PARTS = ["interval",@@ -365,7 +365,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {protected _onSaveClicked() {if (this._isReadonly()) {if (this._isLegacyJavascriptRuleset()) {- showErrorDialog(i18next.t("rulesLegacyJavaScriptWarning"));+ showErrorDialog(this.shadowRoot!, "rulesLegacyJavaScriptWarning");}return;}@@ -397,7 +397,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {if (this._isReadonly()) {if (this._isLegacyJavascriptRuleset(ruleset)) {- showErrorDialog(i18next.t("rulesLegacyJavaScriptWarning"));+ showErrorDialog(this.shadowRoot!, "rulesLegacyJavaScriptWarning");}return;}@@ -437,7 +437,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {if (response.status !== (isNew ? 200 : 204)) {fail = true;- showErrorDialog("Create ruleset returned unexpected status: " + response.status);+ showErrorDialog(this.shadowRoot!, "Create ruleset returned unexpected status: " + response.status);return;} else if (response.data) {ruleset.id = response.data;@@ -451,7 +451,7 @@ export class OrRuleViewer extends translate(i18next)(LitElement) {this.saveBtnElem.disabled = false;if (fail) {- showErrorDialog(i18next.t("saveRulesetFailed"));+ showErrorDialog(this.shadowRoot!, "saveRulesetFailed");}this.dispatchEvent(new OrRulesSaveEvent({diff --git a/ui/component/or-vaadin-components/package.json b/ui/component/or-vaadin-components/package.jsonindex 622333ca3..e9dc76f46 100644--- a/ui/component/or-vaadin-components/package.json+++ b/ui/component/or-vaadin-components/package.json@@ -36,6 +36,7 @@"@vaadin/checkbox": "~25.2.4","@vaadin/checkbox-group": "~25.2.4","@vaadin/combo-box": "~25.2.4",+ "@vaadin/confirm-dialog": "~25.2.4","@vaadin/date-picker": "~25.2.4","@vaadin/date-time-picker": "~25.2.4","@vaadin/dialog": "~25.2.4",diff --git a/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.ts b/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.tsnew file mode 100644index 000000000..5a8aa26f5--- /dev/null+++ b/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.ts@@ -0,0 +1,147 @@+/*+ * Copyright 2026, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+import {ConfirmDialog} from "@vaadin/confirm-dialog";+import {OrVaadinComponent} from "./util";+import {css, type TemplateResult, type LitElement, render, html} from "lit";+import {customElement} from "lit/decorators.js";+import {when} from "lit/directives/when.js";+import {Util} from "@openremote/core";++type WithLit<T> = T & typeof LitElement;++/**+ * Helper function for rendering the `<or-vaadin-confirm-dialog>` dynamically, to "show a dialog on command".+ * This saves initial render time for components, and prevents state handling on the consumer side.+ * `showConfirmDialog()` appends (and updates) dialogs to the host element when called,+ * and automatically removes the element upon closing the dialog.+ * It also conveniently adds HTML attributes like `cancel-button-visible` when a slotted element is present.+ * @param host - Host element (often shadow root) to append the dialog container as a child.+ * @param dialog - A {@link TemplateResult} to render. It is required to contain a `<or-vaadin-confirm-dialog>` tag.+ */+export function showConfirmDialog(host: Node, dialog: TemplateResult) {+ const container = document.createElement("div");+ container.id = `dialog-${Util.generateUniqueUUID()}`;+ render(dialog, container); // Render Lit template inside the container++ const dialogElem = container.querySelector("or-vaadin-confirm-dialog") as OrVaadinConfirmDialog | null;+ if(dialogElem) {+ dialogElem.opened = true;+ dialogElem.addEventListener("closed", () => container.remove());+ if(dialogElem.querySelector("[slot='cancel-button']")) {+ dialogElem.cancelButtonVisible = true;+ }+ if(dialogElem.querySelector("[slot='reject-button']")) {+ dialogElem.rejectButtonVisible = true;+ }+ } else {+ // As no or-vaadin-confirm-dialog is present, we can remove the HTMLElement+ container.remove();+ return;+ }+ host.appendChild(container);+}++/**+ * Helper function for simplifying the generation of `<or-vaadin-confirm-dialog>` content.+ * Instead of using declarative HTML, this function provides an easy alternative with automatically translated keys.+ * Example: `getConfirmDialogContent("areYouSure", "deleteWarning", "remove", "cancel")`+ *+ * @param theme - Optional theme to use for the dialog and its buttons (for example 'error').+ * @param header - Dialog header that is either a translation key, or a {@link TemplateResult}+ * @param content - Dialog content that is either a translation key, or a {@link TemplateResult}+ * @param confirmKey - Translation key to display inside the "confirm" button. If `undefined` the button will not be visible.+ * @param cancelKey - Translation key to display inside the "cancel" button. If `undefined` the button will not be visible.+ * @param rejectKey - Translation key to display inside the "reject" button. If `undefined` the button will not be visible.+ */+export function getConfirmDialogContent(theme: string | undefined, header: TemplateResult | string, content: TemplateResult | string, confirmKey?: string, cancelKey?: string, rejectKey?: string): TemplateResult {+ return html`+ ${typeof header === "string"+ ? html`<or-translate slot="header" value=${header}></or-translate>`+ : html`<div slot="header">${header}</div>`+ }+ ${typeof content === "string"+ ? html`<or-translate value=${content}></or-translate>`+ : content+ }+ ${when(confirmKey, () => html`+ <or-vaadin-button theme=${theme && theme.includes(' ') ? theme : (theme + " primary")} slot="confirm-button">+ <or-translate value=${confirmKey}></or-translate>+ </or-vaadin-button>+ `)}+ ${when(cancelKey, () => html`+ <or-vaadin-button theme=${theme ? `tertiary ${theme}` : "tertiary"} slot="cancel-button">+ <or-translate value=${cancelKey}></or-translate>+ </or-vaadin-button>+ `)}+ ${when(rejectKey, () => html`+ <or-vaadin-button theme=${theme ? `tertiary ${theme}` : "tertiary"} slot="reject-button">+ <or-translate value=${rejectKey}></or-translate>+ </or-vaadin-button>+ `)}+ `;+}++/**+ * Helper function for rendering the `<or-vaadin-confirm-dialog>` dynamically, to "show an error dialog on command".+ * This saves initial render time for components, and prevents state handling on the consumer side.+ * It utilizes {@link showConfirmDialog}, to render the given message and title.+ * @param host - Host element (often shadow root) to append the dialog container as a child.+ * @param message - The translation key or {@link TemplateResult} to render as dialog message.+ * @param title - Optional translation key or {@link TemplateResult} to render as dialog title.+ */+export function showErrorDialog(host: Node, message: string | TemplateResult, title: string | TemplateResult = "errorOccurred") {+ return showConfirmDialog(host, html`+ <or-vaadin-confirm-dialog>+ ${getConfirmDialogContent("error tertiary", title, message, "close")}+ </or-vaadin-confirm-dialog>+ `)+}++@customElement("or-vaadin-confirm-dialog")+export class OrVaadinConfirmDialog extends (ConfirmDialog as new () => ConfirmDialog & LitElement) implements OrVaadinComponent {++ static get styles() {+ return [+ (ConfirmDialog as WithLit<typeof ConfirmDialog>).styles,+ css`+ ::part(header),+ ::part(content) {+ background-color: var(--lumo-contrast-5pct);+ margin-inline-start: 0;+ }+ ::part(header),+ ::part(footer) {+ padding: var(--lumo-space-l);+ }+ ::part(content) {+ padding: 0 var(--lumo-space-l);+ }+ `+ ];+ }++ public open() {+ this.setAttribute("opened", "true");+ }++ public close() {+ this.toggleAttribute("opened", false);+ }+}diff --git a/ui/component/or-vaadin-components/stories/or-vaadin-confirm-dialog.stories.ts b/ui/component/or-vaadin-components/stories/or-vaadin-confirm-dialog.stories.tsnew file mode 100644index 000000000..a4277a152--- /dev/null+++ b/ui/component/or-vaadin-components/stories/or-vaadin-confirm-dialog.stories.ts@@ -0,0 +1,78 @@+/*+ * Copyright 2026, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+import {setCustomElementsManifest, type Meta, type StoryObj } from "@storybook/web-components";+import {getORStorybookHelpers} from "../../storybook-utils";+import customElements from "../custom-elements.json" with { type: "json" };+import packageJson from "../package.json" with { type: "json" };+import {html} from "lit";+import {OrVaadinConfirmDialog} from "../src/or-vaadin-confirm-dialog";+import "../src/or-vaadin-button";+import "../src/or-vaadin-confirm-dialog";++const tagName = "or-vaadin-confirm-dialog";+type Story = StoryObj;+setCustomElementsManifest(customElements);++const { events, args, argTypes, template } = getORStorybookHelpers(tagName);++const meta: Meta = {+ title: "Playground/or-vaadin-components/confirm-dialog",+ component: tagName,+ args: args,+ argTypes: argTypes,+ render: storyArgs => template(storyArgs),+ excludeStories: /^[a-z].*/,+ parameters: {+ actions: {+ handles: events+ },+ docs: {+ subtitle: `<${tagName}>`,+ description: "Confirm Dialog is a modal Dialog used to confirm user actions. Compared to other components, users can not dismiss this dialog."+ }+ }+};++export const Primary: Story = {+ render: (_args) => {+ return html`+ <or-vaadin-confirm-dialog cancel-button-visible>+ <span slot="header">Header</span>+ <span>Content</span>+ <vaadin-button slot="confirm-button" theme="primary">Confirm</vaadin-button>+ </or-vaadin-confirm-dialog>+ <or-vaadin-button @click="${() => (document.querySelector('or-vaadin-confirm-dialog') as OrVaadinConfirmDialog).open()}">Show dialog</or-vaadin-button>+ `;+ },+ parameters: {+ docs: {+ story: {+ height: "360px"+ }+ }+ }+};++export const examples: Story[] = [];++export {customElements, packageJson};+++export default meta;diff --git a/ui/component/or-vaadin-components/stories/or-vaadin-dialog.stories.ts b/ui/component/or-vaadin-components/stories/or-vaadin-dialog.stories.tsindex 2aab5d460..10582d721 100644--- a/ui/component/or-vaadin-components/stories/or-vaadin-dialog.stories.ts+++ b/ui/component/or-vaadin-components/stories/or-vaadin-dialog.stories.ts@@ -56,10 +56,9 @@ const meta: Meta = {export const Primary: Story = {render: (_args) => {return html`- <or-vaadin-dialog- ${dialogHeaderRenderer(() => html`<h2>Dialog title</h2>`)}- ${dialogRenderer(() => html`<p>Content</p>`)}- ></or-vaadin-dialog>+ <or-vaadin-dialog ${dialogHeaderRenderer(() => html`<h2>Dialog title</h2>`)}>+ <p>Content</p>+ </or-vaadin-dialog><or-vaadin-button @click="${() => (document.querySelector('or-vaadin-dialog') as OrVaadinDialog).open()}">Show dialog</or-vaadin-button>`;},@@ -80,10 +79,8 @@ export const MapExample: Story = {`;return html`<or-vaadin-dialog header-title="Configure area" ${dialogFooterRenderer(footer)}>- <div>- <or-map style="aspect-ratio: 1/1;"></or-map>- <or-vaadin-number-field label="Radius (min. 100m)" min="100" value="100"></or-vaadin-number-field>- </div>+ <or-map style="aspect-ratio: 1/1;"></or-map>+ <or-vaadin-number-field label="Radius (min. 100m)" min="100" value="100"></or-vaadin-number-field></or-vaadin-dialog><or-vaadin-button @click="${() => (document.querySelector('or-vaadin-dialog') as OrVaadinDialog).open()}">Show dialog</or-vaadin-button>`;diff --git a/ui/component/theme/src/components/index.css b/ui/component/theme/src/components/index.cssindex 16e0dc385..d77ae475a 100644--- a/ui/component/theme/src/components/index.css+++ b/ui/component/theme/src/components/index.css@@ -27,6 +27,7 @@@import "./or-vaadin-checkbox-group.css";@import "./or-vaadin-checkbox.css"; /* Must be after the checkbox-group */@import "./or-vaadin-combo-box.css";+@import "./or-vaadin-confirm-dialog.css";@import "./or-vaadin-date-time-picker.css";@import "./or-vaadin-date-picker.css"; /* Must be after the date-time-picker */@import "./or-vaadin-dialog.css";diff --git a/ui/component/theme/src/components/or-vaadin-confirm-dialog.css b/ui/component/theme/src/components/or-vaadin-confirm-dialog.cssnew file mode 100644index 000000000..0e602c4b5--- /dev/null+++ b/ui/component/theme/src/components/or-vaadin-confirm-dialog.css@@ -0,0 +1,30 @@+/*+ * Copyright 2026, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+@import "@vaadin/vaadin-lumo-styles/components/confirm-dialog.css";++:root::before,+:host::before {+ --_lumo-vaadin-confirm-dialog-overlay-inject: 1;+ --_lumo-vaadin-confirm-dialog-overlay-inject-modules:+ lumo_mixins_overlay,+ lumo_components_dialog-overlay,+ lumo_components_confirm-dialog-overlay;+}+diff --git a/yarn.lock b/yarn.lockindex 316e6954f..81db715a0 100644--- a/yarn.lock+++ b/yarn.lock@@ -2429,6 +2429,7 @@ __metadata:"@vaadin/checkbox": "npm:~25.2.4""@vaadin/checkbox-group": "npm:~25.2.4""@vaadin/combo-box": "npm:~25.2.4"+ "@vaadin/confirm-dialog": "npm:~25.2.4""@vaadin/date-picker": "npm:~25.2.4""@vaadin/date-time-picker": "npm:~25.2.4""@vaadin/dialog": "npm:~25.2.4"@@ -4378,6 +4379,21 @@ __metadata:languageName: nodelinkType: hard+"@vaadin/confirm-dialog@npm:~25.2.4":+ version: 25.2.4+ resolution: "@vaadin/confirm-dialog@npm:25.2.4"+ dependencies:+ "@open-wc/dedupe-mixin": "npm:^1.3.0"+ "@vaadin/button": "npm:~25.2.4"+ "@vaadin/component-base": "npm:~25.2.4"+ "@vaadin/dialog": "npm:~25.2.4"+ "@vaadin/overlay": "npm:~25.2.4"+ "@vaadin/vaadin-themable-mixin": "npm:~25.2.4"+ lit: "npm:^3.0.0"+ checksum: 10c0/43443a2973bde72fbee28fa2b04cfa3e0307ab9cb298b594e29910178623b8a4ab3add9f81d626e7f40ee269511a0ab20f1a1a14339da9cbfffabb56e51c7e18+ languageName: node+ linkType: hard+"@vaadin/context-menu@npm:~25.2.4":version: 25.2.4resolution: "@vaadin/context-menu@npm:25.2.4"