@@ -11,10 +11,22 @@ const _ = require('lodash');
1111const config = require ( 'config' ) ;
1212
1313const projectTypes = {
14- app_dev : 'Full App' ,
15- generic : 'Work Project' ,
16- visual_prototype : 'Design & Prototype' ,
17- visual_design : 'Design' ,
14+ app_dev : {
15+ label : 'Full App' ,
16+ color : '#96d957'
17+ } ,
18+ generic : {
19+ label : 'Work Project' ,
20+ color : '#b47dd6'
21+ } ,
22+ visual_prototype : {
23+ label : 'Design & Prototype' ,
24+ color : '#67c5ef'
25+ } ,
26+ visual_design : {
27+ label : 'Design' ,
28+ color : '#67c5ef'
29+ }
1830} ;
1931const icons = {
2032 slack : {
@@ -39,14 +51,17 @@ module.exports = {
3951 projectInReview : ( data ) => {
4052 return {
4153 channel : `${ config . get ( 'SLACK_CHANNEL_MANAGERS' ) } ` ,
54+ color : projectTypes [ data . project . type ] . color ,
4255 pretext : 'A project is ready to be reviewed.' ,
4356 fallback : 'A project is ready to be reviewed.' ,
4457 title : _ . get ( data , 'project.name' , '' ) ,
4558 title_link : `https://connect.${ config . get ( 'AUTH_DOMAIN' ) } /projects/${ data . project . id } /` ,
46- text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , { length : 200 , separator : / , ? + ., / } ) ,
59+ text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , {
60+ length : 200 ,
61+ separator : / , ? + ., /
62+ } ) ,
4763 ts : ( new Date ( _ . get ( data , 'project.updatedAt' , null ) ) ) . getTime ( ) / 1000 ,
48- fields : [
49- {
64+ fields : [ {
5065 title : 'Ref Code' ,
5166 value : _ . get ( data , 'project.details.utm.code' , '' ) ,
5267 short : false ,
@@ -58,7 +73,7 @@ module.exports = {
5873 } ,
5974 {
6075 title : 'Project Type' ,
61- value : projectTypes [ data . project . type ] ,
76+ value : projectTypes [ data . project . type ] . label ,
6277 short : false ,
6378 } ,
6479 ] ,
@@ -67,58 +82,64 @@ module.exports = {
6782 projectUnclaimed : ( data ) => {
6883 return {
6984 icon_url : icons . slack . CoderBotIcon ,
85+ color : projectTypes [ data . project . type ] . color ,
7086 channel : `${ config . get ( 'SLACK_CHANNEL_COPILOTS' ) } ` ,
7187 pretext : 'A project has been reviewed and needs a copilot. Please check it out and claim it.' ,
7288 fallback : 'A project has been reviewed and needs a copilot. Please check it out and claim it.' ,
7389 title : _ . get ( data , 'project.name' , '' ) ,
7490 title_link : `https://connect.${ config . get ( 'AUTH_DOMAIN' ) } /projects/${ data . project . id } /` ,
75- text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , { length : 200 , separator : / , ? + ., / } ) ,
91+ text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , {
92+ length : 200 ,
93+ separator : / , ? + ., /
94+ } ) ,
7695 ts : ( new Date ( _ . get ( data , 'project.updatedAt' , null ) ) ) . getTime ( ) / 1000 ,
77- fields : [
78- {
79- title : 'Project Type' ,
80- value : projectTypes [ data . project . type ] ,
81- short : false ,
82- } ,
83- ]
96+ fields : [ {
97+ title : 'Project Type' ,
98+ value : projectTypes [ data . project . type ] . label ,
99+ short : false ,
100+ } , ]
84101 }
85102 } ,
86103 projectUnclaimedReposted : ( data ) => {
87104 return {
88105 icon_url : icons . slack . CoderErrorIcon ,
106+ color : projectTypes [ data . project . type ] . color ,
89107 channel : `${ config . get ( 'SLACK_CHANNEL_COPILOTS' ) } ` ,
90108 pretext : 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.' ,
91109 fallback : 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.' ,
92110 title : _ . get ( data , 'project.name' , '' ) ,
93111 title_link : `https://connect.${ config . get ( 'AUTH_DOMAIN' ) } /projects/${ data . project . id } /` ,
94- text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , { length : 200 , separator : / , ? + ., / } ) ,
112+ text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , {
113+ length : 200 ,
114+ separator : / , ? + ., /
115+ } ) ,
95116 ts : ( new Date ( _ . get ( data , 'project.updatedAt' , null ) ) ) . getTime ( ) / 1000 ,
96- fields : [
97- {
98- title : 'Project Type' ,
99- value : projectTypes [ data . project . type ] ,
100- short : false ,
101- } ,
102- ]
117+ fields : [ {
118+ title : 'Project Type' ,
119+ value : projectTypes [ data . project . type ] . label ,
120+ short : false ,
121+ } , ]
103122 }
104123 } ,
105124 projectClaimed : ( data ) => {
106125 return {
107126 icon_url : icons . slack . CoderGrinningIcon ,
127+ color : projectTypes [ data . project . type ] . color ,
108128 channel : `${ config . get ( 'SLACK_CHANNEL_COPILOTS' ) } ` ,
109129 pretext : `${ data . firstName } ${ data . lastName } has claimed a project. Welcome to the team!` ,
110130 fallback : `${ data . firstName } ${ data . lastName } has claimed a project. Welcome to the team!` ,
111131 title : _ . get ( data , 'project.name' , '' ) ,
112132 title_link : `https://connect.${ config . get ( 'AUTH_DOMAIN' ) } /projects/${ data . project . id } /` ,
113- text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , { length : 200 , separator : / , ? + ., / } ) ,
133+ text : _ . truncate ( _ . get ( data , 'project.description' , '' ) , {
134+ length : 200 ,
135+ separator : / , ? + ., /
136+ } ) ,
114137 ts : ( new Date ( _ . get ( data , 'project.updatedAt' , null ) ) ) . getTime ( ) / 1000 ,
115- fields : [
116- {
117- title : 'Project Type' ,
118- value : projectTypes [ data . project . type ] ,
119- short : false ,
120- } ,
121- ]
138+ fields : [ {
139+ title : 'Project Type' ,
140+ value : projectTypes [ data . project . type ] . label ,
141+ short : false ,
142+ } , ]
122143 }
123144 } ,
124145 } ,
@@ -177,19 +198,52 @@ module.exports = {
177198 } ,
178199 } ,
179200 project : {
180- created : { notificationType : 'Project.Created' , subject : 'Created' } ,
181- submittedForReview : { notificationType : 'Project.SubmittedForReview' , subject : 'Submitted for review' } ,
182- availableForReview : { notificationType : 'Project.AvailableForReview' , subject : 'Available for review' } ,
183- reviewed : { notificationType : 'Project.Reviewed' , subject : 'Reviewed' } ,
184- availableToClaim : { notificationType : 'Project.AvailableToClaim' , subject : 'Reviewed - Available to claim' } ,
201+ created : {
202+ notificationType : 'Project.Created' ,
203+ subject : 'Created'
204+ } ,
205+ submittedForReview : {
206+ notificationType : 'Project.SubmittedForReview' ,
207+ subject : 'Submitted for review'
208+ } ,
209+ availableForReview : {
210+ notificationType : 'Project.AvailableForReview' ,
211+ subject : 'Available for review'
212+ } ,
213+ reviewed : {
214+ notificationType : 'Project.Reviewed' ,
215+ subject : 'Reviewed'
216+ } ,
217+ availableToClaim : {
218+ notificationType : 'Project.AvailableToClaim' ,
219+ subject : 'Reviewed - Available to claim'
220+ } ,
185221 } ,
186222 teamMember : {
187- added : { notificationType : 'Project.Member.Added' , subject : 'Member added' } ,
188- managerJoined : { notificationType : 'Project.Member.ManagerJoined' , subject : 'Manager joined' } ,
189- copilotJoined : { notificationType : 'Project.Member.CopilotJoined' , subject : 'Copilot joined' } ,
190- removed : { notificationType : 'Project.Member.Removed' , subject : 'Member removed' } ,
191- left : { notificationType : 'Project.Member.Left' , subject : 'Member left' } ,
192- ownerChanged : { notificationType : 'Project.Member.OwnerChanged' , subject : 'Ownership changed' } ,
223+ added : {
224+ notificationType : 'Project.Member.Added' ,
225+ subject : 'Member added'
226+ } ,
227+ managerJoined : {
228+ notificationType : 'Project.Member.ManagerJoined' ,
229+ subject : 'Manager joined'
230+ } ,
231+ copilotJoined : {
232+ notificationType : 'Project.Member.CopilotJoined' ,
233+ subject : 'Copilot joined'
234+ } ,
235+ removed : {
236+ notificationType : 'Project.Member.Removed' ,
237+ subject : 'Member removed'
238+ } ,
239+ left : {
240+ notificationType : 'Project.Member.Left' ,
241+ subject : 'Member left'
242+ } ,
243+ ownerChanged : {
244+ notificationType : 'Project.Member.OwnerChanged' ,
245+ subject : 'Ownership changed'
246+ } ,
193247 } ,
194248 } ,
195249 projectStatuses : {
0 commit comments