@@ -5,56 +5,34 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
55
66Copyright (c) 2025 ClearCode Inc.
77*/
8- export class Config {
9- Culture ;
10- GroupLabel = "Typical Reply" ;
11- TabMailInsertAfterMso = "GroupMailRespond" ;
12- TabReadInsertAfterMso = "GroupRespond" ;
13- ContextMenuInsertAfterMso = "Forward" ;
14- ButtonConfigList ;
158
16- constructor ( {
17- Culture,
18- GroupLabel,
19- TabMailInsertAfterMso,
20- TabReadInsertAfterMso,
21- ContextMenuInsertAfterMso,
22- ButtonConfigList,
23- } ) {
24- this . Culture = Culture ;
25- this . GroupLabel = GroupLabel ;
26- this . TabMailInsertAfterMso = TabMailInsertAfterMso ;
27- this . TabReadInsertAfterMso = TabReadInsertAfterMso ;
28- this . ContextMenuInsertAfterMso = ContextMenuInsertAfterMso ;
29- this . ButtonConfigList = ButtonConfigList ;
30- }
31- }
9+ export class ButtonConfigEnums {
10+ static ForwardType = {
11+ Unknown : 0 ,
12+ Attachment : 1 ,
13+ Inline : 2 ,
14+ } ;
3215
33- const ForwardType = {
34- Unknown : 0 ,
35- Attachment : 1 ,
36- Inline : 2 ,
37- } ;
16+ static RecipientsType = {
17+ Unknown : 0 ,
18+ Blank : 1 ,
19+ Sender : 2 ,
20+ All : 3 ,
21+ SpecifiedByUser : 4 ,
22+ } ;
3823
39- const RecipientsType = {
40- Unknown : 0 ,
41- Blank : 1 ,
42- Sender : 2 ,
43- All : 3 ,
44- SpecifiedByUser : 4 ,
45- } ;
24+ static AllowedDomainsType = {
25+ Unknown : 0 ,
26+ All : 1 ,
27+ SpecifiedByUser : 2 ,
28+ } ;
4629
47- const AllowedDomainsType = {
48- Unknown : 0 ,
49- All : 1 ,
50- SpecifiedByUser : 2 ,
51- } ;
52-
53- const ButtonSize = {
54- Unknown : 0 ,
55- Normal : 1 ,
56- Large : 2 ,
57- } ;
30+ static ButtonSize = {
31+ Unknown : 0 ,
32+ Normal : 1 ,
33+ Large : 2 ,
34+ } ;
35+ }
5836
5937export class ButtonConfig {
6038 Id ;
@@ -70,7 +48,7 @@ export class ButtonConfig {
7048 AllowedDomainsType ;
7149 ForwardType ;
7250 Size ;
73- Image = "logo.png" ;
51+ Image ;
7452
7553 constructor ( {
7654 Id,
@@ -81,41 +59,84 @@ export class ButtonConfig {
8159 Recipients,
8260 QuoteType,
8361 AllowedDomains,
84- AllowedDomainsType,
8562 ForwardType,
8663 Size,
8764 Image,
8865 } ) {
89- this . Id = Id ;
90- this . Label = Label ;
91- this . SubjectPrefix = SubjectPrefix ;
92- this . Subject = Subject ;
93- this . Body = Body ;
94- this . Recipients = Recipients ;
95- this . QuoteType = QuoteType ;
96- this . AllowedDomains = AllowedDomains ;
97- this . ForwardType = ForwardType ;
98- this . Size = Size ;
99- this . Image = Image ;
66+ this . Id = Id ?? "" ;
67+ this . Label = Label ?? "" ;
68+ this . SubjectPrefix = SubjectPrefix ?? "" ;
69+ this . Subject = Subject ?? "" ;
70+ this . Body = Body ?? "" ;
71+ this . Recipients = Recipients ?? [ ] ;
72+ this . QuoteType = QuoteType ?? false ;
73+ this . AllowedDomains = AllowedDomains ?? [ ] ;
74+ this . ForwardType = ForwardType ?? ButtonConfigEnums . ForwardType . Unknown ;
75+ this . Size = Size ?? ButtonConfigEnums . ButtonSize . Unknown ;
76+ this . Image = Image ?? "logo.png" ;
10077
10178 if ( ! Recipients || Recipients . length == 0 ) {
102- this . RecipientsType = RecipientsType . Blank ;
79+ this . RecipientsType = ButtonConfigEnums . RecipientsType . Blank ;
10380 } else {
104- this . RecipientsType = RecipientsType . SpecifiedByUser ;
105- for ( const key of Object . keys ( RecipientsType ) ) {
81+ this . RecipientsType = ButtonConfigEnums . RecipientsType . SpecifiedByUser ;
82+ for ( const key of Object . keys ( ButtonConfigEnums . RecipientsType ) ) {
10683 const lowerdKey = key . toLowerCase ( ) ;
10784 const inputRecipientLower = Recipients [ 0 ] . toLowerCase ( ) ;
10885 if ( lowerdKey === inputRecipientLower ) {
109- this . RecipientsType = RecipientsType [ key ] ;
86+ this . RecipientsType = ButtonConfigEnums . RecipientsType [ key ] ;
11087 break ;
11188 }
11289 }
11390 }
11491
11592 if ( ! AllowedDomains || AllowedDomains . length == 0 || AllowedDomains [ 0 ] === "*" ) {
116- this . AllowedDomainsType = AllowedDomainsType . Blank ;
93+ this . AllowedDomainsType = ButtonConfigEnums . AllowedDomainsType . Blank ;
11794 } else {
118- this . AllowedDomainsType = AllowedDomainsType . SpecifiedByUser ;
95+ this . AllowedDomainsType = ButtonConfigEnums . AllowedDomainsType . SpecifiedByUser ;
96+ }
97+ }
98+ }
99+
100+ export class Config {
101+ Culture ;
102+ GroupLabel ;
103+ TabMailInsertAfterMso ;
104+ TabReadInsertAfterMso ;
105+ ContextMenuInsertAfterMso ;
106+ ButtonConfigList ;
107+
108+ constructor ( {
109+ Culture,
110+ GroupLabel,
111+ TabMailInsertAfterMso,
112+ TabReadInsertAfterMso,
113+ ContextMenuInsertAfterMso,
114+ ButtonConfigList,
115+ } ) {
116+ this . Culture = Culture ?? "en-US" ;
117+ this . GroupLabel = GroupLabel ?? "Typical Reply" ;
118+ this . TabMailInsertAfterMso = TabMailInsertAfterMso ?? "GroupMailRespond" ;
119+ this . TabReadInsertAfterMso = TabReadInsertAfterMso ?? "GroupRespond" ;
120+ this . ContextMenuInsertAfterMso = ContextMenuInsertAfterMso ?? "Forward" ;
121+ this . ButtonConfigList = [ ] ;
122+ if ( ButtonConfigList ) {
123+ for ( const buttonConfig of ButtonConfigList ) {
124+ this . ButtonConfigList . push ( new ButtonConfig ( buttonConfig ) ) ;
125+ }
126+ }
127+ }
128+ }
129+
130+ export class TypicalReplyConfig {
131+ Priority ;
132+ ConfigList ;
133+ constructor ( { Priority, ConfigList } ) {
134+ this . Priority = Priority ?? 0 ;
135+ this . ConfigList = [ ] ;
136+ if ( ConfigList ) {
137+ for ( const config of ConfigList ) {
138+ this . ConfigList . push ( new Config ( config ) ) ;
139+ }
119140 }
120141 }
121142}
0 commit comments