Skip to content

Commit

Permalink
Add menu with remove option to application credentials (#21139)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jun 26, 2024
1 parent 76daa2b commit 57d8544
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
18 changes: 11 additions & 7 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
}
Expand Down

0 comments on commit 57d8544

Please sign in to comment.