Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu with remove option to application credentials #21139

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,28 @@ 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.panel.config.application_credentials.picker.remove.button"
),
frenck marked this conversation as resolved.
Show resolved Hide resolved
action: () => this._removeCredential(credential),
},
]}
>
</ha-icon-overflow-menu>
`,
},
};

return columns;
Expand Down Expand Up @@ -153,6 +176,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.remove"),
dismissText: this.hass.localize("ui.common.cancel"),
destructive: true,
});
if (!confirm) {
return;
}
await deleteApplicationCredential(this.hass, credential.id);
};
frenck marked this conversation as resolved.
Show resolved Hide resolved

private _removeSelected() {
showConfirmationDialog(this, {
title: this.hass.localize(
Expand All @@ -164,6 +205,7 @@ export class HaConfigApplicationCredentials extends LitElement {
),
confirmText: this.hass.localize("ui.common.remove"),
dismissText: this.hass.localize("ui.common.cancel"),
destructive: true,
frenck marked this conversation as resolved.
Show resolved Hide resolved
confirm: async () => {
try {
await Promise.all(
Expand Down
4 changes: 4 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4441,6 +4441,10 @@
"client_id": "OAuth client ID",
"application": "Integration"
},
"remove": {
"button": "Remove application credential",
"confirm_title": "Remove application credential?"
},
"remove_selected": {
"button": "Remove selected",
"confirm_title": "Do you want to remove {number} {number, plural,\n one {credential}\n other {credentials}\n}?",
Expand Down
Loading