BigW Consortium Gitlab

Commit 9e74d936 by Filipa Lacerda Committed by Grzegorz Bizon

Adds folder_path to frontend

parent 54ede0b8
...@@ -111,11 +111,11 @@ export default { ...@@ -111,11 +111,11 @@ export default {
}, },
methods: { methods: {
toggleFolder(folder, folderUrl) { toggleFolder(folder) {
this.store.toggleFolder(folder); this.store.toggleFolder(folder);
if (!folder.isOpen) { if (!folder.isOpen) {
this.fetchChildEnvironments(folder, folderUrl, true); this.fetchChildEnvironments(folder, true);
} }
}, },
...@@ -143,10 +143,10 @@ export default { ...@@ -143,10 +143,10 @@ export default {
.catch(this.errorCallback); .catch(this.errorCallback);
}, },
fetchChildEnvironments(folder, folderUrl, showLoader = false) { fetchChildEnvironments(folder, showLoader = false) {
this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', showLoader); this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', showLoader);
this.service.getFolderContent(folderUrl) this.service.getFolderContent(folder.folder_path)
.then(resp => resp.json()) .then(resp => resp.json())
.then(response => this.store.setfolderContent(folder, response.environments)) .then(response => this.store.setfolderContent(folder, response.environments))
.then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false)) .then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false))
...@@ -174,10 +174,7 @@ export default { ...@@ -174,10 +174,7 @@ export default {
const openFolders = this.store.getOpenFolders(); const openFolders = this.store.getOpenFolders();
if (openFolders.length) { if (openFolders.length) {
openFolders.forEach((folder) => { openFolders.forEach((folder) => {
// TODO - Move this to the backend return this.fetchChildEnvironments(folder);
const folderUrl = `${window.location.pathname}/folders/${folder.folderName}`;
return this.fetchChildEnvironments(folder, folderUrl);
}); });
} }
}, },
......
...@@ -410,20 +410,11 @@ export default { ...@@ -410,20 +410,11 @@ export default {
this.hasStopAction || this.hasStopAction ||
this.canRetry; this.canRetry;
}, },
/**
* Constructs folder URL based on the current location and the folder id.
*
* @return {String}
*/
folderUrl() {
return `${window.location.pathname}/folders/${this.model.folderName}`;
},
}, },
methods: { methods: {
onClickFolder() { onClickFolder() {
eventHub.$emit('toggleFolder', this.model, this.folderUrl); eventHub.$emit('toggleFolder', this.model);
}, },
}, },
}; };
......
...@@ -26,5 +26,9 @@ class EnvironmentEntity < Grape::Entity ...@@ -26,5 +26,9 @@ class EnvironmentEntity < Grape::Entity
terminal_project_environment_path(environment.project, environment) terminal_project_environment_path(environment.project, environment)
end end
expose :folder_path do |environment|
# folder_project_environments_path(environment.project, environment)
end
expose :created_at, :updated_at expose :created_at, :updated_at
end end
---
title: Adds folder_path in API response
merge_request:
author:
...@@ -16,6 +16,10 @@ describe EnvironmentEntity do ...@@ -16,6 +16,10 @@ describe EnvironmentEntity do
expect(subject).to include(:id, :name, :state, :environment_path) expect(subject).to include(:id, :name, :state, :environment_path)
end end
it 'exposes folder path' do
expect(subject).to include(:folder_path)
end
context 'metrics disabled' do context 'metrics disabled' do
before do before do
allow(environment).to receive(:has_metrics?).and_return(false) allow(environment).to receive(:has_metrics?).and_return(false)
......
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