mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Fix config entry menu (#20908)
This commit is contained in:
parent
c0e048023d
commit
c00287c401
@ -1,6 +1,6 @@
|
|||||||
import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
|
import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
|
||||||
import "@material/mwc-list/mwc-list";
|
import "@material/mwc-list/mwc-list";
|
||||||
import { RequestSelectedDetail } from "@material/mwc-list/mwc-list-item-base";
|
import "@material/web/divider/divider";
|
||||||
import {
|
import {
|
||||||
mdiAlertCircle,
|
mdiAlertCircle,
|
||||||
mdiBookshelf,
|
mdiBookshelf,
|
||||||
@ -27,13 +27,13 @@ import {
|
|||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import {
|
import {
|
||||||
css,
|
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
|
||||||
LitElement,
|
LitElement,
|
||||||
nothing,
|
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
|
css,
|
||||||
|
html,
|
||||||
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { classMap } from "lit/directives/class-map";
|
import { classMap } from "lit/directives/class-map";
|
||||||
@ -41,15 +41,15 @@ import { until } from "lit/directives/until";
|
|||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
import { isDevVersion } from "../../../common/config/version";
|
import { isDevVersion } from "../../../common/config/version";
|
||||||
import { shouldHandleRequestSelectedEvent } from "../../../common/mwc/handle-request-selected-event";
|
|
||||||
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
|
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
|
||||||
import { nextRender } from "../../../common/util/render-status";
|
import { nextRender } from "../../../common/util/render-status";
|
||||||
import "../../../components/ha-button";
|
import "../../../components/ha-button";
|
||||||
|
import "../../../components/ha-button-menu-new";
|
||||||
import "../../../components/ha-card";
|
import "../../../components/ha-card";
|
||||||
import "../../../components/ha-list-item";
|
import "../../../components/ha-list-item";
|
||||||
import "../../../components/ha-list-new";
|
|
||||||
import "../../../components/ha-list-item-new";
|
import "../../../components/ha-list-item-new";
|
||||||
import "../../../components/ha-button-menu-new";
|
import "../../../components/ha-list-new";
|
||||||
|
import "../../../components/ha-menu-item";
|
||||||
import {
|
import {
|
||||||
deleteApplicationCredential,
|
deleteApplicationCredential,
|
||||||
fetchApplicationCredentialsConfigEntry,
|
fetchApplicationCredentialsConfigEntry,
|
||||||
@ -57,13 +57,13 @@ import {
|
|||||||
import { getSignedPath } from "../../../data/auth";
|
import { getSignedPath } from "../../../data/auth";
|
||||||
import {
|
import {
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
|
DisableConfigEntryResult,
|
||||||
|
ERROR_STATES,
|
||||||
|
RECOVERABLE_STATES,
|
||||||
deleteConfigEntry,
|
deleteConfigEntry,
|
||||||
disableConfigEntry,
|
disableConfigEntry,
|
||||||
DisableConfigEntryResult,
|
|
||||||
enableConfigEntry,
|
enableConfigEntry,
|
||||||
ERROR_STATES,
|
|
||||||
getConfigEntries,
|
getConfigEntries,
|
||||||
RECOVERABLE_STATES,
|
|
||||||
reloadConfigEntry,
|
reloadConfigEntry,
|
||||||
updateConfigEntry,
|
updateConfigEntry,
|
||||||
} from "../../../data/config_entries";
|
} from "../../../data/config_entries";
|
||||||
@ -80,13 +80,13 @@ import {
|
|||||||
} from "../../../data/entity_registry";
|
} from "../../../data/entity_registry";
|
||||||
import { getErrorLogDownloadUrl } from "../../../data/error_log";
|
import { getErrorLogDownloadUrl } from "../../../data/error_log";
|
||||||
import {
|
import {
|
||||||
|
IntegrationLogInfo,
|
||||||
|
IntegrationManifest,
|
||||||
|
LogSeverity,
|
||||||
domainToName,
|
domainToName,
|
||||||
fetchIntegrationManifest,
|
fetchIntegrationManifest,
|
||||||
integrationIssuesUrl,
|
integrationIssuesUrl,
|
||||||
IntegrationLogInfo,
|
|
||||||
IntegrationManifest,
|
|
||||||
integrationsWithPanel,
|
integrationsWithPanel,
|
||||||
LogSeverity,
|
|
||||||
setIntegrationLogLevel,
|
setIntegrationLogLevel,
|
||||||
subscribeLogInfo,
|
subscribeLogInfo,
|
||||||
} from "../../../data/integration";
|
} from "../../../data/integration";
|
||||||
@ -792,104 +792,98 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
RECOVERABLE_STATES.includes(item.state) &&
|
RECOVERABLE_STATES.includes(item.state) &&
|
||||||
item.supports_unload &&
|
item.supports_unload &&
|
||||||
item.source !== "system"
|
item.source !== "system"
|
||||||
? html`<ha-list-item
|
? html`
|
||||||
@request-selected=${this._handleReload}
|
<ha-menu-item @click=${this._handleReload}>
|
||||||
graphic="icon"
|
<ha-svg-icon slot="start" .path=${mdiReload}></ha-svg-icon>
|
||||||
>
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_entry.reload"
|
"ui.panel.config.integrations.config_entry.reload"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiReload}></ha-svg-icon>
|
</ha-menu-item>
|
||||||
</ha-list-item>`
|
`
|
||||||
: ""}
|
: nothing}
|
||||||
|
|
||||||
<ha-list-item @request-selected=${this._handleRename} graphic="icon">
|
<ha-menu-item @click=${this._handleRename} graphic="icon">
|
||||||
|
<ha-svg-icon slot="start" .path=${mdiRenameBox}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_entry.rename"
|
"ui.panel.config.integrations.config_entry.rename"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiRenameBox}></ha-svg-icon>
|
</ha-menu-item>
|
||||||
</ha-list-item>
|
|
||||||
|
|
||||||
<li divider role="separator"></li>
|
<md-divider role="separator" tabindex="-1"></md-divider>
|
||||||
|
|
||||||
${this._diagnosticHandler && item.state === "loaded"
|
${this._diagnosticHandler && item.state === "loaded"
|
||||||
? html`<a
|
? html`
|
||||||
|
<ha-menu-item
|
||||||
href=${getConfigEntryDiagnosticsDownloadUrl(item.entry_id)}
|
href=${getConfigEntryDiagnosticsDownloadUrl(item.entry_id)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@click=${this._signUrl}
|
@click=${this._signUrl}
|
||||||
>
|
>
|
||||||
<ha-list-item graphic="icon">
|
<ha-svg-icon slot="start" .path=${mdiDownload}></ha-svg-icon>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_entry.download_diagnostics"
|
"ui.panel.config.integrations.config_entry.download_diagnostics"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiDownload}></ha-svg-icon>
|
</ha-menu-item>
|
||||||
</ha-list-item>
|
`
|
||||||
</a>`
|
|
||||||
: ""}
|
: ""}
|
||||||
${!item.disabled_by &&
|
${!item.disabled_by &&
|
||||||
item.supports_reconfigure &&
|
item.supports_reconfigure &&
|
||||||
item.source !== "system"
|
item.source !== "system"
|
||||||
? html`<ha-list-item
|
? html`
|
||||||
@request-selected=${this._handleReconfigure}
|
<ha-menu-item @click=${this._handleReconfigure}>
|
||||||
graphic="icon"
|
<ha-svg-icon slot="start" .path=${mdiWrench}></ha-svg-icon>
|
||||||
>
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_entry.reconfigure"
|
"ui.panel.config.integrations.config_entry.reconfigure"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiWrench}></ha-svg-icon>
|
</ha-menu-item>
|
||||||
</ha-list-item>`
|
`
|
||||||
: ""}
|
: nothing}
|
||||||
|
|
||||||
<ha-list-item
|
<ha-menu-item @click=${this._handleSystemOptions} graphic="icon">
|
||||||
@request-selected=${this._handleSystemOptions}
|
<ha-svg-icon slot="start" .path=${mdiCog}></ha-svg-icon>
|
||||||
graphic="icon"
|
|
||||||
>
|
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.integrations.config_entry.system_options"
|
"ui.panel.config.integrations.config_entry.system_options"
|
||||||
)}
|
)}
|
||||||
<ha-svg-icon slot="graphic" .path=${mdiCog}></ha-svg-icon>
|
</ha-menu-item>
|
||||||
</ha-list-item>
|
|
||||||
${item.disabled_by === "user"
|
${item.disabled_by === "user"
|
||||||
? html`<ha-list-item
|
? html`
|
||||||
@request-selected=${this._handleEnable}
|
<ha-menu-item @click=${this._handleEnable}>
|
||||||
graphic="icon"
|
|
||||||
>
|
|
||||||
${this.hass.localize("ui.common.enable")}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="start"
|
||||||
.path=${mdiPlayCircleOutline}
|
.path=${mdiPlayCircleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>`
|
${this.hass.localize("ui.common.enable")}
|
||||||
|
</ha-menu-item>
|
||||||
|
`
|
||||||
: item.source !== "system"
|
: item.source !== "system"
|
||||||
? html`<ha-list-item
|
? html`
|
||||||
|
<ha-menu-item
|
||||||
class="warning"
|
class="warning"
|
||||||
@request-selected=${this._handleDisable}
|
@click=${this._handleDisable}
|
||||||
graphic="icon"
|
graphic="icon"
|
||||||
>
|
>
|
||||||
${this.hass.localize("ui.common.disable")}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="start"
|
||||||
class="warning"
|
class="warning"
|
||||||
.path=${mdiStopCircleOutline}
|
.path=${mdiStopCircleOutline}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>`
|
${this.hass.localize("ui.common.disable")}
|
||||||
: ""}
|
</ha-menu-item>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
${item.source !== "system"
|
${item.source !== "system"
|
||||||
? html`<ha-list-item
|
? html`
|
||||||
class="warning"
|
<ha-menu-item class="warning" @click=${this._handleDelete}>
|
||||||
@request-selected=${this._handleDelete}
|
|
||||||
graphic="icon"
|
|
||||||
>
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.integrations.config_entry.delete"
|
|
||||||
)}
|
|
||||||
<ha-svg-icon
|
<ha-svg-icon
|
||||||
slot="graphic"
|
slot="start"
|
||||||
class="warning"
|
class="warning"
|
||||||
.path=${mdiDelete}
|
.path=${mdiDelete}
|
||||||
></ha-svg-icon>
|
></ha-svg-icon>
|
||||||
</ha-list-item>`
|
${this.hass.localize(
|
||||||
: ""}
|
"ui.panel.config.integrations.config_entry.delete"
|
||||||
|
)}
|
||||||
|
</ha-menu-item>
|
||||||
|
`
|
||||||
|
: nothing}
|
||||||
</ha-button-menu-new>
|
</ha-button-menu-new>
|
||||||
</ha-list-item-new>`;
|
</ha-list-item-new>`;
|
||||||
}
|
}
|
||||||
@ -1055,64 +1049,43 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleRename(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleRename(ev: Event): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._editEntryName(
|
this._editEntryName(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleReload(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleReload(ev: Event): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._reloadIntegration(
|
this._reloadIntegration(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleReconfigure(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleReconfigure(ev: Event): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._reconfigureIntegration(
|
this._reconfigureIntegration(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleDelete(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleDelete(ev: Event): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._removeIntegration(
|
this._removeIntegration(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleDisable(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleDisable(ev: Event): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._disableIntegration(
|
this._disableIntegration(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleEnable(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleEnable(ev: Event): void {
|
||||||
if (ev.detail.source && !shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._enableIntegration(
|
this._enableIntegration(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleSystemOptions(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleSystemOptions(ev: Event): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._showSystemOptions(
|
this._showSystemOptions(
|
||||||
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
((ev.target as HTMLElement).closest(".config_entry") as any).configEntry
|
||||||
);
|
);
|
||||||
@ -1327,7 +1300,7 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _signUrl(ev) {
|
private async _signUrl(ev) {
|
||||||
const anchor = ev.target.closest("a");
|
const anchor = ev.currentTarget;
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
const signedUrl = await getSignedPath(
|
const signedUrl = await getSignedPath(
|
||||||
this.hass,
|
this.hass,
|
||||||
@ -1438,8 +1411,8 @@ class HaConfigIntegrationPage extends SubscribeMixin(LitElement) {
|
|||||||
--mdc-list-item-meta-size: auto;
|
--mdc-list-item-meta-size: auto;
|
||||||
--mdc-list-item-meta-display: flex;
|
--mdc-list-item-meta-display: flex;
|
||||||
}
|
}
|
||||||
ha-button-menu-new ha-list-item {
|
ha-button-menu-new ha-menu-item {
|
||||||
--mdc-list-item-meta-size: 24px;
|
--mdc-icon-size: 24px;
|
||||||
}
|
}
|
||||||
ha-list-item-new.config_entry::after {
|
ha-list-item-new.config_entry::after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user