diff --git a/app/assets/javascripts/packages_and_registries/package_registry/components/list/package_search.vue b/app/assets/javascripts/packages_and_registries/package_registry/components/list/package_search.vue index df50f5a52b411aa225b8ea2746838fe11e358e7a..c3dd3bf0facd1713d8609521bbb23c723b6175ca 100644 --- a/app/assets/javascripts/packages_and_registries/package_registry/components/list/package_search.vue +++ b/app/assets/javascripts/packages_and_registries/package_registry/components/list/package_search.vue @@ -49,6 +49,11 @@ export default { }; }, computed: { + localStorageKey() { + return this.isGroupPage + ? 'group_package_registry_list_sorting' + : 'package_registry_list_sorting'; + }, sortableFields() { return sortableFields(this.isGroupPage); }, @@ -114,7 +119,7 @@ export default { <template> <local-storage-sync - storage-key="package_registry_list_sorting" + :storage-key="localStorageKey" :value="sorting" @input="updateSortingFromLocalStorage" > diff --git a/spec/frontend/packages_and_registries/package_registry/components/list/packages_search_spec.js b/spec/frontend/packages_and_registries/package_registry/components/list/packages_search_spec.js index 6a1c34df5963e1baef19710b3bdf95d79bde5126..eb5c546d2becfe9829c084f004edb3a152d5d59e 100644 --- a/spec/frontend/packages_and_registries/package_registry/components/list/packages_search_spec.js +++ b/spec/frontend/packages_and_registries/package_registry/components/list/packages_search_spec.js @@ -52,7 +52,7 @@ describe('Package Search', () => { expect(findPersistedSearch().exists()).toBe(false); }); - it('has a LocalStorageSync component', () => { + it('has a LocalStorageSync component with project key', () => { mountComponent(); expect(findLocalStorageSync().props()).toMatchObject({ @@ -64,6 +64,18 @@ describe('Package Search', () => { }); }); + it('has a LocalStorageSync component with group key', () => { + mountComponent(true); + + expect(findLocalStorageSync().props()).toMatchObject({ + storageKey: 'group_package_registry_list_sorting', + value: { + orderBy: LIST_KEY_CREATED_AT, + sort: 'desc', + }, + }); + }); + it.each` isGroupPage | page ${false} | ${'project'}