Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve plugins Manage Version's select UI #2424

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

Merged
merged 5 commits into from
May 17, 2025

Conversation

apexskier
Copy link
Contributor

@apexskier apexskier commented Apr 30, 2025

♻️ Current situation

The plugin "Manage Version" window has a couple minor (extremely minor) issues.

This screenshot shows it immediately after opening with no subsequent interaction.

  1. The install button next to the select element should be enabled, as the selected version is 1.0.8, which is newer than the currently installed version of 1.0.6. I realize that the prior row is the latest version, which is the intended option here.
  2. To that point, the default selected version in the select element I selected is always going to be the same as one of the tagged versions (I think always latest), so it's kind of redundant here.

Homebridge C647 - Safari - 2025-04-30 at 14 28 30@2x

💡 Proposed solution

This PR proposes selecting the currently installed version by default in the select element, which makes the disabling of the install button make sense. It also adds a checkmark within the option element to indicate which is installed, which is nice when interacting with the control.

Homebridge C647 - Safari - 2025-04-30 at 14 51 50@2x
Homebridge C647 - Safari - 2025-04-30 at 14 51 54@2x

⚙️ Release Notes

No breaking changes.

Select and highlight current version in the plugin Manage Versions window.

➕ Additional Information

I also cleaned up some of the angular conditionals in this template. There were a lot of cases of if (condition); if (!condition) that could be replaced with if (condition) else (This is a code smell, as it's not clear from reading only the second conditional that it's mutually exclusive with the prior).

A couple notes as a first time contributor:

  • npm run lint fails locally (and I can't rely on the PR since running requires maintainer kickoff).
    ❯ npm run lint
    
    > [email protected] lint
    > eslint . --max-warnings=0
    
    
    Oops! Something went wrong! :(
    
    ESLint: 9.25.0
    
    Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/cameronlittle/Developer/homebridge-config-ui-x/node_modules/@antfu/eslint-config/dist/index.js from /Users/cameronlittle/Developer/homebridge-config-ui-x/eslint.config.js not supported.
    Instead change the require of index.js in /Users/cameronlittle/Developer/homebridge-config-ui-x/eslint.config.js to a dynamic import() which is available in all CommonJS modules.
        at TracingChannel.traceSync (node:diagnostics_channel:315:14)
        at Object.<anonymous> (/Users/cameronlittle/Developer/homebridge-config-ui-x/eslint.config.js:1:19)
    
  • formatOnSave is enabled in vscode (great!) but the file I'm working on here isn't formatted already, which leads to a ton of mess in the PR without disabling or manually reverting changes. Ideally a big PR would go through formatting everything and requiring formatting in PR checks so I wouldn't have to worry about this.

Testing

No tests added or changed (didn't see any existing test patterns for this detailed a UI concern). Manually tested locally.

Reviewer Nudging

See inline comments.

@github-actions github-actions bot added the latest Related to Latest Branch label Apr 30, 2025
<button class="btn btn-primary m-0 ms-3" [disabled]="!versionSelect" (click)="doInstall(versionSelect)">
<i class="fas fa-fw fa-arrow-alt-circle-down"></i>
</button>
} @if (versionSelect && versionSelect === plugin.installedVersion) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This conditional felt confusingly complicated. Hopefully the new version is simpler: a single conditional controls both changes in logic (inner icon and enablement)

@@ -51,17 +51,22 @@ <h6 class="mb-3">{{ 'plugins.manage.select_version' | translate }}</h6>
<br />
<select class="custom-select w-100" style="font-size: 0.875rem" [(ngModel)]="versionSelect">
@for (version of versions; track version) {
<option [value]="version.version">v{{ version.version }}</option>
<option [value]="version.version" [selected]="versionSelect == version.version">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new selected attribute is the main functional change here.

@apexskier apexskier marked this pull request as ready for review April 30, 2025 20:58
@apexskier apexskier changed the title Manage version select Improve plugin's Manage Version's select UI Apr 30, 2025
@apexskier apexskier changed the title Improve plugin's Manage Version's select UI Improve plugins Manage Version's select UI Apr 30, 2025
@bwp91
Copy link
Contributor

bwp91 commented May 3, 2025

hi @apexskier im happy to fix the lint issues if it is easier for you

@apexskier
Copy link
Contributor Author

@bwp91 Just pushed an attempt (though wasn't able to run locally still), but if that doesn't work, feel free.

@apexskier
Copy link
Contributor Author

The test failure doesn't look related to me - only 1 / 10 in the matrix failed, timeout on gateway.

@bwp91 bwp91 requested review from Copilot and bwp91 May 4, 2025 10:40
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the Manage Version UI for plugins by selecting the currently installed version by default and cleaning up conditional logic in the Angular template.

  • Updates the button logic to properly enable/disable the install button depending on whether the selected version matches the installed version.
  • Enhances the version select options by adding a checkmark for the installed version and refactoring conditional blocks for better clarity.
Comments suppressed due to low confidence (1)

ui/src/app/core/manage-plugins/manage-version/manage-version.component.html:52

  • [nitpick] Consider renaming the 'versionSelect' variable to 'selectedVersion' to better reflect its role as the currently selected version in the UI.
<select class="custom-select w-100" style="font-size: 0.875rem" [(ngModel)]="versionSelect">

@@ -51,17 +51,23 @@ <h6 class="mb-3">{{ 'plugins.manage.select_version' | translate }}</h6>
<br />
<select class="custom-select w-100" style="font-size: 0.875rem" [(ngModel)]="versionSelect">
@for (version of versions; track version) {
<option [value]="version.version">v{{ version.version }}</option>
<option [value]="version.version" [selected]="versionSelect == version.version">
Copy link
Preview

Copilot AI May 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The option element uses both ngModel binding and the [selected] attribute, which can be redundant. Consider relying solely on ngModel to manage the selected state and remove the [selected] attribute for simpler, clearer code.

Suggested change
<option [value]="version.version" [selected]="versionSelect == version.version">
<option [value]="version.version">

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

could be true that [selected] is not needed when there is an [(ngModel)] on the select attribute.

@apexskier was there a particular situation where it was not working before but adding the [selected] made it work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first screenshot demonstrates this not working in Safari. However, I'm having trouble reproducing this now (I've done that update since) so I'm not 100% confident.

I haven't used angular 2 much at all, but reading the docs for ngModel, I don't see any indication that it manages the select attribute.

@bwp91 bwp91 merged commit 11f28b1 into homebridge:latest May 17, 2025
13 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
latest Related to Latest Branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants