Commit ace8bf48 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'frequent-items' into 'master'

Use `getTopFrequentItems` in projects dropdown to show recently used

See merge request gitlab-org/gitlab!58851
parents 9c7732b5 fda7a608
......@@ -15,7 +15,8 @@ import { mapState, mapActions } from 'vuex';
import Api from '~/api';
import createFlash, { FLASH_TYPES } from '~/flash';
import { STORAGE_KEY, FREQUENT_ITEMS } from '~/frequent_items/constants';
import { STORAGE_KEY } from '~/frequent_items/constants';
import { getTopFrequentItems } from '~/frequent_items/utils';
import AccessorUtilities from '~/lib/utils/accessor';
import { __ } from '~/locale';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
......@@ -137,11 +138,9 @@ export default {
let storedFrequentItems = storedRawItems ? JSON.parse(storedRawItems) : [];
/* Filter for the current group */
storedFrequentItems = storedFrequentItems
.filter((item) => {
return Boolean(item.webUrl?.slice(1)?.startsWith(this.parentItem.fullPath));
})
.sort((a, b) => a.frequency > b.frequency);
storedFrequentItems = storedFrequentItems.filter((item) => {
return Boolean(item.webUrl?.slice(1)?.startsWith(this.parentItem.fullPath));
});
if (searchTerm) {
storedFrequentItems = fuzzaldrinPlus.filter(storedFrequentItems, searchTerm, {
......@@ -149,11 +148,9 @@ export default {
});
}
this.recentItems = storedFrequentItems
.map((item) => {
return { ...item, avatar_url: item.avatarUrl, web_url: item.webUrl };
})
.slice(0, FREQUENT_ITEMS.LIST_COUNT_DESKTOP); // Only keep top 5 results
this.recentItems = getTopFrequentItems(storedFrequentItems).map((item) => {
return { ...item, avatar_url: item.avatarUrl, web_url: item.webUrl };
});
return this.recentItems;
},
......
---
title: Use `getTopFrequentItems` in projects dropdown to show recently used
merge_request: 58851
author:
type: fixed
......@@ -368,7 +368,7 @@ export const mockFrequentlyUsedProjects = [
webUrl: '/gitlab-org/project1',
avatarUrl: null,
lastAccessedOn: 123,
frequency: 1,
frequency: 4,
},
{
id: 2,
......@@ -377,7 +377,7 @@ export const mockFrequentlyUsedProjects = [
webUrl: '/gitlab-org/project2',
avatarUrl: null,
lastAccessedOn: 124,
frequency: 1,
frequency: 3,
},
];
......@@ -389,7 +389,7 @@ export const mockMixedFrequentlyUsedProjects = [
webUrl: '/gitlab-org/project1',
avatarUrl: null,
lastAccessedOn: 123,
frequency: 1,
frequency: 4,
},
{
id: 2,
......@@ -398,6 +398,6 @@ export const mockMixedFrequentlyUsedProjects = [
webUrl: '/gitlab-com/project2',
avatarUrl: null,
lastAccessedOn: 124,
frequency: 1,
frequency: 3,
},
];
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment