mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +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_attributes.${string}`
|
||||
| `state_badge.${string}`
|
||||
| `groups.${string}`
|
||||
| `ui.${string}`
|
||||
| `${keyof TranslationDict["supervisor"]}.${string}`
|
||||
| `component.${string}`;
|
||||
|
@ -4,7 +4,7 @@ import {
|
||||
mdiHomeCircleOutline,
|
||||
mdiCancel,
|
||||
} from "@mdi/js";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { HomeAssistant, TranslationDict } from "../types";
|
||||
import { Credential } from "./auth";
|
||||
|
||||
export const SYSTEM_GROUP_ID_ADMIN = "system-admin";
|
||||
@ -21,7 +21,7 @@ export interface User {
|
||||
is_active: boolean;
|
||||
local_only: boolean;
|
||||
system_generated: boolean;
|
||||
group_ids: string[];
|
||||
group_ids: (keyof TranslationDict["groups"])[];
|
||||
credentials: Credential[];
|
||||
}
|
||||
|
||||
@ -95,7 +95,12 @@ export const computeUserBadges = (
|
||||
includeSystem: boolean
|
||||
) => {
|
||||
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) {
|
||||
labels.push([OWNER_ICON, translate("is_owner")]);
|
||||
|
@ -30,13 +30,13 @@ import { showUserDetailDialog } from "./show-dialog-user-detail";
|
||||
export class HaConfigUsers extends LitElement {
|
||||
@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(
|
||||
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
|
||||
@ -76,7 +76,8 @@ export class HaConfigUsers extends LitElement {
|
||||
width: "20%",
|
||||
direction: "asc",
|
||||
hidden: narrow,
|
||||
template: (groupIds) => html` ${localize(`groups.${groupIds[0]}`)} `,
|
||||
template: (groupIds: User["group_ids"]) =>
|
||||
html` ${localize(`groups.${groupIds[0]}`)} `,
|
||||
},
|
||||
is_active: {
|
||||
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