various different performance improvements

[ci skip]
This commit is contained in:
Phil Hughes 2017-10-26 17:36:27 +01:00
parent 4d18e20011
commit 5c0c345a3a
No known key found for this signature in database
GPG key ID: 32245528C52E0F9F
10 changed files with 24 additions and 37 deletions

View file

@ -11,7 +11,6 @@ export default {
computed: {
...mapState([
'currentBlobView',
'editMode',
]),
...mapGetters([
'isMini',
@ -45,13 +44,14 @@ export default {
<div class="repository-view">
<div class="tree-content-holder" :class="{'tree-content-holder-mini' : isMini}">
<repo-sidebar/>
<div v-if="isMini"
class="panel-right"
:class="{'edit-mode': editMode}">
<div
v-if="isMini"
class="panel-right"
>
<repo-tabs/>
<component
:is="currentBlobView"
class="blob-viewer-container"/>
/>
<repo-file-buttons/>
</div>
</div>

View file

@ -28,7 +28,7 @@ export default {
</script>
<template>
<div>
<div class="editable-mode">
<button
v-if="canEditFile"
class="btn btn-default"

View file

@ -52,12 +52,13 @@ export default {
},
setupEditor() {
if (!this.activeFile) return;
const content = this.activeFile.content !== '' ? this.activeFile.content : this.activeFile.raw;
const foundLang = this.languages.find(lang =>
lang.extensions && lang.extensions.indexOf(this.activeFileExtension) === 0,
);
const newModel = this.monaco.editor.createModel(
this.activeFile.raw, foundLang ? foundLang.id : 'plaintext',
content, foundLang ? foundLang.id : 'plaintext',
);
this.monacoInstance.setModel(newModel);
@ -91,5 +92,5 @@ export default {
</script>
<template>
<div id="ide" v-if='!shouldHideEditor'></div>
<div id="ide" v-if='!shouldHideEditor' class="blob-viewer-container blob-editor-container"></div>
</template>

View file

@ -34,7 +34,6 @@
},
methods: {
...mapActions([
'getTreeData',
'clickedTreeRow',
]),
},

View file

@ -31,7 +31,7 @@ export default {
</script>
<template>
<div>
<div class="blob-viewer-container">
<div
v-if="!activeFile.renderError"
v-html="activeFile.html">

View file

@ -5,13 +5,13 @@ import Repo from './components/repo.vue';
import RepoEditButton from './components/repo_edit_button.vue';
import newBranchForm from './components/new_branch_form.vue';
import newDropdown from './components/new_dropdown/index.vue';
import vStore from './stores';
import store from './stores';
import Translate from '../vue_shared/translate';
function initRepo(el) {
return new Vue({
el,
store: vStore,
store,
components: {
repo: Repo,
},
@ -53,17 +53,20 @@ function initRepo(el) {
function initRepoEditButton(el) {
return new Vue({
el,
store: vStore,
store,
components: {
repoEditButton: RepoEditButton,
},
render(createElement) {
return createElement('repo-edit-button');
},
});
}
function initNewDropdown(el) {
return new Vue({
el,
store: vStore,
store,
components: {
newDropdown,
},
@ -83,7 +86,7 @@ function initNewBranchForm() {
components: {
newBranchForm,
},
store: vStore,
store,
render(createElement) {
return createElement('new-branch-form');
},

View file

@ -10,9 +10,7 @@ export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DAT
export const closeDiscardPopup = ({ commit }) => commit(types.TOGGLE_DISCARD_POPUP, false);
export const discardAllChanges = ({ state, commit, getters, dispatch }) => {
if (state.editMode) return;
export const discardAllChanges = ({ commit, getters, dispatch }) => {
const changedFiles = getters.changedFiles;
changedFiles.forEach((file) => {
@ -82,6 +80,8 @@ export const commitChanges = ({ commit, state, dispatch }, { payload, newMr }) =
dispatch('discardAllChanges');
dispatch('closeAllFiles');
dispatch('toggleEditMode');
window.scrollTo(0, 0);
}
})
.catch(() => flash('Error committing changes. Please try again.'));

View file

@ -72,10 +72,6 @@
text-decoration: underline;
}
}
.cursor {
display: none !important;
}
}
.blob-no-preview {
@ -85,18 +81,8 @@
}
}
&.edit-mode {
.blob-viewer-container {
overflow: hidden;
}
.monaco-editor.vs {
.cursor {
background: $black;
border-color: $black;
display: block !important;
}
}
&.blob-editor-container {
overflow: hidden;
}
.blob-viewer-container {

View file

@ -9,7 +9,7 @@
.tree-controls
- if show_new_repo?
= render 'shared/repo/editable_mode'
.editable-mode
- else
= link_to s_('Commits|History'), project_commits_path(@project, @id), class: 'btn'

View file

@ -1,2 +0,0 @@
.editable-mode
%repo-edit-button