mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Only save non system generated users and tweak text (#5131)
* Only save non system generated users and tweak text * Clean up
This commit is contained in:
parent
b2026c1cd7
commit
e5db86363c
@ -362,6 +362,9 @@ export class HuiEditView extends LitElement {
|
|||||||
paper-spinner[active] {
|
paper-spinner[active] {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
paper-dialog-scrollable {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
.hidden {
|
.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ import {
|
|||||||
CSSResult,
|
CSSResult,
|
||||||
css,
|
css,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "@polymer/paper-input/paper-input";
|
import "@polymer/paper-item/paper-item";
|
||||||
|
import "@polymer/paper-item/paper-item-body";
|
||||||
|
|
||||||
import { HomeAssistant } from "../../../../types";
|
import { HomeAssistant } from "../../../../types";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import { configElementStyle } from "../config-elements/config-elements-style";
|
|
||||||
import { LovelaceViewConfig, ShowViewConfig } from "../../../../data/lovelace";
|
import { LovelaceViewConfig, ShowViewConfig } from "../../../../data/lovelace";
|
||||||
|
|
||||||
import { fetchUsers, User } from "../../../../data/user";
|
import { fetchUsers, User } from "../../../../data/user";
|
||||||
@ -42,16 +42,14 @@ export class HuiViewVisibilityEditor extends LitElement {
|
|||||||
@property() private _visible!: boolean | ShowViewConfig[];
|
@property() private _visible!: boolean | ShowViewConfig[];
|
||||||
|
|
||||||
private _sortedUsers = memoizeOne((users: User[]) => {
|
private _sortedUsers = memoizeOne((users: User[]) => {
|
||||||
return users
|
return users.sort((a, b) => compare(a.name, b.name));
|
||||||
.filter((user) => !user.system_generated)
|
|
||||||
.sort((a, b) => compare(a.name, b.name));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
protected firstUpdated(changedProps: PropertyValues) {
|
||||||
super.firstUpdated(changedProps);
|
super.firstUpdated(changedProps);
|
||||||
|
|
||||||
fetchUsers(this.hass).then((users) => {
|
fetchUsers(this.hass).then((users) => {
|
||||||
this._users = users;
|
this._users = users.filter((user) => !user.system_generated);
|
||||||
fireEvent(this, "iron-resize");
|
fireEvent(this, "iron-resize");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -62,24 +60,23 @@ export class HuiViewVisibilityEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${configElementStyle}
|
<p>
|
||||||
<div class="card-config">
|
${this.hass.localize(
|
||||||
<span>Select which users should have access to this view</span>
|
"ui.panel.lovelace.editor.edit_view.visibility.select_users"
|
||||||
|
|
||||||
${this._sortedUsers(this._users).map(
|
|
||||||
(user) => html`
|
|
||||||
<div class="flex">
|
|
||||||
<div>${user.name}</div>
|
|
||||||
<ha-switch
|
|
||||||
.userId="${user.id}"
|
|
||||||
@change=${this.valChange}
|
|
||||||
.checked=${this.checkUser(user.id)}
|
|
||||||
> </ha-switch
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</p>
|
||||||
|
${this._sortedUsers(this._users).map(
|
||||||
|
(user) => html`
|
||||||
|
<paper-item>
|
||||||
|
<paper-item-body>${user.name}</paper-item-body>
|
||||||
|
<ha-switch
|
||||||
|
.userId="${user.id}"
|
||||||
|
@change=${this.valChange}
|
||||||
|
.checked=${this.checkUser(user.id)}
|
||||||
|
></ha-switch>
|
||||||
|
</paper-item>
|
||||||
|
`
|
||||||
|
)}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,13 +130,8 @@ export class HuiViewVisibilityEditor extends LitElement {
|
|||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
.flex {
|
:host {
|
||||||
flex: 1;
|
display: block;
|
||||||
margin-left: 16px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -1929,7 +1929,10 @@
|
|||||||
"move_right": "Move view right",
|
"move_right": "Move view right",
|
||||||
"tab_settings": "Settings",
|
"tab_settings": "Settings",
|
||||||
"tab_badges": "Badges",
|
"tab_badges": "Badges",
|
||||||
"tab_visibility": "Visibility"
|
"tab_visibility": "Visibility",
|
||||||
|
"visibility": {
|
||||||
|
"select_users": "Select which users should see this view in the navigation"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"edit_card": {
|
"edit_card": {
|
||||||
"header": "Card Configuration",
|
"header": "Card Configuration",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user