mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Add an application credentials display name (#12720)
Co-authored-by: Bram Kragten <mail@bramkragten.nl> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
6ab19d66d5
commit
9a9eec40b2
@ -9,6 +9,7 @@ export interface ApplicationCredential {
|
|||||||
domain: string;
|
domain: string;
|
||||||
client_id: string;
|
client_id: string;
|
||||||
client_secret: string;
|
client_secret: string;
|
||||||
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchApplicationCredentialsConfig = async (hass: HomeAssistant) =>
|
export const fetchApplicationCredentialsConfig = async (hass: HomeAssistant) =>
|
||||||
@ -25,13 +26,15 @@ export const createApplicationCredential = async (
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
domain: string,
|
domain: string,
|
||||||
clientId: string,
|
clientId: string,
|
||||||
clientSecret: string
|
clientSecret: string,
|
||||||
|
name?: string
|
||||||
) =>
|
) =>
|
||||||
hass.callWS<ApplicationCredential>({
|
hass.callWS<ApplicationCredential>({
|
||||||
type: "application_credentials/create",
|
type: "application_credentials/create",
|
||||||
domain,
|
domain,
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
client_secret: clientSecret,
|
client_secret: clientSecret,
|
||||||
|
name,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const deleteApplicationCredential = async (
|
export const deleteApplicationCredential = async (
|
||||||
|
@ -41,6 +41,8 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
|
|
||||||
@state() private _domain?: string;
|
@state() private _domain?: string;
|
||||||
|
|
||||||
|
@state() private _name?: string;
|
||||||
|
|
||||||
@state() private _clientId?: string;
|
@state() private _clientId?: string;
|
||||||
|
|
||||||
@state() private _clientSecret?: string;
|
@state() private _clientSecret?: string;
|
||||||
@ -50,6 +52,7 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
public showDialog(params: AddApplicationCredentialDialogParams) {
|
public showDialog(params: AddApplicationCredentialDialogParams) {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
this._domain = "";
|
this._domain = "";
|
||||||
|
this._name = "";
|
||||||
this._clientId = "";
|
this._clientId = "";
|
||||||
this._clientSecret = "";
|
this._clientSecret = "";
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
@ -99,6 +102,18 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
required
|
required
|
||||||
@value-changed=${this._handleDomainPicked}
|
@value-changed=${this._handleDomainPicked}
|
||||||
></ha-combo-box>
|
></ha-combo-box>
|
||||||
|
<ha-textfield
|
||||||
|
class="name"
|
||||||
|
name="name"
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.application_credentials.editor.name"
|
||||||
|
)}
|
||||||
|
.value=${this._name}
|
||||||
|
required
|
||||||
|
@input=${this._handleValueChanged}
|
||||||
|
error-message=${this.hass.localize("ui.common.error_required")}
|
||||||
|
dialogInitialFocus
|
||||||
|
></ha-textfield>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
class="clientId"
|
class="clientId"
|
||||||
name="clientId"
|
name="clientId"
|
||||||
@ -181,7 +196,8 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
this.hass,
|
this.hass,
|
||||||
this._domain,
|
this._domain,
|
||||||
this._clientId,
|
this._clientId,
|
||||||
this._clientSecret
|
this._clientSecret,
|
||||||
|
this._name
|
||||||
);
|
);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
|
@ -49,13 +49,22 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
private _columns = memoizeOne(
|
private _columns = memoizeOne(
|
||||||
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
|
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
|
||||||
const columns: DataTableColumnContainer<ApplicationCredential> = {
|
const columns: DataTableColumnContainer<ApplicationCredential> = {
|
||||||
|
name: {
|
||||||
|
title: localize(
|
||||||
|
"ui.panel.config.application_credentials.picker.headers.name"
|
||||||
|
),
|
||||||
|
width: "40%",
|
||||||
|
direction: "asc",
|
||||||
|
grows: true,
|
||||||
|
template: (_, entry: ApplicationCredential) => html`${entry.name}`,
|
||||||
|
},
|
||||||
clientId: {
|
clientId: {
|
||||||
title: localize(
|
title: localize(
|
||||||
"ui.panel.config.application_credentials.picker.headers.client_id"
|
"ui.panel.config.application_credentials.picker.headers.client_id"
|
||||||
),
|
),
|
||||||
width: "25%",
|
width: "30%",
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
grows: true,
|
hidden: narrow,
|
||||||
template: (_, entry: ApplicationCredential) =>
|
template: (_, entry: ApplicationCredential) =>
|
||||||
html`${entry.client_id}`,
|
html`${entry.client_id}`,
|
||||||
},
|
},
|
||||||
@ -64,9 +73,8 @@ export class HaConfigApplicationCredentials extends LitElement {
|
|||||||
"ui.panel.config.application_credentials.picker.headers.application"
|
"ui.panel.config.application_credentials.picker.headers.application"
|
||||||
),
|
),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
width: "20%",
|
width: "30%",
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
hidden: narrow,
|
|
||||||
template: (_, entry) => html`${domainToName(localize, entry.domain)}`,
|
template: (_, entry) => html`${domainToName(localize, entry.domain)}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -2883,12 +2883,14 @@
|
|||||||
"caption": "Add Application Credential",
|
"caption": "Add Application Credential",
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
"domain": "Integration",
|
"domain": "Integration",
|
||||||
|
"name": "Name",
|
||||||
"client_id": "OAuth Client ID",
|
"client_id": "OAuth Client ID",
|
||||||
"client_secret": "OAuth Client Secret"
|
"client_secret": "OAuth Client Secret"
|
||||||
},
|
},
|
||||||
"picker": {
|
"picker": {
|
||||||
"add_application_credential": "Add Application Credential",
|
"add_application_credential": "Add Application Credential",
|
||||||
"headers": {
|
"headers": {
|
||||||
|
"name": "Name",
|
||||||
"client_id": "OAuth Client ID",
|
"client_id": "OAuth Client ID",
|
||||||
"application": "Integration"
|
"application": "Integration"
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user