summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorCédric Couralet2018-07-30 13:47:09 +0000
committerCédric Couralet2018-07-31 08:36:56 +0000
commit66d374b1289e6dd33008dc931e9fb642051724d0 (patch)
tree4801a08657d2a0fd04c03a3ed46440e221f0ae23 /public/js
parent93a3ce1164f69af24381c94b941048580891e1b8 (diff)
Add possibility to choose between version v3 or v4 for the gitlab api.
Apart from the uri versioning, one big change is the snippet visibility post data (visibility_level -> visibility) Default gitlab api version to v4 Signed-off-by: Cédric Couralet <cedric.couralet@gmail.com>
Diffstat (limited to 'public/js')
-rw-r--r--public/js/index.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 6e13fe9c..1330deac 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -970,6 +970,7 @@ ui.toolbar.export.snippet.click(function () {
.done(function (data) {
$('#snippetExportModalAccessToken').val(data.accesstoken)
$('#snippetExportModalBaseURL').val(data.baseURL)
+ $('#snippetExportModalVersion').val(data.version)
$('#snippetExportModalLoading').hide()
$('#snippetExportModal').modal('toggle')
$('#snippetExportModalProjects').find('option').remove().end().append('<option value="init" selected="selected" disabled="disabled">Select From Available Projects</option>')
@@ -1021,6 +1022,7 @@ ui.toolbar.import.snippet.click(function () {
.done(function (data) {
$('#snippetImportModalAccessToken').val(data.accesstoken)
$('#snippetImportModalBaseURL').val(data.baseURL)
+ $('#snippetImportModalVersion').val(data.version)
$('#snippetImportModalContent').prop('disabled', false)
$('#snippetImportModalConfirm').prop('disabled', false)
$('#snippetImportModalLoading').hide()
@@ -1243,10 +1245,10 @@ ui.modal.snippetImportProjects.change(function () {
var accesstoken = $('#snippetImportModalAccessToken').val()
var baseURL = $('#snippetImportModalBaseURL').val()
var project = $('#snippetImportModalProjects').val()
-
+ var version = $('#snippetImportModalVersion').val()
$('#snippetImportModalLoading').show()
$('#snippetImportModalContent').val('/projects/' + project)
- $.get(baseURL + '/api/v3/projects/' + project + '/snippets?access_token=' + accesstoken)
+ $.get(baseURL + '/api/' + version + '/projects/' + project + '/snippets?access_token=' + accesstoken)
.done(function (data) {
$('#snippetImportModalSnippets').find('option').remove().end().append('<option value="init" selected="selected" disabled="disabled">Select From Available Snippets</option>')
data.forEach(function (snippet) {
@@ -1433,7 +1435,7 @@ $('#snippetImportModalConfirm').click(function () {
} else {
ui.spinner.show()
var accessToken = '?access_token=' + $('#snippetImportModalAccessToken').val()
- var fullURL = $('#snippetImportModalBaseURL').val() + '/api/v3' + snippeturl
+ var fullURL = $('#snippetImportModalBaseURL').val() + '/api/' + $('#snippetImportModalVersion').val() + snippeturl
$.get(fullURL + accessToken)
.done(function (data) {
var content = '# ' + (data.title || 'Snippet Import')
@@ -1470,15 +1472,19 @@ $('#snippetImportModalConfirm').click(function () {
$('#snippetExportModalConfirm').click(function () {
var accesstoken = $('#snippetExportModalAccessToken').val()
var baseURL = $('#snippetExportModalBaseURL').val()
+ var version = $('#snippetExportModalVersion').val()
+
var data = {
title: $('#snippetExportModalTitle').val(),
file_name: $('#snippetExportModalFileName').val(),
code: editor.getValue(),
- visibility_level: $('#snippetExportModalVisibility').val()
+ visibility_level: $('#snippetExportModalVisibility').val(),
+ visibility: $('#snippetExportModalVisibility').val() === 0 ? 'private' : ($('#snippetExportModalVisibility').val() === 10 ? 'internal' : '')
}
+
if (!data.title || !data.file_name || !data.code || !data.visibility_level || !$('#snippetExportModalProjects').val()) return
$('#snippetExportModalLoading').show()
- var fullURL = baseURL + '/api/v3/projects/' + $('#snippetExportModalProjects').val() + '/snippets?access_token=' + accesstoken
+ var fullURL = baseURL + '/api/' + version + '/projects/' + $('#snippetExportModalProjects').val() + '/snippets?access_token=' + accesstoken
$.post(fullURL
, data
, function (ret) {
@@ -1487,7 +1493,6 @@ $('#snippetExportModalConfirm').click(function () {
var redirect = baseURL + '/' + $("#snippetExportModalProjects option[value='" + $('#snippetExportModalProjects').val() + "']").text() + '/snippets/' + ret.id
showMessageModal('<i class="fa fa-gitlab"></i> Export to Snippet', 'Export Successful!', redirect, 'View Snippet Here', true)
}
- , 'json'
)
})