From 3e6a759309159bdd80dd38649f62e552e12c092c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 26 Aug 2020 15:53:25 +0200 Subject: [PATCH] Changes to add-on options (#6706) --- .../src/addon-view/info/hassio-addon-info.ts | 432 +++++++++--------- hassio/src/system/hassio-host-info.ts | 2 +- hassio/src/system/hassio-supervisor-info.ts | 2 +- 3 files changed, 230 insertions(+), 206 deletions(-) diff --git a/hassio/src/addon-view/info/hassio-addon-info.ts b/hassio/src/addon-view/info/hassio-addon-info.ts index c14ea9d475..a7b3796909 100644 --- a/hassio/src/addon-view/info/hassio-addon-info.ts +++ b/hassio/src/addon-view/info/hassio-addon-info.ts @@ -9,7 +9,6 @@ import { mdiExclamationThick, mdiFlask, mdiHomeAssistant, - mdiInformation, mdiKey, mdiNetwork, mdiPound, @@ -53,6 +52,7 @@ import { HomeAssistant } from "../../../../src/types"; import "../../components/hassio-card-content"; import { showHassioMarkdownDialog } from "../../dialogs/markdown/show-dialog-hassio-markdown"; import { hassioStyle } from "../../resources/hassio-style"; +import "../../../../src/components/ha-settings-row"; const STAGE_ICON = { stable: mdiCheckCircle, @@ -386,79 +386,94 @@ class HassioAddonInfo extends LitElement { ${this.addon.version ? html` -
-
Start on boot
- -
- ${this.hass.userData?.showAdvanced - ? html` -
-
Watchdog
- -
- ` - : ""} - ${this.addon.auto_update || this.hass.userData?.showAdvanced - ? html` -
-
Auto update
- -
- ` - : ""} - ${this.addon.ingress - ? html` -
-
Show in sidebar
- - ${this._computeCannotIngressSidebar - ? html` - - This option requires Home Assistant 0.92 or - later. - - ` - : ""} -
- ` - : ""} - ${this._computeUsesProtectedOptions - ? html` -
-
- Protection mode - - - - Grant the add-on elevated system access. - +
+ + + Start on boot + + + Make the add-on start during a system boot + + + + + ${this.hass.userData?.showAdvanced + ? html` + + + Watchdog -
- -
- ` - : ""} + + This will start the add-on if it crashes + + + + ` + : ""} + ${this.addon.auto_update || this.hass.userData?.showAdvanced + ? html` + + + Auto update + + + Auto update the add-on when there is a new version + available + + + + ` + : ""} + ${this.addon.ingress + ? html` + + + Show in sidebar + + + ${this._computeCannotIngressSidebar + ? "This option requires Home Assistant 0.92 or later." + : "Add this add-on to your sidebar"} + + + + ` + : ""} + ${this._computeUsesProtectedOptions + ? html` + + + Protection mode + + + Blocks elevated system access from the add-on + + + + ` + : ""} +
` : ""} ${this._error ? html`
${this._error}
` : ""} @@ -564,137 +579,6 @@ class HassioAddonInfo extends LitElement { `; } - static get styles(): CSSResult[] { - return [ - haStyle, - hassioStyle, - css` - :host { - display: block; - } - ha-card { - display: block; - margin-bottom: 16px; - } - ha-card.warning { - background-color: var(--error-color); - color: white; - } - ha-card.warning .card-header { - color: white; - } - ha-card.warning .card-content { - color: white; - } - ha-card.warning mwc-button { - --mdc-theme-primary: white !important; - } - .warning { - color: var(--error-color); - --mdc-theme-primary: var(--error-color); - } - .light-color { - color: var(--secondary-text-color); - } - .addon-header { - padding-left: 8px; - font-size: 24px; - color: var(--ha-card-header-color, --primary-text-color); - } - .addon-version { - float: right; - font-size: 15px; - vertical-align: middle; - } - .errors { - color: var(--error-color); - margin-bottom: 16px; - } - .description { - margin-bottom: 16px; - } - img.logo { - max-height: 60px; - margin: 16px 0; - display: block; - } - .state { - display: flex; - margin: 33px 0; - } - .state div { - width: 180px; - display: inline-block; - } - .state ha-svg-icon { - width: 16px; - height: 16px; - color: var(--secondary-text-color); - } - ha-switch { - display: flex; - } - ha-svg-icon.running { - color: var(--paper-green-400); - } - ha-svg-icon.stopped { - color: var(--google-red-300); - } - ha-call-api-button { - font-weight: 500; - color: var(--primary-color); - } - .right { - float: right; - } - protection-enable mwc-button { - --mdc-theme-primary: white; - } - .description a { - color: var(--primary-color); - } - .red { - --ha-label-badge-color: var(--label-badge-red, #df4c1e); - } - .blue { - --ha-label-badge-color: var(--label-badge-blue, #039be5); - } - .green { - --ha-label-badge-color: var(--label-badge-green, #0da035); - } - .yellow { - --ha-label-badge-color: var(--label-badge-yellow, #f4b400); - } - .security { - margin-bottom: 16px; - } - .card-actions { - display: flow-root; - } - .security h3 { - margin-bottom: 8px; - font-weight: normal; - } - .security ha-label-badge { - cursor: pointer; - margin-right: 4px; - --ha-label-badge-padding: 8px 0 0 0; - } - .changelog { - display: contents; - } - .changelog-link { - color: var(--primary-color); - text-decoration: underline; - cursor: pointer; - } - ha-markdown { - padding: 16px; - } - `, - ]; - } - private get _computeHassioApi(): boolean { return ( this.addon.hassio_api && @@ -917,6 +801,146 @@ class HassioAddonInfo extends LitElement { this._error = `Failed to uninstall addon, ${err.body?.message || err}`; } } + + static get styles(): CSSResult[] { + return [ + haStyle, + hassioStyle, + css` + :host { + display: block; + } + ha-card { + display: block; + margin-bottom: 16px; + } + ha-card.warning { + background-color: var(--error-color); + color: white; + } + ha-card.warning .card-header { + color: white; + } + ha-card.warning .card-content { + color: white; + } + ha-card.warning mwc-button { + --mdc-theme-primary: white !important; + } + .warning { + color: var(--error-color); + --mdc-theme-primary: var(--error-color); + } + .light-color { + color: var(--secondary-text-color); + } + .addon-header { + padding-left: 8px; + font-size: 24px; + color: var(--ha-card-header-color, --primary-text-color); + } + .addon-version { + float: right; + font-size: 15px; + vertical-align: middle; + } + .errors { + color: var(--error-color); + margin-bottom: 16px; + } + .description { + margin-bottom: 16px; + } + img.logo { + max-height: 60px; + margin: 16px 0; + display: block; + } + + ha-switch { + display: flex; + } + ha-svg-icon.running { + color: var(--paper-green-400); + } + ha-svg-icon.stopped { + color: var(--google-red-300); + } + ha-call-api-button { + font-weight: 500; + color: var(--primary-color); + } + .right { + float: right; + } + protection-enable mwc-button { + --mdc-theme-primary: white; + } + .description a { + color: var(--primary-color); + } + .red { + --ha-label-badge-color: var(--label-badge-red, #df4c1e); + } + .blue { + --ha-label-badge-color: var(--label-badge-blue, #039be5); + } + .green { + --ha-label-badge-color: var(--label-badge-green, #0da035); + } + .yellow { + --ha-label-badge-color: var(--label-badge-yellow, #f4b400); + } + .security { + margin-bottom: 16px; + } + .card-actions { + display: flow-root; + } + .security h3 { + margin-bottom: 8px; + font-weight: normal; + } + .security ha-label-badge { + cursor: pointer; + margin-right: 4px; + --ha-label-badge-padding: 8px 0 0 0; + } + .changelog { + display: contents; + } + .changelog-link { + color: var(--primary-color); + text-decoration: underline; + cursor: pointer; + } + ha-markdown { + padding: 16px; + } + ha-settings-row { + padding: 0; + height: 54px; + width: 100%; + } + ha-settings-row > span[slot="description"] { + white-space: normal; + color: var(--secondary-text-color); + } + ha-settings-row[three-line] { + height: 74px; + } + + .addon-options { + max-width: 50%; + } + @media (max-width: 720px) { + .addon-options { + max-width: 100%; + } + } + `, + ]; + } } declare global { interface HTMLElementTagNameMap { diff --git a/hassio/src/system/hassio-host-info.ts b/hassio/src/system/hassio-host-info.ts index 544e896adc..b8bd35fca5 100644 --- a/hassio/src/system/hassio-host-info.ts +++ b/hassio/src/system/hassio-host-info.ts @@ -206,7 +206,7 @@ class HassioHostInfo extends LitElement { ha-settings-row[three-line] { height: 74px; } - ha-settings-row[three-line] > div { + ha-settings-row > span[slot="description"] { white-space: normal; color: var(--secondary-text-color); } diff --git a/hassio/src/system/hassio-supervisor-info.ts b/hassio/src/system/hassio-supervisor-info.ts index 4ad09acde9..6213c829ba 100644 --- a/hassio/src/system/hassio-supervisor-info.ts +++ b/hassio/src/system/hassio-supervisor-info.ts @@ -173,7 +173,7 @@ class HassioSupervisorInfo extends LitElement { ha-settings-row[three-line] { height: 74px; } - ha-settings-row[three-line] > div { + ha-settings-row > span[slot="description"] { white-space: normal; color: var(--secondary-text-color); }