Skip to content

Commit c1e6c92

Browse files
author
Vikas Agarwal
committed
making project compatible with current connect app so that the service can be deployed without front end changes
1 parent e957be5 commit c1e6c92

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/events/projects/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ const indexProject = Promise.coroutine(function* (logger, msg) { // eslint-disab
3434
const detail = _.find(memberDetails, md => md.userId === single.userId);
3535
return _.merge(single, _.pick(detail, 'handle', 'firstName', 'lastName', 'email'));
3636
});
37-
// update project member record with details
38-
data.phases = data.phases.map(phase => _.omit(phase, ['deletedAt', 'deletedBy']));
37+
if (data.phases) {
38+
// removes non required fields from phase objects
39+
data.phases = data.phases.map(phase => _.omit(phase, ['deletedAt', 'deletedBy']));
40+
}
3941
// add the record to the index
4042
const result = yield eClient.index({
4143
index: ES_PROJECT_INDEX,

src/routes/admin/project-index-create.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ module.exports = [
5757
if (!project) {
5858
return Promise.resolve(null);
5959
}
60-
// removs the delete audit fields from the index data
61-
project.phases = project.phases.map(phase => _.omit(phase, ['deletedAt', 'deletedBy']));
60+
if (project.phases) {
61+
// removs the delete audit fields from the index data
62+
project.phases = project.phases.map(phase => _.omit(phase, ['deletedAt', 'deletedBy']));
63+
}
6264
return models.ProjectMember.getActiveProjectMembers(project.id)
6365
.then((currentProjectMembers) => {
6466
// check context for project members

src/routes/projects/create.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ function createProjectAndPhases(req, project, projectTemplate, productTemplates)
8181
}).then((newProject) => {
8282
result.newProject = newProject;
8383

84+
// backward compatibility for releasing the service before releasing the front end
8485
if (!projectTemplate) {
8586
return Promise.resolve(result);
8687
}
@@ -132,6 +133,9 @@ function createProjectAndPhases(req, project, projectTemplate, productTemplates)
132133
* @returns {Promise} the promise that resolves to an object containing validated project and product templates
133134
*/
134135
function validateAndFetchTemplates(templateId) {
136+
// backward compatibility for releasing the service before releasing the front end
137+
// we ignore missing template id field and create a project without phase/products
138+
if (!templateId) return Promise.resolve(null);
135139
return models.ProjectTemplate.findById(templateId, { raw: true })
136140
.then((existingProjectTemplate) => {
137141
if (!existingProjectTemplate) {

0 commit comments

Comments
 (0)