Skip to content

Commit 20693ef

Browse files
author
vikasrohit
authored
Merge pull request #1239 from appirio-tech/feature/back-forward-button-project-wizard
Feature/back forward button project wizard
2 parents 9fadaee + 39d7d71 commit 20693ef

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ compile:
1919

2020
deployment:
2121
development:
22-
branch: dev
22+
branch: [dev, 'feature/back-forward-button-project-wizard']
2323
owner: appirio-tech
2424
commands:
2525
- ./deploy.sh DEV

src/config/projectWizard/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,6 @@ export function findProductsOfCategory(category, fetchHidden = true) {
221221
}
222222

223223
export function findProductCategory(product) {
224-
if (product === 'generic_dev') {
225-
return 'Development'
226-
}
227-
if (product === 'generic_design') {
228-
return 'Design'
229-
}
230224
for(const pType in products) {
231225
for(const prd in products[pType].subtypes) {
232226
const subType = products[pType].subtypes[prd]

src/projects/create/components/ProjectWizard.jsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,37 @@ class ProjectWizard extends Component {
9797
}
9898

9999
componentWillReceiveProps(nextProps) {
100-
const { onStepChange } = nextProps
100+
const { onStepChange, params } = nextProps
101101
const type = _.get(nextProps.project, 'type', null)
102102
const product = _.get(nextProps.project, 'details.products[0]', null)
103-
const wizardStep = type && product ? WZ_STEP_FILL_PROJ_DETAILS : null
104-
if (wizardStep) {
103+
// redirect user to project details form, if we already have category and product available
104+
let wizardStep = type && product ? WZ_STEP_FILL_PROJ_DETAILS : null
105+
const updateQuery = {}
106+
if (params && params.product) { // if there exists product path param
107+
// first try the path param to be a project category
108+
let projectType = findCategory(params.product)
109+
if (projectType) {// if its a category
110+
updateQuery['type'] = { $set : projectType.id }
111+
wizardStep = WZ_STEP_SELECT_PROD_TYPE
112+
} else {
113+
// if it is not a category, it should be a product and we should be able to find a category for it
114+
projectType = findProductCategory(params.product)
115+
if (projectType) {// we can have `incomplete` as params.product
116+
updateQuery['type'] = { $set : projectType.id }
117+
updateQuery['details'] = { products : { $set: [params.product] } }
118+
wizardStep = WZ_STEP_FILL_PROJ_DETAILS
119+
}
120+
}
121+
} else { // if there is not product path param, it should be first step of the wizard
122+
updateQuery['type'] = { $set : null }
123+
updateQuery['details'] = { products : { $set: [] } }
124+
wizardStep = WZ_STEP_SELECT_PROJ_TYPE
125+
}
126+
// if wizard setp deduced above and stored in state are not the same, update the state
127+
if (wizardStep && this.state.wizardStep !== wizardStep) {
105128
this.setState({
129+
project: update(this.state.project, updateQuery),
130+
dirtyProject: update(this.state.dirtyProject, updateQuery),
106131
wizardStep
107132
}, () => {
108133
typeof onStepChange === 'function' && onStepChange(this.state.wizardStep)

0 commit comments

Comments
 (0)