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

Improve error messages in config entries #20934

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

silamon
Copy link
Contributor

@silamon silamon commented May 31, 2024

Proposed change

#20764 has been a source of bugs during the beta. After fixing the config flow in second beta, it was still not possible to enable a config entry again since the new material list disable everything (there's an opacity layer and pointer-events none on the whole container). Also found some remaining items that started to show up wrongly in the config menu, I've converted those those menu-items as well. Then lastly, decided to pull in ha-alerts to display the errors so we don't need custom logic.

image

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:

Summary by CodeRabbit

  • New Features

    • Improved the rendering logic for attention and normal entries with added dividers.
    • Introduced ha-alert elements for displaying different states.
    • Added menu items for configuration options and device navigation.
  • Style

    • Updated styling for disabled states, including opacity adjustments.

@silamon silamon added this to the 2024.6 milestone May 31, 2024
Copy link
Contributor

coderabbitai bot commented May 31, 2024

Warning

Rate limit exceeded

@piitaya has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 29 minutes and 18 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between edfb307 and 661081a.

Walkthrough

The updates to the HaConfigIntegrationPage class in ha-config-integration-page.ts focus on improving the rendering logic for list items, introducing ha-alert elements for different states, and refining the menu items for configuration options and device navigation. These changes aim to enhance the user experience by providing clearer state displays and better handling of disabled states.

Changes

File Path Change Summary
src/panels/config/integrations/ha-config-integration-page.ts Adjusted the rendering logic for attention and normal entries, added dividers between items, updated state displays using ha-alert elements, utilized menu items for configuration options and device navigation, and made styling changes for disabled states.

Sequence Diagram(s) (Beta)

Silently ignored as the changes are too specific and do not modify the overall control flow significantly.

Assessment against linked issues

Objective (Issue #20931) Addressed Explanation
Enable button should always be functional / not disabled The provided summary does not specify if the enable button issue has been addressed directly. Further review of the actual code changes is needed to confirm.
Improved handling of disabled states
Clearer state displays using ha-alert elements

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range comments (3)
src/panels/config/integrations/ha-config-integration-page.ts (3)

Line range hint 169-169: Avoid using non-null assertions unless absolutely necessary as they bypass TypeScript's strict null checks.

- this.hass!.localize("ui.common.disable")
+ this.hass?.localize("ui.common.disable")

Line range hint 333-333: Use simple strings instead of template literals when there is no dynamic content.

- `ui.panel.config.integrations.integration_page.attention_entries`
+ "ui.panel.config.integrations.integration_page.attention_entries"

Also applies to: 448-448, 501-501, 530-530, 762-762, 780-780, 796-796


Line range hint 905-905: Avoid using any type. Specify a more precise type to improve type safety and code maintainability.

- catch (err: any) {
+ catch (err: unknown) {

Also applies to: 906-906, 908-908, 950-950, 1066-1066, 1072-1072, 1078-1078, 1084-1084, 1090-1090, 1096-1096

Copy link
Member

@piitaya piitaya left a comment

Choose a reason for hiding this comment

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

Changes are ok for menu-item fix and disabled fix.
For the alert, it doesn't work when there is a configure button :
CleanShot 2024-06-03 at 11 12 31

@silamon
Copy link
Contributor Author

silamon commented Jun 3, 2024

That's more or less how the new list-item works. The more you put in the "end" slot, the more width you'll lose of the content. Do you have a suggestion?

@piitaya
Copy link
Member

piitaya commented Jun 3, 2024

Can we remove this change on this PR so we have fix for the beta? I will discuss that change with the UI/UX team to see how we can better display the error on this page.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range comments (1)
src/panels/config/integrations/ha-config-integration-page.ts (1)

Line range hint 686-802: Refactor the _renderConfigEntry method to avoid non-null assertions and improve type safety.

- class=${classMap({
-   config_entry: true,
-   "state-not-loaded": item!.state === "not_loaded",
-   "state-failed-unload": item!.state === "failed_unload",
-   "state-setup": item!.state === "setup_in_progress",
-   "state-error": ERROR_STATES.includes(item!.state),
-   "state-disabled": item.disabled_by !== null,
- })}
+ class=${classMap({
+   config_entry: true,
+   "state-not-loaded": item?.state === "not_loaded",
+   "state-failed-unload": item?.state === "failed_unload",
+   "state-setup": item?.state === "setup_in_progress",
+   "state-error": item ? ERROR_STATES.includes(item.state) : false,
+   "state-disabled": item?.disabled_by !== null,
+ })}
Tools
Biome

[error] 763-763: Do not use template literals if interpolation and special-character handling are not needed.


[error] 781-781: Do not use template literals if interpolation and special-character handling are not needed.


[error] 797-797: Do not use template literals if interpolation and special-character handling are not needed.

@home-assistant
Copy link

home-assistant bot commented Jun 3, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft June 3, 2024 13:24
@piitaya piitaya marked this pull request as ready for review June 3, 2024 14:28
@home-assistant home-assistant bot requested a review from piitaya June 3, 2024 14:28
@piitaya piitaya merged commit 250f87c into home-assistant:dev Jun 3, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't re-enable disabled config entry
2 participants