mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Add option to deactivate a user (#7757)
This commit is contained in:
parent
9ca84e0694
commit
ca7b8b8b4c
@ -74,9 +74,7 @@ export class HassioUpdate extends LitElement {
|
|||||||
"Supervisor",
|
"Supervisor",
|
||||||
this.supervisor.supervisor,
|
this.supervisor.supervisor,
|
||||||
"hassio/supervisor/update",
|
"hassio/supervisor/update",
|
||||||
`https://github.com//home-assistant/hassio/releases/tag/${
|
`https://github.com//home-assistant/hassio/releases/tag/${this.supervisor.supervisor.version_latest}`
|
||||||
this.supervisor.supervisor.version_latest
|
|
||||||
}`
|
|
||||||
)}
|
)}
|
||||||
${this.supervisor.host.features.includes("hassos")
|
${this.supervisor.host.features.includes("hassos")
|
||||||
? this._renderUpdateCard(
|
? this._renderUpdateCard(
|
||||||
|
@ -20,6 +20,7 @@ export interface User {
|
|||||||
|
|
||||||
export interface UpdateUserParams {
|
export interface UpdateUserParams {
|
||||||
name?: User["name"];
|
name?: User["name"];
|
||||||
|
is_active?: User["is_active"];
|
||||||
group_ids?: User["group_ids"];
|
group_ids?: User["group_ids"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +189,11 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
|
|||||||
? (name, entity: any) =>
|
? (name, entity: any) =>
|
||||||
html`
|
html`
|
||||||
${name}<br />
|
${name}<br />
|
||||||
|
<div class="secondary">
|
||||||
${entity.entity_id} |
|
${entity.entity_id} |
|
||||||
${this.hass.localize(`component.${entity.platform}.title`) ||
|
${this.hass.localize(`component.${entity.platform}.title`) ||
|
||||||
entity.platform}
|
entity.platform}
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
: undefined,
|
: undefined,
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
import { computeRTLDirection } from "../../../common/util/compute_rtl";
|
||||||
import { createCloseHeading } from "../../../components/ha-dialog";
|
import { createCloseHeading } from "../../../components/ha-dialog";
|
||||||
|
import "../../../components/ha-help-tooltip";
|
||||||
import "../../../components/ha-formfield";
|
import "../../../components/ha-formfield";
|
||||||
import "../../../components/ha-switch";
|
import "../../../components/ha-switch";
|
||||||
import { adminChangePassword } from "../../../data/auth";
|
import { adminChangePassword } from "../../../data/auth";
|
||||||
@ -37,6 +38,8 @@ class DialogUserDetail extends LitElement {
|
|||||||
|
|
||||||
@internalProperty() private _isAdmin?: boolean;
|
@internalProperty() private _isAdmin?: boolean;
|
||||||
|
|
||||||
|
@internalProperty() private _isActive?: boolean;
|
||||||
|
|
||||||
@internalProperty() private _error?: string;
|
@internalProperty() private _error?: string;
|
||||||
|
|
||||||
@internalProperty() private _params?: UserDetailDialogParams;
|
@internalProperty() private _params?: UserDetailDialogParams;
|
||||||
@ -48,6 +51,7 @@ class DialogUserDetail extends LitElement {
|
|||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
this._name = params.entry.name || "";
|
this._name = params.entry.name || "";
|
||||||
this._isAdmin = params.entry.group_ids.includes(SYSTEM_GROUP_ID_ADMIN);
|
this._isAdmin = params.entry.group_ids.includes(SYSTEM_GROUP_ID_ADMIN);
|
||||||
|
this._isActive = params.entry.is_active;
|
||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,15 +95,6 @@ class DialogUserDetail extends LitElement {
|
|||||||
</span>
|
</span>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${user.is_active
|
|
||||||
? html`
|
|
||||||
<span class="state"
|
|
||||||
>${this.hass.localize(
|
|
||||||
"ui.panel.config.users.editor.active"
|
|
||||||
)}</span
|
|
||||||
>
|
|
||||||
`
|
|
||||||
: ""}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<paper-input
|
<paper-input
|
||||||
@ -110,8 +105,11 @@ class DialogUserDetail extends LitElement {
|
|||||||
"ui.panel.config.users.editor.name"
|
"ui.panel.config.users.editor.name"
|
||||||
)}"
|
)}"
|
||||||
></paper-input>
|
></paper-input>
|
||||||
|
<div class="row">
|
||||||
<ha-formfield
|
<ha-formfield
|
||||||
.label=${this.hass.localize("ui.panel.config.users.editor.admin")}
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.users.editor.admin"
|
||||||
|
)}
|
||||||
.dir=${computeRTLDirection(this.hass)}
|
.dir=${computeRTLDirection(this.hass)}
|
||||||
>
|
>
|
||||||
<ha-switch
|
<ha-switch
|
||||||
@ -121,6 +119,7 @@ class DialogUserDetail extends LitElement {
|
|||||||
>
|
>
|
||||||
</ha-switch>
|
</ha-switch>
|
||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
|
</div>
|
||||||
${!this._isAdmin
|
${!this._isAdmin
|
||||||
? html`
|
? html`
|
||||||
<br />
|
<br />
|
||||||
@ -129,6 +128,27 @@ class DialogUserDetail extends LitElement {
|
|||||||
)}
|
)}
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
|
<div class="row">
|
||||||
|
<ha-formfield
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.users.editor.active"
|
||||||
|
)}
|
||||||
|
.dir=${computeRTLDirection(this.hass)}
|
||||||
|
>
|
||||||
|
<ha-switch
|
||||||
|
.disabled=${user.system_generated || user.is_owner}
|
||||||
|
.checked=${this._isActive}
|
||||||
|
@change=${this._activeChanged}
|
||||||
|
>
|
||||||
|
</ha-switch>
|
||||||
|
</ha-formfield>
|
||||||
|
<ha-help-tooltip
|
||||||
|
.label=${this.hass.localize(
|
||||||
|
"ui.panel.config.users.editor.active_tooltip"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
</ha-help-tooltip>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -192,11 +212,16 @@ class DialogUserDetail extends LitElement {
|
|||||||
this._isAdmin = ev.target.checked;
|
this._isAdmin = ev.target.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async _activeChanged(ev): Promise<void> {
|
||||||
|
this._isActive = ev.target.checked;
|
||||||
|
}
|
||||||
|
|
||||||
private async _updateEntry() {
|
private async _updateEntry() {
|
||||||
this._submitting = true;
|
this._submitting = true;
|
||||||
try {
|
try {
|
||||||
await this._params!.updateEntry({
|
await this._params!.updateEntry({
|
||||||
name: this._name.trim(),
|
name: this._name.trim(),
|
||||||
|
is_active: this._isActive,
|
||||||
group_ids: [
|
group_ids: [
|
||||||
this._isAdmin ? SYSTEM_GROUP_ID_ADMIN : SYSTEM_GROUP_ID_USER,
|
this._isAdmin ? SYSTEM_GROUP_ID_ADMIN : SYSTEM_GROUP_ID_USER,
|
||||||
],
|
],
|
||||||
@ -293,8 +318,13 @@ class DialogUserDetail extends LitElement {
|
|||||||
.state:not(:first-child) {
|
.state:not(:first-child) {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
ha-switch {
|
.row {
|
||||||
margin-top: 8px;
|
display: flex;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
ha-help-tooltip {
|
||||||
|
margin-left: 4px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
|
@ -46,10 +46,17 @@ export class HaConfigUsers extends LitElement {
|
|||||||
width: "25%",
|
width: "25%",
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
grows: true,
|
grows: true,
|
||||||
template: (name) => html`
|
template: (name, user: any) =>
|
||||||
${name ||
|
narrow
|
||||||
this.hass!.localize("ui.panel.config.users.editor.unnamed_user")}
|
? html` ${name}<br />
|
||||||
`,
|
<div class="secondary">
|
||||||
|
${user.username} |
|
||||||
|
${this.hass.localize(`groups.${user.group_ids[0]}`)}
|
||||||
|
</div>`
|
||||||
|
: html` ${name ||
|
||||||
|
this.hass!.localize(
|
||||||
|
"ui.panel.config.users.editor.unnamed_user"
|
||||||
|
)}`,
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
@ -59,6 +66,7 @@ export class HaConfigUsers extends LitElement {
|
|||||||
filterable: true,
|
filterable: true,
|
||||||
width: "20%",
|
width: "20%",
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
|
hidden: narrow,
|
||||||
template: (username) => html`
|
template: (username) => html`
|
||||||
${username ||
|
${username ||
|
||||||
this.hass!.localize("ui.panel.config.users.editor.unnamed_user")}
|
this.hass!.localize("ui.panel.config.users.editor.unnamed_user")}
|
||||||
@ -71,13 +79,24 @@ export class HaConfigUsers extends LitElement {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
width: "20%",
|
width: "20%",
|
||||||
|
direction: "asc",
|
||||||
|
hidden: narrow,
|
||||||
template: (groupIds) => html`
|
template: (groupIds) => html`
|
||||||
${this.hass.localize(`groups.${groupIds[0]}`)}
|
${this.hass.localize(`groups.${groupIds[0]}`)}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
};
|
is_active: {
|
||||||
if (!narrow) {
|
title: this.hass.localize(
|
||||||
columns.system_generated = {
|
"ui.panel.config.users.picker.headers.is_active"
|
||||||
|
),
|
||||||
|
type: "icon",
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
width: "80px",
|
||||||
|
template: (is_active) =>
|
||||||
|
is_active ? html`<ha-icon icon="hass:check"> </ha-icon>` : "",
|
||||||
|
},
|
||||||
|
system_generated: {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
"ui.panel.config.users.picker.headers.system"
|
"ui.panel.config.users.picker.headers.system"
|
||||||
),
|
),
|
||||||
@ -87,8 +106,9 @@ export class HaConfigUsers extends LitElement {
|
|||||||
width: "160px",
|
width: "160px",
|
||||||
template: (generated) =>
|
template: (generated) =>
|
||||||
generated ? html`<ha-icon icon="hass:check"> </ha-icon>` : "",
|
generated ? html`<ha-icon icon="hass:check"> </ha-icon>` : "",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -2032,7 +2032,8 @@
|
|||||||
"system_generated_users_not_removable": "Unable to remove system generated users.",
|
"system_generated_users_not_removable": "Unable to remove system generated users.",
|
||||||
"system_generated_users_not_editable": "Unable to update system generated users.",
|
"system_generated_users_not_editable": "Unable to update system generated users.",
|
||||||
"unnamed_user": "Unnamed User",
|
"unnamed_user": "Unnamed User",
|
||||||
"confirm_user_deletion": "Are you sure you want to delete {name}?"
|
"confirm_user_deletion": "Are you sure you want to delete {name}?",
|
||||||
|
"active_tooltip": "Controls if user can login"
|
||||||
},
|
},
|
||||||
"add_user": {
|
"add_user": {
|
||||||
"caption": "Add user",
|
"caption": "Add user",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user