Skip to content
Snippets Groups Projects
Verified Commit 60ce5155 authored by Phil Hughes's avatar Phil Hughes
Browse files

fixed bug with tabs not switching correctly

clears all tmp files after cancelling edit mode
parent 10dcaea1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -21,13 +21,22 @@
},
methods: {
createEntryInStore() {
if (this.entryName === '') return;
const originalPath = RepoStore.path;
let entryName = this.entryName;
 
const fileName = this.type === 'tree' ? '.gitkeep' : this.entryName;
if (entryName.indexOf(`${RepoStore.path}/`) !== 0) {
RepoStore.path = '';
} else {
entryName = entryName.replace(`${RepoStore.path}/`, '');
}
if (entryName === '') return;
const fileName = this.type === 'tree' ? '.gitkeep' : entryName;
let tree = RepoStore;
 
if (this.type === 'tree') {
const dirNames = this.entryName.split('/');
const dirNames = entryName.split('/');
 
dirNames.forEach((dirName) => {
if (dirName === '') return;
Loading
Loading
@@ -43,11 +52,13 @@
RepoHelper.setFile(file.entry, file.entry);
 
RepoStore.editMode = true;
RepoStore.toggleBlobView();
RepoStore.currentBlobView = 'repo-editor';
}
}
 
this.toggleModalOpen();
RepoStore.path = originalPath;
},
toggleModalOpen() {
this.$emit('toggle');
Loading
Loading
Loading
Loading
@@ -37,6 +37,9 @@ export default {
dialogSubmitted(status) {
this.toggleDialogOpen(false);
this.dialog.status = status;
// remove tmp files
Helper.removeAllTmpFiles();
},
 
toggleBlobView: Store.toggleBlobView,
Loading
Loading
Loading
Loading
@@ -62,7 +62,6 @@ export default {
if (newBranch) {
payload.start_branch = this.currentBranch;
}
this.submitCommitsLoading = true;
Service.commitFiles(payload)
.then(() => {
this.resetCommitState();
Loading
Loading
@@ -78,6 +77,8 @@ export default {
},
 
tryCommit(e, skipBranchCheck = false, newBranch = false) {
this.submitCommitsLoading = true;
if (skipBranchCheck) {
this.makeCommit(newBranch);
} else {
Loading
Loading
@@ -90,6 +91,7 @@ export default {
this.makeCommit(newBranch);
})
.catch(() => {
this.submitCommitsLoading = false;
Flash('An error occurred while committing your changes');
});
}
Loading
Loading
Loading
Loading
@@ -62,6 +62,7 @@ const RepoHelper = {
});
 
RepoHelper.updateHistoryEntry(tree.url, title);
Store.path = tree.path;
},
 
setDirectoryToClosed(entry) {
Loading
Loading
@@ -157,7 +158,18 @@ const RepoHelper = {
},
 
serializeRepoEntity(type, entity, level = 0) {
const { id, url, name, icon, last_commit, tree_url, path, tempFile, opened = false } = entity;
const {
id,
url,
name,
icon,
last_commit,
tree_url,
path,
tempFile,
active,
opened,
} = entity;
 
return {
id,
Loading
Loading
@@ -172,6 +184,7 @@ const RepoHelper = {
files: [],
loading: false,
opened,
active,
// eslint-disable-next-line camelcase
lastCommit: last_commit ? {
url: `${Store.projectUrl}/commit/${last_commit.id}`,
Loading
Loading
@@ -215,7 +228,7 @@ const RepoHelper = {
},
 
findOpenedFileFromActive() {
return Store.openedFiles.find(openedFile => Store.activeFile.url === openedFile.url);
return Store.openedFiles.find(openedFile => Store.activeFile.id === openedFile.id);
},
 
getFileFromPath(path) {
Loading
Loading
@@ -232,11 +245,13 @@ const RepoHelper = {
 
if (!foundEntry) {
foundEntry = RepoHelper.serializeRepoEntity(type, {
id: name,
name,
path: tree.path ? `${tree.path}/${name}` : name,
icon: type === 'tree' ? 'folder' : 'file-text-o',
tempFile: true,
opened: true,
active: true,
}, tree.level !== undefined ? tree.level + 1 : 0);
 
exists = false;
Loading
Loading
@@ -248,6 +263,11 @@ const RepoHelper = {
exists,
};
},
removeAllTmpFiles() {
Store.openedFiles = Store.openedFiles.filter(f => !f.tempFile);
Store.files = Store.files.filter(f => !f.tempFile);
},
};
 
export default RepoHelper;
Loading
Loading
@@ -76,7 +76,7 @@ const RepoStore = {
RepoStore.blobRaw = file.base64;
} else if (file.newContent || file.plain) {
RepoStore.blobRaw = file.newContent || file.plain;
} else if (!file.tempFile) {
} else {
Service.getRaw(file)
.then((rawResponse) => {
RepoStore.blobRaw = rawResponse.data;
Loading
Loading
@@ -84,14 +84,16 @@ const RepoStore = {
}).catch(Helper.loadingError);
}
 
if (!file.loading) Helper.updateHistoryEntry(file.url, file.pageTitle || file.name);
if (!file.loading && !file.tempFile) {
Helper.updateHistoryEntry(file.url, file.pageTitle || file.name);
}
RepoStore.binary = file.binary;
RepoStore.setActiveLine(-1);
},
 
setFileActivity(file, openedFile, i) {
const activeFile = openedFile;
activeFile.active = file.url === activeFile.url;
activeFile.active = file.id === activeFile.id;
 
if (activeFile.active) RepoStore.setActiveFile(activeFile, i);
 
Loading
Loading
@@ -99,7 +101,7 @@ const RepoStore = {
},
 
setActiveFile(activeFile, i) {
RepoStore.activeFile = Object.assign({}, RepoStore.activeFile, activeFile);
RepoStore.activeFile = Object.assign({}, Helper.getDefaultActiveFile(), activeFile);
RepoStore.activeFileIndex = i;
},
 
Loading
Loading
@@ -175,7 +177,7 @@ const RepoStore = {
// getters
 
isActiveFile(file) {
return file && file.url === RepoStore.activeFile.url;
return file && file.id === RepoStore.activeFile.id;
},
 
isPreviewView() {
Loading
Loading
@@ -183,4 +185,6 @@ const RepoStore = {
},
};
 
window.RepoStore = RepoStore;
export default RepoStore;
Loading
Loading
@@ -205,6 +205,7 @@ class Projects::BlobController < Projects::ApplicationController
tree_path = path_segments.join('/')
 
render json: json.merge(
id: @blob.id,
path: blob.path,
name: blob.name,
extension: blob.extension,
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ import Vue from 'vue';
import repoFileButtons from '~/repo/components/repo_file_buttons.vue';
import RepoStore from '~/repo/stores/repo_store';
 
fdescribe('RepoFileButtons', () => {
describe('RepoFileButtons', () => {
const activeFile = {
extension: 'md',
url: 'url',
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment