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:
authorBryce Johnson <bryce@gitlab.com>2017-04-03 20:54:40 +0300
committerAlfredo Sumaran <alfredo@gitlab.com>2017-04-03 20:54:40 +0300
commitf564cbb21ac31da88841ad93d6051d90677b7c12 (patch)
tree0d7812f9b2c74f0c6eac5c1e846f0885ec6f1295 /app/assets/javascripts/blob_edit
parentca6a7f1e9c9296317315249de9b8b3803d1c6ddc (diff)
Make file templates easy to use and discover
Diffstat (limited to 'app/assets/javascripts/blob_edit')
-rw-r--r--app/assets/javascripts/blob_edit/blob_bundle.js3
-rw-r--r--app/assets/javascripts/blob_edit/edit_blob.js38
2 files changed, 13 insertions, 28 deletions
diff --git a/app/assets/javascripts/blob_edit/blob_bundle.js b/app/assets/javascripts/blob_edit/blob_bundle.js
index c5deccf631e..1c64ccf536f 100644
--- a/app/assets/javascripts/blob_edit/blob_bundle.js
+++ b/app/assets/javascripts/blob_edit/blob_bundle.js
@@ -13,8 +13,9 @@ $(() => {
const urlRoot = editBlobForm.data('relative-url-root');
const assetsPath = editBlobForm.data('assets-prefix');
const blobLanguage = editBlobForm.data('blob-language');
+ const currentAction = $('.js-file-title').data('current-action');
- new EditBlob(`${urlRoot}${assetsPath}`, blobLanguage);
+ new EditBlob(`${urlRoot}${assetsPath}`, blobLanguage, currentAction);
new NewCommitForm(editBlobForm);
}
diff --git a/app/assets/javascripts/blob_edit/edit_blob.js b/app/assets/javascripts/blob_edit/edit_blob.js
index d3560d5df3b..b37988a674d 100644
--- a/app/assets/javascripts/blob_edit/edit_blob.js
+++ b/app/assets/javascripts/blob_edit/edit_blob.js
@@ -1,17 +1,13 @@
/* global ace */
-import BlobLicenseSelectors from '../blob/template_selectors/blob_license_selectors';
-import BlobGitignoreSelectors from '../blob/template_selectors/blob_gitignore_selectors';
-import BlobCiYamlSelectors from '../blob/template_selectors/blob_ci_yaml_selectors';
-import BlobDockerfileSelectors from '../blob/template_selectors/blob_dockerfile_selectors';
+import TemplateSelectorMediator from '../blob/file_template_mediator';
export default class EditBlob {
- constructor(assetsPath, aceMode) {
+ constructor(assetsPath, aceMode, currentAction) {
this.configureAceEditor(aceMode, assetsPath);
- this.prepFileContentForSubmit();
this.initModePanesAndLinks();
this.initSoftWrap();
- this.initFileSelectors();
+ this.initFileSelectors(currentAction);
}
configureAceEditor(aceMode, assetsPath) {
@@ -19,6 +15,10 @@ export default class EditBlob {
ace.config.loadModule('ace/ext/searchbox');
this.editor = ace.edit('editor');
+
+ // This prevents warnings re: automatic scrolling being logged
+ this.editor.$blockScrolling = Infinity;
+
this.editor.focus();
if (aceMode) {
@@ -26,29 +26,13 @@ export default class EditBlob {
}
}
- prepFileContentForSubmit() {
- $('form').submit(() => {
- $('#file-content').val(this.editor.getValue());
+ initFileSelectors(currentAction) {
+ this.fileTemplateMediator = new TemplateSelectorMediator({
+ currentAction,
+ editor: this.editor,
});
}
- initFileSelectors() {
- this.blobTemplateSelectors = [
- new BlobLicenseSelectors({
- editor: this.editor,
- }),
- new BlobGitignoreSelectors({
- editor: this.editor,
- }),
- new BlobCiYamlSelectors({
- editor: this.editor,
- }),
- new BlobDockerfileSelectors({
- editor: this.editor,
- }),
- ];
- }
-
initModePanesAndLinks() {
this.$editModePanes = $('.js-edit-mode-pane');
this.$editModeLinks = $('.js-edit-mode a');