From 2024198da7052b69a206d53a7accc2f9b1291b2f Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Tue, 15 Aug 2017 19:53:41 +0000 Subject: [PATCH] Many Repo Fixes --- app/assets/javascripts/api.js | 1 - app/assets/javascripts/project.js | 2 +- .../javascripts/repo/components/repo.vue | 52 ++++---- .../repo/components/repo_commit_section.vue | 86 +++++++++---- .../repo/components/repo_edit_button.vue | 35 ++++-- .../repo/components/repo_editor.vue | 85 +++++++------ .../javascripts/repo/components/repo_file.vue | 67 ++++++++-- .../repo/components/repo_file_buttons.vue | 47 +++++-- .../repo/components/repo_file_options.vue | 2 +- .../repo/components/repo_loading_file.vue | 61 ++++++--- .../repo/components/repo_prev_directory.vue | 16 ++- .../repo/components/repo_sidebar.vue | 2 +- .../javascripts/repo/components/repo_tab.vue | 8 +- .../javascripts/repo/components/repo_tabs.vue | 3 +- .../repo/helpers/monaco_loader_helper.js | 3 +- .../javascripts/repo/helpers/repo_helper.js | 71 ++++------- app/assets/javascripts/repo/index.js | 2 + .../javascripts/repo/services/repo_service.js | 16 +-- .../javascripts/repo/stores/repo_store.js | 48 ++----- .../vue_shared/components/popup_dialog.vue | 5 - .../stylesheets/framework/animations.scss | 78 ++++++++++++ app/assets/stylesheets/framework/layout.scss | 4 - app/assets/stylesheets/pages/repo.scss | 118 ++---------------- app/controllers/projects/blob_controller.rb | 5 + app/serializers/tree_root_entity.rb | 15 ++- app/views/shared/_ref_switcher.html.haml | 2 +- app/views/shared/_target_switcher.html.haml | 2 +- app/views/shared/repo/_repo.html.haml | 8 +- .../components/repo_commit_section_spec.js | 58 ++++----- .../repo/components/repo_edit_button_spec.js | 16 ++- .../repo/components/repo_file_buttons_spec.js | 18 +-- .../repo/components/repo_file_spec.js | 6 +- .../repo/components/repo_loading_file_spec.js | 2 +- .../repo/components/repo_sidebar_spec.js | 1 + .../repo/components/repo_tabs_spec.js | 8 -- 35 files changed, 516 insertions(+), 437 deletions(-) diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 76b724e1bcb..56f91e95bb9 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -97,7 +97,6 @@ const Api = { }, commitMultiple(id, data, callback) { - // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions const url = Api.buildUrl(Api.commitPath) .replace(':id', id); return $.ajax({ diff --git a/app/assets/javascripts/project.js b/app/assets/javascripts/project.js index 272e8e8c218..d7e3ab42f00 100644 --- a/app/assets/javascripts/project.js +++ b/app/assets/javascripts/project.js @@ -126,7 +126,7 @@ import Cookies from 'js-cookie'; var $form = $dropdown.closest('form'); var $visit = $dropdown.data('visit'); - var shouldVisit = typeof $visit === 'undefined' ? true : $visit; + var shouldVisit = $visit ? true : $visit; var action = $form.attr('action'); var divider = action.indexOf('?') === -1 ? '?' : '&'; if (shouldVisit) { diff --git a/app/assets/javascripts/repo/components/repo.vue b/app/assets/javascripts/repo/components/repo.vue index 703da749ad3..3d5e01c8ec0 100644 --- a/app/assets/javascripts/repo/components/repo.vue +++ b/app/assets/javascripts/repo/components/repo.vue @@ -14,13 +14,13 @@ export default { data: () => Store, mixins: [RepoMixin], components: { - 'repo-sidebar': RepoSidebar, - 'repo-tabs': RepoTabs, - 'repo-file-buttons': RepoFileButtons, + RepoSidebar, + RepoTabs, + RepoFileButtons, 'repo-editor': MonacoLoaderHelper.repoEditorLoader, - 'repo-commit-section': RepoCommitSection, - 'popup-dialog': PopupDialog, - 'repo-preview': RepoPreview, + RepoCommitSection, + PopupDialog, + RepoPreview, }, mounted() { @@ -28,12 +28,12 @@ export default { }, methods: { - dialogToggled(toggle) { + toggleDialogOpen(toggle) { this.dialog.open = toggle; }, dialogSubmitted(status) { - this.dialog.open = false; + this.toggleDialogOpen(false); this.dialog.status = status; }, @@ -43,21 +43,25 @@ export default { diff --git a/app/assets/javascripts/repo/components/repo_commit_section.vue b/app/assets/javascripts/repo/components/repo_commit_section.vue index 344d40be131..5ec4a9b6593 100644 --- a/app/assets/javascripts/repo/components/repo_commit_section.vue +++ b/app/assets/javascripts/repo/components/repo_commit_section.vue @@ -2,7 +2,6 @@ /* global Flash */ import Store from '../stores/repo_store'; import RepoMixin from '../mixins/repo_mixin'; -import Helper from '../helpers/repo_helper'; import Service from '../services/repo_service'; export default { @@ -11,9 +10,12 @@ export default { mixins: [RepoMixin], computed: { + showCommitable() { + return this.isCommitable && this.changedFiles.length; + }, + branchPaths() { - const branch = Helper.getBranch(); - return this.changedFiles.map(f => Helper.getFilePathFromFullPath(f.url, branch)); + return this.changedFiles.map(f => f.path); }, cantCommitYet() { @@ -28,11 +30,10 @@ export default { methods: { makeCommit() { // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions - const branch = Helper.getBranch(); const commitMessage = this.commitMessage; const actions = this.changedFiles.map(f => ({ action: 'update', - file_path: Helper.getFilePathFromFullPath(f.url, branch), + file_path: f.path, content: f.newContent, })); const payload = { @@ -47,49 +48,80 @@ export default { resetCommitState() { this.submitCommitsLoading = false; this.changedFiles = []; - this.openedFiles = []; this.commitMessage = ''; this.editMode = false; - $('html, body').animate({ scrollTop: 0 }, 'fast'); + window.scrollTo(0, 0); }, }, };