diff options
author | Jacob Schatz <jschatz1@gmail.com> | 2017-07-25 16:18:45 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2017-07-25 16:18:45 +0300 |
commit | 40fd91b876b6a5e3ad79fac60398d1b60d8fb735 (patch) | |
tree | ffd9c4f87ab374a45928f027b3eb7b2e4cbea258 /app | |
parent | fbacfdb0f0f484cac57b1c5a85f19ef141370c7c (diff) |
Fixes height problems
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/api.js | 16 | ||||
-rw-r--r-- | app/assets/javascripts/project.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/repo/index.js | 10 | ||||
-rw-r--r-- | app/assets/javascripts/repo/repo_commit_section.js | 23 | ||||
-rw-r--r-- | app/assets/javascripts/repo/repo_commit_section.vue | 102 | ||||
-rw-r--r-- | app/assets/javascripts/repo/repo_service.js | 9 | ||||
-rw-r--r-- | app/assets/javascripts/repo/repo_store.js | 14 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/repo.scss | 4 | ||||
-rw-r--r-- | app/views/projects/tree/_tree_content.html.haml | 42 | ||||
-rw-r--r-- | app/views/projects/tree/_tree_header.html.haml | 2 |
10 files changed, 152 insertions, 71 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 56fa0d71a9a..af1fcbae570 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -13,6 +13,7 @@ const Api = { dockerfilePath: '/api/:version/templates/dockerfiles/:key', issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key', usersPath: '/api/:version/users.json', + commitPath: '/api/:version/projects/:id/repository/commits', group(groupId, callback) { const url = Api.buildUrl(Api.groupPath) @@ -95,6 +96,21 @@ const Api = { .done(projects => callback(projects)); }, + 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({ + url, + type: 'POST', + data: data, + dataType: 'json', + }) + .done(commitData => callback(commitData)) + .fail(message => callback(message.responseJSON)); + + }, + // Return text for a specific license licenseText(key, data, callback) { const url = Api.buildUrl(Api.licensePath) diff --git a/app/assets/javascripts/project.js b/app/assets/javascripts/project.js index 738e710deb9..4e9b69d5a58 100644 --- a/app/assets/javascripts/project.js +++ b/app/assets/javascripts/project.js @@ -77,6 +77,7 @@ import Cookies from 'js-cookie'; }, dataType: "json" }).done(function(refs) { + console.log(refs) return callback(refs); }); }, diff --git a/app/assets/javascripts/repo/index.js b/app/assets/javascripts/repo/index.js index 128a1043bf3..156ef2ab1f6 100644 --- a/app/assets/javascripts/repo/index.js +++ b/app/assets/javascripts/repo/index.js @@ -3,9 +3,9 @@ import $ from 'jquery'; import Vue from 'vue'; import RepoSidebar from './repo_sidebar.vue'; import EditButton from './repo_edit_button'; -import CommitSection from './repo_commit_section'; import Service from './repo_service'; import Store from './repo_store'; +import RepoCommitSection from './repo_commit_section.vue'; import RepoTabs from './repo_tabs.vue'; import RepoFileButtons from './repo_file_buttons.vue'; import RepoBinaryViewer from './repo_binary_viewer.vue'; @@ -18,6 +18,9 @@ function initRepo() { Store.service = Service; Store.service.url = repo.dataset.url; Store.projectName = repo.dataset.projectName; + Store.service.refsUrl = repo.dataset.refsUrl; + Store.currentBranch = $("button.dropdown-menu-toggle").attr('data-ref'); + Store.checkIsCommitable(); new Vue({ el: repo, @@ -30,6 +33,7 @@ function initRepo() { <repo-editor/> <repo-binary-viewer/> </div> + <repo-commit-section/> </div> `, mixins: [RepoMiniMixin], @@ -39,14 +43,12 @@ function initRepo() { 'repo-file-buttons': RepoFileButtons, 'repo-binary-viewer': RepoBinaryViewer, 'repo-editor': RepoEditor, + 'repo-commit-section': RepoCommitSection }, }); const editButton = document.getElementById('editable-mode'); - const commitSection = document.getElementById('commit-area'); - Store.editButton = new EditButton(editButton); - Store.commitSection = new CommitSection(commitSection); } $(initRepo); diff --git a/app/assets/javascripts/repo/repo_commit_section.js b/app/assets/javascripts/repo/repo_commit_section.js deleted file mode 100644 index 87fedd0e0db..00000000000 --- a/app/assets/javascripts/repo/repo_commit_section.js +++ /dev/null @@ -1,23 +0,0 @@ -import Vue from 'vue'; -import Store from './repo_store'; - -export default class RepoCommitSection { - constructor(el) { - this.initVue(el); - } - - initVue(el) { - this.vue = new Vue({ - el, - data: () => Store, - - computed: { - changedFiles() { - const changedFileList = this.openedFiles - .filter(file => file.changed); - return changedFileList; - }, - }, - }); - } -} diff --git a/app/assets/javascripts/repo/repo_commit_section.vue b/app/assets/javascripts/repo/repo_commit_section.vue new file mode 100644 index 00000000000..0e94ee4cd6a --- /dev/null +++ b/app/assets/javascripts/repo/repo_commit_section.vue @@ -0,0 +1,102 @@ +<script> +import Vue from 'vue'; +import Store from './repo_store'; + +const RepoCommitSection = { + data: () => Store, + + methods: { + makeCommit() { + // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions + // branch string + // commit_message string + // actions[] + // author_email + // author_name + const branchName = $("button.dropdown-menu-toggle").attr('data-ref'); + const commitMessage = this.commitMessage; + const actions = this.changedFiles.map(f => { + return f.url.split(branchName)[1]; + }); + console.log(branchName, commitMessage, actions); + } + }, + + computed: { + changedFiles() { + const changedFileList = this.openedFiles + .filter(file => file.changed); + return changedFileList; + }, + }, +} + +export default RepoCommitSection; +</script> + +<template> +<div id="commit-area" v-if="isCommitable && changedFiles.length" > + <form class="form-horizontal"> + <fieldset> + <div class="form-group"> + <label class="col-md-4 control-label">Staged files ({{changedFiles.length}})</label> + <div class="col-md-4"> + <ul class="list-unstyled"> + <li v-for="file in changedFiles"> + <span class="help-block"> + {{file.url}} + </span> + </li> + </ul> + </div> + </div> + <!-- Textarea + --> + <div class="form-group"> + <label class="col-md-4 control-label" for="commit-message">Commit message</label> + <div class="col-md-4"> + <textarea class="form-control" id="commit-message" name="commit-message" v-model="commitMessage"></textarea> + </div> + </div> + <!-- Button Drop Down + --> + <div class="form-group"> + <label class="col-md-4 control-label" for="target-branch">Target branch</label> + <div class="col-md-4"> + <div class="input-group"> + <div class="input-group-btn"> + <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button"> + Action + <i class="fa fa-caret-down"></i> + </button> + <ul class="dropdown-menu pull-right"> + <li> + <a href="#">Target branch</a> + </li> + <li> + <a href="#">Create my own branch</a> + </li> + </ul> + </div> + <input class="form-control" id="target-branch" name="target-branch" placeholder="placeholder" type="text"></input> + </div> + </div> + </div> + <div class="form-group"> + <label class="col-md-4 control-label" for="checkboxes"></label> + <div class="col-md-4"> + <div class="checkbox"> + <label for="checkboxes-0"> + <input id="checkboxes-0" name="checkboxes" type="checkbox" value="1"></input> + Start a new merge request with these changes + </label> + </div> + </div> + </div> + <div class="col-md-offset-4 col-md-4"> + <button type="submit" class="btn btn-success" @click.prevent="makeCommit">Commit {{changedFiles.length}} Files</button> + </div> + </fieldset> + </form> +</div> +</template>
\ No newline at end of file diff --git a/app/assets/javascripts/repo/repo_service.js b/app/assets/javascripts/repo/repo_service.js index 3876b90363f..7c5445f32e2 100644 --- a/app/assets/javascripts/repo/repo_service.js +++ b/app/assets/javascripts/repo/repo_service.js @@ -1,3 +1,4 @@ +import Store from './repo_store'; import axios from 'axios'; const RepoService = { @@ -9,6 +10,14 @@ const RepoService = { }, richExtensionRegExp: /md/, + checkCurrentBranchIsCommitable() { + const url = Store.service.refsUrl; + return axios.get(url, {params: { + ref: Store.currentBranch, + search: Store.currentBranch + }}); + }, + buildParams(url = this.url) { // shallow clone object without reference const params = Object.assign({}, this.options.params); diff --git a/app/assets/javascripts/repo/repo_store.js b/app/assets/javascripts/repo/repo_store.js index ea3708f3500..3a59e8d2636 100644 --- a/app/assets/javascripts/repo/repo_store.js +++ b/app/assets/javascripts/repo/repo_store.js @@ -40,7 +40,10 @@ const RepoStore = { activeLine: 0, activeFileLabel: 'Raw', files: [], + isCommitable: false, binary: false, + currentBranch: '', + commitMessage: 'Update README.md', binaryMimeType: '', // scroll bar space for windows scrollWidth: 0, @@ -55,6 +58,17 @@ const RepoStore = { // mutations + checkIsCommitable() { + RepoStore.service.checkCurrentBranchIsCommitable() + .then((data) => { + // you shouldn't be able to make commits on commits or tags. + let {Branches, Commits, Tags} = data.data; + if(Branches && Branches.length) RepoStore.isCommitable = true; + if(Commits && Commits.length) RepoStore.isCommitable = false; + if(Tags && Tags.length) RepoStore.isCommitable = false; + }); + }, + addFilesToDirectory(inDirectory, currentList, newList) { RepoStore.files = RepoHelper.getNewMergedList(inDirectory, currentList, newList); }, diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index 7602d2c0893..6010e0fc0c0 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -114,7 +114,7 @@ } #ide { - height: 70vh; + height: 75vh; } #repo-file-buttons { @@ -167,7 +167,7 @@ vertical-align: top; width: 20%; border-right: 1px solid $white-normal; - height: 80vh; + height: 100vh; overflow: auto; } diff --git a/app/views/projects/tree/_tree_content.html.haml b/app/views/projects/tree/_tree_content.html.haml index 27bdb7e8b55..5dc5bcc11c1 100644 --- a/app/views/projects/tree/_tree_content.html.haml +++ b/app/views/projects/tree/_tree_content.html.haml @@ -1,44 +1,4 @@ -#repo{ data: { url: repo_url(@project), 'project-name' => @project.name } } - #commit-area{ "v-if" => "changedFiles.length" } - %form.form-horizontal - %fieldset - .form-group - %label.col-md-4.control-label Staged files ({{changedFiles.length}}) - .col-md-4 - %ul.list-unstyled - %li{ "v-for" => "file in changedFiles" } - %span.help-block - {{file.url}} - / Textarea - .form-group - %label.col-md-4.control-label{ :for => "commit-message" } Commit message - .col-md-4 - %textarea#commit-message.form-control{ :name => "commit-message" } Updating README.md - / Button Drop Down - .form-group - %label.col-md-4.control-label{ :for => "target-branch" } Target branch - .col-md-4 - .input-group - .input-group-btn - %button.btn.btn-default.dropdown-toggle{ "data-toggle" => "dropdown", :type => "button" } - Action - = icon "caret-down" - %ul.dropdown-menu.pull-right - %li - %a{ :href => "#" } Target branch - %li - %a{ :href => "#" } Create my own branch - %input#target-branch.form-control{ :name => "target-branch", :placeholder => "placeholder", :type => "text" }/ - / Multiple Checkboxes - .form-group - %label.col-md-4.control-label{ :for => "checkboxes" } - .col-md-4 - .checkbox - %label{ :for => "checkboxes-0" } - %input#checkboxes-0{ :name => "checkboxes", :type => "checkbox", :value => "1" }/ - Start a new merge request with these changes - - +#repo{ data: { url: repo_url(@project), 'project-name' => @project.name, refs_url: refs_namespace_project_path(@project.namespace, @project, format: "json") } } - if can_edit_tree? = render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, @id), method: :post diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index 970ccbb743d..e28e88921b6 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -3,7 +3,7 @@ = render 'shared/ref_switcher', destination: 'tree', path: @path .tree-controls - %a.btn.btn-default#editable-mode{ "href"=>"#", "@click.prevent" => "editClicked", "v-cloak" => 1 } + %a.btn.btn-default#editable-mode{ "href"=>"#", "@click.prevent" => "editClicked", "v-cloak" => 1, "v-if" => "isCommitable" } %i{ ":class" => "buttonIcon" } %span {{buttonLabel}} |