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 @@ ...@@ -34,6 +34,7 @@
createNewItem(type) { createNewItem(type) {
this.modalType = type; this.modalType = type;
this.openModal = true; this.openModal = true;
this.dropdownOpen = false;
}, },
hideModal() { hideModal() {
this.openModal = false; this.openModal = false;
...@@ -75,7 +76,7 @@ ...@@ -75,7 +76,7 @@
<a <a
href="#" href="#"
role="button" role="button"
@click.prevent="createNewItem('blob')" @click.stop.prevent="createNewItem('blob')"
> >
{{ __('New file') }} {{ __('New file') }}
</a> </a>
...@@ -91,7 +92,7 @@ ...@@ -91,7 +92,7 @@
<a <a
href="#" href="#"
role="button" role="button"
@click.prevent="createNewItem('tree')" @click.stop.prevent="createNewItem('tree')"
> >
{{ __('New directory') }} {{ __('New directory') }}
</a> </a>
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
<a <a
href="#" href="#"
role="button" role="button"
@click.prevent="startFileUpload" @click.stop.prevent="startFileUpload"
> >
{{ __('Upload file') }} {{ __('Upload file') }}
</a> </a>
......
...@@ -91,10 +91,11 @@ ...@@ -91,10 +91,11 @@
<tr <tr
class="file" class="file"
:class="fileClass" :class="fileClass"
@click="clickFile(file)"> >
<td <td
class="multi-file-table-name" class="multi-file-table-name"
:colspan="submoduleColSpan" :colspan="submoduleColSpan"
@click="clickFile(file)"
> >
<a <a
class="repo-file-name str-truncated" class="repo-file-name str-truncated"
......
...@@ -21,7 +21,7 @@ export const closeFile = ({ commit, state, dispatch }, file) => { ...@@ -21,7 +21,7 @@ export const closeFile = ({ commit, state, dispatch }, file) => {
const nextIndexToOpen = indexOfClosedFile === 0 ? 0 : indexOfClosedFile - 1; const nextIndexToOpen = indexOfClosedFile === 0 ? 0 : indexOfClosedFile - 1;
const nextFileToOpen = state.openFiles[nextIndexToOpen]; const nextFileToOpen = state.openFiles[nextIndexToOpen];
dispatch('setFileActive', nextFileToOpen); router.push(`/project${nextFileToOpen.url}`);
} else if (!state.openFiles.length) { } else if (!state.openFiles.length) {
router.push(`/project/${file.projectId}/tree/${file.branchId}/`); router.push(`/project/${file.projectId}/tree/${file.branchId}/`);
} }
......
...@@ -38,7 +38,7 @@ export const getTreeData = ( ...@@ -38,7 +38,7 @@ export const getTreeData = (
commit(types.SET_ROOT, data.path === '/'); 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}`]; const selectedTree = tree || state.trees[`${projectId}/${branch}`];
commit(types.SET_PARENT_TREE_URL, data.parent_tree_url); commit(types.SET_PARENT_TREE_URL, data.parent_tree_url);
...@@ -85,7 +85,7 @@ export const handleTreeEntryAction = ({ commit, dispatch }, row) => { ...@@ -85,7 +85,7 @@ export const handleTreeEntryAction = ({ commit, dispatch }, row) => {
commit(types.TOGGLE_LOADING, row); commit(types.TOGGLE_LOADING, row);
visitUrl(row.url); visitUrl(row.url);
} else if (row.type === 'blob' && (row.opened || row.changed)) { } else if (row.type === 'blob' && (row.opened || row.changed)) {
if (row.changed) { if (row.changed && !row.opened) {
commit(types.TOGGLE_FILE_OPEN, row); commit(types.TOGGLE_FILE_OPEN, row);
} }
...@@ -160,7 +160,7 @@ export const getLastCommitData = ({ state, commit, dispatch, getters }, tree = s ...@@ -160,7 +160,7 @@ export const getLastCommitData = ({ state, commit, dispatch, getters }, tree = s
export const updateDirectoryData = ( export const updateDirectoryData = (
{ commit, state }, { commit, state },
{ data, tree, projectId, branch }, { data, tree, projectId, branch, clearTree = true },
) => { ) => {
if (!tree) { if (!tree) {
const existingTree = state.trees[`${projectId}/${branch}`]; const existingTree = state.trees[`${projectId}/${branch}`];
...@@ -173,7 +173,6 @@ export const updateDirectoryData = ( ...@@ -173,7 +173,6 @@ export const updateDirectoryData = (
const level = selectedTree.level !== undefined ? selectedTree.level + 1 : 0; 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 parentTreeUrl = data.parent_tree_url ? `${data.parent_tree_url}${data.path}` : state.endpoints.rootUrl;
const createEntry = (entry, type) => createOrMergeEntry({ const createEntry = (entry, type) => createOrMergeEntry({
tree: selectedTree,
projectId: `${projectId}`, projectId: `${projectId}`,
branchId: branch, branchId: branch,
entry, entry,
...@@ -189,5 +188,11 @@ export const updateDirectoryData = ( ...@@ -189,5 +188,11 @@ export const updateDirectoryData = (
...data.blobs.map(b => createEntry(b, 'blob')), ...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 }); commit(types.SET_DIRECTORY_DATA, { tree: selectedTree, data: formattedData });
}; };
...@@ -155,8 +155,7 @@ export const createTemp = ({ ...@@ -155,8 +155,7 @@ export const createTemp = ({
}); });
}; };
export const createOrMergeEntry = ({ tree, export const createOrMergeEntry = ({ projectId,
projectId,
branchId, branchId,
entry, entry,
type, type,
...@@ -179,16 +178,6 @@ export const createOrMergeEntry = ({ tree, ...@@ -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({ return decorateData({
...entry, ...entry,
projectId, 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