Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpburdette <pburdette@gitlab.com>2019-09-05 22:55:34 +0300
committerpburdette <pburdette@gitlab.com>2019-09-05 22:55:34 +0300
commit5082cd733336bf7ca560b6a71651e0ed350e17d7 (patch)
tree0a57d22f8f4f97163268ccc3319e972db28d727f
parent1efb4ea8d79d242e002de95963f7aab2ddb651c1 (diff)
Move file template selector by filename
Changed functionality to rely on filename input to determine template type for choosing a template via the template picker dropdown
-rw-r--r--app/assets/javascripts/blob/file_template_mediator.js8
-rw-r--r--app/views/projects/blob/_editor.html.haml5
-rw-r--r--app/views/projects/blob/_template_selectors.html.haml4
-rw-r--r--app/views/projects/blob/new.html.haml1
4 files changed, 4 insertions, 14 deletions
diff --git a/app/assets/javascripts/blob/file_template_mediator.js b/app/assets/javascripts/blob/file_template_mediator.js
index 106fe2e0cef..1bc7b0eeed6 100644
--- a/app/assets/javascripts/blob/file_template_mediator.js
+++ b/app/assets/javascripts/blob/file_template_mediator.js
@@ -106,7 +106,7 @@ export default class FileTemplateMediator {
}
this.templateSelectors.forEach(selector => {
- if (selector.config.key === item.key) {
+ if (selector.config.name === this.getFilename()) {
selector.show();
} else {
selector.hide();
@@ -130,7 +130,6 @@ export default class FileTemplateMediator {
.then(file => {
this.showUndoMenu();
this.setEditorContent(file);
- this.setFilename(selector.config.name);
selector.renderLoaded();
})
.catch(err => new Flash(`An error occurred while fetching the template: ${err}`));
@@ -208,7 +207,6 @@ export default class FileTemplateMediator {
restoreFromCache() {
this.setEditorContent(this.cachedContent);
- this.setFilename(this.cachedFilename);
this.setTemplateSelectorToggleText();
}
@@ -232,10 +230,6 @@ export default class FileTemplateMediator {
return this.$filenameInput.val();
}
- setFilename(name) {
- this.$filenameInput.val(name).trigger('change');
- }
-
getSelected() {
return this.templateSelectors.find(selector => selector.selected);
}
diff --git a/app/views/projects/blob/_editor.html.haml b/app/views/projects/blob/_editor.html.haml
index 283b845e40d..dc3a1b96964 100644
--- a/app/views/projects/blob/_editor.html.haml
+++ b/app/views/projects/blob/_editor.html.haml
@@ -14,9 +14,10 @@
- if current_action?(:new) || current_action?(:create)
%span.pull-left.append-right-10
- \/
= text_field_tag 'file_name', params[:file_name], placeholder: "File name",
- required: true, class: 'form-control new-file-name js-file-path-name-input'
+ required: true, class: 'form-control new-file-name js-file-path-name-input',
+ value: '.gitlab-ci.yml'
+ = render 'template_selectors'
.file-buttons
- if is_markdown
diff --git a/app/views/projects/blob/_template_selectors.html.haml b/app/views/projects/blob/_template_selectors.html.haml
index bd46f5a4349..c7e5d5f30ab 100644
--- a/app/views/projects/blob/_template_selectors.html.haml
+++ b/app/views/projects/blob/_template_selectors.html.haml
@@ -1,9 +1,5 @@
.template-selectors-menu
- .templates-selectors-label
- Template
.template-selector-dropdowns-wrap
- .template-type-selector.js-template-type-selector-wrap.hidden
- = dropdown_tag("Choose type", options: { toggle_class: 'js-template-type-selector qa-template-type-dropdown', title: "Choose a template type" } )
.license-selector.js-license-selector-wrap.js-template-selector-wrap.hidden
= dropdown_tag("Apply a license template", options: { toggle_class: 'js-license-selector qa-license-dropdown', title: "Apply a license", filter: true, placeholder: "Filter", data: { data: licenses_for_select(@project), project: @project.name, fullname: @project.namespace.human_name } } )
.gitignore-selector.js-gitignore-selector-wrap.js-template-selector-wrap.hidden
diff --git a/app/views/projects/blob/new.html.haml b/app/views/projects/blob/new.html.haml
index 4be87b9e074..c5e3923f1e8 100644
--- a/app/views/projects/blob/new.html.haml
+++ b/app/views/projects/blob/new.html.haml
@@ -5,7 +5,6 @@
.editor-title-row
%h3.page-title.blob-new-page-title
New file
- = render 'template_selectors'
.file-editor
= form_tag(project_create_blob_path(@project, @id), method: :post, class: 'js-edit-blob-form js-new-blob-form js-quick-submit js-requires-input', data: blob_editor_paths(@project)) do
= render 'projects/blob/editor', ref: @ref