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:
@@ -4,6 +4,7 @@ export interface LovelaceBadgeConfig {
|
||||
type: string;
|
||||
[key: string]: any;
|
||||
visibility?: Condition[];
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export const ensureBadgeConfig = (
|
||||
|
||||
@@ -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()),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user