Skip to content

Commit 312da78

Browse files
committed
feat: log project template info during project creating
Also, log if we are creating a project from scratch or it has been loaded from local storage. All this information could be very useful during debugging or issue reporting.
1 parent 261a723 commit 312da78

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/projects/create/components/ProjectWizard.jsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class ProjectWizard extends Component {
8383
if (projectTemplate) {
8484
// load project details page directly
8585
if (projectTemplate.key === incompleteProjectTemplate.key) {
86+
console.info(`Creating project (restored from local storage) using Project Template (id: "${incompleteProjectTemplate.id}", key: "${incompleteProjectTemplate.key}", alias: "${incompleteProjectTemplate.aliases[0]}").`)
8687
wizardStep = WZ_STEP_FILL_PROJ_DETAILS
8788
updateQuery = {$merge : incompleteProject}
8889
} else {
@@ -127,12 +128,15 @@ class ProjectWizard extends Component {
127128
const templateId = _.get(updateQuery, 'templateId.$set')
128129
const projectTemplate = _.find(projectTemplates, { id: templateId })
129130
const queryParams = _.omit(qs.parse(window.location.search), 'refCode')
130-
// if we already know project template, and there are some query params,
131-
// then pre-populate project data using `queryParamSelectCondition` from template
132-
if (projectTemplate && projectTemplate.scope && !_.isEmpty(queryParams)) {
133-
const prefillProjectQuery = buildProjectUpdateQueryByQueryParamSelectCondition(projectTemplate.scope, queryParams)
134-
projectState = update(projectState, prefillProjectQuery)
135-
dirtyProjectState = update(dirtyProjectState, prefillProjectQuery)
131+
if (projectTemplate && projectTemplate.scope) {
132+
console.info(`Creating project (from scratch) using Project Template (id: "${projectTemplate.id}", key: "${projectTemplate.key}", alias: "${projectTemplate.aliases[0]}").`)
133+
// if we already know project template, and there are some query params,
134+
// then pre-populate project data using `queryParamSelectCondition` from template
135+
if (!_.isEmpty(queryParams)) {
136+
const prefillProjectQuery = buildProjectUpdateQueryByQueryParamSelectCondition(projectTemplate.scope, queryParams)
137+
projectState = update(projectState, prefillProjectQuery)
138+
dirtyProjectState = update(dirtyProjectState, prefillProjectQuery)
139+
}
136140
}
137141

138142
this.setState({
@@ -229,10 +233,15 @@ class ProjectWizard extends Component {
229233
* It also moves the wizard to the project details step if there exists an incomplete project.
230234
*/
231235
loadIncompleteProject() {
232-
const { onStepChange, onProjectUpdate } = this.props
236+
const { onStepChange, onProjectUpdate, projectTemplates } = this.props
233237
const incompleteProjectStr = window.localStorage.getItem(LS_INCOMPLETE_PROJECT)
234238
if(incompleteProjectStr) {
235239
const incompleteProject = JSON.parse(incompleteProjectStr)
240+
const templateId = _.get(incompleteProject, 'templateId')
241+
const projectTemplate = _.find(projectTemplates, { id: templateId })
242+
if (projectTemplate) {
243+
console.info(`Creating project (confirmed: restored from local storage) using Project Template (id: "${projectTemplate.id}", key: "${projectTemplate.key}", alias: "${projectTemplate.aliases[0]}").`)
244+
}
236245
this.setState({
237246
project: update(this.state.project, { $merge : incompleteProject }),
238247
dirtyProject: update(this.state.dirtyProject, { $merge : incompleteProject }),
@@ -252,7 +261,7 @@ class ProjectWizard extends Component {
252261
* Removed incomplete project from the local storage and resets the state. Also, moves wizard to the first step.
253262
*/
254263
removeIncompleteProject() {
255-
const { onStepChange } = this.props
264+
const { onStepChange, projectTemplates } = this.props
256265
// remove incomplete project from local storage
257266
window.localStorage.removeItem(LS_INCOMPLETE_PROJECT)
258267
window.localStorage.removeItem(LS_INCOMPLETE_WIZARD)
@@ -264,6 +273,10 @@ class ProjectWizard extends Component {
264273
if (projectTemplateId) {
265274
project = { type: projectType, templateId: projectTemplateId, details: {} }
266275
wizardStep = WZ_STEP_FILL_PROJ_DETAILS
276+
const projectTemplate = _.find(projectTemplates, { id: projectTemplateId })
277+
if (projectTemplate) {
278+
console.info(`Creating project (confirmed: from scratch) using Project Template (id: "${projectTemplate.id}", key: "${projectTemplate.key}", alias: "${projectTemplate.aliases[0]}").`)
279+
}
267280
}
268281
const refCode = this.getRefCodeFromURL()
269282
if (refCode) {

0 commit comments

Comments
 (0)