summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js
blob: 90bf9f9f0810e7bada047169c03a569c9997eb43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
tosca_definitions_version: tosca_simple_yaml_1_0_0
metadata:
  template_name: Main
imports:
- CommonGlobalTypes:
    file: CommonGlobalTypesServiceTemplate.yaml
- NovaServerGlobalTypes:
    file: NovaServerGlobalTypesServiceTemplate.yaml
- NeutronPortGlobalTypes:
    file: NeutronPortGlobalTypesServiceTemplate.yaml
- NeutronSecurityRulesGlobalTypes:
    file: NeutronSecurityRulesGlobalTypesServiceTemplate.yaml
- NeutronNetGlobalTypes:
    file: NeutronNetGlobalTypesServiceTemplate.yaml
- CinderVolumeGlobalTypes:
    file: CinderVolumeGlobalTypesServiceTemplate.yaml
- ContrailVirtualNetworkGlobalType:
    file: ContrailVirtualNetworkGlobalTypeServiceTemplate.yaml
- ContrailNetworkRuleGlobalType:
    file: ContrailNetworkRuleGlobalTypeServiceTemplate.yaml
- AbstractSubstituteGlobalTypes:
    file: AbstractSubstituteGlobalTypesServiceTemplate.yaml
- ContrailV2VirtualMachineInterfaceGlobalType:
    file: ContrailV2VirtualMachineInterfaceGlobalTypeServiceTemplate.yaml
- ContrailComputeGlobalTypes:
    file: ContrailComputeGlobalTypesServiceTemplate.yaml
- ContrailPortGlobalTypes:
    file: ContrailPortGlobalTypesServiceTemplate.yaml
- ContrailAbstractSubstituteGlobalTypes:
    file: ContrailAbstractSubstituteGlobalTypesServiceTemplate.yaml
- ContrailV2VirtualNetworkGlobalType:
    file: ContrailV2VirtualNetworkGlobalTypeServiceTemplate.yaml
- ContrailV2NetworkRuleGlobalType:
    file: ContrailV2NetworkRuleGlobalTypeServiceTemplate.yaml
- ContrailV2VLANSubInterfaceGlobalType:
    file: ContrailV2VLANSubInterfaceGlobalTypeServiceTemplate.yaml
- GlobalSubstitutionTypes:
    file: GlobalSubstitutionTypesServiceTemplate.yaml
topology_template:
  inputs:
    oam_net_ips:
      label: OAM network ips
      hidden: false
      immutable: false
      type: list
      description: OAM network ips
      entry_schema:
        type: string
    availabilityzone_name:
      label: availabilityzone name
      hidden: false
      immutable: false
      type: string
      description: availabilityzone name
    oam_net_gw:
      label: CPS network gateway
      hidden: false
      immutable: false
      type: string
      description: CPS network gateway
    pcm_server_names:
      label: PCRF CM server names
      hidden: false
      immutable: false
      type: list
      description: name of the PCRF CM instance
      entry_schema:
        type: string
    pcm_image_name:
      label: PCRF CM image name
      hidden: false
      immutable: false
      type: string
      description: PCRF CM image name
    cps_net_ips:
      label: CPS network ips
      hidden: false
      immutable: false
      type: list
      description: CPS network ips
      entry_schema:
        type: string
    security_group_name:
      label: security group name
      hidden: false
      immutable: false
      type: string
      description: the name of security group
    pcm_volumes:
      label: CPS Cluman Cinder Volume
      hidden: false
      immutable: false
      type: list
      description: CPS Cluman Cinder Volume
      entry_schema:
        type: string
    pcm_flavor_name:
      label: PCRF CM flavor name
      hidden: false
      immutable: false
      type: string
      description: flavor name of PCRF CM instance
    cps_net_name:
      label: CPS network name
      hidden: false
      immutable: false
      type: string
      description: CPS network name
    cps_net_mask:
      label: CPS network mask
      hidden: false
      immutable: false
      type: string
      description: CPS network mask
    oam_net_mask:
      label: CPS network mask
      hidden: false
      immutable: false
      type: string
      description: CPS network mask
    oam_net_name:
      label: OAM network name
      hidden: false
      immutable: false
      type: string
      description: OAM network name
  node_templates:
    server_pcm_001:
      type
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
/*!
 * Copyright © 2016-2018 European Support Limited
 * Modifications copyright (c) 2021 Nokia
 * Modifications Copyright (C) 2021 Nordix Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
import showFileSaveDialog from 'nfvo-utils/ShowFileSaveDialog.js';
import Configuration from 'sdc-app/config/Configuration.js';
import i18n from 'nfvo-utils/i18n/i18n.js';
import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js';
import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';

import {
    actionTypes,
    onboardingOriginTypes,
    PRODUCT_QUESTIONNAIRE,
    forms
} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js';
import SoftwareProductComponentsActionHelper from './components/SoftwareProductComponentsActionHelper.js';
import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
import { actionTypes as HeatSetupActions } from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js';
import { actionTypes as featureGroupsActionConstants } from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js';
import { actionTypes as licenseAgreementActionTypes } from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js';
import { actionTypes as componentActionTypes } from './components/SoftwareProductComponentsConstants.js';
import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js';
import { default as ItemsHelper } from 'sdc-app/common/helpers/ItemsHelper.js';
import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
import MergeEditorActionHelper from 'sdc-app/common/merge/MergeEditorActionHelper.js';
import { CommitModalType } from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx';
import { actionTypes as commonActionTypes } from 'sdc-app/common/reducers/PlainDataReducerConstants.js';
import versionPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js';
import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
import getValue from 'nfvo-utils/getValue.js';
import {
    itemStatus,
    versionStatus
} from 'sdc-app/common/helpers/ItemsHelperConstants.js';

let shouldDisplayTimingValidationInfo = true;
let alertValidationTiming = Configuration.get(
    'displayAlertValidationAfterMilisec'
);

function getLicensingData(licensingData = {}) {
    const { licenseAgreement, featureGroups } = licensingData;
    const newlicenseAgreement = getValue(licenseAgreement);
    const newfeatureGroups = getValue(featureGroups);
    return newlicenseAgreement
        ? {
              licenseAgreement: newlicenseAgreement,
              featureGroups: newfeatureGroups
          }
        : undefined;
}

function getTimingInfoWarning() {
    return {
        type: modalActionTypes.GLOBAL_MODAL_WARNING,
        data: {
            title: 'Please be patient',
            msg: 'Large files processing may take up to several minutes.',
            cancelButtonText: 'OK'
        }
    };
}

function displayTimingValidationInfo(dispatch) {
    shouldDisplayTimingValidationInfo = true;
    setTimeout(() => {
        if (shouldDisplayTimingValidationInfo) {
            dispatch(getTimingInfoWarning());
        }
    }, alertValidationTiming);
}

function closeTimingValidationInfo(dispatch) {
    shouldDisplayTimingValidationInfo = false;
    dispatch({
        type: modalActionTypes.GLOBAL_MODAL_CLOSE
    });
}

function baseUrl() {
    const restPrefix = Configuration.get('restPrefix');
    return `${restPrefix}/v1.0/vendor-software-products/`;
}

function softwareProductCategoriesUrl() {
    const restCatalogPrefix = Configuration.get('restCatalogPrefix');
    return `${restCatalogPrefix}/v1/categories/resources/`;
}

function getModelUrl() {
    const restCatalogPrefix = Configuration.get('restCatalogPrefix');
    return `${restCatalogPrefix}/v1/catalog/model?modelType=normative`;
}

function uploadFile(vspId, formData, version, onUploadProgress = undefined) {
    const options = {
        noLoading: true
    };
    if (onUploadProgress) {
        options.onUploadProgress = onUploadProgress;
    }
    return RestAPIUtil.post(
        `${baseUrl()}${vspId}/versions/${
            version.id
        }/orchestration-template-candidate`,
        formData,
        options
    );
}

function uploadVNFFile(csarId, softwareProductId, version) {
    let verId = typeof version === 'object' ? version.id : version;
    return RestAPIUtil.post(
        `${baseUrl()}${softwareProductId}/versions/${verId}/vnfrepository/vnfpackage/${csarId}/import`
    );
}
function putSoftwareProduct({ softwareProduct, version }) {
    return RestAPIUtil.put(
        `${baseUrl()}${softwareProduct.id}/versions/${version.id}`,
        {
            name: softwareProduct.name,
            description: softwareProduct.description,
            category: softwareProduct.category,
            subCategory: softwareProduct.subCategory,
            vendorId: softwareProduct.vendorId,
            vendorName: softwareProduct.vendorName,
            licensingVersion: softwareProduct.licensingVersion
                ? softwareProduct.licensingVersion
                : undefined,
            icon: softwareProduct.icon,
            licenseType: softwareProduct.licenseType,
            selectedModelList: softwareProduct.selectedModelList,
            licensingData: getLicensingData(softwareProduct.licensingData)
        }
    );
}

function putSoftwareProductQuestionnaire(vspId, qdata, version) {
    return RestAPIUtil.put(
        `${baseUrl()}${vspId}/versions/${version.id}/questionnaire`,
        qdata
    );
}

function putSoftwareProductAction(id, action, version) {
    return RestAPIUtil.put(`${baseUrl()}${id}/versions/${version.id}/actions`, {
        action: action
    });
}

function fetchSoftwareProductList() {
    return RestAPIUtil.fetch(
        `${baseUrl()}?versionFilter=${versionStatus.DRAFT}`
    );
}

function fetchArchivedSoftwareProductList() {
    return RestAPIUtil.fetch(`${baseUrl()}?Status=${itemStatus.ARCHIVED}`);
}

function fetchFinalizedSoftwareProductList() {
    return RestAPIUtil.fetch(
        `${baseUrl()}?versionFilter=${versionStatus.CERTIFIED}`
    );
}

function fetchSoftwareProduct(vspId, version) {
    return RestAPIUtil.fetch(`${baseUrl()}${vspId}/versions/${version.id}`);
}

function fetchSoftwareProductQuestionnaire(vspId, version) {
    return RestAPIUtil.fetch(
        `${baseUrl()}${vspId}/versions/${version.id}/questionnaire`
    );
}

function updateSoftwareProductHeatCandidate(
    softwareProductId,
    heatCandidate,
    version
) {
    return RestAPIUtil.put(
        `${baseUrl()}${softwareProductId}/versions/${
            version.id
        }/orchestration-template-candidate/manifest`,
        heatCandidate
    );
}
function validateHeatCandidate(softwareProductId, version) {
    return RestAPIUtil.put(
        `${baseUrl()}${softwareProductId}/versions/${
            version.id
        }/orchestration-template-candidate/process`
    );
}

function fetchOrchestrationTemplateCandidate(softwareProductId, version) {
    return RestAPIUtil.fetch(
        `${baseUrl()}${softwareProductId}/versions/${
            version.id
        }/orchestration-template-candidate`,
        { dataType: 'binary' }
    );
}

function abortValidationProcess(softwareProductId, version) {
    return RestAPIUtil.destroy(
        `${baseUrl()}${softwareProductId}/versions/${
            version.id
        }/orchestration-template-candidate`
    );
}

function objToString(obj) {
    let str = '';
    if (obj instanceof Array) {
        obj.forEach(item => {
            str += objToString(item) + '\n';
        });
    } else {
        for (let p in obj) {
            if (obj.hasOwnProperty(p)) {
                str += obj[p] + '\n';
            }
        }
    }
    return str.replace(/\n$/, '');
}

function parseUploadErrorMsg(error) {
    let message = '';
    for (let key in error) {
        if (error.hasOwnProperty(key)) {
            message += objToString(error[key]) + '\n';
        }
    }
    return message.replace(/\n$/, '');
}

function showWarningValidationInfo(dispatch, errors) {
    dispatch({
        type: modalActionTypes.GLOBAL_MODAL_WARNING,
        data: {
            title: 'Validation messages',
            msg: parseUploadErrorMsg(errors),
            cancelButtonText: 'OK'
        }
    });
}

function fetchSoftwareProductCategories(dispatch) {
    let handleResponse = response =>
        dispatch({
            type: actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED,
            softwareProductCategories: response
        });
    return RestAPIUtil.fetch(softwareProductCategoriesUrl())
        .then(handleResponse)
        .catch(() => handleResponse(null));
}

function fetchModelList(dispatch) {
    let handleResponse = response =>
        dispatch({
            type: actionTypes.SOFTWARE_PRODUCT_MODELS_LOADED,
            modelList: response
        });
    RestAPIUtil.fetch(getModelUrl())
        .then(handleResponse)
        .catch(() => handleResponse(null));
}

function loadLicensingData(dispatch, { licenseModelId, licensingVersion }) {
    return ItemsHelper.fetchVersion({
        itemId: licenseModelId,
        versionId: licensingVersion
    }).then(() => {
        return Promise.all([
            LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {
                licenseModelId,
                version: { id: licensingVersion }
            }),
            FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {
                licenseModelId,
                version: { id: licensingVersion }
            })
        ]);
    });
}

function getExpandedItemsId(items, itemIdToToggle) {
    for (let i = 0; i < items.length; i++) {
        if (items[i].id === itemIdToToggle) {
            if (items[i].expanded) {
                return {};
            } else {
                return { [itemIdToToggle]: true };
            }
        } else if (items[i].items && items[i].items.length > 0) {
            let mapOfExpandedIds = getExpandedItemsId(
                items[i].items,
                itemIdToToggle
            );
            if (mapOfExpandedIds !== false) {
                mapOfExpandedIds[items[i].id] = true;
                return mapOfExpandedIds;
            }
        }
    }
    return false;
}

function migrateSoftwareProduct(vspId, version) {
    return RestAPIUtil.put(`${baseUrl()}${vspId}/versions/${version.id}/heal`);
}

const SoftwareProductActionHelper = {
    fetchFinalizedSoftwareProductList(dispatch) {
        return fetchFinalizedSoftwareProductList().then(response =>
            dispatch({
                type: actionTypes.FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED,
                response
            })
        );
    },

    fetchArchivedSoftwareProductList(dispatch) {
        return fetchArchivedSoftwareProductList().then(response =>
            dispatch({
                type: actionTypes.ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED,
                response
            })
        );
    },

    fetchUploadStatus(vspId, versionId) {
        const options = {
            validateStatus: function(status) {
                return status < 400 || status === 404;
            },
            noLoading: true
        };
        return RestAPIUtil.get(
            `${baseUrl()}${vspId}/versions/${versionId}/orchestration-template-candidate/upload`,
            options
        );
    },

    createUploadStatus(vspId, versionId) {
        const options = {
            noLoading: true
        };
        return RestAPIUtil.post(
            `${baseUrl()}${vspId}/versions/${versionId}/orchestration-template-candidate/upload`,
            options
        );
    },

    loadSoftwareProductAssociatedData(dispatch) {
        fetchSoftwareProductCategories(dispatch);
        fetchModelList(dispatch);
        LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch);
    },

    loadSoftwareProductDetailsData(
        dispatch,
        { licenseModelId, licensingVersion }
    ) {
        SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch);
        if (licensingVersion) {
            return loadLicensingData(dispatch, {
                licenseModelId,
                licensingVersion
            });
        }
        return Promise.resolve();
    },

    fetchSoftwareProductList(dispatch) {
        return fetchSoftwareProductList().then(response =>
            dispatch({
                type: actionTypes.SOFTWARE_PRODUCT_LIST_LOADED,
                response
            })
        );
    },

    loadSoftwareProductHeatCandidate(dispatch, { softwareProductId, version }) {
        return RestAPIUtil.fetch(
            `${baseUrl()}${softwareProductId}/versions/${
                version.id
            }/orchestration-template-candidate/manifest`
        ).then(response =>
            dispatch({
                type: HeatSetupActions.MANIFEST_LOADED,
                response
            })
        );
    },

    loadLicensingVersionsList(dispatch, { licenseModelId }) {
        return ItemsHelper.fetchVersions({ itemId: licenseModelId }).then(
            response => {
                dispatch({
                    type: actionTypes.LOAD_LICENSING_VERSIONS_LIST,
                    licensingVersionsList: response.results
                });
            }
        );
    },
    updateSoftwareProductHeatCandidate(
        dispatch,
        { softwareProductId, heatCandidate, version }
    ) {
        return updateSoftwareProductHeatCandidate(
            softwareProductId,
            heatCandidate,
            version
        );
    },

    processAndValidateHeatCandidate(dispatch, { softwareProductId, version }) {
        displayTimingValidationInfo(dispatch);
        return validateHeatCandidate(softwareProductId, version).then(
            response => {
                if (response.status === 'Success') {
                    SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(
                        dispatch,
                        { softwareProductId, version }
                    );
                    SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {
                        softwareProductId,
                        version
                    });
                } else {
                    SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {
                        softwareProductId,
                        version
                    });
                }
                closeTimingValidationInfo(dispatch);
            }
        );
    },

    uploadFile(
        dispatch,
        {
            softwareProductId,
            formData,
            failedNotificationTitle,
            version,
            onUploadProgress = undefined
        }
    ) {
        dispatch({
            type: HeatSetupActions.FILL_HEAT_SETUP_CACHE,
            payload: {}
        });
        return Promise.resolve()
            .then(() =>
                uploadFile(
                    softwareProductId,
                    formData,
                    version,
                    onUploadProgress
                )
            )
            .then(response => {
                if (response.status === 'Success') {
                    dispatch({
                        type: commonActionTypes.DATA_CHANGED,
                        deltaData: {
                            onboardingOrigin: response.onboardingOrigin
                        },
                        formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS
                    });
                    switch (response.onboardingOrigin) {
                        case onboardingOriginTypes.ZIP:
                            ScreensHelper.loadScreen(dispatch, {
                                screen:
                                    enums.SCREEN
                                        .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP,
                                screenType: screenTypes.SOFTWARE_PRODUCT,
                                props: { softwareProductId, version }
                            });
                            dispatch({
                                type: actionTypes.CANDIDATE_IN_PROCESS,
                                inProcess: true
                            });
                            break;
                        case onboardingOriginTypes.CSAR:
                            ScreensHelper.loadScreen(dispatch, {
                                screen:
                                    enums.SCREEN
                                        .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION,
                                screenType: screenTypes.SOFTWARE_PRODUCT,
                                props: { softwareProductId, version }
                            });
                            break;
                    }
                    closeTimingValidationInfo(dispatch);
                    if (
                        response.errors !== null &&
                        Object.keys(response.errors).length !== 0
                    ) {
                        showWarningValidationInfo(dispatch, response.errors);
                    }
                } else {
                    throw new Error(parseUploadErrorMsg(response.errors));
                }
            })
            .catch(error => {
                dispatch(
                    {
                        type: modalActionTypes.GLOBAL_MODAL_ERROR,
                        data: {
                            title: failedNotificationTitle,
                            msg:
                                error.message ||
                                (error.responseJSON &&
                                    error.responseJSON.message) ||
                                parseUploadErrorMsg(error.responseJSON.errors)
                        }
                    },
                    closeTimingValidationInfo(dispatch)
                );
            });
    },

    uploadVNFFile(
        dispatch,
        { csarId, failedNotificationTitle, softwareProductId, version }
    ) {
        dispatch({
            type: HeatSetupActions.FILL_HEAT_SETUP_CACHE,
            payload: {}
        });

        Promise.resolve()
            .then(() => uploadVNFFile(csarId, softwareProductId, version))
            .then(response => {
                if (response.status === 'Success') {
                    dispatch({
                        type: commonActionTypes.DATA_CHANGED,
                        deltaData: {
                            onboardingOrigin: response.onboardingOrigin
                        },
                        formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS
                    });
                    switch (response.onboardingOrigin) {
                        case onboardingOriginTypes.ZIP:
                            OnboardingActionHelper.navigateToSoftwareProductAttachmentsSetupTab(
                                dispatch,
                                { softwareProductId, version }
                            );
                            break;
                        case onboardingOriginTypes.CSAR:
                            OnboardingActionHelper.navigateToSoftwareProductAttachmentsValidationTab(
                                dispatch,
                                { softwareProductId, version }
                            );
                            break;
                    }
                } else {
                    throw new Error(parseUploadErrorMsg(response.errors));
                }
            })
            .catch(error => {
                dispatch({
                    type: modalActionTypes.GLOBAL_MODAL_ERROR,
                    data: {
                        title: failedNotificationTitle,
                        msg: error.message
                    }
                });
            });
    },
    downloadHeatFile(
        dispatch,
        { softwareProductId, heatCandidate, isReadOnlyMode, version }
    ) {
        let p = isReadOnlyMode
            ? Promise.resolve()
            : SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(
                  dispatch,
                  {
                      softwareProductId,
                      heatCandidate,
                      version
                  }
              );
        p.then(() => {
            fetchOrchestrationTemplateCandidate(
                softwareProductId,
                version
            ).then(response => {
                showFileSaveDialog({
                    blob: response.blob,
                    headers: response.headers,
                    defaultFilename: 'HEAT_file.zip',
                    addTimestamp: true
                });
            });
        }, null /* do not download if data was not saved correctly*/);
    },

    hideUploadConfirm(dispatch) {
        dispatch({
            type: actionTypes.softwareProductEditor.UPLOAD_CONFIRMATION
        });
    },
    updateSoftwareProduct(dispatch, { softwareProduct, version, qdata }) {
        return Promise.all([
            SoftwareProductActionHelper.updateSoftwareProductData(dispatch, {
                softwareProduct,
                version
            }).then(() =>
                dispatch({
                    type: actionTypes.SOFTWARE_PRODUCT_LIST_EDIT,
                    payload: { softwareProduct }
                })
            ),
            SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(
                dispatch,
                {
                    softwareProductId: softwareProduct.id,
                    qdata,
                    version
                }
            )
        ]);
    },

    updateSoftwareProductData(dispatch, { softwareProduct, version }) {
        return putSoftwareProduct({ softwareProduct, version });
    },

    updateSoftwareProductQuestionnaire(
        dispatch,
        { softwareProductId, qdata, version }
    ) {
        return putSoftwareProductQuestionnaire(
            softwareProductId,
            qdata,
            version
        );
    },

    softwareProductEditorDataChanged(dispatch, { deltaData }) {
        dispatch({
            type: actionTypes.softwareProductEditor.DATA_CHANGED,
            deltaData
        });
    },

    softwareProductQuestionnaireUpdate(dispatch, { data }) {
        dispatch({
            type: actionTypes.SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE,
            payload: { qdata: data }
        });
    },

    softwareProductEditorVendorChanged(dispatch, { deltaData, formName }) {
        if (deltaData.licensingVersion) {
            return loadLicensingData(dispatch, {
                licenseModelId: deltaData.vendorId,
                licensingVersion: deltaData.licensingVersion
            }).then(() => {
                ValidationHelper.dataChanged(dispatch, { deltaData, formName });
                return Promise.resolve();
            });
        } else if (deltaData.vendorId) {
            ValidationHelper.dataChanged(dispatch, { deltaData, formName });
            return SoftwareProductActionHelper.loadLicensingVersionsList(
                dispatch,
                {
                    licenseModelId: deltaData.vendorId
                }
            ).then(() =>
                OnboardingActionHelper.forceBreadCrumbsUpdate(dispatch)
            );
        } else {
            ValidationHelper.dataChanged(dispatch, { deltaData, formName });

            dispatch({
                type: licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED,
                response: { results: [] }
            });

            dispatch({
                type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED,
                response: { results: [] }
            });
        }
    },

    setIsValidityData(dispatch, { isValidityData }) {
        dispatch({
            type: actionTypes.softwareProductEditor.IS_VALIDITY_DATA_CHANGED,
            isValidityData
        });
    },

    fetchSoftwareProduct(dispatch, { softwareProductId, version }) {
        return Promise.all([
            fetchSoftwareProduct(softwareProductId, version).then(response => {
                dispatch({
                    type: actionTypes.SOFTWARE_PRODUCT_LOADED,
                    response
                });
                return response;
            }),
            fetchSoftwareProductQuestionnaire(softwareProductId, version).then(
                response => {
                    ValidationHelper.qDataLoaded(dispatch, {
                        response: {
                            qdata: response.data
                                ? JSON.parse(response.data)
                                : {},
                            qschema: JSON.parse(response.schema)
                        },
                        qName: PRODUCT_QUESTIONNAIRE
                    });
                }
            )
        ]);
    },

    manageSubmitAction(dispatch, { softwareProductId, version, isDirty }) {
        if (isDirty) {
            const onCommit = comment => {
                return this.performVCAction(dispatch, {
                    softwareProductId,
                    action: VersionControllerActionsEnum.COMMIT,
                    version,
                    comment
                }).then(() => {
                    return this.performSubmitAction(dispatch, {
                        softwareProductId,
                        version
                    });
                });
            };
            dispatch({
                type: modalActionTypes.GLOBAL_MODAL_SHOW,
                data: {
                    modalComponentName: modalContentMapper.COMMIT_COMMENT,
                    modalComponentProps: {
                        onCommit,
                        type: CommitModalType.COMMIT_SUBMIT
                    },
                    title: i18n('Commit & Submit')
                }
            });
            return Promise.resolve(version);
        }
        return this.performSubmitAction(dispatch, {
            softwareProductId,
            version
        });
    },

    performSubmitAction(dispatch, { softwareProductId, version }) {
        return putSoftwareProductAction(
            softwareProductId,
            VersionControllerActionsEnum.SUBMIT,
            version
        ).then(
            () => {
                return putSoftwareProductAction(
                    softwareProductId,
                    VersionControllerActionsEnum.CREATE_PACKAGE,
                    version
                ).then(() => {
                    return ItemsHelper.checkItemStatus(dispatch, {
                        itemId: softwareProductId,
                        versionId: version.id
                    }).then(updatedVersion => {
                        dispatch({
                            type: modalActionTypes.GLOBAL_MODAL_SUCCESS,
                            data: {
                                title: i18n('Submit Succeeded'),
                                msg: i18n(
                                    'This software product successfully submitted'
                                ),
                                cancelButtonText: i18n('OK'),
                                timeout: 2000
                            }
                        });
                        versionPageActionHelper.fetchVersions(dispatch, {
                            itemType: itemTypes.SOFTWARE_PRODUCT,
                            itemId: softwareProductId
                        });
                        return Promise.resolve(updatedVersion);
                    });
                });
            },
            error => {
                dispatch({
                    type: modalActionTypes.GLOBAL_MODAL_ERROR,
                    data: {
                        modalComponentName:
                            modalContentMapper.SUMBIT_ERROR_RESPONSE,
                        title: i18n('Submit Failed'),
                        modalComponentProps: {
                            validationResponse: error.responseJSON
                        },
                        cancelButtonText: i18n('OK')
                    }
                });
                return Promise.reject(error.responseJSON);
            }
        );
    },

    performVCAction(dispatch, { softwareProductId, action, version, comment }) {
        return MergeEditorActionHelper.analyzeSyncResult(dispatch, {
            itemId: softwareProductId,
            version
        }).then(({ inMerge, isDirty, updatedVersion }) => {
            if (
                (updatedVersion.status === versionStatus.CERTIFIED ||
                    updatedVersion.archivedStatus === itemStatus.ARCHIVED) &&
                (action === VersionControllerActionsEnum.COMMIT ||
                    action === VersionControllerActionsEnum.SYNC)
            ) {
                versionPageActionHelper.fetchVersions(dispatch, {
                    itemType: itemTypes.SOFTWARE_PRODUCT,
                    itemId: softwareProductId
                });
                const msg =
                    updatedVersion.archivedStatus === itemStatus.ARCHIVED
                        ? i18n('Item was Archived')
                        : i18n('Item version already Certified');
                dispatch({
                    type: modalActionTypes.GLOBAL_MODAL_WARNING,
                    data: {
                        title: i18n('Commit error'),
                        msg,
                        cancelButtonText: i18n('Cancel')
                    }
                });
                return Promise.resolve(updatedVersion);
            }
            if (!inMerge) {
                if (action === VersionControllerActionsEnum.SUBMIT) {
                    return this.manageSubmitAction(dispatch, {
                        softwareProductId,
                        version,
                        isDirty
                    });
                } else {
                    let isCallActionValid =
                        action !== VersionControllerActionsEnum.COMMIT ||
                        isDirty;
                    if (isCallActionValid) {
                        return ItemsHelper.performVCAction({
                            itemId: softwareProductId,
                            action,
                            version,
                            comment
                        }).then(() => {
                            versionPageActionHelper.fetchVersions(dispatch, {
                                itemType: itemTypes.LICENSE_MODEL,
                                itemId: softwareProductId
                            });
                            if (action === VersionControllerActionsEnum.SYNC) {
                                return MergeEditorActionHelper.analyzeSyncResult(
                                    dispatch,
                                    { itemId: softwareProductId, version }
                                ).then(({ updatedVersion }) => {
                                    return Promise.resolve(updatedVersion);
                                });
                            } else {
                                return ItemsHelper.checkItemStatus(dispatch, {
                                    itemId: softwareProductId,
                                    versionId: version.id
                                });
                            }
                        });
                    } else {
                        dispatch({
                            type: modalActionTypes.GLOBAL_MODAL_ERROR,
                            data: {
                                title: i18n('Commit Failed'),
                                msg: i18n('There is nothing to commit')
                            }
                        });
                    }
                }
            }
        });
    },

    toggleNavigationItems(dispatch, { items, itemIdToExpand }) {
        let mapOfExpandedIds = getExpandedItemsId(items, itemIdToExpand);
        dispatch({
            type: actionTypes.TOGGLE_NAVIGATION_ITEM,
            mapOfExpandedIds
        });
    },

    /** for the next verision */
    addComponent(dispatch, { softwareProductId, version }) {
        SoftwareProductComponentsActionHelper.clearComponentCreationData(
            dispatch
        );
        dispatch({
            type: componentActionTypes.COMPONENT_CREATE_OPEN
        });
        dispatch({
            type: modalActionTypes.GLOBAL_MODAL_SHOW,
            data: {
                modalComponentName: modalContentMapper.COMPONENT_CREATION,
                modalComponentProps: { softwareProductId, version },
                title: 'Create Virtual Function Component'
            }
        });
    },

    migrateSoftwareProduct(dispatch, { softwareProduct }) {
        let { id: softwareProductId, version } = softwareProduct;
        const newVer = version.id;
        migrateSoftwareProduct(softwareProductId, version).then(() =>
            ScreensHelper.loadScreen(dispatch, {
                screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE,
                screenType: screenTypes.SOFTWARE_PRODUCT,
                props: {
                    softwareProductId,
                    version: { id: newVer, label: newVer }
                }
            })
        );
    },

    abortCandidateValidation(dispatch, { softwareProductId, version }) {
        return abortValidationProcess(softwareProductId, version);
    }
};

export default SoftwareProductActionHelper;