-
Notifications
You must be signed in to change notification settings - Fork 136
Description
After this issue 2472 is completed we can remove some additional calls for project and product templates on the project page and reuse already loaded data in the Redux Store.
Current Redux Store
{
projectState: {
...
projectTemlate: {}, // current project's projectTemplate
productTemplates: [], // current project's productTemplates
allProductTemplates: [], // all possbile productTemplates
},
templates: {
projectTemplates: [...] // all possible projectTemplates
projectCategories: [...] // all possible projectTypes
isLoading: false
}
}What we can do:
-
Currently, project page loads one project template assosiated with it to
projectState.projectTemplatemaking separate API call. As after previous issue is done we already have allprojectTemplatesin the store, we can find needed project template by its id. We have to make sure that templates are already loaded in the store at this point, and if not, then call action to load all templates.
Note: after this we shouldn't haveprojectState.projectTemplatein the store anymore. -
On the project page we load
projectState.allProductTemplateswith ALL product templates foradd phasefunctionality. Also, we load SOME product templates used in the project toprojectState.productTemplates. Instead we should get product templates fromprojectState.allProductTemplatesfor a project using ids.
Note: after this we shouldn't haveprojectState.productTemplatesin the store anymore. -
After previous two steps we still have
allProductTemplatesinprojectStatewhich is not a good place for it. AsprojectStatesuppose to keep some concrete project data, butallProductTemplatesdoesn’t depend on the concrete project. So it's better to move it to thetemplatessection of the store and rename toproductTemplates.
Note: after this we shouldn't haveprojectState.allProductTemplatesin store anymore, and havetemplate.productTemplatesinstead.
After these steps Redux Store should look like this:
{
projectState: {
...
// don't keep templates data anymore
},
templates: {
// stay as before
projectTemplates: [...] // == /v4/projects/metadata -> projectTemplates
projectCategories: [...] // == /v4/projects/metadata -> projectTypes
isLoading: false
// moved from projectState, before it was allProductTemplates
productTemplates: [...] // == /v4/projects/metadata -> productTemplates
}
}fyi @RishiRajSahu