mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +00:00
Fix localize key types to remove user groups exception (#13259)
This commit is contained in:
parent
c73677f15d
commit
086c33d8b3
@ -15,7 +15,6 @@ type LocalizeKeyExceptions =
|
|||||||
| `state.${string}`
|
| `state.${string}`
|
||||||
| `state_attributes.${string}`
|
| `state_attributes.${string}`
|
||||||
| `state_badge.${string}`
|
| `state_badge.${string}`
|
||||||
| `groups.${string}`
|
|
||||||
| `ui.${string}`
|
| `ui.${string}`
|
||||||
| `${keyof TranslationDict["supervisor"]}.${string}`
|
| `${keyof TranslationDict["supervisor"]}.${string}`
|
||||||
| `component.${string}`;
|
| `component.${string}`;
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
mdiHomeCircleOutline,
|
mdiHomeCircleOutline,
|
||||||
mdiCancel,
|
mdiCancel,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { HomeAssistant } from "../types";
|
import { HomeAssistant, TranslationDict } from "../types";
|
||||||
import { Credential } from "./auth";
|
import { Credential } from "./auth";
|
||||||
|
|
||||||
export const SYSTEM_GROUP_ID_ADMIN = "system-admin";
|
export const SYSTEM_GROUP_ID_ADMIN = "system-admin";
|
||||||
@ -21,7 +21,7 @@ export interface User {
|
|||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
local_only: boolean;
|
local_only: boolean;
|
||||||
system_generated: boolean;
|
system_generated: boolean;
|
||||||
group_ids: string[];
|
group_ids: (keyof TranslationDict["groups"])[];
|
||||||
credentials: Credential[];
|
credentials: Credential[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,12 @@ export const computeUserBadges = (
|
|||||||
includeSystem: boolean
|
includeSystem: boolean
|
||||||
) => {
|
) => {
|
||||||
const labels: [string, string][] = [];
|
const labels: [string, string][] = [];
|
||||||
const translate = (key) => hass.localize(`ui.panel.config.users.${key}`);
|
const translate = (
|
||||||
|
key: Extract<
|
||||||
|
keyof TranslationDict["ui"]["panel"]["config"]["users"],
|
||||||
|
`is_${string}`
|
||||||
|
>
|
||||||
|
) => hass.localize(`ui.panel.config.users.${key}`);
|
||||||
|
|
||||||
if (user.is_owner) {
|
if (user.is_owner) {
|
||||||
labels.push([OWNER_ICON, translate("is_owner")]);
|
labels.push([OWNER_ICON, translate("is_owner")]);
|
||||||
|
@ -30,13 +30,13 @@ import { showUserDetailDialog } from "./show-dialog-user-detail";
|
|||||||
export class HaConfigUsers extends LitElement {
|
export class HaConfigUsers extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property() public _users: User[] = [];
|
@property({ attribute: false }) public _users: User[] = [];
|
||||||
|
|
||||||
@property() public isWide!: boolean;
|
@property({ type: Boolean }) public isWide!: boolean;
|
||||||
|
|
||||||
@property() public narrow!: boolean;
|
@property({ type: Boolean }) public narrow!: boolean;
|
||||||
|
|
||||||
@property() public route!: Route;
|
@property({ attribute: false }) public route!: Route;
|
||||||
|
|
||||||
private _columns = memoizeOne(
|
private _columns = memoizeOne(
|
||||||
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
|
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
|
||||||
@ -76,7 +76,8 @@ export class HaConfigUsers extends LitElement {
|
|||||||
width: "20%",
|
width: "20%",
|
||||||
direction: "asc",
|
direction: "asc",
|
||||||
hidden: narrow,
|
hidden: narrow,
|
||||||
template: (groupIds) => html` ${localize(`groups.${groupIds[0]}`)} `,
|
template: (groupIds: User["group_ids"]) =>
|
||||||
|
html` ${localize(`groups.${groupIds[0]}`)} `,
|
||||||
},
|
},
|
||||||
is_active: {
|
is_active: {
|
||||||
title: this.hass.localize(
|
title: this.hass.localize(
|
||||||
@ -238,3 +239,9 @@ export class HaConfigUsers extends LitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"ha-config-users": HaConfigUsers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user