Skip to content

View Editor: Badge Preview#5335

Merged
bramkragten merged 5 commits into
home-assistant:devfrom
zsarnett:badge-preview
Mar 31, 2020
Merged

View Editor: Badge Preview#5335
bramkragten merged 5 commits into
home-assistant:devfrom
zsarnett:badge-preview

Conversation

@zsarnett
Copy link
Copy Markdown
Contributor

Proposed change

Preview Badges in the View Editor

image

Type of change

  • New feature (thank you!)

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

private _config?: LovelaceBadgeConfig;

private get _error() {
return this._element?.tagName === "HUI-ERROR-BADGE";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to determine if its an error. May need to create a public error on the state label badge.

OR

do we need to do anything special for errors on badges? Maybe just checking if the entity exists?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a hui-error-card as that is handled in create-element-base

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we do have an error-badge but it is currently unused.

try {
this._element.setConfig(configValue);
} catch (err) {
this._createBadge(createErrorBadgeConfig(err.message));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have 2 error elements, an error-badge we create here, and an error-card we create when the type is unknown in create-element-base.

The error-badge would only be used here, we should align that with the behavior of hui-view so either make that create an error-badge instead of error-card or create an error-card here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesnt ever seem to hit it :)

@bramkragten bramkragten merged commit 454d81f into home-assistant:dev Mar 31, 2020
@bramkragten bramkragten mentioned this pull request Apr 1, 2020
@lock lock Bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview for badges on View Configuration UI editor

3 participants