Commit 958e9f09 authored by Tim Zallmann's avatar Tim Zallmann Committed by Filipa Lacerda

Upgrade underscore.js

parent f460e2dc
...@@ -100,9 +100,10 @@ export default { ...@@ -100,9 +100,10 @@ export default {
fetchSearchedProjects(searchQuery) { fetchSearchedProjects(searchQuery) {
this.searchQuery = searchQuery; this.searchQuery = searchQuery;
this.toggleLoader(true); this.toggleLoader(true);
this.service.getSearchedProjects(this.searchQuery) this.service
.getSearchedProjects(this.searchQuery)
.then(res => res.json()) .then(res => res.json())
.then((results) => { .then(results => {
this.toggleSearchProjectsList(true); this.toggleSearchProjectsList(true);
this.store.setSearchedProjects(results); this.store.setSearchedProjects(results);
}) })
......
...@@ -50,7 +50,7 @@ export default class ProjectsService { ...@@ -50,7 +50,7 @@ export default class ProjectsService {
} else { } else {
// Check if project is already present in frequents list // Check if project is already present in frequents list
// When found, update metadata of it. // When found, update metadata of it.
storedFrequentProjects = JSON.parse(storedRawProjects).map((projectItem) => { storedFrequentProjects = JSON.parse(storedRawProjects).map(projectItem => {
if (projectItem.id === project.id) { if (projectItem.id === project.id) {
matchFound = true; matchFound = true;
const diff = Math.abs(project.lastAccessedOn - projectItem.lastAccessedOn) / HOUR_IN_MS; const diff = Math.abs(project.lastAccessedOn - projectItem.lastAccessedOn) / HOUR_IN_MS;
...@@ -104,13 +104,17 @@ export default class ProjectsService { ...@@ -104,13 +104,17 @@ export default class ProjectsService {
return []; return [];
} }
if (bp.getBreakpointSize() === 'sm' || if (bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'xs') {
bp.getBreakpointSize() === 'xs') {
frequentProjectsCount = FREQUENT_PROJECTS.LIST_COUNT_MOBILE; frequentProjectsCount = FREQUENT_PROJECTS.LIST_COUNT_MOBILE;
} }
const frequentProjects = storedFrequentProjects const frequentProjects = storedFrequentProjects.filter(
.filter(project => project.frequency >= FREQUENT_PROJECTS.ELIGIBLE_FREQUENCY); project => project.frequency >= FREQUENT_PROJECTS.ELIGIBLE_FREQUENCY,
);
if (!frequentProjects || frequentProjects.length === 0) {
return [];
}
// Sort all frequent projects in decending order of frequency // Sort all frequent projects in decending order of frequency
// and then by lastAccessedOn with recent most first // and then by lastAccessedOn with recent most first
......
---
title: Upgrade underscore.js to 1.9.0
merge_request: 18578
author:
type: other
...@@ -23,7 +23,8 @@ const createComponent = () => { ...@@ -23,7 +23,8 @@ const createComponent = () => {
}); });
}; };
const returnServicePromise = (data, failed) => new Promise((resolve, reject) => { const returnServicePromise = (data, failed) =>
new Promise((resolve, reject) => {
if (failed) { if (failed) {
reject(data); reject(data);
} else { } else {
...@@ -33,7 +34,7 @@ const returnServicePromise = (data, failed) => new Promise((resolve, reject) => ...@@ -33,7 +34,7 @@ const returnServicePromise = (data, failed) => new Promise((resolve, reject) =>
}, },
}); });
} }
}); });
describe('AppComponent', () => { describe('AppComponent', () => {
describe('computed', () => { describe('computed', () => {
...@@ -185,7 +186,7 @@ describe('AppComponent', () => { ...@@ -185,7 +186,7 @@ describe('AppComponent', () => {
describe('fetchSearchedProjects', () => { describe('fetchSearchedProjects', () => {
const searchQuery = 'test'; const searchQuery = 'test';
it('should perform search with provided search query', (done) => { it('should perform search with provided search query', done => {
const mockData = [mockRawProject]; const mockData = [mockRawProject];
spyOn(vm, 'toggleLoader'); spyOn(vm, 'toggleLoader');
spyOn(vm, 'toggleSearchProjectsList'); spyOn(vm, 'toggleSearchProjectsList');
...@@ -203,7 +204,7 @@ describe('AppComponent', () => { ...@@ -203,7 +204,7 @@ describe('AppComponent', () => {
}, 0); }, 0);
}); });
it('should update props for showing search failure', (done) => { it('should update props for showing search failure', done => {
spyOn(vm, 'toggleSearchProjectsList'); spyOn(vm, 'toggleSearchProjectsList');
spyOn(vm.service, 'getSearchedProjects').and.returnValue(returnServicePromise({}, true)); spyOn(vm.service, 'getSearchedProjects').and.returnValue(returnServicePromise({}, true));
...@@ -219,7 +220,7 @@ describe('AppComponent', () => { ...@@ -219,7 +220,7 @@ describe('AppComponent', () => {
}); });
describe('logCurrentProjectAccess', () => { describe('logCurrentProjectAccess', () => {
it('should log current project access via service', (done) => { it('should log current project access via service', done => {
spyOn(vm.service, 'logProjectAccess'); spyOn(vm.service, 'logProjectAccess');
vm.currentProject = mockProject; vm.currentProject = mockProject;
...@@ -257,7 +258,7 @@ describe('AppComponent', () => { ...@@ -257,7 +258,7 @@ describe('AppComponent', () => {
}); });
describe('created', () => { describe('created', () => {
it('should bind event listeners on eventHub', (done) => { it('should bind event listeners on eventHub', done => {
spyOn(eventHub, '$on'); spyOn(eventHub, '$on');
createComponent().$mount(); createComponent().$mount();
...@@ -273,7 +274,7 @@ describe('AppComponent', () => { ...@@ -273,7 +274,7 @@ describe('AppComponent', () => {
}); });
describe('beforeDestroy', () => { describe('beforeDestroy', () => {
it('should unbind event listeners on eventHub', (done) => { it('should unbind event listeners on eventHub', done => {
const vm = createComponent(); const vm = createComponent();
spyOn(eventHub, '$off'); spyOn(eventHub, '$off');
...@@ -305,7 +306,7 @@ describe('AppComponent', () => { ...@@ -305,7 +306,7 @@ describe('AppComponent', () => {
expect(vm.$el.querySelector('.search-input-container')).toBeDefined(); expect(vm.$el.querySelector('.search-input-container')).toBeDefined();
}); });
it('should render loading animation', (done) => { it('should render loading animation', done => {
vm.toggleLoader(true); vm.toggleLoader(true);
Vue.nextTick(() => { Vue.nextTick(() => {
const loadingEl = vm.$el.querySelector('.loading-animation'); const loadingEl = vm.$el.querySelector('.loading-animation');
...@@ -317,7 +318,7 @@ describe('AppComponent', () => { ...@@ -317,7 +318,7 @@ describe('AppComponent', () => {
}); });
}); });
it('should render frequent projects list header', (done) => { it('should render frequent projects list header', done => {
vm.toggleFrequentProjectsList(true); vm.toggleFrequentProjectsList(true);
Vue.nextTick(() => { Vue.nextTick(() => {
const sectionHeaderEl = vm.$el.querySelector('.section-header'); const sectionHeaderEl = vm.$el.querySelector('.section-header');
...@@ -328,7 +329,7 @@ describe('AppComponent', () => { ...@@ -328,7 +329,7 @@ describe('AppComponent', () => {
}); });
}); });
it('should render frequent projects list', (done) => { it('should render frequent projects list', done => {
vm.toggleFrequentProjectsList(true); vm.toggleFrequentProjectsList(true);
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.$el.querySelector('.projects-list-frequent-container')).toBeDefined(); expect(vm.$el.querySelector('.projects-list-frequent-container')).toBeDefined();
...@@ -336,7 +337,7 @@ describe('AppComponent', () => { ...@@ -336,7 +337,7 @@ describe('AppComponent', () => {
}); });
}); });
it('should render searched projects list', (done) => { it('should render searched projects list', done => {
vm.toggleSearchProjectsList(true); vm.toggleSearchProjectsList(true);
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.$el.querySelector('.section-header')).toBe(null); expect(vm.$el.querySelector('.section-header')).toBe(null);
......
...@@ -8091,9 +8091,9 @@ undefsafe@^2.0.1: ...@@ -8091,9 +8091,9 @@ undefsafe@^2.0.1:
dependencies: dependencies:
debug "^2.2.0" debug "^2.2.0"
underscore@^1.8.3: underscore@^1.9.0:
version "1.8.3" version "1.9.0"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.0.tgz#31dbb314cfcc88f169cd3692d9149d81a00a73e4"
underscore@~1.7.0: underscore@~1.7.0:
version "1.7.0" version "1.7.0"
......
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