Add menu with remove option to application credentials (#21139)

This commit is contained in:
Bram Kragten 2024-06-26 09:47:46 +02:00 committed by GitHub
parent 76daa2bb7f
commit 57d8544dbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 52 additions and 8 deletions

View File

@ -11,6 +11,7 @@ import {
import "../../../components/ha-fab";
import "../../../components/ha-help-tooltip";
import "../../../components/ha-svg-icon";
import "../../../components/ha-icon-overflow-menu";
import {
ApplicationCredential,
deleteApplicationCredential,
@ -70,6 +71,26 @@ export class HaConfigApplicationCredentials extends LitElement {
width: "30%",
direction: "asc",
},
actions: {
title: "",
width: "64px",
type: "overflow-menu",
template: (credential) => html`
<ha-icon-overflow-menu
.hass=${this.hass}
narrow
.items=${[
{
path: mdiDelete,
warning: true,
label: this.hass.localize("ui.common.delete"),
action: () => this._removeCredential(credential),
},
]}
>
</ha-icon-overflow-menu>
`,
},
};
return columns;
@ -153,6 +174,24 @@ export class HaConfigApplicationCredentials extends LitElement {
this._selected = ev.detail.value;
}
private _removeCredential = async (credential) => {
const confirm = await showConfirmationDialog(this, {
title: this.hass.localize(
`ui.panel.config.application_credentials.picker.remove.confirm_title`
),
text: this.hass.localize(
"ui.panel.config.application_credentials.picker.remove_selected.confirm_text"
),
confirmText: this.hass.localize("ui.common.delete"),
dismissText: this.hass.localize("ui.common.cancel"),
destructive: true,
});
if (!confirm) {
return;
}
await deleteApplicationCredential(this.hass, credential.id);
};
private _removeSelected() {
showConfirmationDialog(this, {
title: this.hass.localize(
@ -162,8 +201,9 @@ export class HaConfigApplicationCredentials extends LitElement {
text: this.hass.localize(
"ui.panel.config.application_credentials.picker.remove_selected.confirm_text"
),
confirmText: this.hass.localize("ui.common.remove"),
confirmText: this.hass.localize("ui.common.delete"),
dismissText: this.hass.localize("ui.common.cancel"),
destructive: true,
confirm: async () => {
try {
await Promise.all(

View File

@ -4253,9 +4253,9 @@
"config_entry": {
"application_credentials": {
"delete_title": "Application credentials",
"delete_prompt": "Would you like to also remove Application Credentials for this integration?",
"delete_detail": "If you remove them, you will need to enter credentials when setting up the integration again. If you keep them, they will be used automatically when setting up the integration again or may be acccessed from the Application Credentials menu.",
"delete_error_title": "Removing application credentials failed",
"delete_prompt": "Would you like to also delete Application Credentials for this integration?",
"delete_detail": "If you delete them, you will need to enter credentials when setting up the integration again. If you keep them, they will be used automatically when setting up the integration again or may be acccessed from the Application Credentials menu.",
"delete_error_title": "Deleting application credentials failed",
"dismiss": "Keep",
"learn_more": "Learn more about application credentials"
},
@ -4454,11 +4454,15 @@
"client_id": "OAuth client ID",
"application": "Integration"
},
"remove": {
"button": "Delete application credential",
"confirm_title": "Delete application credential?"
},
"remove_selected": {
"button": "Remove selected",
"confirm_title": "Do you want to remove {number} {number, plural,\n one {credential}\n other {credentials}\n}?",
"confirm_text": "Application credentials in use by an integration may not be removed.",
"error_title": "Removing application credentials failed"
"button": "Delete selected",
"confirm_title": "Do you want to delete {number} {number, plural,\n one {credential}\n other {credentials}\n}?",
"confirm_text": "Application credentials in use by an integration may not be deleted.",
"error_title": "Deleting application credentials failed"
},
"selected": "{number} selected"
}