Add delete action in label overflow menu (#20261)

This commit is contained in:
Paul Bottein 2024-03-29 10:25:54 +01:00 committed by GitHub
parent 510e010f97
commit 5dd029cc05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { mdiHelpCircle, mdiPlus } from "@mdi/js";
import { mdiDelete, mdiHelpCircle, mdiPlus } from "@mdi/js";
import { LitElement, PropertyValues, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
@ -11,6 +11,7 @@ import {
import "../../../components/ha-fab";
import "../../../components/ha-icon-button";
import "../../../components/ha-relative-time";
import "../../../components/ha-icon-overflow-menu";
import {
LabelRegistryEntry,
LabelRegistryEntryMutableParams,
@ -71,6 +72,26 @@ export class HaConfigLabels extends LitElement {
filterable: true,
grows: true,
},
actions: {
title: "",
width: "64px",
type: "overflow-menu",
template: (label) => html`
<ha-icon-overflow-menu
.hass=${this.hass}
narrow
.items=${[
{
label: this.hass.localize("ui.common.delete"),
path: mdiDelete,
action: () => this._removeLabel(label),
warning: true,
},
]}
>
</ha-icon-overflow-menu>
`,
},
};
return columns;
});
@ -189,6 +210,7 @@ export class HaConfigLabels extends LitElement {
}),
dismissText: this.hass!.localize("ui.common.cancel"),
confirmText: this.hass!.localize("ui.common.remove"),
destructive: true,
}))
) {
return false;