From 394d5528562ec1e9f649cf8e5968a7d1eb9120f1 Mon Sep 17 00:00:00 2001 From: Josh McCarty Date: Tue, 17 Nov 2020 14:29:20 -0700 Subject: [PATCH] Use ha-dialog for dialog-system-log-details, add close icon button (#7513) --- .../config/logs/dialog-system-log-detail.ts | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/panels/config/logs/dialog-system-log-detail.ts b/src/panels/config/logs/dialog-system-log-detail.ts index 34d0cfcd1a..320657f8c4 100644 --- a/src/panels/config/logs/dialog-system-log-detail.ts +++ b/src/panels/config/logs/dialog-system-log-detail.ts @@ -1,6 +1,6 @@ +import "../../../components/ha-header-bar"; import "@material/mwc-icon-button/mwc-icon-button"; -import { mdiContentCopy } from "@mdi/js"; -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; +import { mdiContentCopy, mdiClose } from "@mdi/js"; import "@polymer/paper-tooltip/paper-tooltip"; import type { PaperTooltipElement } from "@polymer/paper-tooltip/paper-tooltip"; import { @@ -14,7 +14,7 @@ import { TemplateResult, } from "lit-element"; import { fireEvent } from "../../../common/dom/fire_event"; -import "../../../components/dialog/ha-paper-dialog"; +import "../../../components/ha-dialog"; import "../../../components/ha-svg-icon"; import { domainToName, @@ -23,7 +23,6 @@ import { IntegrationManifest, } from "../../../data/integration"; import { getLoggedErrorIntegration } from "../../../data/system_log"; -import type { PolymerChangedEvent } from "../../../polymer-types"; import { haStyleDialog } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; import type { SystemLogDetailDialogParams } from "./show-dialog-system-log-detail"; @@ -36,7 +35,7 @@ class DialogSystemLogDetail extends LitElement { @internalProperty() private _manifest?: IntegrationManifest; - @query("paper-tooltip", true) private _toolTip?: PaperTooltipElement; + @query("paper-tooltip") private _toolTip?: PaperTooltipElement; public async showDialog(params: SystemLogDetailDialogParams): Promise { this._params = params; @@ -69,23 +68,23 @@ class DialogSystemLogDetail extends LitElement { const integration = getLoggedErrorIntegration(item); return html` - -
-

+ + + + + + ${this.hass.localize( "ui.panel.config.logs.details", "level", item.level )} -

- + + ${this.hass.localize("ui.common.copied")} -
- + +

Logger: ${item.name}
Source: ${item.source.join(":")} @@ -150,8 +149,8 @@ class DialogSystemLogDetail extends LitElement { ` : item.message[0]} ${item.exception ? html`

${item.exception}
` : html``} - - +
+ `; } @@ -163,15 +162,9 @@ class DialogSystemLogDetail extends LitElement { } } - private _openedChanged(ev: PolymerChangedEvent): void { - if (!(ev.detail as any).value) { - this.closeDialog(); - } - } - private _copyLog(): void { const copyElement = this.shadowRoot?.querySelector( - "paper-dialog-scrollable" + ".contents" ) as HTMLElement; const selection = window.getSelection()!; @@ -192,9 +185,6 @@ class DialogSystemLogDetail extends LitElement { return [ haStyleDialog, css` - ha-paper-dialog { - direction: ltr; - } a { color: var(--primary-color); } @@ -205,13 +195,19 @@ class DialogSystemLogDetail extends LitElement { margin-bottom: 0; font-family: var(--code-font-family, monospace); } - .heading { - display: flex; - align-items: center; - justify-content: space-between; + + ha-header-bar { + --mdc-theme-on-primary: var(--primary-text-color); + --mdc-theme-primary: var(--mdc-theme-surface); + flex-shrink: 0; + border-bottom: 1px solid + var(--mdc-dialog-scroll-divider-color, rgba(0, 0, 0, 0.12)); } - .heading ha-svg-icon { - cursor: pointer; + + @media all and (min-width: 451px) and (min-height: 501px) { + ha-dialog { + --mdc-dialog-max-width: 90vw; + } } `, ];