Remove tabs from scene and script edit page (#13592)

This commit is contained in:
Bram Kragten 2022-09-05 14:03:00 +02:00 committed by GitHub
parent 8ffe676827
commit fe8e79a67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 31 deletions

View File

@ -11,9 +11,13 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined"; import { ifDefined } from "lit/directives/if-defined";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent, HASSDomEvent } from "../../../common/dom/fire_event";
import { computeStateName } from "../../../common/entity/compute_state_name"; import { computeStateName } from "../../../common/entity/compute_state_name";
import { DataTableColumnContainer } from "../../../components/data-table/ha-data-table"; import { navigate } from "../../../common/navigate";
import {
DataTableColumnContainer,
RowClickedEvent,
} from "../../../components/data-table/ha-data-table";
import "../../../components/ha-button-related-filter-menu"; import "../../../components/ha-button-related-filter-menu";
import "../../../components/ha-fab"; import "../../../components/ha-fab";
import "../../../components/ha-icon-button"; import "../../../components/ha-icon-button";
@ -165,6 +169,8 @@ class HaSceneDashboard extends LitElement {
)} )}
@clear-filter=${this._clearFilter} @clear-filter=${this._clearFilter}
hasFab hasFab
clickable
@row-click=${this._handleRowClicked}
> >
<ha-icon-button <ha-icon-button
slot="toolbar-icon" slot="toolbar-icon"
@ -196,6 +202,14 @@ class HaSceneDashboard extends LitElement {
`; `;
} }
private _handleRowClicked(ev: HASSDomEvent<RowClickedEvent>) {
const scene = this.scenes.find((a) => a.entity_id === ev.detail.id);
if (scene?.attributes.id) {
navigate(`/config/scene/edit/${scene?.attributes.id}`);
}
}
private _relatedFilterChanged(ev: CustomEvent) { private _relatedFilterChanged(ev: CustomEvent) {
this._filterValue = ev.detail.value; this._filterValue = ev.detail.value;
if (!this._filterValue) { if (!this._filterValue) {

View File

@ -63,13 +63,13 @@ import {
showAlertDialog, showAlertDialog,
showConfirmationDialog, showConfirmationDialog,
} from "../../../dialogs/generic/show-dialog-box"; } from "../../../dialogs/generic/show-dialog-box";
import "../../../layouts/hass-subpage";
import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin"; import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin";
import { SubscribeMixin } from "../../../mixins/subscribe-mixin"; import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import { HomeAssistant, Route } from "../../../types"; import { HomeAssistant, Route } from "../../../types";
import { showToast } from "../../../util/toast"; import { showToast } from "../../../util/toast";
import "../ha-config-section"; import "../ha-config-section";
import { configSections } from "../ha-panel-config";
interface DeviceEntities { interface DeviceEntities {
id: string; id: string;
@ -214,17 +214,16 @@ export class HaSceneEditor extends SubscribeMixin(
this._deviceEntityLookup, this._deviceEntityLookup,
this._deviceRegistryEntries this._deviceRegistryEntries
); );
const name = this._scene
? computeStateName(this._scene)
: this.hass.localize("ui.panel.config.scene.editor.default_name");
return html` return html`
<hass-tabs-subpage <hass-subpage
.hass=${this.hass} .hass=${this.hass}
.narrow=${this.narrow} .narrow=${this.narrow}
.route=${this.route} .route=${this.route}
.backCallback=${this._backTapped} .backCallback=${this._backTapped}
.tabs=${configSections.automations} .header=${this._scene
? computeStateName(this._scene)
: this.hass.localize("ui.panel.config.scene.editor.default_name")}
> >
<ha-button-menu <ha-button-menu
corner="BOTTOM_START" corner="BOTTOM_START"
@ -272,7 +271,6 @@ export class HaSceneEditor extends SubscribeMixin(
</mwc-list-item> </mwc-list-item>
</ha-button-menu> </ha-button-menu>
${this._errors ? html` <div class="errors">${this._errors}</div> ` : ""} ${this._errors ? html` <div class="errors">${this._errors}</div> ` : ""}
${this.narrow ? html` <span slot="header">${name}</span> ` : ""}
<div <div
id="root" id="root"
class=${classMap({ class=${classMap({
@ -281,15 +279,7 @@ export class HaSceneEditor extends SubscribeMixin(
> >
${this._config ${this._config
? html` ? html`
<ha-config-section vertical .isWide=${this.isWide}> <div class="container">
${!this.narrow
? html` <span slot="header">${name}</span> `
: ""}
<div slot="introduction">
${this.hass.localize(
"ui.panel.config.scene.editor.introduction"
)}
</div>
<ha-card outlined> <ha-card outlined>
<div class="card-content"> <div class="card-content">
<ha-textfield <ha-textfield
@ -322,7 +312,7 @@ export class HaSceneEditor extends SubscribeMixin(
</ha-area-picker> </ha-area-picker>
</div> </div>
</ha-card> </ha-card>
</ha-config-section> </div>
<ha-config-section vertical .isWide=${this.isWide}> <ha-config-section vertical .isWide=${this.isWide}>
<div slot="header"> <div slot="header">
@ -486,7 +476,7 @@ export class HaSceneEditor extends SubscribeMixin(
> >
<ha-svg-icon slot="icon" .path=${mdiContentSave}></ha-svg-icon> <ha-svg-icon slot="icon" .path=${mdiContentSave}></ha-svg-icon>
</ha-fab> </ha-fab>
</hass-tabs-subpage> </hass-subpage>
`; `;
} }
@ -963,6 +953,16 @@ export class HaSceneEditor extends SubscribeMixin(
ha-card { ha-card {
overflow: hidden; overflow: hidden;
} }
.container {
display: flex;
justify-content: center;
margin-top: 24px;
}
.container > * {
max-width: 1040px;
flex: 1 1 auto;
}
.errors { .errors {
padding: 20px; padding: 20px;
font-weight: bold; font-weight: bold;

View File

@ -18,7 +18,7 @@ import {
PropertyValues, PropertyValues,
TemplateResult, TemplateResult,
} from "lit"; } from "lit";
import { property, state, query } from "lit/decorators"; import { property, query, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map"; import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { computeObjectId } from "../../../common/entity/compute_object_id"; import { computeObjectId } from "../../../common/entity/compute_object_id";
@ -51,13 +51,13 @@ import {
} from "../../../data/script"; } from "../../../data/script";
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box"; import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
import "../../../layouts/ha-app-layout"; import "../../../layouts/ha-app-layout";
import "../../../layouts/hass-subpage";
import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin"; import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import type { HomeAssistant, Route } from "../../../types"; import type { HomeAssistant, Route } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url"; import { documentationUrl } from "../../../util/documentation-url";
import { showToast } from "../../../util/toast"; import { showToast } from "../../../util/toast";
import { HaDeviceAction } from "../automation/action/types/ha-automation-action-device_id"; import { HaDeviceAction } from "../automation/action/types/ha-automation-action-device_id";
import { configSections } from "../ha-panel-config";
import "./blueprint-script-editor"; import "./blueprint-script-editor";
export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
@ -168,12 +168,12 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
}; };
return html` return html`
<hass-tabs-subpage <hass-subpage
.hass=${this.hass} .hass=${this.hass}
.narrow=${this.narrow} .narrow=${this.narrow}
.route=${this.route} .route=${this.route}
.backCallback=${this._backTapped} .backCallback=${this._backTapped}
.tabs=${configSections.automations} .header=${!this._config?.alias ? "" : this._config.alias}
> >
<ha-button-menu <ha-button-menu
corner="BOTTOM_START" corner="BOTTOM_START"
@ -255,9 +255,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
</ha-svg-icon> </ha-svg-icon>
</mwc-list-item> </mwc-list-item>
</ha-button-menu> </ha-button-menu>
${this.narrow
? html`<span slot="header">${this._config?.alias}</span>`
: ""}
<div <div
class="content ${classMap({ class="content ${classMap({
"yaml-mode": this._mode === "yaml", "yaml-mode": this._mode === "yaml",
@ -415,7 +412,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
> >
<ha-svg-icon slot="icon" .path=${mdiContentSave}></ha-svg-icon> <ha-svg-icon slot="icon" .path=${mdiContentSave}></ha-svg-icon>
</ha-fab> </ha-fab>
</hass-tabs-subpage> </hass-subpage>
`; `;
} }

View File

@ -11,10 +11,14 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { formatDateTime } from "../../../common/datetime/format_date_time"; import { formatDateTime } from "../../../common/datetime/format_date_time";
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent, HASSDomEvent } from "../../../common/dom/fire_event";
import { computeStateName } from "../../../common/entity/compute_state_name"; import { computeStateName } from "../../../common/entity/compute_state_name";
import { navigate } from "../../../common/navigate";
import { computeRTL } from "../../../common/util/compute_rtl"; import { computeRTL } from "../../../common/util/compute_rtl";
import { DataTableColumnContainer } from "../../../components/data-table/ha-data-table"; import {
DataTableColumnContainer,
RowClickedEvent,
} from "../../../components/data-table/ha-data-table";
import "../../../components/ha-button-related-filter-menu"; import "../../../components/ha-button-related-filter-menu";
import "../../../components/ha-fab"; import "../../../components/ha-fab";
import "../../../components/ha-icon-button"; import "../../../components/ha-icon-button";
@ -191,6 +195,8 @@ class HaScriptPicker extends LitElement {
)} )}
@clear-filter=${this._clearFilter} @clear-filter=${this._clearFilter}
hasFab hasFab
clickable
@row-click=${this._handleRowClicked}
> >
<ha-icon-button <ha-icon-button
slot="toolbar-icon" slot="toolbar-icon"
@ -241,6 +247,10 @@ class HaScriptPicker extends LitElement {
this._filterValue = undefined; this._filterValue = undefined;
} }
private _handleRowClicked(ev: HASSDomEvent<RowClickedEvent>) {
navigate(`/config/script/edit/${ev.detail.id}`);
}
private _runScript = async (ev) => { private _runScript = async (ev) => {
ev.stopPropagation(); ev.stopPropagation();
const script = ev.currentTarget.script as HassEntity; const script = ev.currentTarget.script as HassEntity;

View File

@ -2331,7 +2331,6 @@
} }
}, },
"editor": { "editor": {
"introduction": "Use scenes to bring your home to life.",
"default_name": "New Scene", "default_name": "New Scene",
"load_error_not_editable": "Only scenes in scenes.yaml are editable.", "load_error_not_editable": "Only scenes in scenes.yaml are editable.",
"load_error_unknown": "Error loading scene ({err_no}).", "load_error_unknown": "Error loading scene ({err_no}).",