diff options
author | Phil Hughes <me@iamphill.com> | 2017-10-31 11:24:42 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-10-31 11:24:42 +0000 |
commit | e6a1a798f503705f12420b684c90026486d2927b (patch) | |
tree | b4abb6e7cb6e9af69625c683c0a7eed6b10dbda4 /app | |
parent | 307883a5eb582ac203fe0777fcb11fa7d6c3ddca (diff) | |
parent | a9446093b12a9dffef97541915e2b6872875ad3f (diff) | |
download | gitlab-ce-e6a1a798f503705f12420b684c90026486d2927b.tar.gz |
Merge branch 'master' into multi-file-editor-vuex
Diffstat (limited to 'app')
8 files changed, 92 insertions, 8 deletions
diff --git a/app/assets/javascripts/behaviors/autosize.js b/app/assets/javascripts/behaviors/autosize.js index e00af4b2fa8..add43b81f6d 100644 --- a/app/assets/javascripts/behaviors/autosize.js +++ b/app/assets/javascripts/behaviors/autosize.js @@ -1,8 +1,8 @@ -import autosize from 'vendor/autosize'; +import Autosize from 'autosize'; document.addEventListener('DOMContentLoaded', () => { const autosizeEls = document.querySelectorAll('.js-autosize'); - autosize(autosizeEls); - autosize.update(autosizeEls); + Autosize(autosizeEls); + Autosize.update(autosizeEls); }); diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index ab101a56db8..705bec23b53 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -12,7 +12,7 @@ newline-per-chained-call, no-useless-escape, class-methods-use-this */ import $ from 'jquery'; import _ from 'underscore'; import Cookies from 'js-cookie'; -import autosize from 'vendor/autosize'; +import Autosize from 'autosize'; import 'vendor/jquery.caret'; // required by jquery.atwho import 'vendor/jquery.atwho'; import AjaxCache from '~/lib/utils/ajax_cache'; @@ -25,7 +25,7 @@ import TaskList from './task_list'; import { ajaxPost, isInViewport, getPagePath, scrollToElement, isMetaKey } from './lib/utils/common_utils'; import imageDiffHelper from './image_diff/helpers/index'; -window.autosize = autosize; +window.autosize = Autosize; function normalizeNewlines(str) { return str.replace(/\r\n/g, '\n'); diff --git a/app/assets/javascripts/notes/components/issue_comment_form.vue b/app/assets/javascripts/notes/components/issue_comment_form.vue index ad384a1cc36..db8f85759b2 100644 --- a/app/assets/javascripts/notes/components/issue_comment_form.vue +++ b/app/assets/javascripts/notes/components/issue_comment_form.vue @@ -1,7 +1,7 @@ <script> import { mapActions, mapGetters } from 'vuex'; import _ from 'underscore'; - import autosize from 'vendor/autosize'; + import Autosize from 'autosize'; import Flash from '../../flash'; import Autosave from '../../autosave'; import TaskList from '../../task_list'; @@ -219,7 +219,7 @@ }, resizeTextarea() { this.$nextTick(() => { - autosize.update(this.$refs.textarea); + Autosize.update(this.$refs.textarea); }); }, }, diff --git a/app/assets/javascripts/repo/components/new_dropdown/index.vue b/app/assets/javascripts/repo/components/new_dropdown/index.vue index 5e93ce7bc0f..9e1597add53 100644 --- a/app/assets/javascripts/repo/components/new_dropdown/index.vue +++ b/app/assets/javascripts/repo/components/new_dropdown/index.vue @@ -1,10 +1,12 @@ <script> import { mapState } from 'vuex'; import newModal from './modal.vue'; + import upload from './upload.vue'; export default { components: { newModal, + upload, }, data() { return { @@ -56,6 +58,11 @@ </a> </li> <li> + <upload + :current-path="currentPath" + /> + </li> + <li> <a href="#" role="button" diff --git a/app/assets/javascripts/repo/components/new_dropdown/upload.vue b/app/assets/javascripts/repo/components/new_dropdown/upload.vue new file mode 100644 index 00000000000..cbea9c08249 --- /dev/null +++ b/app/assets/javascripts/repo/components/new_dropdown/upload.vue @@ -0,0 +1,67 @@ +<script> + import eventHub from '../../event_hub'; + + export default { + props: { + currentPath: { + type: String, + required: true, + }, + }, + methods: { + createFile(target, file, isText) { + const { name } = file; + const nameWithPath = `${this.currentPath !== '' ? `${this.currentPath}/` : ''}${name}`; + let { result } = target; + + if (!isText) { + result = result.split('base64,')[1]; + } + + eventHub.$emit('createNewEntry', { + name: nameWithPath, + type: 'blob', + content: result, + toggleModal: false, + base64: !isText, + }, isText); + }, + readFile(file) { + const reader = new FileReader(); + const isText = file.type.match(/text.*/) !== null; + + reader.addEventListener('load', e => this.createFile(e.target, file, isText), { once: true }); + + if (isText) { + reader.readAsText(file); + } else { + reader.readAsDataURL(file); + } + }, + openFile() { + Array.from(this.$refs.fileUpload.files).forEach(file => this.readFile(file)); + }, + }, + mounted() { + this.$refs.fileUpload.addEventListener('change', this.openFile); + }, + beforeDestroy() { + this.$refs.fileUpload.removeEventListener('change', this.openFile); + }, + }; +</script> + +<template> + <label + role="button" + class="menu-item" + > + {{ __('Upload file') }} + <input + id="file-upload" + type="file" + class="hidden" + ref="fileUpload" + /> + </label> +</template> diff --git a/app/assets/javascripts/repo/components/repo_preview.vue b/app/assets/javascripts/repo/components/repo_preview.vue index d4d0a667ce4..d1883299bd9 100644 --- a/app/assets/javascripts/repo/components/repo_preview.vue +++ b/app/assets/javascripts/repo/components/repo_preview.vue @@ -38,6 +38,13 @@ export default { v-html="activeFile.html"> </div> <div + v-else-if="activeFile.tempFile" + class="vertical-center render-error"> + <p class="text-center"> + The source could not be displayed for this temporary file. + </p> + </div> + <div v-else-if="renderErrorTooLarge" class="vertical-center render-error"> <p class="text-center"> diff --git a/app/assets/javascripts/repo/services/index.js b/app/assets/javascripts/repo/services/index.js index 49301fb47d5..dc222ccac01 100644 --- a/app/assets/javascripts/repo/services/index.js +++ b/app/assets/javascripts/repo/services/index.js @@ -13,7 +13,7 @@ export default { }, getRawFileData(file) { if (file.tempFile) { - return Promise.resolve(''); + return Promise.resolve(file.content); } return Vue.http.get(file.rawPath, { params: { format: 'json' } }) diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss index a9d804e735d..1aa53b8f8cf 100644 --- a/app/assets/stylesheets/framework/dropdowns.scss +++ b/app/assets/stylesheets/framework/dropdowns.scss @@ -776,12 +776,15 @@ a, button, .menu-item { + margin-bottom: 0; border-radius: 0; box-shadow: none; padding: 8px 16px; text-align: left; white-space: normal; width: 100%; + font-weight: $gl-font-weight-normal; + line-height: normal; &.dropdown-menu-user-link { white-space: nowrap; |