Skip to content

Commit 719aed9

Browse files
πŸ›πŸŽ¨ Pass WEBSERVER_FOLDERS flag to frontend and use it (#6206)
Co-authored-by: matusdrobuliak66 <[email protected]> Co-authored-by: matusdrobuliak66 <[email protected]>
1 parent 3c05604 commit 719aed9

File tree

5 files changed

+33
-15
lines changed

5 files changed

+33
-15
lines changed

β€Žservices/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.jsβ€Ž

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
100100
initResources: function() {
101101
this._resourcesList = [];
102102
const promises = [
103-
this.__getActiveStudy(),
104-
osparc.store.Folders.getInstance().fetchFolders(null)
103+
this.__getActiveStudy()
105104
];
105+
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
106+
promises.push(osparc.store.Folders.getInstance().fetchFolders());
107+
}
106108
Promise.all(promises)
107109
.then(() => {
108110
this.getChildControl("resources-layout");
@@ -182,11 +184,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
182184
// Most probably is a product-stranger user (it can also be that the catalog is down)
183185
const nStudies = "_meta" in resp ? resp["_meta"]["total"] : 0;
184186
if (nStudies === 0) {
185-
Promise.all([
187+
const promises = [
186188
osparc.store.Store.getInstance().getTemplates(),
187189
osparc.service.Store.getServicesLatest(),
188-
osparc.store.Folders.getInstance().fetchFolders(),
189-
]).then(values => {
190+
];
191+
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
192+
promises.push(osparc.store.Folders.getInstance().fetchFolders());
193+
}
194+
Promise.all(promises).then(values => {
190195
const templates = values[0];
191196
const services = values[1];
192197
if (templates.length === 0 && Object.keys(services).length === 0) {
@@ -388,15 +393,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
388393
},
389394

390395
__applyCurrentFolderId: function(currentFolderId) {
391-
osparc.store.Folders.getInstance().fetchFolders(currentFolderId)
392-
.then(() => {
393-
this._resourcesContainer.setResourcesToList([]);
394-
this._resourcesList = [];
395-
this.invalidateStudies();
396-
397-
this.__reloadResources();
398-
})
399-
.catch(console.error);
396+
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
397+
osparc.store.Folders.getInstance().fetchFolders(currentFolderId)
398+
.then(() => {
399+
this._resourcesContainer.setResourcesToList([]);
400+
this._resourcesList = [];
401+
this.invalidateStudies();
402+
403+
this.__reloadResources();
404+
})
405+
.catch(console.error);
406+
}
400407
},
401408

402409
_folderUpdated: function() {

β€Žservices/static-webserver/client/source/class/osparc/store/Folders.jsβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ qx.Class.define("osparc.store.Folders", {
2929
foldersCached: null,
3030

3131
fetchFolders: function(folderId = null) {
32+
if (osparc.auth.Data.getInstance().isGuest()) {
33+
return new Promise(resolve => {
34+
resolve([]);
35+
});
36+
}
37+
3238
const params = {
3339
"url": {
3440
folderId

β€Žservices/static-webserver/client/source/class/osparc/utils/DisabledPlugins.jsβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ qx.Class.define("osparc.utils.DisabledPlugins", {
2929
VERSION_CONTROL: "WEBSERVER_VERSION_CONTROL",
3030
META_MODELING: "WEBSERVER_META_MODELING",
3131
CLUSTERS: "WEBSERVER_CLUSTERS",
32+
FOLDERS: "WEBSERVER_FOLDERS",
3233

3334
isFoldersEnabled: function() {
34-
return osparc.utils.Utils.isDevelopmentPlatform();
35+
return !this.__isPluginDisabled(this.FOLDERS);
3536
},
3637

3738
isExportDisabled: function() {

β€Žservices/web/server/src/simcore_service_webserver/application_settings.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def _get_disabled_public_plugins(self) -> list[str]:
317317
public_plugin_candidates: Final = {
318318
"WEBSERVER_CLUSTERS",
319319
"WEBSERVER_EXPORTER",
320+
"WEBSERVER_FOLDERS",
320321
"WEBSERVER_META_MODELING",
321322
"WEBSERVER_PAYMENTS",
322323
"WEBSERVER_SCICRUNCH",

β€Žservices/web/server/tests/unit/isolated/test_application_settings.pyβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ def test_settings_to_client_statics_plugins(
216216
monkeypatch.setenv("WEBSERVER_VERSION_CONTROL", "0")
217217
disable_plugins.add("WEBSERVER_VERSION_CONTROL")
218218

219+
monkeypatch.setenv("WEBSERVER_FOLDERS", "0")
220+
disable_plugins.add("WEBSERVER_FOLDERS")
221+
219222
settings = ApplicationSettings.create_from_envs()
220223
statics = settings.to_client_statics()
221224

0 commit comments

Comments
Β (0)