Commit 05d94db1 authored by Kushal Pandya's avatar Kushal Pandya Committed by Heinrich Lee Yu

Add JIRA connect script and stylesheet

Move out inline JS for JIRA connect in favour of dedicated script
and stylesheet.
parent 7e3f9e25
......@@ -181,6 +181,8 @@ module Gitlab
## EE-specific assets config START
%w[images javascripts stylesheets].each do |path|
config.assets.paths << "#{config.root}/ee/app/assets/#{path}"
config.assets.precompile << "jira_connect.js"
config.assets.precompile << "pages/jira_connect.css"
end
config.assets.paths << "#{config.root}/vendor/assets/javascripts/"
......
/* eslint-disable func-names, prefer-arrow-callback, no-var, no-alert */
/* global $ */
/* global AP */
/**
* This script is not going through Webpack bundling
* as it is only included in `ee/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() {
document.addEventListener('DOMContentLoaded', function() {
var reqComplete = function() {
AP.navigator.reload();
};
var reqFailed = function(res) {
alert(res.responseJSON.error);
};
$('#add-subscription-form').on('submit', function(e) {
var actionUrl = $(this).attr('action');
e.preventDefault();
AP.context.getToken(function(token) {
$.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) {
$.ajax({
url: href,
method: 'DELETE',
data: {
jwt: token,
format: 'json',
},
})
.done(reqComplete)
.fail(reqFailed);
});
});
});
})();
@import 'framework/variables';
$atlaskit-border-color: #dfe1e6;
.ac-content {
margin: 20px;
.subscription-form {
margin-bottom: 20px;
.field-group-input {
display: flex;
padding-top: $gl-padding-4;
.ak-button {
height: auto;
margin-left: $btn-margin-5;
}
}
}
}
.subscriptions {
tbody {
tr {
border-bottom: 1px solid $atlaskit-border-color;
}
td {
padding: $gl-padding-8;
}
}
}
%h1
GitLab for Jira Configuration
%form#add-subscription-form{ style: 'margin-bottom: 20px;' }
%form#add-subscription-form.subscription-form{ action: jira_connect_subscriptions_path }
.ak-field-group
%label
Namespace
%input#namespace-input.ak-field-text{ type: 'text', required: true }
.ak-field-group
.ak-field-group.field-group-input
%input#namespace-input.ak-field-text{ type: 'text', required: true }
%button.ak-button.ak-button__appearance-primary{ type: 'submit' }
Link namespace to Jira
......@@ -24,46 +24,5 @@
%td= subscription.created_at
%td= link_to 'Remove', jira_connect_subscription_path(subscription), class: 'remove-subscription'
:javascript
window.onload = function() {
$('#add-subscription-form').submit(function(e) {
e.preventDefault();
AP.context.getToken(function(token) {
$.post('/-/jira_connect/subscriptions', {
jwt: token,
namespace_path: $('#namespace-input').val(),
format: 'json',
})
.done(function(response) {
AP.navigator.reload();
})
.fail(function(xhr) {
alert(xhr.responseJSON.error);
});
});
});
$('.remove-subscription').click(function(e) {
e.preventDefault();
var href = $(this).attr('href');
AP.context.getToken(function(token) {
$.ajax({
url: href,
method: 'DELETE',
data: {
jwt: token,
format: 'json',
},
})
.done(function(response) {
AP.navigator.reload();
})
.fail(function(xhr) {
alert(xhr.responseJSON.error);
});
});
});
};
= page_specific_javascript_tag('jira_connect.js')
= stylesheet_link_tag 'pages/jira_connect'
......@@ -9,5 +9,5 @@
= javascript_include_tag 'https://unpkg.com/jquery@3.3.1/dist/jquery.min.js'
= yield :head
%body
.ac-content{ style: 'margin: 20px;' }
.ac-content
= yield
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