Commit 28726729 authored by Felipe's avatar Felipe
Browse files

Load issues and merge requests templates from repository

parent 7f853e22
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ v 8.11.0 (unreleased)
  - Various redundant database indexes have been removed
  - Various redundant database indexes have been removed
  - Update `timeago` plugin to use multiple string/locale settings
  - Update `timeago` plugin to use multiple string/locale settings
  - Remove unused images (ClemMakesApps)
  - Remove unused images (ClemMakesApps)
  - Get issue and merge request description templates from repositories
  - Limit git rev-list output count to one in forced push check
  - Limit git rev-list output count to one in forced push check
  - Show deployment status on merge requests with external URLs
  - Show deployment status on merge requests with external URLs
  - Clean up unused routes (Josef Strzibny)
  - Clean up unused routes (Josef Strzibny)
+30 −21
Original line number Original line Diff line number Diff line
@@ -9,10 +9,11 @@
    licensePath: "/api/:version/licenses/:key",
    licensePath: "/api/:version/licenses/:key",
    gitignorePath: "/api/:version/gitignores/:key",
    gitignorePath: "/api/:version/gitignores/:key",
    gitlabCiYmlPath: "/api/:version/gitlab_ci_ymls/:key",
    gitlabCiYmlPath: "/api/:version/gitlab_ci_ymls/:key",
    issuableTemplatePath: "/:namespace_path/:project_path/templates/:type/:key",

    group: function(group_id, callback) {
    group: function(group_id, callback) {
      var url;
      var url = Api.buildUrl(Api.groupPath)
      url = Api.buildUrl(Api.groupPath);
        .replace(':id', group_id);
      url = url.replace(':id', group_id);
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
        data: {
        data: {
@@ -24,8 +25,7 @@
      });
      });
    },
    },
    groups: function(query, skip_ldap, callback) {
    groups: function(query, skip_ldap, callback) {
      var url;
      var url = Api.buildUrl(Api.groupsPath);
      url = Api.buildUrl(Api.groupsPath);
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
        data: {
        data: {
@@ -39,8 +39,7 @@
      });
      });
    },
    },
    namespaces: function(query, callback) {
    namespaces: function(query, callback) {
      var url;
      var url = Api.buildUrl(Api.namespacesPath);
      url = Api.buildUrl(Api.namespacesPath);
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
        data: {
        data: {
@@ -54,8 +53,7 @@
      });
      });
    },
    },
    projects: function(query, order, callback) {
    projects: function(query, order, callback) {
      var url;
      var url = Api.buildUrl(Api.projectsPath);
      url = Api.buildUrl(Api.projectsPath);
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
        data: {
        data: {
@@ -70,9 +68,8 @@
      });
      });
    },
    },
    newLabel: function(project_id, data, callback) {
    newLabel: function(project_id, data, callback) {
      var url;
      var url = Api.buildUrl(Api.labelsPath)
      url = Api.buildUrl(Api.labelsPath);
        .replace(':id', project_id);
      url = url.replace(':id', project_id);
      data.private_token = gon.api_token;
      data.private_token = gon.api_token;
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
@@ -86,9 +83,8 @@
      });
      });
    },
    },
    groupProjects: function(group_id, query, callback) {
    groupProjects: function(group_id, query, callback) {
      var url;
      var url = Api.buildUrl(Api.groupProjectsPath)
      url = Api.buildUrl(Api.groupProjectsPath);
        .replace(':id', group_id);
      url = url.replace(':id', group_id);
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
        data: {
        data: {
@@ -102,8 +98,8 @@
      });
      });
    },
    },
    licenseText: function(key, data, callback) {
    licenseText: function(key, data, callback) {
      var url;
      var url = Api.buildUrl(Api.licensePath)
      url = Api.buildUrl(Api.licensePath).replace(':key', key);
        .replace(':key', key);
      return $.ajax({
      return $.ajax({
        url: url,
        url: url,
        data: data
        data: data
@@ -112,19 +108,32 @@
      });
      });
    },
    },
    gitignoreText: function(key, callback) {
    gitignoreText: function(key, callback) {
      var url;
      var url = Api.buildUrl(Api.gitignorePath)
      url = Api.buildUrl(Api.gitignorePath).replace(':key', key);
        .replace(':key', key);
      return $.get(url, function(gitignore) {
      return $.get(url, function(gitignore) {
        return callback(gitignore);
        return callback(gitignore);
      });
      });
    },
    },
    gitlabCiYml: function(key, callback) {
    gitlabCiYml: function(key, callback) {
      var url;
      var url = Api.buildUrl(Api.gitlabCiYmlPath)
      url = Api.buildUrl(Api.gitlabCiYmlPath).replace(':key', key);
        .replace(':key', key);
      return $.get(url, function(file) {
      return $.get(url, function(file) {
        return callback(file);
        return callback(file);
      });
      });
    },
    },
    issueTemplate: function(namespacePath, projectPath, key, type, callback) {
      var url = Api.buildUrl(Api.issuableTemplatePath)
        .replace(':key', key)
        .replace(':type', type)
        .replace(':project_path', projectPath)
        .replace(':namespace_path', namespacePath);
      $.ajax({
        url: url,
        dataType: 'json'
      }).done(function(file) {
        callback(null, file);
      }).error(callback);
    },
    buildUrl: function(url) {
    buildUrl: function(url) {
      if (gon.relative_url_root != null) {
      if (gon.relative_url_root != null) {
        url = gon.relative_url_root + url;
        url = gon.relative_url_root + url;
+1 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@
/*= require date.format */
/*= require date.format */
/*= require_directory ./behaviors */
/*= require_directory ./behaviors */
/*= require_directory ./blob */
/*= require_directory ./blob */
/*= require_directory ./templates */
/*= require_directory ./commit */
/*= require_directory ./commit */
/*= require_directory ./extensions */
/*= require_directory ./extensions */
/*= require_directory ./lib/utils */
/*= require_directory ./lib/utils */
+19 −3
Original line number Original line Diff line number Diff line
@@ -9,6 +9,7 @@
      }
      }
      this.onClick = bind(this.onClick, this);
      this.onClick = bind(this.onClick, this);
      this.dropdown = opts.dropdown, this.data = opts.data, this.pattern = opts.pattern, this.wrapper = opts.wrapper, this.editor = opts.editor, this.fileEndpoint = opts.fileEndpoint, this.$input = (ref = opts.$input) != null ? ref : $('#file_name');
      this.dropdown = opts.dropdown, this.data = opts.data, this.pattern = opts.pattern, this.wrapper = opts.wrapper, this.editor = opts.editor, this.fileEndpoint = opts.fileEndpoint, this.$input = (ref = opts.$input) != null ? ref : $('#file_name');
      this.dropdownIcon = $('.fa-chevron-down', this.dropdown);
      this.buildDropdown();
      this.buildDropdown();
      this.bindEvents();
      this.bindEvents();
      this.onFilenameUpdate();
      this.onFilenameUpdate();
@@ -60,11 +61,26 @@
      return this.requestFile(item);
      return this.requestFile(item);
    };
    };


    TemplateSelector.prototype.requestFile = function(item) {};
    TemplateSelector.prototype.requestFile = function(item) {
      // This `requestFile` method is an abstract method that should
      // be added by all subclasses.
    };


    TemplateSelector.prototype.requestFileSuccess = function(file) {
    TemplateSelector.prototype.requestFileSuccess = function(file, skipFocus) {
      this.editor.setValue(file.content, 1);
      this.editor.setValue(file.content, 1);
      return this.editor.focus();
      if (!skipFocus) this.editor.focus();
    };

    TemplateSelector.prototype.startLoadingSpinner = function() {
      this.dropdownIcon
        .addClass('fa-spinner fa-spin')
        .removeClass('fa-chevron-down');
    };

    TemplateSelector.prototype.stopLoadingSpinner = function() {
      this.dropdownIcon
        .addClass('fa-chevron-down')
        .removeClass('fa-spinner fa-spin');
    };
    };


    return TemplateSelector;
    return TemplateSelector;
+2 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@
          shortcut_handler = new ShortcutsNavigation();
          shortcut_handler = new ShortcutsNavigation();
          new GLForm($('.issue-form'));
          new GLForm($('.issue-form'));
          new IssuableForm($('.issue-form'));
          new IssuableForm($('.issue-form'));
          new IssuableTemplateSelectors();
          break;
          break;
        case 'projects:merge_requests:new':
        case 'projects:merge_requests:new':
        case 'projects:merge_requests:edit':
        case 'projects:merge_requests:edit':
@@ -62,6 +63,7 @@
          shortcut_handler = new ShortcutsNavigation();
          shortcut_handler = new ShortcutsNavigation();
          new GLForm($('.merge-request-form'));
          new GLForm($('.merge-request-form'));
          new IssuableForm($('.merge-request-form'));
          new IssuableForm($('.merge-request-form'));
          new IssuableTemplateSelectors();
          break;
          break;
        case 'projects:tags:new':
        case 'projects:tags:new':
          new ZenMode();
          new ZenMode();
Loading