Commit a0e53bcb authored by Phil Hughes's avatar Phil Hughes

correctly sets URL when closing a file

adds tempFiles into list
parent 2a2373c9
......@@ -34,6 +34,7 @@
createNewItem(type) {
this.modalType = type;
this.openModal = true;
this.dropdownOpen = false;
},
hideModal() {
this.openModal = false;
......@@ -75,7 +76,7 @@
<a
href="#"
role="button"
@click.prevent="createNewItem('blob')"
@click.stop.prevent="createNewItem('blob')"
>
{{ __('New file') }}
</a>
......@@ -91,7 +92,7 @@
<a
href="#"
role="button"
@click.prevent="createNewItem('tree')"
@click.stop.prevent="createNewItem('tree')"
>
{{ __('New directory') }}
</a>
......
......@@ -73,7 +73,7 @@
<a
href="#"
role="button"
@click.prevent="startFileUpload"
@click.stop.prevent="startFileUpload"
>
{{ __('Upload file') }}
</a>
......
......@@ -91,10 +91,11 @@
<tr
class="file"
:class="fileClass"
@click="clickFile(file)">
>
<td
class="multi-file-table-name"
:colspan="submoduleColSpan"
@click="clickFile(file)"
>
<a
class="repo-file-name str-truncated"
......
......@@ -21,7 +21,7 @@ export const closeFile = ({ commit, state, dispatch }, file) => {
const nextIndexToOpen = indexOfClosedFile === 0 ? 0 : indexOfClosedFile - 1;
const nextFileToOpen = state.openFiles[nextIndexToOpen];
dispatch('setFileActive', nextFileToOpen);
router.push(`/project${nextFileToOpen.url}`);
} else if (!state.openFiles.length) {
router.push(`/project/${file.projectId}/tree/${file.branchId}/`);
}
......
......@@ -38,7 +38,7 @@ export const getTreeData = (
commit(types.SET_ROOT, data.path === '/');
}
dispatch('updateDirectoryData', { data, tree, projectId, branch });
dispatch('updateDirectoryData', { data, tree, projectId, branch, clearTree: false });
const selectedTree = tree || state.trees[`${projectId}/${branch}`];
commit(types.SET_PARENT_TREE_URL, data.parent_tree_url);
......@@ -85,7 +85,7 @@ export const handleTreeEntryAction = ({ commit, dispatch }, row) => {
commit(types.TOGGLE_LOADING, row);
visitUrl(row.url);
} else if (row.type === 'blob' && (row.opened || row.changed)) {
if (row.changed) {
if (row.changed && !row.opened) {
commit(types.TOGGLE_FILE_OPEN, row);
}
......@@ -160,7 +160,7 @@ export const getLastCommitData = ({ state, commit, dispatch, getters }, tree = s
export const updateDirectoryData = (
{ commit, state },
{ data, tree, projectId, branch },
{ data, tree, projectId, branch, clearTree = true },
) => {
if (!tree) {
const existingTree = state.trees[`${projectId}/${branch}`];
......@@ -173,7 +173,6 @@ export const updateDirectoryData = (
const level = selectedTree.level !== undefined ? selectedTree.level + 1 : 0;
const parentTreeUrl = data.parent_tree_url ? `${data.parent_tree_url}${data.path}` : state.endpoints.rootUrl;
const createEntry = (entry, type) => createOrMergeEntry({
tree: selectedTree,
projectId: `${projectId}`,
branchId: branch,
entry,
......@@ -189,5 +188,11 @@ export const updateDirectoryData = (
...data.blobs.map(b => createEntry(b, 'blob')),
];
if (!clearTree) {
formattedData.push(
state.changedFiles.filter(f => f.tempFile && f.path === `${tree.path}/${f.name}`),
);
}
commit(types.SET_DIRECTORY_DATA, { tree: selectedTree, data: formattedData });
};
......@@ -155,8 +155,7 @@ export const createTemp = ({
});
};
export const createOrMergeEntry = ({ tree,
projectId,
export const createOrMergeEntry = ({ projectId,
branchId,
entry,
type,
......@@ -179,16 +178,6 @@ export const createOrMergeEntry = ({ tree,
}
}
const found = findEntry(tree.tree || tree, type, entry.name);
if (found) {
return Object.assign({}, found, {
id: entry.id,
url: entry.url,
tempFile: false,
});
}
return decorateData({
...entry,
projectId,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment