diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-05-07 09:08:43 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-05-07 09:08:43 +0000 |
commit | 9f7a6742466931f219cb83ff63e6debcec5db221 (patch) | |
tree | f86121d03ebcee4ee3a8dacc93a0636b2bb85b22 | |
parent | f460e2dc0fd38090621fe71b20d2e87d16e6d85b (diff) | |
parent | 958e9f09864b1b7a431ea4a43dece3a59690bdad (diff) | |
download | gitlab-ce-9f7a6742466931f219cb83ff63e6debcec5db221.tar.gz |
Merge branch 'tz-upgrade-underscore' into 'master'
Upgrade underscore.js
See merge request gitlab-org/gitlab-ce!18578
-rw-r--r-- | app/assets/javascripts/projects_dropdown/components/app.vue | 5 | ||||
-rw-r--r-- | app/assets/javascripts/projects_dropdown/service/projects_service.js | 14 | ||||
-rw-r--r-- | changelogs/unreleased/tz-upgrade-underscore.yml | 5 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | spec/javascripts/projects_dropdown/components/app_spec.js | 41 | ||||
-rw-r--r-- | yarn.lock | 6 |
6 files changed, 42 insertions, 31 deletions
diff --git a/app/assets/javascripts/projects_dropdown/components/app.vue b/app/assets/javascripts/projects_dropdown/components/app.vue index 34a60dd574b..0bbd8a41753 100644 --- a/app/assets/javascripts/projects_dropdown/components/app.vue +++ b/app/assets/javascripts/projects_dropdown/components/app.vue @@ -100,9 +100,10 @@ export default { fetchSearchedProjects(searchQuery) { this.searchQuery = searchQuery; this.toggleLoader(true); - this.service.getSearchedProjects(this.searchQuery) + this.service + .getSearchedProjects(this.searchQuery) .then(res => res.json()) - .then((results) => { + .then(results => { this.toggleSearchProjectsList(true); this.store.setSearchedProjects(results); }) diff --git a/app/assets/javascripts/projects_dropdown/service/projects_service.js b/app/assets/javascripts/projects_dropdown/service/projects_service.js index 7231f520933..ed1c3deead2 100644 --- a/app/assets/javascripts/projects_dropdown/service/projects_service.js +++ b/app/assets/javascripts/projects_dropdown/service/projects_service.js @@ -50,7 +50,7 @@ export default class ProjectsService { } else { // Check if project is already present in frequents list // When found, update metadata of it. - storedFrequentProjects = JSON.parse(storedRawProjects).map((projectItem) => { + storedFrequentProjects = JSON.parse(storedRawProjects).map(projectItem => { if (projectItem.id === project.id) { matchFound = true; const diff = Math.abs(project.lastAccessedOn - projectItem.lastAccessedOn) / HOUR_IN_MS; @@ -104,13 +104,17 @@ export default class ProjectsService { return []; } - if (bp.getBreakpointSize() === 'sm' || - bp.getBreakpointSize() === 'xs') { + if (bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'xs') { frequentProjectsCount = FREQUENT_PROJECTS.LIST_COUNT_MOBILE; } - const frequentProjects = storedFrequentProjects - .filter(project => project.frequency >= FREQUENT_PROJECTS.ELIGIBLE_FREQUENCY); + const frequentProjects = storedFrequentProjects.filter( + project => project.frequency >= FREQUENT_PROJECTS.ELIGIBLE_FREQUENCY, + ); + + if (!frequentProjects || frequentProjects.length === 0) { + return []; + } // Sort all frequent projects in decending order of frequency // and then by lastAccessedOn with recent most first diff --git a/changelogs/unreleased/tz-upgrade-underscore.yml b/changelogs/unreleased/tz-upgrade-underscore.yml new file mode 100644 index 00000000000..5dfd8154ecd --- /dev/null +++ b/changelogs/unreleased/tz-upgrade-underscore.yml @@ -0,0 +1,5 @@ +--- +title: Upgrade underscore.js to 1.9.0 +merge_request: 18578 +author: +type: other diff --git a/package.json b/package.json index e95add1d7e9..c2137ab8316 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "three-orbit-controls": "^82.1.0", "three-stl-loader": "^1.0.4", "timeago.js": "^3.0.2", - "underscore": "^1.8.3", + "underscore": "^1.9.0", "url-loader": "^0.6.2", "visibilityjs": "^1.2.4", "vue": "^2.5.16", diff --git a/spec/javascripts/projects_dropdown/components/app_spec.js b/spec/javascripts/projects_dropdown/components/app_spec.js index 2054fef790b..38b31c3d727 100644 --- a/spec/javascripts/projects_dropdown/components/app_spec.js +++ b/spec/javascripts/projects_dropdown/components/app_spec.js @@ -23,17 +23,18 @@ const createComponent = () => { }); }; -const returnServicePromise = (data, failed) => new Promise((resolve, reject) => { - if (failed) { - reject(data); - } else { - resolve({ - json() { - return data; - }, - }); - } -}); +const returnServicePromise = (data, failed) => + new Promise((resolve, reject) => { + if (failed) { + reject(data); + } else { + resolve({ + json() { + return data; + }, + }); + } + }); describe('AppComponent', () => { describe('computed', () => { @@ -185,7 +186,7 @@ describe('AppComponent', () => { describe('fetchSearchedProjects', () => { const searchQuery = 'test'; - it('should perform search with provided search query', (done) => { + it('should perform search with provided search query', done => { const mockData = [mockRawProject]; spyOn(vm, 'toggleLoader'); spyOn(vm, 'toggleSearchProjectsList'); @@ -203,7 +204,7 @@ describe('AppComponent', () => { }, 0); }); - it('should update props for showing search failure', (done) => { + it('should update props for showing search failure', done => { spyOn(vm, 'toggleSearchProjectsList'); spyOn(vm.service, 'getSearchedProjects').and.returnValue(returnServicePromise({}, true)); @@ -219,7 +220,7 @@ describe('AppComponent', () => { }); describe('logCurrentProjectAccess', () => { - it('should log current project access via service', (done) => { + it('should log current project access via service', done => { spyOn(vm.service, 'logProjectAccess'); vm.currentProject = mockProject; @@ -257,7 +258,7 @@ describe('AppComponent', () => { }); describe('created', () => { - it('should bind event listeners on eventHub', (done) => { + it('should bind event listeners on eventHub', done => { spyOn(eventHub, '$on'); createComponent().$mount(); @@ -273,7 +274,7 @@ describe('AppComponent', () => { }); describe('beforeDestroy', () => { - it('should unbind event listeners on eventHub', (done) => { + it('should unbind event listeners on eventHub', done => { const vm = createComponent(); spyOn(eventHub, '$off'); @@ -305,7 +306,7 @@ describe('AppComponent', () => { expect(vm.$el.querySelector('.search-input-container')).toBeDefined(); }); - it('should render loading animation', (done) => { + it('should render loading animation', done => { vm.toggleLoader(true); Vue.nextTick(() => { const loadingEl = vm.$el.querySelector('.loading-animation'); @@ -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); Vue.nextTick(() => { const sectionHeaderEl = vm.$el.querySelector('.section-header'); @@ -328,7 +329,7 @@ describe('AppComponent', () => { }); }); - it('should render frequent projects list', (done) => { + it('should render frequent projects list', done => { vm.toggleFrequentProjectsList(true); Vue.nextTick(() => { expect(vm.$el.querySelector('.projects-list-frequent-container')).toBeDefined(); @@ -336,7 +337,7 @@ describe('AppComponent', () => { }); }); - it('should render searched projects list', (done) => { + it('should render searched projects list', done => { vm.toggleSearchProjectsList(true); Vue.nextTick(() => { expect(vm.$el.querySelector('.section-header')).toBe(null); diff --git a/yarn.lock b/yarn.lock index 1e6ffa5f524..33e129a8e51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8091,9 +8091,9 @@ undefsafe@^2.0.1: dependencies: debug "^2.2.0" -underscore@^1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" +underscore@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.0.tgz#31dbb314cfcc88f169cd3692d9149d81a00a73e4" underscore@~1.7.0: version "1.7.0" |