Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-12-01 09:09:24 +00:00
parent 01d4c393e1
commit a7704bf16a
6 changed files with 69 additions and 69 deletions

View File

@ -1,63 +0,0 @@
/* eslint-disable func-names, no-var, no-alert */
/* global $ */
/* global AP */
/**
* This script is not going through Webpack bundling
* as it is only included in `app/views/jira_connect/subscriptions/index.html.haml`
* which is going to be rendered within iframe on Jira app dashboard
* hence any code written here needs to be IE11+ compatible (no fully ES6)
*/
function onLoaded() {
var reqComplete = function() {
AP.navigator.reload();
};
var reqFailed = function(res) {
alert(res.responseJSON.error);
};
AP.getLocation(function(location) {
$('.js-jira-connect-sign-in').each(function() {
var updatedLink = `${$(this).attr('href')}?return_to=${location}`;
$(this).attr('href', updatedLink);
});
});
$('#add-subscription-form').on('submit', function(e) {
var actionUrl = $(this).attr('action');
e.preventDefault();
AP.context.getToken(function(token) {
// eslint-disable-next-line no-jquery/no-ajax
$.post(actionUrl, {
jwt: token,
namespace_path: $('#namespace-input').val(),
format: 'json',
})
.done(reqComplete)
.fail(reqFailed);
});
});
$('.remove-subscription').on('click', function(e) {
var href = $(this).attr('href');
e.preventDefault();
AP.context.getToken(function(token) {
// eslint-disable-next-line no-jquery/no-ajax
$.ajax({
url: href,
method: 'DELETE',
data: {
jwt: token,
format: 'json',
},
})
.done(reqComplete)
.fail(reqFailed);
});
});
}
document.addEventListener('DOMContentLoaded', onLoaded);

View File

@ -1,9 +1,68 @@
import Vue from 'vue';
import $ from 'jquery';
import App from './components/app.vue';
/**
* Initialize necessary form handlers for the Jira Connect app
*/
const initJiraFormHandlers = () => {
const reqComplete = () => {
AP.navigator.reload();
};
const reqFailed = res => {
// eslint-disable-next-line no-alert
alert(res.responseJSON.error);
};
AP.getLocation(location => {
$('.js-jira-connect-sign-in').each(() => {
const updatedLink = `${$(this).attr('href')}?return_to=${location}`;
$(this).attr('href', updatedLink);
});
});
$('#add-subscription-form').on('submit', e => {
const actionUrl = $(this).attr('action');
e.preventDefault();
AP.context.getToken(token => {
// eslint-disable-next-line no-jquery/no-ajax
$.post(actionUrl, {
jwt: token,
namespace_path: $('#namespace-input').val(),
format: 'json',
})
.done(reqComplete)
.fail(reqFailed);
});
});
$('.remove-subscription').on('click', e => {
const href = $(this).attr('href');
e.preventDefault();
AP.context.getToken(token => {
// eslint-disable-next-line no-jquery/no-ajax
$.ajax({
url: href,
method: 'DELETE',
data: {
jwt: token,
format: 'json',
},
})
.done(reqComplete)
.fail(reqFailed);
});
});
};
function initJiraConnect() {
const el = document.querySelector('.js-jira-connect-app');
initJiraFormHandlers();
return new Vue({
el,
render(createElement) {

View File

@ -62,5 +62,4 @@
= webpack_bundle_tag 'performance_bar' if performance_bar_enabled?
= webpack_bundle_tag 'jira_connect_app'
= page_specific_javascript_tag('jira_connect.js')
- add_page_specific_style 'page_bundles/jira_connect', defer: false

View File

@ -9,7 +9,7 @@ module Gitlab
APPLICATION_JSON_TYPES = %W{#{APPLICATION_JSON} application/vnd.git-lfs+json}.freeze
ERROR_MESSAGE = 'You cannot perform write operations on a read-only instance'
ALLOWLISTED_GIT_ROUTES = {
ALLOWLISTED_GIT_READ_ONLY_ROUTES = {
'repositories/git_http' => %w{git_upload_pack}
}.freeze
@ -34,7 +34,7 @@ module Gitlab
end
def call
if disallowed_request? && Gitlab::Database.read_only?
if disallowed_request? && read_only?
Gitlab::AppLogger.debug('GitLab ReadOnly: preventing possible non read-only operation')
if json_request?
@ -57,6 +57,11 @@ module Gitlab
!allowlisted_routes
end
# Overridden in EE module
def read_only?
Gitlab::Database.read_only?
end
def json_request?
APPLICATION_JSON_TYPES.include?(request.media_type)
end
@ -97,7 +102,7 @@ module Gitlab
return false unless request.post? &&
request.path.end_with?('.git/git-upload-pack')
ALLOWLISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action])
ALLOWLISTED_GIT_READ_ONLY_ROUTES[route_hash[:controller]]&.include?(route_hash[:action])
end
def internal_route?

View File

@ -2,7 +2,7 @@
module QA
RSpec.describe 'Create' do
describe 'Open a fork in Web IDE' do
describe 'Open a fork in Web IDE', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/284081', type: :investigating } do
let(:parent_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'parent-project'

View File

@ -25,7 +25,7 @@ RSpec.shared_context 'with a mocked GitLab instance' do
let(:request) { Rack::MockRequest.new(rack_stack) }
subject do
described_class.new(fake_app).tap do |app|
Gitlab::Middleware::ReadOnly.new(fake_app).tap do |app|
app.extend(observe_env)
end
end