Commit 6f71ed60 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'ide-folder-button-path' into 'master'

Fixes the web IDE link in tree list opening the wrong URL

Closes #44477

See merge request gitlab-org/gitlab-ce!17900
parents 294a9e98 724cca8d
...@@ -43,6 +43,7 @@ export default { ...@@ -43,6 +43,7 @@ export default {
'file-open': this.isBlob && this.file.opened, 'file-open': this.isBlob && this.file.opened,
'file-active': this.isBlob && this.file.active, 'file-active': this.isBlob && this.file.active,
folder: this.isTree, folder: this.isTree,
'is-open': this.file.opened,
}; };
}, },
}, },
......
...@@ -54,41 +54,61 @@ const router = new VueRouter({ ...@@ -54,41 +54,61 @@ const router = new VueRouter({
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.params.namespace && to.params.project) { if (to.params.namespace && to.params.project) {
store.dispatch('getProjectData', { store
namespace: to.params.namespace, .dispatch('getProjectData', {
projectId: to.params.project, namespace: to.params.namespace,
}) projectId: to.params.project,
.then(() => { })
const fullProjectId = `${to.params.namespace}/${to.params.project}`; .then(() => {
const fullProjectId = `${to.params.namespace}/${to.params.project}`;
if (to.params.branch) { if (to.params.branch) {
store.dispatch('getBranchData', { store.dispatch('getBranchData', {
projectId: fullProjectId, projectId: fullProjectId,
branchId: to.params.branch, branchId: to.params.branch,
}); });
store.dispatch('getFiles', { store
projectId: fullProjectId, .dispatch('getFiles', {
branchId: to.params.branch, projectId: fullProjectId,
}) branchId: to.params.branch,
.then(() => { })
if (to.params[0]) { .then(() => {
const treeEntry = store.state.entries[to.params[0]]; if (to.params[0]) {
if (treeEntry) { const path =
store.dispatch('handleTreeEntryAction', treeEntry); to.params[0].slice(-1) === '/'
} ? to.params[0].slice(0, -1)
} : to.params[0];
}) const treeEntry = store.state.entries[path];
.catch((e) => { if (treeEntry) {
flash('Error while loading the branch files. Please try again.', 'alert', document, null, false, true); store.dispatch('handleTreeEntryAction', treeEntry);
throw e; }
}); }
} })
}) .catch(e => {
.catch((e) => { flash(
flash('Error while loading the project data. Please try again.', 'alert', document, null, false, true); 'Error while loading the branch files. Please try again.',
throw e; 'alert',
}); document,
null,
false,
true,
);
throw e;
});
}
})
.catch(e => {
flash(
'Error while loading the project data. Please try again.',
'alert',
document,
null,
false,
true,
);
throw e;
});
} }
next(); next();
......
import { import { decorateData, sortTree } from '../utils';
decorateData,
sortTree,
} from '../utils';
self.addEventListener('message', (e) => { self.addEventListener('message', e => {
const { data, projectId, branchId, tempFile = false, content = '', base64 = false } = e.data; const {
data,
projectId,
branchId,
tempFile = false,
content = '',
base64 = false,
} = e.data;
const treeList = []; const treeList = [];
let file; let file;
...@@ -15,7 +19,9 @@ self.addEventListener('message', (e) => { ...@@ -15,7 +19,9 @@ self.addEventListener('message', (e) => {
if (pathSplit.length > 0) { if (pathSplit.length > 0) {
pathSplit.reduce((pathAcc, folderName) => { pathSplit.reduce((pathAcc, folderName) => {
const parentFolder = acc[pathAcc[pathAcc.length - 1]]; const parentFolder = acc[pathAcc[pathAcc.length - 1]];
const folderPath = `${(parentFolder ? `${parentFolder.path}/` : '')}${folderName}`; const folderPath = `${
parentFolder ? `${parentFolder.path}/` : ''
}${folderName}`;
const foundEntry = acc[folderPath]; const foundEntry = acc[folderPath];
if (!foundEntry) { if (!foundEntry) {
...@@ -25,9 +31,11 @@ self.addEventListener('message', (e) => { ...@@ -25,9 +31,11 @@ self.addEventListener('message', (e) => {
id: folderPath, id: folderPath,
name: folderName, name: folderName,
path: folderPath, path: folderPath,
url: `/${projectId}/tree/${branchId}/${folderPath}`, url: `/${projectId}/tree/${branchId}/${folderPath}/`,
type: 'tree', type: 'tree',
parentTreeUrl: parentFolder ? parentFolder.url : `/${projectId}/tree/${branchId}/`, parentTreeUrl: parentFolder
? parentFolder.url
: `/${projectId}/tree/${branchId}/`,
tempFile, tempFile,
changed: tempFile, changed: tempFile,
opened: tempFile, opened: tempFile,
...@@ -62,7 +70,9 @@ self.addEventListener('message', (e) => { ...@@ -62,7 +70,9 @@ self.addEventListener('message', (e) => {
path, path,
url: `/${projectId}/blob/${branchId}/${path}`, url: `/${projectId}/blob/${branchId}/${path}`,
type: 'blob', type: 'blob',
parentTreeUrl: fileFolder ? fileFolder.url : `/${projectId}/blob/${branchId}`, parentTreeUrl: fileFolder
? fileFolder.url
: `/${projectId}/blob/${branchId}`,
tempFile, tempFile,
changed: tempFile, changed: tempFile,
content, content,
......
...@@ -62,8 +62,7 @@ ...@@ -62,8 +62,7 @@
return `${gon.sprite_file_icons}#${iconName}`; return `${gon.sprite_file_icons}#${iconName}`;
}, },
folderIconName() { folderIconName() {
// We don't have a open folder icon yet return this.opened ? 'folder-open' : 'folder';
return this.opened ? 'folder' : 'folder';
}, },
iconSizeClass() { iconSizeClass() {
return this.size ? `s${this.size}` : ''; return this.size ? `s${this.size}` : '';
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
= render 'projects/find_file_link' = render 'projects/find_file_link'
= succeed " " do = succeed " " do
= link_to ide_edit_path(@project, @id), class: 'btn btn-default' do = link_to ide_edit_path(@project, @id, ""), class: 'btn btn-default' do
= _('Web IDE') = _('Web IDE')
= render 'projects/buttons/download', project: @project, ref: @ref = render 'projects/buttons/download', project: @project, ref: @ref
---
title: Fixed IDE button opening the wrong URL in tree list
merge_request:
author:
type: fixed
...@@ -25,4 +25,18 @@ feature 'Projects tree' do ...@@ -25,4 +25,18 @@ feature 'Projects tree' do
expect(page).to have_selector('.label-lfs', text: 'LFS') expect(page).to have_selector('.label-lfs', text: 'LFS')
end end
end end
context 'web IDE', :js do
before do
visit project_tree_path(project, File.join('master', 'bar'))
click_link 'Web IDE'
find('.ide-file-list')
end
it 'opens folder in IDE' do
expect(page).to have_selector('.is-open', text: 'bar')
end
end
end end
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