From caee9d5882050b3998f05edf7aff8bd3c36591c3 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 12 Oct 2017 10:55:11 +0100 Subject: [PATCH] Add new files & directories in the multi-file editor Closes #38614 --- .../repo/components/new_dropdown/index.vue | 70 +++++++++++ .../repo/components/new_dropdown/modal.vue | 115 ++++++++++++++++++ .../repo/components/repo_commit_section.vue | 2 +- .../repo/components/repo_editor.vue | 43 ++++--- .../repo/components/repo_file_buttons.vue | 12 +- .../javascripts/repo/components/repo_tab.vue | 4 +- .../javascripts/repo/helpers/repo_helper.js | 4 +- app/assets/javascripts/repo/index.js | 15 +++ .../javascripts/repo/mixins/repo_mixin.js | 2 +- .../javascripts/repo/stores/repo_store.js | 7 +- .../vue_shared/components/popup_dialog.vue | 11 +- .../projects/tree/_tree_header.html.haml | 4 +- 12 files changed, 257 insertions(+), 32 deletions(-) create mode 100644 app/assets/javascripts/repo/components/new_dropdown/index.vue create mode 100644 app/assets/javascripts/repo/components/new_dropdown/modal.vue diff --git a/app/assets/javascripts/repo/components/new_dropdown/index.vue b/app/assets/javascripts/repo/components/new_dropdown/index.vue new file mode 100644 index 00000000000..652c8027ae3 --- /dev/null +++ b/app/assets/javascripts/repo/components/new_dropdown/index.vue @@ -0,0 +1,70 @@ + + + diff --git a/app/assets/javascripts/repo/components/new_dropdown/modal.vue b/app/assets/javascripts/repo/components/new_dropdown/modal.vue new file mode 100644 index 00000000000..95ecfb29dd3 --- /dev/null +++ b/app/assets/javascripts/repo/components/new_dropdown/modal.vue @@ -0,0 +1,115 @@ + + + diff --git a/app/assets/javascripts/repo/components/repo_commit_section.vue b/app/assets/javascripts/repo/components/repo_commit_section.vue index 185cd90ac06..e3003fbf477 100644 --- a/app/assets/javascripts/repo/components/repo_commit_section.vue +++ b/app/assets/javascripts/repo/components/repo_commit_section.vue @@ -49,7 +49,7 @@ export default { // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions const commitMessage = this.commitMessage; const actions = this.changedFiles.map(f => ({ - action: 'update', + action: f.tempFile ? 'create' : 'update', file_path: f.path, content: f.newContent, })); diff --git a/app/assets/javascripts/repo/components/repo_editor.vue b/app/assets/javascripts/repo/components/repo_editor.vue index 4639bee6d66..9f567d4e94d 100644 --- a/app/assets/javascripts/repo/components/repo_editor.vue +++ b/app/assets/javascripts/repo/components/repo_editor.vue @@ -16,28 +16,35 @@ const RepoEditor = { }, mounted() { - Service.getRaw(this.activeFile.raw_path) - .then((rawResponse) => { - Store.blobRaw = rawResponse.data; - Store.activeFile.plain = rawResponse.data; + if (!this.activeFile.tempFile) { + Service.getRaw(this.activeFile.raw_path) + .then((rawResponse) => { + Store.blobRaw = rawResponse.data; + Store.activeFile.plain = rawResponse.data; - const monacoInstance = Helper.monaco.editor.create(this.$el, { - model: null, - readOnly: false, - contextmenu: true, - scrollBeyondLastLine: false, - }); - - Helper.monacoInstance = monacoInstance; - - this.addMonacoEvents(); - - this.setupEditor(); - }) - .catch(Helper.loadingError); + this.createMonacoInstance(); + }) + .catch(Helper.loadingError); + } else { + this.createMonacoInstance(); + } }, methods: { + createMonacoInstance() { + const monacoInstance = Helper.monaco.editor.create(this.$el, { + model: null, + readOnly: false, + contextmenu: true, + scrollBeyondLastLine: false, + }); + + Helper.monacoInstance = monacoInstance; + + this.addMonacoEvents(); + + this.setupEditor(); + }, setupEditor() { this.showHide(); diff --git a/app/assets/javascripts/repo/components/repo_file_buttons.vue b/app/assets/javascripts/repo/components/repo_file_buttons.vue index 03cd219e718..354be2545f4 100644 --- a/app/assets/javascripts/repo/components/repo_file_buttons.vue +++ b/app/assets/javascripts/repo/components/repo_file_buttons.vue @@ -11,7 +11,12 @@ const RepoFileButtons = { mixins: [RepoMixin], computed: { - + showButtons() { + return this.activeFile.raw_path || + this.activeFile.blame_path || + this.activeFile.commits_path || + this.activeFile.permalink; + }, rawDownloadButtonLabel() { return this.binary ? 'Download' : 'Raw'; }, @@ -30,7 +35,10 @@ export default RepoFileButtons;