You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2021/10/05 19:47:18 UTC

[airavata-django-portal] 07/24: AIRAVATA-3477 Fixes to setting initial project and GRP id

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 99eaba7cafeb1850c8eb8e88f8b8440d60d7478c
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Sep 1 13:31:50 2021 -0400

    AIRAVATA-3477 Fixes to setting initial project and GRP id
    
    Vuex getters get cached so it works better to get the values directly from state.
---
 .../js/web-components/vuestore.js                  | 29 ++++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/vuestore.js b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/vuestore.js
index fd5de65..a2128f5 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/vuestore.js
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/vuestore.js
@@ -8,6 +8,7 @@ const PROMISES = {
   workspacePreferences: null,
 };
 export default new Vuex.Store({
+  strict: process.env.NODE_ENV !== "production",
   state: {
     experiment: null,
     projects: null,
@@ -113,27 +114,37 @@ export default new Vuex.Store({
       commit("setExperiment", { experiment });
       await dispatch("loadExperimentData");
     },
-    async loadExperimentData({ commit, dispatch, getters }) {
+    async loadExperimentData({ commit, dispatch, getters, state }) {
       await Promise.all([
         dispatch("loadProjects"),
         dispatch("loadWorkspacePreferences"),
         dispatch("loadGroupResourceProfiles"),
       ]);
 
-      if (!getters.experiment.projectId) {
-        commit("updateProjectId", { projectId: getters.defaultProjectId });
+      if (!state.experiment.projectId) {
+        commit("updateProjectId", {
+          projectId: state.workspacePreferences.most_recent_project_id,
+        });
       }
       // If there is no groupResourceProfileId set on the experiment, or there
       // is one set but it is no longer in the list of accessible
       // groupResourceProfiles, set to the default one
-      if (!getters.groupResourceProfileId || !getters.groupResourceProfile) {
+      let groupResourceProfileId =
+        state.experiment.userConfigurationData.groupResourceProfileId;
+      if (
+        !groupResourceProfileId ||
+        !getters.findGroupResourceProfile(groupResourceProfileId)
+      ) {
         commit("updateGroupResourceProfileId", {
-          groupResourceProfileId: getters.defaultGroupResourceProfileId,
+          groupResourceProfileId:
+            state.workspacePreferences.most_recent_group_resource_profile_id,
         });
       }
+      groupResourceProfileId =
+        state.experiment.userConfigurationData.groupResourceProfileId;
       // If experiment has a group resource profile and user has access to it,
       // load additional necessary data and re-apply group resource profile
-      if (getters.groupResourceProfile) {
+      if (getters.findGroupResourceProfile(groupResourceProfileId)) {
         await dispatch("loadApplicationDeployments");
         await dispatch("loadAppDeploymentQueues");
         await dispatch("applyGroupResourceProfile");
@@ -410,12 +421,14 @@ export default new Vuex.Store({
       state.experiment
         ? state.experiment.userConfigurationData.groupResourceProfileId
         : null,
-    groupResourceProfile: (state, getters) =>
+    findGroupResourceProfile: (state) => (groupResourceProfileId) =>
       state.groupResourceProfiles
         ? state.groupResourceProfiles.find(
-            (g) => g.groupResourceProfileId === getters.groupResourceProfileId
+            (g) => g.groupResourceProfileId === groupResourceProfileId
           )
         : null,
+    groupResourceProfile: (state, getters) =>
+      getters.findGroupResourceProfile(getters.groupResourceProfileId),
     resourceHostId: (state) =>
       state.experiment &&
       state.experiment.userConfigurationData &&