1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-05-08 17:28:46 +01:00

Disabled config badge (#27172)

* Add disabled option for badge

* Add disabled to struct
This commit is contained in:
Paul Bottein
2025-09-25 17:45:06 +02:00
committed by GitHub
parent fbf7ebdfe4
commit c9931b3a3c
4 changed files with 17 additions and 5 deletions
+1
View File
@@ -4,6 +4,7 @@ export interface LovelaceBadgeConfig {
type: string;
[key: string]: any;
visibility?: Condition[];
disabled?: boolean;
}
export const ensureBadgeConfig = (
+12 -3
View File
@@ -161,7 +161,7 @@ export class HuiBadge extends ReactiveElement {
);
}
private _updateVisibility(forceVisible?: boolean) {
private _updateVisibility(ignoreConditions?: boolean) {
if (!this._element || !this.hass) {
return;
}
@@ -171,9 +171,18 @@ export class HuiBadge extends ReactiveElement {
return;
}
if (this.preview) {
this._setElementVisibility(true);
return;
}
if (this.config?.disabled) {
this._setElementVisibility(false);
return;
}
const visible =
forceVisible ||
this.preview ||
ignoreConditions ||
!this.config?.visibility ||
checkConditionsMet(this.config.visibility, this.hass);
this._setElementVisibility(visible);
@@ -1,6 +1,7 @@
import { object, string, any } from "superstruct";
import { object, string, any, optional, boolean } from "superstruct";
export const baseLovelaceBadgeConfig = object({
type: string(),
visibility: any(),
disabled: optional(boolean()),
});
@@ -1,4 +1,4 @@
import { object, string, any } from "superstruct";
import { object, string, any, optional, boolean } from "superstruct";
export const baseLovelaceCardConfig = object({
type: string(),
@@ -6,4 +6,5 @@ export const baseLovelaceCardConfig = object({
layout_options: any(),
grid_options: any(),
visibility: any(),
disabled: optional(boolean()),
});