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

20240705.0 #21306

Merged
merged 18 commits into from
Jul 5, 2024
Merged

20240705.0 #21306

merged 18 commits into from
Jul 5, 2024

Conversation

bramkragten
Copy link
Member

@bramkragten bramkragten commented Jul 5, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced grid layout customization with auto-sizing options.
    • New UI elements added to the card layout editor for improved user interaction.
  • Bug Fixes

    • Corrected styling for disabled grid layout sliders.
  • Localization

    • Updated and improved text prompts and dashboard descriptions in the English translation file.

bramkragten and others added 18 commits July 3, 2024 13:26
* Fix automation picker overflow menu for keyboard

* some updates from review

* typing

* no removeEventListener

* updates from review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Add auto-height option to resize editor

* Use min instead of max

* Remove auto height
Fix energy selection card in grid layout
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Simon Lamon <[email protected]>
Co-authored-by: Franck Nijhof <[email protected]>
@github-actions github-actions bot added Demo Related to frontend demo content Design Related to Home Assistant design gallery labels Jul 5, 2024
Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

Walkthrough

The recent updates involve styling adjustments, the addition of new imports, property value changes, and the modification of text prompts in different components of the Lovelace UI. The changes also include the ability to set the grid_rows property to "auto" in the grid layout options, enhancing flexibility in grid configurations. Additionally, new text entities and titles have been added to enhance the dashboard's descriptive content.

Changes

Files Change Summaries
src/panels/lovelace/editor/card-editor/...slider.ts Added styling for .active class when HaGridLayoutSlider is disabled, setting background to var(--disabled-color)
src/panels/lovelace/editor/card-editor/...editor.ts Added imports ha-settings-row and ha-switch, introduced sizeValue constant, adjusted template rendering.
src/panels/lovelace/sections/...section.ts Changed grid_rows property from number to "auto" in DEFAULT_GRID_OPTIONS and updated GridSizeValue type.
src/panels/lovelace/types.ts Modified LovelaceLayoutOptions interface to allow grid_rows property as a number or "auto".
src/translations/en.json Updated textual prompts and added new titles, sections, and entities in the dashboard description.

Note: Sequence diagrams were not generated as the changes primarily involve styling, property adjustments, and text modifications, which do not significantly impact control flow or feature functions warranting such visualization.


Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 58ba9f6 and 42b5fbe.

Files ignored due to path filters (2)
  • demo/public/assets/sections/images/media_player_family_room.jpg is excluded by !**/*.jpg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (27)
  • demo/src/configs/sections/entities.ts (4 hunks)
  • demo/src/configs/sections/lovelace.ts (10 hunks)
  • demo/src/stubs/entities.ts (1 hunks)
  • demo/src/stubs/lovelace.ts (1 hunks)
  • gallery/src/pages/Text/remove-delete-add-create.markdown (2 hunks)
  • package.json (4 hunks)
  • pyproject.toml (1 hunks)
  • src/components/data-table/ha-data-table.ts (6 hunks)
  • src/components/ha-grid-size-picker.ts (4 hunks)
  • src/components/ha-menu-item.ts (1 hunks)
  • src/components/ha-menu.ts (2 hunks)
  • src/dialogs/more-info/ha-more-info-dialog.ts (1 hunks)
  • src/dialogs/more-info/ha-more-info-history.ts (1 hunks)
  • src/fake_data/demo_panels.ts (1 hunks)
  • src/layouts/hass-tabs-subpage-data-table.ts (2 hunks)
  • src/panels/config/automation/ha-automation-picker.ts (11 hunks)
  • src/panels/config/devices/ha-config-device-page.ts (5 hunks)
  • src/panels/config/tags/ha-config-tags.ts (1 hunks)
  • src/panels/lovelace/cards/energy/hui-energy-date-selection-card.ts (3 hunks)
  • src/panels/lovelace/cards/hui-entity-card.ts (5 hunks)
  • src/panels/lovelace/cards/hui-iframe-card.ts (1 hunks)
  • src/panels/lovelace/cards/hui-tile-card.ts (1 hunks)
  • src/panels/lovelace/editor/card-editor/ha-grid-layout-slider.ts (1 hunks)
  • src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts (3 hunks)
  • src/panels/lovelace/sections/hui-grid-section.ts (1 hunks)
  • src/panels/lovelace/types.ts (1 hunks)
  • src/translations/en.json (2 hunks)
Additional context used
Markdownlint
gallery/src/pages/Text/remove-delete-add-create.markdown

6-6: null
Multiple top-level headings in the same document

(MD025, single-title, single-h1)

Biome
src/panels/config/tags/ha-config-tags.ts

[error] 304-304: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 308-308: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 309-309: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

src/panels/config/automation/ha-automation-picker.ts

[error] 1060-1060: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1060-1060: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1060-1060: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1066-1066: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1066-1066: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1066-1066: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1076-1076: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1076-1076: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1076-1076: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 1083-1083: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1083-1083: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1083-1083: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

src/panels/config/devices/ha-config-device-page.ts

[error] 689-689: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


[error] 745-745: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 747-747: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 749-749: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 752-752: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 753-753: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 757-757: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 758-758: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 761-761: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 762-762: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 767-767: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 770-770: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

Additional comments not posted (56)
pyproject.toml (1)

7-7: Version update confirmed.

The version number has been updated to 20240705.0.

src/components/ha-menu.ts (3)

2-6: Imports look good.

The imported entities from @material/web/menu/menu and @material/web/menu/internal/controllers/shared are correctly used.


13-16: Event listener implementation is correct.

The connectedCallback method correctly adds an event listener for the "close-menu" event.


18-26: Event handler implementation is correct.

The _handleCloseMenu method correctly handles the "close-menu" event, checking for specific conditions before invoking the clickAction.

src/components/ha-menu-item.ts (2)

3-3: Imports look good.

The imported entities from lit and lit/decorators are correctly used.


7-7: New property addition is correct.

The clickAction property is correctly defined with an optional attribute.

demo/src/stubs/lovelace.ts (3)

10-10: Import of mapEntities looks good.

The addition of the mapEntities import is appropriate for adding entities to the map configuration.


16-24: Mock WebSocket handler for lovelace/config looks good.

The addition of the WebSocket handler correctly handles the map URL path by adding entities using mapEntities().


27-27: Fetching Lovelace configuration with Promise.all looks good.

The use of Promise.all to fetch the selected demo configuration and localization function is appropriate.

src/fake_data/demo_panels.ts (1)

69-72: Map panel configuration looks good.

The addition of the map panel configuration with the correct component name, icon, title, and URL path is appropriate.

src/panels/lovelace/cards/energy/hui-energy-date-selection-card.ts (1)

67-73: CSS styles for ha-card look good.

The addition of CSS styles to ensure that the ha-card element takes up the full height and uses flexbox for layout is appropriate.

src/panels/lovelace/cards/hui-iframe-card.ts (1)

132-133: CSS styles for ha-card look good.

The addition of CSS styles to ensure that the ha-card element uses flexbox for layout is appropriate.

src/panels/lovelace/types.ts (1)

45-45: LGTM! But verify the usage of grid_rows.

The code changes are approved.

However, ensure that all code using grid_rows handles the new possible value "auto" correctly.

demo/src/stubs/entities.ts (1)

3-50: LGTM! But verify the usage of new entities.

The code changes are approved.

However, ensure that all new entities are correctly integrated and used within the system.

src/components/ha-grid-size-picker.ts (2)

51-51: Handle auto value for rows correctly.

Ensure that the auto value for rows is handled correctly in the rendering logic.

Verification successful

Handle auto value for rows correctly.

The auto value for rows is appropriately handled in the rendering logic by setting rowValue to rowMin when autoHeight is true, ensuring the component renders correctly.

  • src/components/ha-grid-size-picker.ts:
    • render method: rowValue is set to rowMin when autoHeight is true.
    • Usage of rowValue: Correctly used in the HTML template for rendering.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of `auto` value for rows in the rendering logic.

# Test: Search for the usage of `auto` value for rows. Expect: The `auto` value is handled correctly in the rendering logic.
rg --type typescript $'"auto"'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify the handling of `auto` value for rows in the rendering logic.

# Test: Search for the usage of `auto` value for rows. Expect: The `auto` value is handled correctly in the rendering logic.
rg '"auto"' --glob '*.ts'

Length of output: 10916


Script:

#!/bin/bash
# Description: Extract the rendering logic from ha-grid-size-picker.ts to verify the handling of `auto` value for rows.

# Extract the render function and any related methods from ha-grid-size-picker.ts
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  render() {
    $$$
  }
  $$$  
}' src/components/ha-grid-size-picker.ts

Length of output: 130


Script:

#!/bin/bash
# Description: Search for the render method and any related methods in ha-grid-size-picker.ts to verify the handling of `auto` value for rows.

# Search for the render method in ha-grid-size-picker.ts
rg 'render()' src/components/ha-grid-size-picker.ts

# Search for the usage of the autoHeight variable in ha-grid-size-picker.ts
rg 'autoHeight' src/components/ha-grid-size-picker.ts

Length of output: 255


Script:

#!/bin/bash
# Description: Extract the full render method and any related methods that use rowValue in ha-grid-size-picker.ts to verify the handling of `auto` value for rows.

# Extract the full render method from ha-grid-size-picker.ts
rg -A 20 'protected render()' src/components/ha-grid-size-picker.ts

# Search for the usage of rowValue in ha-grid-size-picker.ts
rg 'rowValue' src/components/ha-grid-size-picker.ts

Length of output: 1002


13-13: LGTM! But verify the usage of rows.

The code changes are approved.

However, ensure that all code using rows in GridSizeValue handles the new possible value "auto" correctly.

Verification successful

Verified the usage of rows

The rows property is correctly handled for the new possible value "auto" in the codebase.

  • The autoHeight variable is used to check if rows is "auto".
  • The rowValue is set appropriately based on the autoHeight check.
  • CSS variables are set correctly to reflect the rows value.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all code handling `rows` in `GridSizeValue`.

# Test: Search for the usage of `rows`. Expect: All code handles the new possible value `"auto"`.
rg --type typescript $'rows'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify all code handling `rows` in `GridSizeValue`.

# Search for the usage of `rows` in all TypeScript files.
rg 'rows' --glob '*.ts'

Length of output: 51965


Script:

#!/bin/bash
# Description: Verify all code handling `rows` in `GridSizeValue`.

# Extract relevant lines where `rows` is used in `src/components/ha-grid-size-picker.ts` and related files.
rg 'rows' src/components/ha-grid-size-picker.ts

Length of output: 879


Script:

#!/bin/bash
# Description: Extract methods containing the usage of `rows` in `src/components/ha-grid-size-picker.ts` to verify handling of the "auto" value.

# Extract methods containing the usage of `rows`.
ast-grep --lang typescript --pattern $'function $_(...) {
  $$$
}' src/components/ha-grid-size-picker.ts

Length of output: 105


Script:

#!/bin/bash
# Description: Extract surrounding context of lines where `rows` is used in `src/components/ha-grid-size-picker.ts` to verify handling of the "auto" value.

# Extract surrounding context (10 lines before and after) where `rows` is used.
rg 'rows' src/components/ha-grid-size-picker.ts -C 10

Length of output: 6243

demo/src/configs/sections/lovelace.ts (1)

Line range hint 4-263:
LGTM! But verify the usage of new titles.

The code changes are approved.

However, ensure that all new titles are correctly integrated and used within the system.

Verification successful

New titles are correctly integrated and used within the system.

  • The new titles were found in the demo/src/configs/sections/lovelace.ts file and are being localized correctly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all code handling new titles.

# Test: Search for the usage of new titles. Expect: All new titles are correctly integrated and used within the system.
rg --type typescript $'ui.panel.page-demo.config.sections.titles.welcome' $'ui.panel.page-demo.config.sections.titles.living_room' $'ui.panel.page-demo.config.sections.titles.kitchen' $'ui.panel.page-demo.config.sections.titles.energy' $'ui.panel.page-demo.config.sections.titles.climate' $'ui.panel.page-demo.config.sections.titles.study' $'ui.panel.page-demo.config.sections.titles.outdoor' $'ui.panel.page-demo.config.sections.titles.updates'

Length of output: 458


Script:

#!/bin/bash
# Description: Verify all code handling new titles.

# Test: Search for the usage of new titles. Expect: All new titles are correctly integrated and used within the system.
rg 'ui.panel.page-demo.config.sections.titles.welcome' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.living_room' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.kitchen' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.energy' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.climate' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.study' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.outdoor' --glob '*.ts'
rg 'ui.panel.page-demo.config.sections.titles.updates' --glob '*.ts'

Length of output: 1576

src/dialogs/more-info/ha-more-info-history.ts (1)

78-84: LGTM!

The changes correctly handle the __DEMO__ condition to return nothing.

src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts (1)

66-67: LGTM!

The changes correctly introduce and use the sizeValue constant.

src/panels/lovelace/sections/hui-grid-section.ts (2)

29-29: LGTM!

The change to set grid_rows to "auto" in DEFAULT_GRID_OPTIONS is correctly implemented.


33-33: LGTM!

The change to allow rows to be either a number or "auto" in GridSizeValue is correctly implemented.

package.json (2)

36-36: Dependency Addition Approved: @codemirror/view

The addition of @codemirror/view version 6.28.3 is approved. Ensure it is compatible with other dependencies.


188-188: DevDependency Addition Approved: @typescript-eslint/eslint-plugin

The addition of @typescript-eslint/eslint-plugin version 7.15.0 is approved. Ensure it is compatible with other devDependencies.

src/panels/lovelace/cards/hui-entity-card.ts (3)

77-77: Property Addition Approved: layout

The addition of the layout property to the HuiEntityCard class is approved. Ensure it is correctly integrated and utilized.


138-139: Variable Addition Approved: fixedFooter

The addition of the fixedFooter variable to the render method is approved. Ensure it is correctly integrated and utilized.


142-146: Render Method Update Approved

The updates to the render method, including the fixedFooter variable in the classMap, are approved. Ensure it is correctly integrated and utilized.

src/panels/lovelace/editor/card-editor/ha-grid-layout-slider.ts (1)

381-383: Styling Update Approved: .active Class

The update to the styling of the .active class when the component is disabled, setting the background to var(--disabled-color), is approved. Ensure it is correctly integrated and utilized.

demo/src/configs/sections/entities.ts (3)

116-139: Attributes Addition Approved: media_player.living_room_nest_mini

The addition of new attributes to the media_player.living_room_nest_mini entity is approved. Ensure they are correctly integrated and utilized.


190-210: Attributes Addition Approved: media_player.kitchen_nest_audio

The addition of new attributes to the media_player.kitchen_nest_audio entity is approved. Ensure they are correctly integrated and utilized.


374-395: Attributes Addition Approved: media_player.study_nest_hub

The addition of new attributes to the media_player.study_nest_hub entity is approved. Ensure they are correctly integrated and utilized.

src/panels/lovelace/cards/hui-tile-card.ts (3)

126-126: Ensure grid_min_columns is correctly set.

The line sets grid_min_columns to 2 by default. This seems logical, but ensure that this default value aligns with the rest of the layout logic.


133-134: Verify the increment of grid_rows and setting grid_min_columns.

The lines increment grid_rows and set grid_min_columns to 1 if the vertical property is true. Ensure these changes are consistent with the desired layout behavior.


140-140: Ensure grid_min_columns is correctly returned.

The line returns grid_min_columns as part of the layout options. Ensure that this value is correctly used in the layout.

src/dialogs/more-info/ha-more-info-dialog.ts (1)

328-328: Ensure the settings icon button is correctly added.

The line adds an icon button for settings in the default view of the dialog. Ensure that this button functions as expected and does not interfere with other elements.

src/layouts/hass-tabs-subpage-data-table.ts (2)

433-433: Ensure the localize property is correctly passed.

The line passes the localize property to the ha-data-table component. Ensure that this property is correctly used within the data table for localization purposes.


579-581: Ensure the results button displays the correct number of items.

The lines add a button to show results with the number of data items. Ensure that the number of items is correctly calculated and displayed.

src/components/data-table/ha-data-table.ts (3)

37-37: Import statement for LocalizeFunc looks good.

The import of LocalizeFunc is necessary for the new localizeFunc property and follows the project's import style.


114-115: Addition of localizeFunc property looks good.

The localizeFunc property provides an optional localization function, enhancing the flexibility of the component.


323-324: Assignment of localize variable looks good.

The localize variable now uses localizeFunc if available, otherwise defaults to this.hass.localize. This enhances flexibility and reusability.

src/panels/config/automation/ha-automation-picker.ts (5)

Line range hint 1107-1121:
LGTM!

The function logic is correct and there are no flagged issues.


1123-1131: LGTM!

The function logic is correct and there are no flagged issues.


Line range hint 1133-1150:
LGTM!

The function logic is correct and there are no flagged issues.


Line range hint 1170-1196:
LGTM!

The function logic is correct and there are no flagged issues.


Line range hint 1198-1211:
LGTM!

The function logic is correct and there are no flagged issues.

src/panels/config/devices/ha-config-device-page.ts (10)

664-674: Ensure proper usage of properties in the render method.

The render method starts with returning a hass-subpage element. Verify that the properties hass, narrow, and header are correctly assigned.


24-24: Verify the usage of newly imported constants.

Ensure that ASSIST_ENTITIES and SENSOR_ENTITIES are used correctly in the file.

Verification successful

Verified: The import statements for ASSIST_ENTITIES and SENSOR_ENTITIES are necessary and used correctly in the file.

  • The constants ASSIST_ENTITIES and SENSOR_ENTITIES are used in if statements within the src/panels/config/devices/ha-config-device-page.ts file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `ASSIST_ENTITIES` and `SENSOR_ENTITIES` in the codebase.

# Test: Search for the usage of `ASSIST_ENTITIES` and `SENSOR_ENTITIES`. Expect: Usage in the current file.
rg --type ts 'ASSIST_ENTITIES|SENSOR_ENTITIES'

Length of output: 969


833-836: Ensure correct rendering of automation, scene, and script cards.

The code renders the automation, scene, and script cards when not in narrow mode. Verify that the properties and conditions are correctly assigned and used.

Verification successful

Ensure correct rendering of automation, scene, and script cards.

The properties and conditions for rendering the automation, scene, and script cards based on the narrow property are correctly assigned and used.

  • narrow is defined as a boolean property with a default value of false.
  • automationCard, sceneCard, and scriptCard are properly assigned using the isComponentLoaded function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the properties and conditions used to render automation, scene, and script cards.

# Test: Search for the properties and conditions used to render these cards. Expect: Proper assignment and usage of these properties and conditions.
rg --type ts 'this\.automationCard|this\.sceneCard|this\.scriptCard|this\.narrow'

Length of output: 35591


Script:

#!/bin/bash
# Description: Verify the definitions and assignments of automationCard, sceneCard, scriptCard, and narrow within ha-config-device-page.ts.

# Find the definitions and assignments of automationCard, sceneCard, scriptCard, and narrow in ha-config-device-page.ts
rg 'automationCard|sceneCard|scriptCard|narrow' src/panels/config/devices/ha-config-device-page.ts

Length of output: 632


675-686: Check the conditional rendering of the area link.

The code conditionally renders a link to the area if area is defined. Ensure that area is properly defined and used.

Verification successful

Conditional rendering of the area link is correct.

The area variable is properly defined as const area = device.area_id ? this.hass.areas[device.area_id] : undefined;, ensuring it is only assigned when device.area_id is present. This aligns with the conditional rendering logic in the provided code.

  • src/panels/config/devices/ha-config-device-page.ts: const area = device.area_id ? this.hass.areas[device.area_id] : undefined;
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `area` in the code.

# Test: Search for the property `area` in the class. Expect: Proper assignment and usage of this property.
rg --type ts 'this\.area'

Length of output: 399


Script:

#!/bin/bash
# Description: Search for the definition and usage of `area` in the ha-config-device-page.ts file.

# Test: Search for the keyword 'area' in the ha-config-device-page.ts file.
rg 'area' src/panels/config/devices/ha-config-device-page.ts

Length of output: 345


837-869: Ensure correct rendering of entity cards by category.

The code renders various entity cards by category. Verify that the properties and conditions are correctly assigned and used.

Verification successful

The properties and conditions for rendering entity cards by category are correctly assigned and used.

  • The properties entities and entitiesByCategory are properly set and utilized in the rendering logic within the ha-config-device-page.ts file.
  • The conditions for rendering the entity cards are correctly implemented.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the properties and conditions used to render entity cards by category.

# Test: Search for the properties and conditions used to render these cards. Expect: Proper assignment and usage of these properties and conditions.
rg --type ts 'this\.entitiesByCategory|this\.entities'

Length of output: 2584


Script:

#!/bin/bash
# Refined search in the specific file to verify the properties and conditions used to render entity cards by category.

# Search for the usage of entitiesByCategory and entities in the specific file.
rg --type ts 'entitiesByCategory|entities' src/panels/config/devices/ha-config-device-page.ts

Length of output: 1638


725-737: Ensure correct handling of device alerts.

The code conditionally renders device alerts if this._deviceAlerts is defined. Verify that this._deviceAlerts is correctly assigned and used.

Verification successful

Ensure correct handling of device alerts.

The code properly handles the fetching, assignment, and rendering of device alerts. There are no issues with the assignment or usage of this._deviceAlerts.

  • Initialization: this._deviceAlerts is initially set to undefined.
  • Conditional check: It is checked along with other properties.
  • Assignment: It is assigned an empty array and later populated with deviceAlerts.
  • Rendering: It is used in the rendering logic to display alerts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `this._deviceAlerts` in the code.

# Test: Search for the property `this._deviceAlerts` in the class. Expect: Proper assignment and usage of this property.
rg --type ts 'this\._deviceAlerts'

Length of output: 564


Script:

#!/bin/bash
# Extract surrounding lines for each occurrence of `this._deviceAlerts` to understand its context.

# Print 5 lines before and after each match to understand the context.
rg --type ts --context 5 'this\._deviceAlerts'

Length of output: 4227


Script:

#!/bin/bash
# Extract surrounding lines for the assignment of `deviceAlerts` to `this._deviceAlerts` to ensure it is fetched and assigned correctly.

# Print 10 lines before and after the assignment to understand the context.
rg --type ts --context 10 'this\._deviceAlerts = deviceAlerts;'

Length of output: 1732


738-832: Ensure correct rendering of device info card and actions.

The code renders the ha-device-info-card and associated actions. Verify that the properties and actions are correctly assigned and used.

Verification successful

Verified: The properties and actions used in the ha-device-info-card are correctly assigned and utilized.

  • The properties deviceInfo, firstDeviceAction, and actions are properly initialized and used within the file src/panels/config/devices/ha-config-device-page.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the properties and actions used in the `ha-device-info-card`.

# Test: Search for the properties and actions used in the `ha-device-info-card`. Expect: Proper assignment and usage of these properties and actions.
rg --type ts 'this\.deviceInfo|this\.firstDeviceAction|this\.actions'

Length of output: 1012


Script:

#!/bin/bash
# Description: Verify the properties and actions used in the `ha-config-device-page.ts`.

# Test: Search for the properties and actions used in the `ha-config-device-page.ts`. Expect: Proper assignment and usage of these properties and actions.
rg 'this\.deviceInfo|this\.firstDeviceAction|this\.actions' src/panels/config/devices/ha-config-device-page.ts

Length of output: 112


Script:

#!/bin/bash
# Description: Search for any instances of deviceInfo, firstDeviceAction, and actions in ha-config-device-page.ts to understand their usage.

# Test: Search for any instances of deviceInfo, firstDeviceAction, and actions in ha-config-device-page.ts
rg 'deviceInfo|firstDeviceAction|actions' src/panels/config/devices/ha-config-device-page.ts

Length of output: 2400


Script:

#!/bin/bash
# Description: Verify the initialization and definition of deviceInfo, firstDeviceAction, and actions in ha-config-device-page.ts.

# Test: Search for the initialization and definition of deviceInfo, firstDeviceAction, and actions in ha-config-device-page.ts
rg 'const deviceInfo|const firstDeviceAction|const actions' src/panels/config/devices/ha-config-device-page.ts

Length of output: 529

Tools
Biome

[error] 745-745: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 747-747: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 749-749: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 752-752: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 753-753: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 757-757: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 758-758: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 761-761: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 762-762: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 767-767: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 770-770: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


688-702: Ensure correct handling of battery information.

The code conditionally renders the battery information if battery is defined. Verify that battery and batteryDomain are correctly assigned and used.

Verification successful

The handling of battery and batteryDomain is correct.

The properties battery and batteryDomain are defined and used appropriately within the ha-config-device-page.ts file. The values are fetched and utilized correctly in the code segment.

  • battery is derived from batteryEntity.
  • batteryDomain is computed from battery.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `battery` and `batteryDomain` in the code.

# Test: Search for the properties `battery` and `batteryDomain` in the class. Expect: Proper assignment and usage of these properties.
rg --type ts 'this\.battery|this\.batteryDomain'

Length of output: 313


Script:

#!/bin/bash
# Description: Verify the definition and usage of `battery` and `batteryDomain` in ha-config-device-page.ts.

# Test: Search for the properties `battery` and `batteryDomain` in ha-config-device-page.ts. Expect: Proper assignment and usage of these properties.
rg 'this\.battery|this\.batteryDomain' src/panels/config/devices/ha-config-device-page.ts

Length of output: 91


Script:

#!/bin/bash
# Description: Verify the presence and usage of `battery` and `batteryDomain` in ha-config-device-page.ts.

# Test: Search for the terms `battery` and `batteryDomain` in ha-config-device-page.ts. Expect: Identify all instances where these terms are used.
rg 'battery|batteryDomain' src/panels/config/devices/ha-config-device-page.ts

Length of output: 1094

Tools
Biome

[error] 689-689: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)


870-890: Ensure correct rendering of logbook card in narrow mode.

The code renders the logbook card when in narrow mode. Verify that the properties and conditions are correctly assigned and used.

Verification successful

Ensure correct rendering of logbook card in narrow mode.

The narrow property is correctly defined and initialized, and its usage in the template is consistent with its intended purpose. The rendering logic for the logbook card in narrow mode is correctly implemented.

  • Definition: @property({ type: Boolean, reflect: true }) public narrow = false;
  • Usage: Correctly used to control the rendering logic in the template.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the properties and conditions used to render the logbook card in narrow mode.

# Test: Search for the properties and conditions used to render the logbook card. Expect: Proper assignment and usage of these properties and conditions.
rg --type ts 'this\.logbookCard|this\.narrow'

Length of output: 35555


Script:

#!/bin/bash
# Description: Verify the definition and usage of `this.narrow` within the `ha-config-device-page.ts` file.

# Test: Search for `this.narrow` within the `ha-config-device-page.ts` file.
rg --type ts 'this\.narrow' src/panels/config/devices/ha-config-device-page.ts

Length of output: 254


Script:

#!/bin/bash
# Description: Find the definition and initialization of `this.narrow` within the `ha-config-device-page.ts` file.

# Test: Search for the definition and initialization of `this.narrow` within the `ha-config-device-page.ts` file.
rg --type ts 'narrow' src/panels/config/devices/ha-config-device-page.ts

Length of output: 450


703-721: Ensure correct handling of integration logo.

The code conditionally renders the integration logo if integrations.length is greater than 0. Verify that integrations is correctly assigned and used.

Verification successful

The handling of the integrations property is correct.

The integrations property is derived from _integrations, which processes device, entries, and manifests to create a list of ConfigEntry objects. The code snippet correctly handles the conditional rendering of the integration logo based on the integrations list.

  • The _integrations function is defined using memoizeOne and correctly processes the inputs to create a list of ConfigEntry objects.
  • The conditional rendering logic in the snippet is appropriate and should work as expected.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definition and usage of `integrations` in the code.

# Test: Search for the property `integrations` in the class. Expect: Proper assignment and usage of this property.
rg --type ts 'this\.integrations'

Length of output: 35


Script:

#!/bin/bash
# Search for any references to `integrations` within the specific file.
rg 'integrations' src/panels/config/devices/ha-config-device-page.ts

Length of output: 1225


Script:

#!/bin/bash
# Search for the definition and usage of `_integrations` within the specific file.
rg '_integrations' src/panels/config/devices/ha-config-device-page.ts

Length of output: 523


Script:

#!/bin/bash
# Extract the definition and implementation details of `_integrations` from the specific file.
rg --context 10 'private _integrations = memoizeOne' src/panels/config/devices/ha-config-device-page.ts

Length of output: 772


Script:

#!/bin/bash
# Extract the full implementation details of the function passed to `memoizeOne` for `_integrations`.
rg --context 50 'private _integrations = memoizeOne' src/panels/config/devices/ha-config-device-page.ts

Length of output: 3005

src/translations/en.json (2)

2110-2111: LGTM!

The changes add new confirmation messages for deleting a tag.


6633-6650: LGTM!

The changes add a description for a dashboard and new titles and entities for various sections.


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: 10

@@ -3,13 +3,16 @@ title: When to use remove, delete, add and create
subtitle: The difference between remove/delete and add/create.
---

# Remove vs Delete
# Removing or deleting content
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix multiple top-level headings in the same document.

Having multiple top-level headings violates markdown linting rule MD025. Consider using subheadings.

- # Removing or deleting content
+ ## Removing or deleting content
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Removing or deleting content
## Removing or deleting content
Tools
Markdownlint

6-6: null
Multiple top-level headings in the same document

(MD025, single-title, single-h1)

Comment on lines +1076 to +1077
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using non-null assertion and any type.

Replace the non-null assertion with the optional chaining operator and specify a different type instead of any.

- const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!.automation;
+ const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Tools
Biome

[error] 1076-1076: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1076-1076: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1076-1076: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

Comment on lines +1066 to +1067
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using non-null assertion and any type.

Replace the non-null assertion with the optional chaining operator and specify a different type instead of any.

- const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!.automation;
+ const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Tools
Biome

[error] 1066-1066: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1066-1066: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1066-1066: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

Comment on lines +1083 to +1084
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using non-null assertion and any type.

Replace the non-null assertion with the optional chaining operator and specify a different type instead of any.

- const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!.automation;
+ const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Tools
Biome

[error] 1083-1083: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1083-1083: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1083-1083: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

Comment on lines +1060 to +1061
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using non-null assertion and any type.

Replace the non-null assertion with the optional chaining operator and specify a different type instead of any.

- const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!.automation;
+ const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const automation = ((item.parentElement as HaMenu)!.anchorElement as any)!
.automation;
const automation = ((item.parentElement as HaMenu)?.anchorElement as HTMLElement)?.automation;
Tools
Biome

[error] 1060-1060: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1060-1060: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 1060-1060: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

@@ -301,12 +301,13 @@ export class HaConfigTags extends SubscribeMixin(LitElement) {
private async _removeTag(selectedTag: Tag) {
if (
!(await showConfirmationDialog(this, {
title: this.hass!.localize("ui.panel.config.tag.confirm_remove_title"),
text: this.hass.localize("ui.panel.config.tag.confirm_remove", {
title: this.hass!.localize("ui.panel.config.tag.confirm_delete_title"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace non-null assertion with optional chain operator.

The non-null assertion operator is unsafe. Replace it with the optional chain operator.

-        title: this.hass!.localize("ui.panel.config.tag.confirm_delete_title"),
+        title: this.hass?.localize("ui.panel.config.tag.confirm_delete_title"),
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
title: this.hass!.localize("ui.panel.config.tag.confirm_delete_title"),
title: this.hass?.localize("ui.panel.config.tag.confirm_delete_title"),
Tools
Biome

[error] 304-304: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

title: this.hass!.localize("ui.panel.config.tag.confirm_remove_title"),
text: this.hass.localize("ui.panel.config.tag.confirm_remove", {
title: this.hass!.localize("ui.panel.config.tag.confirm_delete_title"),
text: this.hass.localize("ui.panel.config.tag.confirm_delete", {
tag: selectedTag.name || selectedTag.id,
}),
dismissText: this.hass!.localize("ui.common.cancel"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace non-null assertion with optional chain operator.

The non-null assertion operator is unsafe. Replace it with the optional chain operator.

-        dismissText: this.hass!.localize("ui.common.cancel"),
+        dismissText: this.hass?.localize("ui.common.cancel"),
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dismissText: this.hass!.localize("ui.common.cancel"),
dismissText: this.hass?.localize("ui.common.cancel"),
Tools
Biome

[error] 308-308: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

tag: selectedTag.name || selectedTag.id,
}),
dismissText: this.hass!.localize("ui.common.cancel"),
confirmText: this.hass!.localize("ui.common.remove"),
confirmText: this.hass!.localize("ui.common.delete"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace non-null assertion with optional chain operator.

The non-null assertion operator is unsafe. Replace it with the optional chain operator.

-        confirmText: this.hass!.localize("ui.common.delete"),
+        confirmText: this.hass?.localize("ui.common.delete"),
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
confirmText: this.hass!.localize("ui.common.delete"),
confirmText: this.hass?.localize("ui.common.delete"),
Tools
Biome

[error] 309-309: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

: ""}
<div class="header-right">
${battery &&
(batteryDomain === "binary_sensor" || !isNaN(battery.state as any))
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using any type.

Specify a different type instead of using any.

- (battery.state as any)
+ (battery.state as unknown as number)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(batteryDomain === "binary_sensor" || !isNaN(battery.state as any))
(batteryDomain === "binary_sensor" || !isNaN(battery.state as unknown as number))
Tools
Biome

[error] 689-689: Unexpected any. Specify a different type.

any disables many type checking rules. Its use should be avoided.

(lint/suspicious/noExplicitAny)

Comment on lines +745 to +823
.path=${deviceAction.icon}
slot="graphic"
></ha-svg-icon>
`
: ""}
${deviceAction.trailingIcon
? html`
<ha-svg-icon
slot="meta"
.path=${deviceAction.trailingIcon}
></ha-svg-icon>
`
: ""}
</mwc-list-item>`;
return deviceAction.href
? html`<a
href=${deviceAction.href}
target=${ifDefined(
deviceAction.target
)}
rel=${ifDefined(
deviceAction.target
? "noreferrer"
: undefined
)}
>${listItem}
</a>`
: listItem;
})}
</ha-button-menu>
`
: ""}
</div>
`
: ""
}
</ha-device-info-card>
${!this.narrow ? [automationCard, sceneCard, scriptCard] : ""}
</div>
<div class="column">
${(
[
"control",
"sensor",
"notify",
"event",
"assist",
"config",
"diagnostic",
] as const
).map((category) =>
// Make sure we render controls if no other cards will be rendered
entitiesByCategory[category].length > 0 ||
(entities.length === 0 && category === "control")
? html`
<ha-device-entities-card
.hass=${this.hass}
.header=${this.hass.localize(
`ui.panel.config.devices.entities.${category}`
)}
.deviceName=${deviceName}
.entities=${entitiesByCategory[category]}
.showHidden=${device.disabled_by !== null}
>
</ha-device-entities-card>
`
: ""
)}
<ha-device-via-devices-card
.hass=${this.hass}
.deviceId=${this.deviceId}
></ha-device-via-devices-card>
</div>
<div class="column">
${this.narrow ? [automationCard, sceneCard, scriptCard] : ""}
${
isComponentLoaded(this.hass, "logbook")
? html`
<ha-card outlined>
<h1 class="card-header">
${this.hass.localize("panel.logbook")}
</h1>
<ha-logbook
.hass=${this.hass}
.time=${this._logbookTime}
.entityIds=${this._entityIds(entities)}
.deviceIds=${this._deviceIdInList(this.deviceId)}
virtualize
narrow
no-icon
></ha-logbook>
</ha-card>
`
: ""
}
</div>
</div>
</ha-config-section>
</hass-subpage> `;
>${listItem}
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace non-null assertions with optional chain operator ?..

The non-null assertions should be replaced with the optional chain operator ?. for safer runtime checks.

- href=${ifDefined(firstDeviceAction!.href)}
+ href=${ifDefined(firstDeviceAction?.href)}

- rel=${ifDefined(firstDeviceAction!.target ? "noreferrer" : undefined)}
+ rel=${ifDefined(firstDeviceAction?.target ? "noreferrer" : undefined)}

- target=${ifDefined(firstDeviceAction!.target)}
+ target=${ifDefined(firstDeviceAction?.target)}

- class=${ifDefined(firstDeviceAction!.classes)}
+ class=${ifDefined(firstDeviceAction?.classes)}

- .action=${firstDeviceAction!.action}
+ .action=${firstDeviceAction?.action}

- ${firstDeviceAction!.label}
+ ${firstDeviceAction?.label}

- ${firstDeviceAction!.icon
+ ${firstDeviceAction?.icon

- class=${ifDefined(firstDeviceAction!.classes)}
+ class=${ifDefined(firstDeviceAction?.classes)}

- .path=${firstDeviceAction!.icon}
+ .path=${firstDeviceAction?.icon}

- ${firstDeviceAction!.trailingIcon
+ ${firstDeviceAction?.trailingIcon

- .path=${firstDeviceAction!.trailingIcon}
+ .path=${firstDeviceAction?.trailingIcon}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
href=${ifDefined(firstDeviceAction!.href)}
rel=${ifDefined(
firstDeviceAction!.target ? "noreferrer" : undefined
)}
</div>
`
: ""
}
<ha-device-info-card
.hass=${this.hass}
.device=${device}
>
${deviceInfo}
${
firstDeviceAction || actions.length
? html`
<div class="card-actions" slot="actions">
<div>
<a
href=${ifDefined(firstDeviceAction!.href)}
rel=${ifDefined(
firstDeviceAction!.target
? "noreferrer"
: undefined
)}
target=${ifDefined(firstDeviceAction!.target)}
>
<mwc-button
class=${ifDefined(firstDeviceAction!.classes)}
.action=${firstDeviceAction!.action}
target=${ifDefined(firstDeviceAction!.target)}
>
<mwc-button
class=${ifDefined(firstDeviceAction!.classes)}
.action=${firstDeviceAction!.action}
@click=${this._deviceActionClicked}
graphic="icon"
>
${firstDeviceAction!.label}
${firstDeviceAction!.icon
? html`
<ha-svg-icon
class=${ifDefined(firstDeviceAction!.classes)}
.path=${firstDeviceAction!.icon}
slot="graphic"
></ha-svg-icon>
`
: ""}
${firstDeviceAction!.trailingIcon
? html`
<ha-svg-icon
.path=${firstDeviceAction!.trailingIcon}
slot="trailingIcon"
></ha-svg-icon>
`
: ""}
</mwc-button>
</a>
</div>
${actions.length
? html`
<ha-button-menu>
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
${actions.map((deviceAction) => {
const listItem = html`<mwc-list-item
class=${ifDefined(deviceAction.classes)}
.action=${deviceAction.action}
@click=${this._deviceActionClicked}
graphic="icon"
.hasMeta=${Boolean(deviceAction.trailingIcon)}
>
${firstDeviceAction!.label}
${firstDeviceAction!.icon
${deviceAction.label}
${deviceAction.icon
? html`
<ha-svg-icon
class=${ifDefined(
firstDeviceAction!.classes
)}
.path=${firstDeviceAction!.icon}
class=${ifDefined(deviceAction.classes)}
.path=${deviceAction.icon}
slot="graphic"
></ha-svg-icon>
`
: ""}
${firstDeviceAction!.trailingIcon
${deviceAction.trailingIcon
? html`
<ha-svg-icon
.path=${firstDeviceAction!.trailingIcon}
slot="trailingIcon"
slot="meta"
.path=${deviceAction.trailingIcon}
></ha-svg-icon>
`
: ""}
</mwc-button>
</a>
</div>
${actions.length
? html`
<ha-button-menu>
<ha-icon-button
slot="trigger"
.label=${this.hass.localize(
"ui.common.menu"
</mwc-list-item>`;
return deviceAction.href
? html`<a
href=${deviceAction.href}
target=${ifDefined(deviceAction.target)}
rel=${ifDefined(
deviceAction.target
? "noreferrer"
: undefined
)}
.path=${mdiDotsVertical}
></ha-icon-button>
${actions.map((deviceAction) => {
const listItem = html`<mwc-list-item
class=${ifDefined(deviceAction.classes)}
.action=${deviceAction.action}
@click=${this._deviceActionClicked}
graphic="icon"
.hasMeta=${Boolean(
deviceAction.trailingIcon
)}
>
${deviceAction.label}
${deviceAction.icon
? html`
<ha-svg-icon
class=${ifDefined(
deviceAction.classes
)}
.path=${deviceAction.icon}
slot="graphic"
></ha-svg-icon>
`
: ""}
${deviceAction.trailingIcon
? html`
<ha-svg-icon
slot="meta"
.path=${deviceAction.trailingIcon}
></ha-svg-icon>
`
: ""}
</mwc-list-item>`;
return deviceAction.href
? html`<a
href=${deviceAction.href}
target=${ifDefined(
deviceAction.target
)}
rel=${ifDefined(
deviceAction.target
? "noreferrer"
: undefined
)}
>${listItem}
</a>`
: listItem;
})}
</ha-button-menu>
`
: ""}
</div>
`
: ""
}
</ha-device-info-card>
${!this.narrow ? [automationCard, sceneCard, scriptCard] : ""}
</div>
<div class="column">
${(
[
"control",
"sensor",
"notify",
"event",
"assist",
"config",
"diagnostic",
] as const
).map((category) =>
// Make sure we render controls if no other cards will be rendered
entitiesByCategory[category].length > 0 ||
(entities.length === 0 && category === "control")
? html`
<ha-device-entities-card
.hass=${this.hass}
.header=${this.hass.localize(
`ui.panel.config.devices.entities.${category}`
)}
.deviceName=${deviceName}
.entities=${entitiesByCategory[category]}
.showHidden=${device.disabled_by !== null}
>
</ha-device-entities-card>
`
: ""
)}
<ha-device-via-devices-card
.hass=${this.hass}
.deviceId=${this.deviceId}
></ha-device-via-devices-card>
</div>
<div class="column">
${this.narrow ? [automationCard, sceneCard, scriptCard] : ""}
${
isComponentLoaded(this.hass, "logbook")
? html`
<ha-card outlined>
<h1 class="card-header">
${this.hass.localize("panel.logbook")}
</h1>
<ha-logbook
.hass=${this.hass}
.time=${this._logbookTime}
.entityIds=${this._entityIds(entities)}
.deviceIds=${this._deviceIdInList(this.deviceId)}
virtualize
narrow
no-icon
></ha-logbook>
</ha-card>
`
: ""
}
</div>
</div>
</ha-config-section>
</hass-subpage> `;
>${listItem}
href=${ifDefined(firstDeviceAction?.href)}
rel=${ifDefined(
firstDeviceAction?.target ? "noreferrer" : undefined
)}
target=${ifDefined(firstDeviceAction?.target)}
>
<mwc-button
class=${ifDefined(firstDeviceAction?.classes)}
.action=${firstDeviceAction?.action}
@click=${this._deviceActionClicked}
graphic="icon"
>
${firstDeviceAction?.label}
${firstDeviceAction?.icon
? html`
<ha-svg-icon
class=${ifDefined(firstDeviceAction?.classes)}
.path=${firstDeviceAction?.icon}
slot="graphic"
></ha-svg-icon>
`
: ""}
${firstDeviceAction?.trailingIcon
? html`
<ha-svg-icon
.path=${firstDeviceAction?.trailingIcon}
slot="trailingIcon"
></ha-svg-icon>
`
: ""}
</mwc-button>
</a>
</div>
${actions.length
? html`
<ha-button-menu>
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
${actions.map((deviceAction) => {
const listItem = html`<mwc-list-item
class=${ifDefined(deviceAction.classes)}
.action=${deviceAction.action}
@click=${this._deviceActionClicked}
graphic="icon"
.hasMeta=${Boolean(deviceAction.trailingIcon)}
>
${deviceAction.label}
${deviceAction.icon
? html`
<ha-svg-icon
class=${ifDefined(deviceAction.classes)}
.path=${deviceAction.icon}
slot="graphic"
></ha-svg-icon>
`
: ""}
${deviceAction.trailingIcon
? html`
<ha-svg-icon
slot="meta"
.path=${deviceAction.trailingIcon}
></ha-svg-icon>
`
: ""}
</mwc-list-item>`;
return deviceAction.href
? html`<a
href=${deviceAction.href}
target=${ifDefined(deviceAction.target)}
rel=${ifDefined(
deviceAction.target
? "noreferrer"
: undefined
)}
>${listItem}
Tools
Biome

[error] 745-745: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 747-747: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 749-749: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 752-752: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 753-753: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 757-757: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 758-758: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 761-761: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 762-762: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 767-767: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)


[error] 770-770: Forbidden non-null assertion.

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

(lint/style/noNonNullAssertion)

@bramkragten bramkragten merged commit 895333a into master Jul 5, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Demo Related to frontend demo content Design Related to Home Assistant design gallery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants