Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added translation to badge on alarm panel #5823

Merged
merged 2 commits into from
May 9, 2020

Conversation

matstrange
Copy link
Contributor

Proposed change

Fixed issue #5786 by using a tranlated state for the badge label. Have removed legacy code that seemed to handle these names in a way that is now handled in the translations.

Screenshots below of the new translations showing:

2020-05-09_11-57
2020-05-09_11-58
2020-05-09_11-58_1
2020-05-09_11-59

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

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:

return stateLabel === "disarmed" ||
stateLabel === "triggered" ||
!stateLabel
? ""
Copy link
Member

Choose a reason for hiding this comment

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

You now also changed the logic of not showing the state on the badge when it is disarmed or triggered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my second screenshot down you can see the badge in the disarmed state so I'm not sure this logic was being used any more?

I reinstated using your suggestion below swapping : stateLabel; to this._stateDisplay(state) and tested and this stopped text rendering again until it was borked to disrmed at which point it skipped it and rendered the translation correctly using the amended this._stateDisplay(state)

I slimmed down to this:

  private _stateIconLabel(state: string): string {return this._stateDisplay(state);
  }

And it worked for both of these states:

image

image

Copy link
Member

Choose a reason for hiding this comment

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

But in the original code, there is no text in the badge when the state is disarmed.

Copy link
Member

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, d'oh. I got so wrapped up in the translations, I missed that!

stateLabel === "triggered" ||
!stateLabel
? ""
: stateLabel;
Copy link
Member

Choose a reason for hiding this comment

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

You could replace this with:

this._stateDisplay(state)

@bramkragten bramkragten merged commit f5da130 into home-assistant:dev May 9, 2020
@RenzoBeux
Copy link

Hi!, thanks for fixing it!
I have a very noob question... how do i update the frontend, i mean how do i do to see this changes?
Thank you! (and sorry for such a stupid question)

@bramkragten
Copy link
Member

It will be in Home Assistant Core 0.110

@bramkragten bramkragten mentioned this pull request May 12, 2020
@lock lock bot locked and limited conversation to collaborators May 20, 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.

Translation of Alarm panel card badge
4 participants