mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 08:16:36 +00:00
Update add application credentials dialog (#13879)
This commit is contained in:
parent
c79955e76a
commit
01fd2787be
@ -1,8 +1,9 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import "@material/mwc-list/mwc-list-item";
|
import "@material/mwc-list/mwc-list-item";
|
||||||
|
import { mdiOpenInNew } from "@mdi/js";
|
||||||
|
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
||||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { ComboBoxLitRenderer } from "@vaadin/combo-box/lit";
|
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
import { fireEvent } from "../../../common/dom/fire_event";
|
||||||
import "../../../components/ha-circular-progress";
|
import "../../../components/ha-circular-progress";
|
||||||
import "../../../components/ha-combo-box";
|
import "../../../components/ha-combo-box";
|
||||||
@ -10,14 +11,15 @@ import { createCloseHeading } from "../../../components/ha-dialog";
|
|||||||
import "../../../components/ha-markdown";
|
import "../../../components/ha-markdown";
|
||||||
import "../../../components/ha-textfield";
|
import "../../../components/ha-textfield";
|
||||||
import {
|
import {
|
||||||
fetchApplicationCredentialsConfig,
|
|
||||||
createApplicationCredential,
|
|
||||||
ApplicationCredentialsConfig,
|
|
||||||
ApplicationCredential,
|
ApplicationCredential,
|
||||||
|
ApplicationCredentialsConfig,
|
||||||
|
createApplicationCredential,
|
||||||
|
fetchApplicationCredentialsConfig,
|
||||||
} from "../../../data/application_credential";
|
} from "../../../data/application_credential";
|
||||||
import { domainToName } from "../../../data/integration";
|
import { domainToName } from "../../../data/integration";
|
||||||
import { haStyleDialog } from "../../../resources/styles";
|
import { haStyleDialog } from "../../../resources/styles";
|
||||||
import { HomeAssistant } from "../../../types";
|
import { HomeAssistant } from "../../../types";
|
||||||
|
import { documentationUrl } from "../../../util/documentation-url";
|
||||||
import { AddApplicationCredentialDialogParams } from "./show-dialog-add-application-credential";
|
import { AddApplicationCredentialDialogParams } from "./show-dialog-add-application-credential";
|
||||||
|
|
||||||
interface Domain {
|
interface Domain {
|
||||||
@ -98,6 +100,25 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
|
${this._error ? html` <div class="error">${this._error}</div> ` : ""}
|
||||||
|
<p>
|
||||||
|
${this.hass.localize(
|
||||||
|
"ui.panel.config.application_credentials.editor.description"
|
||||||
|
)}
|
||||||
|
<br />
|
||||||
|
<a
|
||||||
|
href=${documentationUrl(
|
||||||
|
this.hass!,
|
||||||
|
"/integrations/application_credentials"
|
||||||
|
)}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.panel.config.application_credentials.editor.view_documentation"
|
||||||
|
)}
|
||||||
|
<ha-svg-icon .path=${mdiOpenInNew}></ha-svg-icon>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
<ha-combo-box
|
<ha-combo-box
|
||||||
name="domain"
|
name="domain"
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@ -143,6 +164,10 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
@input=${this._handleValueChanged}
|
@input=${this._handleValueChanged}
|
||||||
error-message=${this.hass.localize("ui.common.error_required")}
|
error-message=${this.hass.localize("ui.common.error_required")}
|
||||||
dialogInitialFocus
|
dialogInitialFocus
|
||||||
|
.helper=${this.hass.localize(
|
||||||
|
"ui.panel.config.application_credentials.editor.client_id_helper"
|
||||||
|
)}
|
||||||
|
helperPersistent
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
<ha-textfield
|
<ha-textfield
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
@ -154,6 +179,10 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
required
|
required
|
||||||
@input=${this._handleValueChanged}
|
@input=${this._handleValueChanged}
|
||||||
error-message=${this.hass.localize("ui.common.error_required")}
|
error-message=${this.hass.localize("ui.common.error_required")}
|
||||||
|
.helper=${this.hass.localize(
|
||||||
|
"ui.panel.config.application_credentials.editor.client_secret_helper"
|
||||||
|
)}
|
||||||
|
helperPersistent
|
||||||
></ha-textfield>
|
></ha-textfield>
|
||||||
</div>
|
</div>
|
||||||
${this._loading
|
${this._loading
|
||||||
@ -163,15 +192,18 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
|
<mwc-button slot="primaryAction" @click=${this._abortDialog}>
|
||||||
|
${this.hass.localize("ui.common.cancel")}
|
||||||
|
</mwc-button>
|
||||||
<mwc-button
|
<mwc-button
|
||||||
slot="primaryAction"
|
slot="primaryAction"
|
||||||
.disabled=${!this._domain ||
|
.disabled=${!this._domain ||
|
||||||
!this._clientId ||
|
!this._clientId ||
|
||||||
!this._clientSecret}
|
!this._clientSecret}
|
||||||
@click=${this._createApplicationCredential}
|
@click=${this._addApplicationCredential}
|
||||||
>
|
>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.application_credentials.editor.create"
|
"ui.panel.config.application_credentials.editor.add"
|
||||||
)}
|
)}
|
||||||
</mwc-button>
|
</mwc-button>
|
||||||
`}
|
`}
|
||||||
@ -213,7 +245,7 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
this.closeDialog();
|
this.closeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _createApplicationCredential(ev) {
|
private async _addApplicationCredential(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
if (!this._domain || !this._clientId || !this._clientSecret) {
|
if (!this._domain || !this._clientId || !this._clientSecret) {
|
||||||
return;
|
return;
|
||||||
@ -260,6 +292,12 @@ export class DialogAddApplicationCredential extends LitElement {
|
|||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a ha-svg-icon {
|
||||||
|
--mdc-icon-size: 16px;
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -3014,12 +3014,16 @@
|
|||||||
"caption": "Application Credentials",
|
"caption": "Application Credentials",
|
||||||
"description": "Manage the OAuth Application Credentials used by Integrations",
|
"description": "Manage the OAuth Application Credentials used by Integrations",
|
||||||
"editor": {
|
"editor": {
|
||||||
"caption": "Add Application Credential",
|
"caption": "Add Credential",
|
||||||
"create": "Create",
|
"description": "OAuth is used to grant Home Assistant access to information on other websites without giving a passwords. This mechanism is used by companies such as Spotify, Google, Withings, Microsoft, and Twitter.",
|
||||||
|
"view_documentation": "View documentation",
|
||||||
|
"add": "Add",
|
||||||
"domain": "Integration",
|
"domain": "Integration",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"client_id": "OAuth Client ID",
|
"client_id": "OAuth Client ID",
|
||||||
"client_secret": "OAuth Client Secret"
|
"client_id_helper": "Public identifier of the OAuth application",
|
||||||
|
"client_secret": "OAuth Client Secret",
|
||||||
|
"client_secret_helper": "Secret of the OAuth application"
|
||||||
},
|
},
|
||||||
"picker": {
|
"picker": {
|
||||||
"add_application_credential": "Add Application Credential",
|
"add_application_credential": "Add Application Credential",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user