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

UI: helper sort-objects to alphabetize list items #24103

Merged
merged 14 commits into from
Nov 14, 2023

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Nov 10, 2023

Fixes #14176 by sorting models using a new helper sort-objects in the hbs template

Screenshot 2023-11-10 at 12 50 34 PM

before

Screenshot 2023-11-10 at 12 50 55 PM

@hellobontempo hellobontempo added this to the 1.16.0-rc1 milestone Nov 10, 2023
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Nov 10, 2023
Copy link

github-actions bot commented Nov 10, 2023

Build Results:
All builds succeeded! ✅

@@ -5,7 +5,7 @@

<Identity::EntityNav @identityType={{this.identityType}} @model={{this.model}} />
{{#if this.model.meta.total}}
{{#each this.model as |item|}}
{{#each (sort-objects this.model "name") as |item|}}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll want to sort in lazyPaginatedQuery instead, otherwise this will only sort the items on the current page

@@ -4,4 +4,29 @@
*/

import IdentitySerializer from './_base';
export default IdentitySerializer.extend();
export default IdentitySerializer.extend({
extractLazyPaginatedData(payload) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have to serialize the data here so that the information is sortable by name in lazyPaginatedQuery

export default IdentitySerializer.extend({
extractLazyPaginatedData(payload) {
return payload.data.keys.map((key) => {
const model = payload.data.key_info[key];
Copy link
Contributor

Choose a reason for hiding this comment

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

Used the same logic that's in the IdentitySerializer's normalizeItems method so we still have metadata on the list

Copy link
Contributor

@hashishaw hashishaw left a comment

Choose a reason for hiding this comment

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

teamwork 🎉

@hashishaw hashishaw merged commit c265f5a into main Nov 14, 2023
69 checks passed
@hashishaw hashishaw deleted the ui/VAULT-21867/sort-list-items branch November 14, 2023 21:57
hashishaw added a commit that referenced this pull request Nov 15, 2023
* move list to component

* use helper instead

* add changelog

* clarify changelog copy

* delete components now that helper is in use

* move helper to util, remove template helper invokation

* add optional sorting to lazyPaginatedQuery based on sortBy query attribute

* Add serialization to entity-alias and entity so that they can be sorted by name on list view

* Same logic as base normalizeItems for extractLazyPaginatedData so that metadata shows on list

* Add headers

---------

Co-authored-by: Chelsea Shaw <[email protected]>
Co-authored-by: Chelsea Shaw <[email protected]>
hashishaw added a commit that referenced this pull request Nov 15, 2023
* move list to component

* use helper instead

* add changelog

* clarify changelog copy

* delete components now that helper is in use

* move helper to util, remove template helper invokation

* add optional sorting to lazyPaginatedQuery based on sortBy query attribute

* Add serialization to entity-alias and entity so that they can be sorted by name on list view

* Same logic as base normalizeItems for extractLazyPaginatedData so that metadata shows on list

* Add headers

---------

Co-authored-by: Chelsea Shaw <[email protected]>
Co-authored-by: Chelsea Shaw <[email protected]>
@hellobontempo hellobontempo modified the milestones: 1.16.0-rc1, 1.13.11 Nov 15, 2023
hashishaw added a commit that referenced this pull request Nov 15, 2023
* move list to component

* use helper instead

* add changelog

* clarify changelog copy

* delete components now that helper is in use

* move helper to util, remove template helper invokation

* add optional sorting to lazyPaginatedQuery based on sortBy query attribute

* Add serialization to entity-alias and entity so that they can be sorted by name on list view

* Same logic as base normalizeItems for extractLazyPaginatedData so that metadata shows on list

* Add headers

---------

Co-authored-by: claire bontempo <[email protected]>
hashishaw added a commit that referenced this pull request Nov 15, 2023
* move list to component

* use helper instead

* add changelog

* clarify changelog copy

* delete components now that helper is in use

* move helper to util, remove template helper invokation

* add optional sorting to lazyPaginatedQuery based on sortBy query attribute

* Add serialization to entity-alias and entity so that they can be sorted by name on list view

* Same logic as base normalizeItems for extractLazyPaginatedData so that metadata shows on list

* Add headers

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vault-UI: Present entities & aliases sorted by name
2 participants