Skip to content

Commit

Permalink
πŸ›πŸŽ¨ Pass WEBSERVER_FOLDERS flag to frontend and use it (#6206)
Browse files Browse the repository at this point in the history
Co-authored-by: matusdrobuliak66 <[email protected]>
Co-authored-by: matusdrobuliak66 <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2024
1 parent 3c05604 commit 719aed9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
initResources: function() {
this._resourcesList = [];
const promises = [
this.__getActiveStudy(),
osparc.store.Folders.getInstance().fetchFolders(null)
this.__getActiveStudy()
];
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
promises.push(osparc.store.Folders.getInstance().fetchFolders());
}
Promise.all(promises)
.then(() => {
this.getChildControl("resources-layout");
Expand Down Expand Up @@ -182,11 +184,14 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
// Most probably is a product-stranger user (it can also be that the catalog is down)
const nStudies = "_meta" in resp ? resp["_meta"]["total"] : 0;
if (nStudies === 0) {
Promise.all([
const promises = [
osparc.store.Store.getInstance().getTemplates(),
osparc.service.Store.getServicesLatest(),
osparc.store.Folders.getInstance().fetchFolders(),
]).then(values => {
];
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
promises.push(osparc.store.Folders.getInstance().fetchFolders());
}
Promise.all(promises).then(values => {
const templates = values[0];
const services = values[1];
if (templates.length === 0 && Object.keys(services).length === 0) {
Expand Down Expand Up @@ -388,15 +393,17 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
},

__applyCurrentFolderId: function(currentFolderId) {
osparc.store.Folders.getInstance().fetchFolders(currentFolderId)
.then(() => {
this._resourcesContainer.setResourcesToList([]);
this._resourcesList = [];
this.invalidateStudies();

this.__reloadResources();
})
.catch(console.error);
if (osparc.utils.DisabledPlugins.isFoldersEnabled()) {
osparc.store.Folders.getInstance().fetchFolders(currentFolderId)
.then(() => {
this._resourcesContainer.setResourcesToList([]);
this._resourcesList = [];
this.invalidateStudies();

this.__reloadResources();
})
.catch(console.error);
}
},

_folderUpdated: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ qx.Class.define("osparc.store.Folders", {
foldersCached: null,

fetchFolders: function(folderId = null) {
if (osparc.auth.Data.getInstance().isGuest()) {
return new Promise(resolve => {
resolve([]);
});
}

const params = {
"url": {
folderId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ qx.Class.define("osparc.utils.DisabledPlugins", {
VERSION_CONTROL: "WEBSERVER_VERSION_CONTROL",
META_MODELING: "WEBSERVER_META_MODELING",
CLUSTERS: "WEBSERVER_CLUSTERS",
FOLDERS: "WEBSERVER_FOLDERS",

isFoldersEnabled: function() {
return osparc.utils.Utils.isDevelopmentPlatform();
return !this.__isPluginDisabled(this.FOLDERS);
},

isExportDisabled: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def _get_disabled_public_plugins(self) -> list[str]:
public_plugin_candidates: Final = {
"WEBSERVER_CLUSTERS",
"WEBSERVER_EXPORTER",
"WEBSERVER_FOLDERS",
"WEBSERVER_META_MODELING",
"WEBSERVER_PAYMENTS",
"WEBSERVER_SCICRUNCH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ def test_settings_to_client_statics_plugins(
monkeypatch.setenv("WEBSERVER_VERSION_CONTROL", "0")
disable_plugins.add("WEBSERVER_VERSION_CONTROL")

monkeypatch.setenv("WEBSERVER_FOLDERS", "0")
disable_plugins.add("WEBSERVER_FOLDERS")

settings = ApplicationSettings.create_from_envs()
statics = settings.to_client_statics()

Expand Down

0 comments on commit 719aed9

Please sign in to comment.