Commit 30d42bcd authored by Stan Hu's avatar Stan Hu

Merge branch 'ce-to-ee-2018-02-15' into 'master'

CE upstream - 2018-02-15 18:29 UTC

See merge request gitlab-org/gitlab-ee!4562
parents 84cad03a 326d3cb1
/* eslint-disable func-names, wrap-iife, consistent-return,
no-return-assign, no-param-reassign, one-var-declaration-per-line, no-unused-vars,
prefer-template, object-shorthand, prefer-arrow-callback */
import { pluralize } from './lib/utils/text_utility'; import { pluralize } from './lib/utils/text_utility';
import { localTimeAgo } from './lib/utils/datetime_utility'; import { localTimeAgo } from './lib/utils/datetime_utility';
import Pager from './pager'; import Pager from './pager';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
export default (function () { export default class CommitsList {
const CommitsList = {}; constructor(limit = 0) {
this.timer = null;
CommitsList.timer = null;
CommitsList.init = function (limit) {
this.$contentList = $('.content_list'); this.$contentList = $('.content_list');
$('body').on('click', '.day-commits-table li.commit', function (e) { Pager.init(parseInt(limit, 10), false, false, this.processCommits.bind(this));
if (e.target.nodeName !== 'A') {
location.href = $(this).attr('url');
e.stopPropagation();
return false;
}
});
Pager.init(parseInt(limit, 10), false, false, this.processCommits);
this.content = $('#commits-list'); this.content = $('#commits-list');
this.searchField = $('#commits-search'); this.searchField = $('#commits-search');
this.lastSearch = this.searchField.val(); this.lastSearch = this.searchField.val();
return this.initSearch(); this.initSearch();
}; }
CommitsList.initSearch = function () { initSearch() {
this.timer = null; this.timer = null;
return this.searchField.keyup((function (_this) { this.searchField.on('keyup', () => {
return function () { clearTimeout(this.timer);
clearTimeout(_this.timer); this.timer = setTimeout(this.filterResults.bind(this), 500);
return _this.timer = setTimeout(_this.filterResults, 500); });
}; }
})(this));
};
CommitsList.filterResults = function () { filterResults() {
const form = $('.commits-search-form'); const form = $('.commits-search-form');
const search = CommitsList.searchField.val(); const search = this.searchField.val();
if (search === CommitsList.lastSearch) return Promise.resolve(); if (search === this.lastSearch) return Promise.resolve();
const commitsUrl = form.attr('action') + '?' + form.serialize(); const commitsUrl = `${form.attr('action')}?${form.serialize()}`;
CommitsList.content.fadeTo('fast', 0.5); this.content.fadeTo('fast', 0.5);
const params = form.serializeArray().reduce((acc, obj) => Object.assign(acc, { const params = form.serializeArray().reduce((acc, obj) => Object.assign(acc, {
[obj.name]: obj.value, [obj.name]: obj.value,
}), {}); }), {});
...@@ -55,9 +39,9 @@ export default (function () { ...@@ -55,9 +39,9 @@ export default (function () {
params, params,
}) })
.then(({ data }) => { .then(({ data }) => {
CommitsList.lastSearch = search; this.lastSearch = search;
CommitsList.content.html(data.html); this.content.html(data.html);
CommitsList.content.fadeTo('fast', 1.0); this.content.fadeTo('fast', 1.0);
// Change url so if user reload a page - search results are saved // Change url so if user reload a page - search results are saved
history.replaceState({ history.replaceState({
...@@ -65,16 +49,16 @@ export default (function () { ...@@ -65,16 +49,16 @@ export default (function () {
}, document.title, commitsUrl); }, document.title, commitsUrl);
}) })
.catch(() => { .catch(() => {
CommitsList.content.fadeTo('fast', 1.0); this.content.fadeTo('fast', 1.0);
CommitsList.lastSearch = null; this.lastSearch = null;
}); });
}; }
// Prepare loaded data. // Prepare loaded data.
CommitsList.processCommits = (data) => { processCommits(data) {
let processedData = data; let processedData = data;
const $processedData = $(processedData); const $processedData = $(processedData);
const $commitsHeadersLast = CommitsList.$contentList.find('li.js-commit-header').last(); const $commitsHeadersLast = this.$contentList.find('li.js-commit-header').last();
const lastShownDay = $commitsHeadersLast.data('day'); const lastShownDay = $commitsHeadersLast.data('day');
const $loadedCommitsHeadersFirst = $processedData.filter('li.js-commit-header').first(); const $loadedCommitsHeadersFirst = $processedData.filter('li.js-commit-header').first();
const loadedShownDayFirst = $loadedCommitsHeadersFirst.data('day'); const loadedShownDayFirst = $loadedCommitsHeadersFirst.data('day');
...@@ -97,7 +81,5 @@ export default (function () { ...@@ -97,7 +81,5 @@ export default (function () {
localTimeAgo($processedData.find('.js-timeago')); localTimeAgo($processedData.find('.js-timeago'));
return processedData; return processedData;
}; }
}
return CommitsList;
})();
...@@ -234,6 +234,11 @@ var Dispatcher; ...@@ -234,6 +234,11 @@ var Dispatcher;
.then(callDefault) .then(callDefault)
.catch(fail); .catch(fail);
break; break;
case 'projects:services:edit':
import('./pages/projects/services/edit')
.then(callDefault)
.catch(fail);
break;
case 'projects:snippets:edit': case 'projects:snippets:edit':
case 'projects:snippets:update': case 'projects:snippets:update':
import('./pages/projects/snippets/edit') import('./pages/projects/snippets/edit')
......
...@@ -3,7 +3,7 @@ import GpgBadges from '~/gpg_badges'; ...@@ -3,7 +3,7 @@ import GpgBadges from '~/gpg_badges';
import ShortcutsNavigation from '~/shortcuts_navigation'; import ShortcutsNavigation from '~/shortcuts_navigation';
export default () => { export default () => {
CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commitsLimit); new CommitsList(document.querySelector('.js-project-commits-show').dataset.commitsLimit); // eslint-disable-line no-new
new ShortcutsNavigation(); // eslint-disable-line no-new new ShortcutsNavigation(); // eslint-disable-line no-new
GpgBadges.fetch(); GpgBadges.fetch();
}; };
/* eslint-disable no-new */ import IntegrationSettingsForm from '~/integrations/integration_settings_form';
import IntegrationSettingsForm from './integration_settings_form';
$(() => { export default () => {
const integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form'); const integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form');
integrationSettingsForm.init(); integrationSettingsForm.init();
}); };
- content_for :page_specific_javascripts do
= webpack_bundle_tag('integrations')
.row.prepend-top-default.append-bottom-default .row.prepend-top-default.append-bottom-default
.col-lg-3 .col-lg-3
%h4.prepend-top-0 %h4.prepend-top-0
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
- if show_archive_options - if show_archive_options
%li.divider %li.divider
%li.js-filter-archived-projects %li.js-filter-archived-projects
= link_to group_children_path(@group, archived: nil), class: ("is-active" unless params[:archived].present?) do = link_to filter_groups_path(archived: nil), class: ("is-active" unless params[:archived].present?) do
Hide archived projects Hide archived projects
%li.js-filter-archived-projects %li.js-filter-archived-projects
= link_to group_children_path(@group, archived: true), class: ("is-active" if Gitlab::Utils.to_boolean(params[:archived])) do = link_to filter_groups_path(archived: true), class: ("is-active" if Gitlab::Utils.to_boolean(params[:archived])) do
Show archived projects Show archived projects
%li.js-filter-archived-projects %li.js-filter-archived-projects
= link_to group_children_path(@group, archived: 'only'), class: ("is-active" if params[:archived] == 'only') do = link_to filter_groups_path(archived: 'only'), class: ("is-active" if params[:archived] == 'only') do
Show archived projects only Show archived projects only
title: Fix 404 when listing archived projects in a group where all projects have been archived
merge_request: 17077
author: Ashley Dumaine
type: fixed
---
title: Fixed bug with unauthenticated requests through git ssh
merge_request: 17149
author:
type: fixed
...@@ -26,6 +26,7 @@ class Rack::Attack ...@@ -26,6 +26,7 @@ class Rack::Attack
throttle('throttle_unauthenticated', Gitlab::Throttle.unauthenticated_options) do |req| throttle('throttle_unauthenticated', Gitlab::Throttle.unauthenticated_options) do |req|
Gitlab::Throttle.settings.throttle_unauthenticated_enabled && Gitlab::Throttle.settings.throttle_unauthenticated_enabled &&
req.unauthenticated? && req.unauthenticated? &&
!req.api_internal_request? &&
req.ip req.ip
end end
...@@ -54,6 +55,10 @@ class Rack::Attack ...@@ -54,6 +55,10 @@ class Rack::Attack
path.start_with?('/api') path.start_with?('/api')
end end
def api_internal_request?
path =~ %r{^/api/v\d+/internal/}
end
def web_request? def web_request?
!api_request? !api_request?
end end
......
...@@ -75,7 +75,6 @@ var config = { ...@@ -75,7 +75,6 @@ var config = {
issues: './issues/issues_bundle.js', issues: './issues/issues_bundle.js',
how_to_merge: './how_to_merge.js', how_to_merge: './how_to_merge.js',
issue_show: './issue_show/index.js', issue_show: './issue_show/index.js',
integrations: './integrations',
job_details: './jobs/job_details_bundle.js', job_details: './jobs/job_details_bundle.js',
ldap_group_links: './groups/ldap_group_links.js', ldap_group_links: './groups/ldap_group_links.js',
locale: './locale/index.js', locale: './locale/index.js',
......
...@@ -4,6 +4,8 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -4,6 +4,8 @@ import axios from '~/lib/utils/axios_utils';
import CommitsList from '~/commits'; import CommitsList from '~/commits';
describe('Commits List', () => { describe('Commits List', () => {
let commitsList;
beforeEach(() => { beforeEach(() => {
setFixtures(` setFixtures(`
<form class="commits-search-form" action="/h5bp/html5-boilerplate/commits/master"> <form class="commits-search-form" action="/h5bp/html5-boilerplate/commits/master">
...@@ -11,6 +13,7 @@ describe('Commits List', () => { ...@@ -11,6 +13,7 @@ describe('Commits List', () => {
</form> </form>
<ol id="commits-list"></ol> <ol id="commits-list"></ol>
`); `);
commitsList = new CommitsList(25);
}); });
it('should be defined', () => { it('should be defined', () => {
...@@ -19,7 +22,7 @@ describe('Commits List', () => { ...@@ -19,7 +22,7 @@ describe('Commits List', () => {
describe('processCommits', () => { describe('processCommits', () => {
it('should join commit headers', () => { it('should join commit headers', () => {
CommitsList.$contentList = $(` commitsList.$contentList = $(`
<div> <div>
<li class="commit-header" data-day="2016-09-20"> <li class="commit-header" data-day="2016-09-20">
<span class="day">20 Sep, 2016</span> <span class="day">20 Sep, 2016</span>
...@@ -39,7 +42,7 @@ describe('Commits List', () => { ...@@ -39,7 +42,7 @@ describe('Commits List', () => {
// The last commit header should be removed // The last commit header should be removed
// since the previous one has the same data-day value. // since the previous one has the same data-day value.
expect(CommitsList.processCommits(data).find('li.commit-header').length).toBe(0); expect(commitsList.processCommits(data).find('li.commit-header').length).toBe(0);
}); });
}); });
...@@ -48,8 +51,7 @@ describe('Commits List', () => { ...@@ -48,8 +51,7 @@ describe('Commits List', () => {
let mock; let mock;
beforeEach(() => { beforeEach(() => {
CommitsList.init(25); commitsList.searchField.val('');
CommitsList.searchField.val('');
spyOn(history, 'replaceState').and.stub(); spyOn(history, 'replaceState').and.stub();
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
...@@ -66,11 +68,11 @@ describe('Commits List', () => { ...@@ -66,11 +68,11 @@ describe('Commits List', () => {
}); });
it('should save the last search string', (done) => { it('should save the last search string', (done) => {
CommitsList.searchField.val('GitLab'); commitsList.searchField.val('GitLab');
CommitsList.filterResults() commitsList.filterResults()
.then(() => { .then(() => {
expect(ajaxSpy).toHaveBeenCalled(); expect(ajaxSpy).toHaveBeenCalled();
expect(CommitsList.lastSearch).toEqual('GitLab'); expect(commitsList.lastSearch).toEqual('GitLab');
done(); done();
}) })
...@@ -78,10 +80,10 @@ describe('Commits List', () => { ...@@ -78,10 +80,10 @@ describe('Commits List', () => {
}); });
it('should not make ajax call if the input does not change', (done) => { it('should not make ajax call if the input does not change', (done) => {
CommitsList.filterResults() commitsList.filterResults()
.then(() => { .then(() => {
expect(ajaxSpy).not.toHaveBeenCalled(); expect(ajaxSpy).not.toHaveBeenCalled();
expect(CommitsList.lastSearch).toEqual(''); expect(commitsList.lastSearch).toEqual('');
done(); done();
}) })
......
...@@ -22,6 +22,7 @@ describe 'Rack Attack global throttles' do ...@@ -22,6 +22,7 @@ describe 'Rack Attack global throttles' do
let(:url_that_does_not_require_authentication) { '/users/sign_in' } let(:url_that_does_not_require_authentication) { '/users/sign_in' }
let(:url_that_requires_authentication) { '/dashboard/snippets' } let(:url_that_requires_authentication) { '/dashboard/snippets' }
let(:url_api_internal) { '/api/v4/internal/check' }
let(:api_partial_url) { '/todos' } let(:api_partial_url) { '/todos' }
around do |example| around do |example|
...@@ -172,6 +173,15 @@ describe 'Rack Attack global throttles' do ...@@ -172,6 +173,15 @@ describe 'Rack Attack global throttles' do
get url_that_does_not_require_authentication get url_that_does_not_require_authentication
expect(response).to have_http_status 200 expect(response).to have_http_status 200
end end
context 'when the request is to the api internal endpoints' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
get url_api_internal, secret_token: Gitlab::Shell.secret_token
expect(response).to have_http_status 200
end
end
end
end end
context 'when the throttle is disabled' do context 'when the throttle is disabled' do
......
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