From ffad6f340fa5ce9a8199267eef666c00798e2f13 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 1 Sep 2022 22:43:30 -0400 Subject: [PATCH 1/7] Fix some descriptions (#13562) --- src/data/automation_i18n.ts | 89 ++++++++++++++++++++++++++++++++----- src/data/script_i18n.ts | 38 ++++++++++------ 2 files changed, 103 insertions(+), 24 deletions(-) diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index d3b5fba7cd..1c7e8a1537 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -1,4 +1,5 @@ import secondsToDuration from "../common/datetime/seconds_to_duration"; +import { ensureArray } from "../common/ensure-array"; import { computeStateName } from "../common/entity/compute_state_name"; import type { HomeAssistant } from "../types"; import { Condition, Trigger } from "./automation"; @@ -74,7 +75,7 @@ export const describeTrigger = ( } // State Trigger - if (trigger.platform === "state" && trigger.entity_id) { + if (trigger.platform === "state") { let base = "When"; let entities = ""; @@ -95,12 +96,17 @@ export const describeTrigger = ( } ${computeStateName(states[entity]) || entity}`; } } - } else { + } else if (trigger.entity_id) { entities = states[trigger.entity_id] ? computeStateName(states[trigger.entity_id]) : trigger.entity_id; } + if (!entities) { + // no entity_id or empty array + entities = "something"; + } + base += ` ${entities} changes`; if (trigger.from) { @@ -286,7 +292,7 @@ export const describeTrigger = ( } // MQTT Trigger if (trigger.platform === "mqtt") { - return "When a MQTT payload has been received"; + return "When an MQTT message has been received"; } // Template Trigger @@ -300,6 +306,9 @@ export const describeTrigger = ( } if (trigger.platform === "device") { + if (!trigger.device_id) { + return "Device trigger"; + } const config = trigger as DeviceTrigger; const localized = localizeDeviceAutomationTrigger(hass, config); if (localized) { @@ -311,7 +320,9 @@ export const describeTrigger = ( }`; } - return `${trigger.platform || "Unknown"} trigger`; + return `${ + trigger.platform ? trigger.platform.replace(/_/g, " ") : "Unknown" + } trigger`; }; export const describeCondition = ( @@ -323,15 +334,64 @@ export const describeCondition = ( return condition.alias; } - if (["or", "and", "not"].includes(condition.condition)) { - return `multiple conditions using "${condition.condition}"`; + if (!condition.condition) { + const shorthands: Array<"and" | "or" | "not"> = ["and", "or", "not"]; + for (const key of shorthands) { + if (!(key in condition)) { + continue; + } + if (ensureArray(condition[key])) { + condition = { + condition: key, + conditions: condition[key], + }; + } + } + } + + if (condition.condition === "or") { + const conditions = ensureArray(condition.conditions); + + let count = "condition"; + + if (conditions && conditions.length > 0) { + count = `of ${conditions.length} conditions`; + } + + return `Test if any ${count} matches`; + } + + if (condition.condition === "and") { + const conditions = ensureArray(condition.conditions); + + const count = + conditions && conditions.length > 0 + ? `${conditions.length} ` + : "multiple"; + + return `Test if ${count} conditions match`; + } + + if (condition.condition === "not") { + const conditions = ensureArray(condition.conditions); + + const what = + conditions && conditions.length > 0 + ? `none of ${conditions.length} conditions match` + : "no condition matches"; + + return `Test if ${what}`; } // State Condition - if (condition.condition === "state" && condition.entity_id) { + if (condition.condition === "state") { let base = "Confirm"; const stateObj = hass.states[condition.entity_id]; - const entity = stateObj ? computeStateName(stateObj) : condition.entity_id; + const entity = stateObj + ? computeStateName(stateObj) + : condition.entity_id + ? condition.entity_id + : "an entity"; if ("attribute" in condition) { base += ` ${condition.attribute} from`; @@ -347,10 +407,14 @@ export const describeCondition = ( : "" } ${state}`; } - } else { + } else if (condition.state) { states = condition.state.toString(); } + if (!states) { + states = "a state"; + } + base += ` ${entity} is ${states}`; if ("for" in condition) { @@ -487,6 +551,9 @@ export const describeCondition = ( } if (condition.condition === "device") { + if (!condition.device_id) { + return "Device condition"; + } const config = condition as DeviceCondition; const localized = localizeDeviceAutomationCondition(hass, config); if (localized) { @@ -498,5 +565,7 @@ export const describeCondition = ( }`; } - return `${condition.condition} condition`; + return `${ + condition.condition ? condition.condition.replace(/_/g, " ") : "Unknown" + } condition`; }; diff --git a/src/data/script_i18n.ts b/src/data/script_i18n.ts index ffdb1b0b3b..69e85b69c2 100644 --- a/src/data/script_i18n.ts +++ b/src/data/script_i18n.ts @@ -61,7 +61,7 @@ export const describeAction = ( ? `${domainToName(hass.localize, domain)}: ${service.name}` : `Call service: ${config.service}`; } else { - return actionType; + return "Call a service"; } if (config.target) { const targets: string[] = []; @@ -137,9 +137,11 @@ export const describeAction = ( } else if (typeof config.delay === "string") { duration = isTemplate(config.delay) ? "based on a template" - : `for ${config.delay}`; - } else { + : `for ${config.delay || "a duration"}`; + } else if (config.delay) { duration = `for ${formatDuration(config.delay)}`; + } else { + duration = "for a duration"; } return `Delay ${duration}`; @@ -153,13 +155,12 @@ export const describeAction = ( } else { entityId = config.target?.entity_id || config.entity_id; } + if (!entityId) { + return "Activate a scene"; + } const sceneStateObj = entityId ? hass.states[entityId] : undefined; - return `Scene ${ - sceneStateObj - ? computeStateName(sceneStateObj) - : "scene" in config - ? config.scene - : config.target?.entity_id || config.entity_id || "" + return `Active scene ${ + sceneStateObj ? computeStateName(sceneStateObj) : entityId }`; } @@ -167,16 +168,22 @@ export const describeAction = ( const config = action as PlayMediaAction; const entityId = config.target?.entity_id || config.entity_id; const mediaStateObj = entityId ? hass.states[entityId] : undefined; - return `Play ${config.metadata.title || config.data.media_content_id} on ${ + return `Play ${ + config.metadata.title || config.data.media_content_id || "media" + } on ${ mediaStateObj ? computeStateName(mediaStateObj) - : config.target?.entity_id || config.entity_id + : entityId || "a media player" }`; } if (actionType === "wait_for_trigger") { const config = action as WaitForTriggerAction; - return `Wait for ${ensureArray(config.wait_for_trigger) + const triggers = ensureArray(config.wait_for_trigger); + if (!triggers || triggers.length === 0) { + return "Wait for a trigger"; + } + return `Wait for ${triggers .map((trigger) => describeTrigger(trigger, hass)) .join(", ")}`; } @@ -199,12 +206,12 @@ export const describeAction = ( } if (actionType === "check_condition") { - return `Test ${describeCondition(action as Condition, hass)}`; + return describeCondition(action as Condition, hass); } if (actionType === "stop") { const config = action as StopAction; - return `Stopped${config.stop ? ` because: ${config.stop}` : ""}`; + return `Stop${config.stop ? ` because: ${config.stop}` : ""}`; } if (actionType === "if") { @@ -258,6 +265,9 @@ export const describeAction = ( if (actionType === "device_action") { const config = action as DeviceAction; + if (!config.device_id) { + return "Device action"; + } const localized = localizeDeviceAutomationAction(hass, config); if (localized) { return localized; From ec257710ffc4298ba9a2f270b39b9900ee0a1d31 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Fri, 2 Sep 2022 19:01:05 +0200 Subject: [PATCH 2/7] Add overflow menu to automation picker (#13569) --- src/components/ha-icon-overflow-menu.ts | 27 ++- .../config/automation/ha-automation-picker.ts | 187 ++++++++++++++++-- src/translations/en.json | 2 + 3 files changed, 188 insertions(+), 28 deletions(-) diff --git a/src/components/ha-icon-overflow-menu.ts b/src/components/ha-icon-overflow-menu.ts index 4f81550e30..6ff579c2a8 100644 --- a/src/components/ha-icon-overflow-menu.ts +++ b/src/components/ha-icon-overflow-menu.ts @@ -3,6 +3,8 @@ import { mdiDotsVertical } from "@mdi/js"; import "@polymer/paper-tooltip/paper-tooltip"; import { css, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; +import { classMap } from "lit/directives/class-map"; +import { haStyle } from "../resources/styles"; import { HomeAssistant } from "../types"; import "./ha-button-menu"; import "./ha-icon-button"; @@ -16,6 +18,7 @@ export interface IconOverflowMenuItem { disabled?: boolean; tooltip?: string; onClick: CallableFunction; + warning?: boolean; } @customElement("ha-icon-overflow-menu") @@ -49,9 +52,13 @@ export class HaIconOverflowMenu extends LitElement { graphic="icon" .disabled=${item.disabled} @click=${item.action} + class=${classMap({ warning: Boolean(item.warning) })} >
- +
${item.label} @@ -81,7 +88,8 @@ export class HaIconOverflowMenu extends LitElement { `; } - protected _handleIconOverflowMenuOpened() { + protected _handleIconOverflowMenuOpened(e) { + e.stopPropagation(); // If this component is used inside a data table, the z-index of the row // needs to be increased. Otherwise the ha-button-menu would be displayed // underneath the next row in the table. @@ -99,12 +107,15 @@ export class HaIconOverflowMenu extends LitElement { } static get styles() { - return css` - :host { - display: flex; - justify-content: flex-end; - } - `; + return [ + haStyle, + css` + :host { + display: flex; + justify-content: flex-end; + } + `, + ]; } } diff --git a/src/panels/config/automation/ha-automation-picker.ts b/src/panels/config/automation/ha-automation-picker.ts index aba85d255b..7ee6e86dda 100644 --- a/src/panels/config/automation/ha-automation-picker.ts +++ b/src/panels/config/automation/ha-automation-picker.ts @@ -1,4 +1,16 @@ -import { mdiHelpCircle, mdiInformationOutline, mdiPlus } from "@mdi/js"; +import { + mdiCancel, + mdiContentDuplicate, + mdiDelete, + mdiHelpCircle, + mdiInformationOutline, + mdiPlay, + mdiPlayCircleOutline, + mdiPlus, + mdiStopCircleOutline, + mdiTransitConnection, +} from "@mdi/js"; +import "@polymer/paper-tooltip/paper-tooltip"; import { CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; @@ -13,11 +25,22 @@ import type { RowClickedEvent, } from "../../../components/data-table/ha-data-table"; import "../../../components/ha-button-related-filter-menu"; +import "../../../components/ha-chip"; import "../../../components/ha-fab"; import "../../../components/ha-icon-button"; +import "../../../components/ha-icon-overflow-menu"; import "../../../components/ha-svg-icon"; -import type { AutomationEntity } from "../../../data/automation"; -import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; +import { + AutomationEntity, + deleteAutomation, + getAutomationConfig, + showAutomationEditor, + triggerAutomationActions, +} from "../../../data/automation"; +import { + showAlertDialog, + showConfirmationDialog, +} from "../../../dialogs/generic/show-dialog-box"; import "../../../layouts/hass-tabs-subpage-data-table"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant, Route } from "../../../types"; @@ -63,6 +86,7 @@ class HaAutomationPicker extends LitElement { ...automation, name: computeStateName(automation), last_triggered: automation.attributes.last_triggered || undefined, + disabled: automation.state === "off", })); } ); @@ -123,22 +147,105 @@ class HaAutomationPicker extends LitElement { }, }; } + + columns.disabled = this.narrow + ? { + title: "", + template: (disabled: boolean) => + disabled + ? html` + + ${this.hass.localize( + "ui.panel.config.automation.picker.disabled" + )} + + + ` + : "", + } + : { + width: "20%", + title: "", + template: (disabled: boolean) => + disabled + ? html` + + ${this.hass.localize( + "ui.panel.config.automation.picker.disabled" + )} + + ` + : "", + }; + columns.actions = { title: "", - label: this.hass.localize( - "ui.panel.config.automation.picker.headers.actions" - ), - type: "icon-button", - template: (_info, automation: any) => html` - - `, + width: this.narrow ? undefined : "10%", + type: "overflow-menu", + template: (_: string, automation: any) => + html` + this._showInfo(automation), + }, + { + path: mdiPlay, + label: this.hass.localize( + "ui.panel.config.automation.editor.run" + ), + action: () => this._runActions(automation), + }, + { + path: mdiTransitConnection, + label: this.hass.localize( + "ui.panel.config.automation.editor.show_trace" + ), + action: () => this._showTrace(automation), + }, + { + path: mdiContentDuplicate, + label: this.hass.localize( + "ui.panel.config.automation.picker.duplicate" + ), + action: () => this.duplicate(automation), + }, + { + path: + automation.state === "off" + ? mdiPlayCircleOutline + : mdiStopCircleOutline, + label: + automation.state === "off" + ? this.hass.localize( + "ui.panel.config.automation.editor.enable" + ) + : this.hass.localize( + "ui.panel.config.automation.editor.disable" + ), + action: () => this._toggle(automation), + }, + { + label: this.hass.localize( + "ui.panel.config.automation.picker.delete" + ), + path: mdiDelete, + action: () => this._deleteConfirm(automation), + warning: true, + }, + ]} + > + + `, }; return columns; } @@ -210,12 +317,52 @@ class HaAutomationPicker extends LitElement { this._filterValue = undefined; } - private _showInfo(ev) { - ev.stopPropagation(); - const automation = ev.currentTarget.automation; + private _showInfo(automation: any) { fireEvent(this, "hass-more-info", { entityId: automation.entity_id }); } + private _runActions(automation: any) { + triggerAutomationActions(this.hass, automation.entity_id); + } + + private _showTrace(automation: any) { + navigate(`/config/automation/trace/${automation.attributes.id}`); + } + + private async _toggle(automation): Promise { + const service = automation.state === "off" ? "turn_on" : "turn_off"; + await this.hass.callService("automation", service, { + entity_id: automation.entity_id, + }); + } + + private async _deleteConfirm(automation) { + showConfirmationDialog(this, { + text: this.hass.localize( + "ui.panel.config.automation.picker.delete_confirm" + ), + confirmText: this.hass!.localize("ui.common.delete"), + dismissText: this.hass!.localize("ui.common.cancel"), + confirm: () => this._delete(automation), + }); + } + + private async _delete(automation) { + await deleteAutomation(this.hass, automation.attributes.id); + } + + private async duplicate(automation) { + const config = await getAutomationConfig( + this.hass, + automation.attributes.id + ); + showAutomationEditor({ + ...config, + id: undefined, + alias: undefined, + }); + } + private _showHelp() { showAlertDialog(this, { title: this.hass.localize("ui.panel.config.automation.caption"), diff --git a/src/translations/en.json b/src/translations/en.json index 920ec90499..e38adf3c96 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1793,6 +1793,7 @@ "delete": "Delete", "delete_confirm": "Are you sure you want to delete this automation?", "duplicate": "Duplicate", + "disabled": "Disabled", "headers": { "toggle": "Enable/disable", "name": "Name", @@ -1822,6 +1823,7 @@ "run": "[%key:ui::panel::config::automation::editor::actions::run%]", "rename": "[%key:ui::panel::config::automation::editor::triggers::rename%]", "show_trace": "Traces", + "show_info": "Information", "introduction": "Use automations to bring your home to life.", "default_name": "New Automation", "missing_name": "Cannot save automation without a name", From efa4f65686472e700fd60958fbae097151282300 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Fri, 2 Sep 2022 19:02:01 +0200 Subject: [PATCH 3/7] Add information in overflow menu (#13570) --- .../config/automation/ha-automation-editor.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index bc4068b2b0..37b7a915b7 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -5,6 +5,7 @@ import { mdiContentSave, mdiDelete, mdiDotsVertical, + mdiInformationOutline, mdiPencil, mdiPlay, mdiPlayCircleOutline, @@ -25,6 +26,7 @@ import { } from "lit"; import { property, state, query } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; +import { fireEvent } from "../../../common/dom/fire_event"; import { navigate } from "../../../common/navigate"; import { copyToClipboard } from "../../../common/util/copy-clipboard"; import "../../../components/ha-button-menu"; @@ -125,6 +127,14 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { .path=${mdiDotsVertical} > + + ${this.hass.localize("ui.panel.config.automation.editor.show_info")} + + + Date: Fri, 2 Sep 2022 19:02:36 +0200 Subject: [PATCH 4/7] Improve blueprint editor layout (#13564) --- .../automation/blueprint-automation-editor.ts | 83 +++++++------------ .../config/automation/ha-automation-editor.ts | 3 +- 2 files changed, 30 insertions(+), 56 deletions(-) diff --git a/src/panels/config/automation/blueprint-automation-editor.ts b/src/panels/config/automation/blueprint-automation-editor.ts index 5215c06dd1..be9c0ec9c1 100644 --- a/src/panels/config/automation/blueprint-automation-editor.ts +++ b/src/panels/config/automation/blueprint-automation-editor.ts @@ -1,6 +1,6 @@ import "@material/mwc-button/mwc-button"; import { HassEntity } from "home-assistant-js-websocket"; -import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit"; +import { css, CSSResultGroup, html, LitElement } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../common/dom/fire_event"; import "../../../components/ha-blueprint-picker"; @@ -34,8 +34,6 @@ export class HaBlueprintAutomationEditor extends LitElement { @state() private _blueprints?: Blueprints; - @state() private _showDescription = false; - protected firstUpdated(changedProps) { super.firstUpdated(changedProps); this._getBlueprints(); @@ -48,55 +46,28 @@ export class HaBlueprintAutomationEditor extends LitElement { return this._blueprints[this.config.use_blueprint.path]; } - protected willUpdate(changedProps: PropertyValues): void { - super.willUpdate(changedProps); - if ( - !this._showDescription && - changedProps.has("config") && - this.config.description - ) { - this._showDescription = true; - } - } - protected render() { const blueprint = this._blueprint; return html` - - - ${this.hass.localize( - "ui.panel.config.automation.editor.introduction" - )} - - -
- ${this._showDescription - ? html` - - ` - : html` - - `} -
-
-
+

+ ${this.hass.localize("ui.panel.config.automation.editor.introduction")} +

+ +
+ +
+
Date: Fri, 2 Sep 2022 19:02:50 +0200 Subject: [PATCH 5/7] Fix automation trace link (#13563) --- src/panels/config/automation/ha-automation-editor.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 2d4e5a4afe..70c0d5a7f0 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -144,15 +144,9 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
- ${stateObj - ? html` - + ${stateObj && this._config + ? html` + ${this.hass.localize( "ui.panel.config.automation.editor.show_trace" )} From 031ecf5be8c5acb84e81ffc3678bc8d00122a64d Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Fri, 2 Sep 2022 19:03:53 +0200 Subject: [PATCH 6/7] Align visuals of automation and script editor after redesign (#13567) --- .../config/automation/action/ha-automation-action-row.ts | 8 ++++++++ .../automation/condition/ha-automation-condition-row.ts | 8 ++++++++ .../automation/trigger/ha-automation-trigger-row.ts | 8 ++++++++ src/panels/config/script/ha-script-editor.ts | 4 +++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index 2df0a0f60d..310b38c90d 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -230,6 +230,7 @@ export default class HaAutomationActionRow extends LitElement { ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")} ${!yamlMode ? html`` @@ -242,6 +243,7 @@ export default class HaAutomationActionRow extends LitElement { )} ${yamlMode ? html`` @@ -539,6 +541,12 @@ export default class HaAutomationActionRow extends LitElement { .warning ul { margin: 4px 0; } + .selected_menu_item { + color: var(--primary-color); + } + li[role="separator"] { + border-bottom-color: var(--divider-color); + } `, ]; } diff --git a/src/panels/config/automation/condition/ha-automation-condition-row.ts b/src/panels/config/automation/condition/ha-automation-condition-row.ts index 23f59cde9e..8c2f1204b5 100644 --- a/src/panels/config/automation/condition/ha-automation-condition-row.ts +++ b/src/panels/config/automation/condition/ha-automation-condition-row.ts @@ -145,6 +145,7 @@ export default class HaAutomationConditionRow extends LitElement { ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")} ${!this._yamlMode ? html`` @@ -157,6 +158,7 @@ export default class HaAutomationConditionRow extends LitElement { )} ${this._yamlMode ? html`` @@ -477,6 +479,12 @@ export default class HaAutomationConditionRow extends LitElement { .testing.pass { background-color: var(--success-color); } + .selected_menu_item { + color: var(--primary-color); + } + li[role="separator"] { + border-bottom-color: var(--divider-color); + } `, ]; } diff --git a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts index b2bac12383..b3c32cdc92 100644 --- a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts +++ b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts @@ -170,6 +170,7 @@ export default class HaAutomationTriggerRow extends LitElement { ${this.hass.localize("ui.panel.config.automation.editor.edit_ui")} ${!yamlMode ? html`` @@ -182,6 +183,7 @@ export default class HaAutomationTriggerRow extends LitElement { )} ${yamlMode ? html`` @@ -592,6 +594,12 @@ export default class HaAutomationTriggerRow extends LitElement { display: block; margin-bottom: 24px; } + .selected_menu_item { + color: var(--primary-color); + } + li[role="separator"] { + border-bottom-color: var(--divider-color); + } `, ]; } diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 2fcd139bf8..f740f48421 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -210,7 +210,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { "ui.panel.config.automation.editor.edit_yaml" )} graphic="icon" - ?activated=${this._mode === "yaml"} > ${this.hass.localize("ui.panel.config.automation.editor.edit_yaml")} ${this._mode === "yaml" @@ -833,6 +832,9 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { font-weight: 400; flex: 1; } + .header a { + color: var(--secondary-text-color); + } `, ]; } From 72aea57105fdba80cff53ce3e8f919a2b9d5f9bf Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 2 Sep 2022 16:14:53 -0400 Subject: [PATCH 7/7] Bumped version to 20220902.0 --- pyproject.toml | 2 +- src/layouts/hass-subpage.ts | 32 +++++++++++++++++++ .../config/automation/ha-automation-editor.ts | 6 ++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9a413e0d22..38b0d8ad8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20220901.0" +version = "20220902.0" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md" diff --git a/src/layouts/hass-subpage.ts b/src/layouts/hass-subpage.ts index d8658966e5..10859151c8 100644 --- a/src/layouts/hass-subpage.ts +++ b/src/layouts/hass-subpage.ts @@ -15,6 +15,8 @@ class HassSubpage extends LitElement { @property({ type: String, attribute: "back-path" }) public backPath?: string; + @property() public backCallback?: () => void; + @property({ type: Boolean, reflect: true }) public narrow = false; @property({ type: Boolean }) public supervisor = false; @@ -52,6 +54,9 @@ class HassSubpage extends LitElement {
+
+ +
`; } @@ -61,6 +66,10 @@ class HassSubpage extends LitElement { } private _backTapped(): void { + if (this.backCallback) { + this.backCallback(); + return; + } history.back(); } @@ -116,6 +125,29 @@ class HassSubpage extends LitElement { overflow: auto; -webkit-overflow-scrolling: touch; } + + #fab { + position: fixed; + right: calc(16px + env(safe-area-inset-right)); + bottom: calc(16px + env(safe-area-inset-bottom)); + z-index: 1; + } + :host([narrow]) #fab.tabs { + bottom: calc(84px + env(safe-area-inset-bottom)); + } + #fab[is-wide] { + bottom: 24px; + right: 24px; + } + :host([rtl]) #fab { + right: auto; + left: calc(16px + env(safe-area-inset-left)); + } + :host([rtl][is-wide]) #fab { + bottom: 24px; + left: 24px; + right: auto; + } `; } } diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 70c0d5a7f0..77cd37c48c 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -51,7 +51,7 @@ import { showPromptDialog, } from "../../../dialogs/generic/show-dialog-box"; import "../../../layouts/ha-app-layout"; -import "../../../layouts/hass-tabs-subpage"; +import "../../../layouts/hass-subpage"; import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant, Route } from "../../../types"; @@ -113,7 +113,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { ? this.hass.states[this._entityId] : undefined; return html` - - + `; }