-
Notifications
You must be signed in to change notification settings - Fork 398
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
Conversation
<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) { |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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.
hi @apexskier im happy to fix the lint issues if it is easier for you |
@bwp91 Just pushed an attempt (though wasn't able to run locally still), but if that doesn't work, feel free. |
The test failure doesn't look related to me - only 1 / 10 in the matrix failed, timeout on gateway. |
There was a problem hiding this 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"> |
There was a problem hiding this comment.
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.
<option [value]="version.version" [selected]="versionSelect == version.version"> | |
<option [value]="version.version"> |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
♻️ 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.
💡 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.
⚙️ 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 withif (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).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.