architecture-viewer 0.0.1-security → 4.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of architecture-viewer might be problematic. Click here for more details.

Files changed (96) hide show
  1. package/2/package.json +10 -0
  2. package/2/postinstall.js +33 -0
  3. package/New Folder/architecture-viewer/.babelrc +9 -0
  4. package/New Folder/architecture-viewer/.whitesource +8 -0
  5. package/New Folder/architecture-viewer/CODEOWNERS +2 -0
  6. package/New Folder/architecture-viewer/LICENSE.txt +201 -0
  7. package/New Folder/architecture-viewer/README.md +238 -0
  8. package/New Folder/architecture-viewer/licenses.csv +40 -0
  9. package/New Folder/architecture-viewer/package-lock.json +16126 -0
  10. package/New Folder/architecture-viewer/package.json +60 -0
  11. package/New Folder/architecture-viewer/preact.config.js +62 -0
  12. package/New Folder/architecture-viewer/readme_resources/screenrecord_arch_diagram.gif +0 -0
  13. package/New Folder/architecture-viewer/sample_json_data/large_web.json +289 -0
  14. package/New Folder/architecture-viewer/sample_json_data/no_steps.json +185 -0
  15. package/New Folder/architecture-viewer/sample_json_data/readme_example.json +55 -0
  16. package/New Folder/architecture-viewer/sample_json_data/section_example.json +323 -0
  17. package/New Folder/architecture-viewer/sample_json_data/simple_structure.json +131 -0
  18. package/New Folder/architecture-viewer/sample_json_data/zones_example.json +445 -0
  19. package/New Folder/architecture-viewer/sample_plantuml_data/example.adoc +65 -0
  20. package/New Folder/architecture-viewer/sample_plantuml_data/example.png +0 -0
  21. package/New Folder/architecture-viewer/sample_plantuml_data/example.svg +1 -0
  22. package/New Folder/architecture-viewer/src/assets/data.json +445 -0
  23. package/New Folder/architecture-viewer/src/assets/favicon.ico +0 -0
  24. package/New Folder/architecture-viewer/src/assets/grid_data.json +1126 -0
  25. package/New Folder/architecture-viewer/src/assets/icons/android-chrome-192x192.png +0 -0
  26. package/New Folder/architecture-viewer/src/assets/icons/android-chrome-512x512.png +0 -0
  27. package/New Folder/architecture-viewer/src/assets/icons/apple-touch-icon.png +0 -0
  28. package/New Folder/architecture-viewer/src/assets/icons/favicon-16x16.png +0 -0
  29. package/New Folder/architecture-viewer/src/assets/icons/favicon-32x32.png +0 -0
  30. package/New Folder/architecture-viewer/src/assets/icons/info.png +0 -0
  31. package/New Folder/architecture-viewer/src/assets/icons/mstile-150x150.png +0 -0
  32. package/New Folder/architecture-viewer/src/assets/test_data.json +32 -0
  33. package/New Folder/architecture-viewer/src/components/app.js +231 -0
  34. package/New Folder/architecture-viewer/src/components/controls.js +195 -0
  35. package/New Folder/architecture-viewer/src/components/diagram.js +362 -0
  36. package/New Folder/architecture-viewer/src/components/diagramArea.js +68 -0
  37. package/New Folder/architecture-viewer/src/components/info.js +37 -0
  38. package/New Folder/architecture-viewer/src/components/infoArea.js +75 -0
  39. package/New Folder/architecture-viewer/src/components/key.js +42 -0
  40. package/New Folder/architecture-viewer/src/components/tableOfContents.js +112 -0
  41. package/New Folder/architecture-viewer/src/components/tocStep.js +100 -0
  42. package/New Folder/architecture-viewer/src/components/zoneLegend.js +55 -0
  43. package/New Folder/architecture-viewer/src/index.js +20 -0
  44. package/New Folder/architecture-viewer/src/manifest.json +19 -0
  45. package/New Folder/architecture-viewer/src/routes/home/index.js +29 -0
  46. package/New Folder/architecture-viewer/src/routes/home/style.less +23 -0
  47. package/New Folder/architecture-viewer/src/routes/profile/index.js +63 -0
  48. package/New Folder/architecture-viewer/src/routes/profile/style.less +23 -0
  49. package/New Folder/architecture-viewer/src/style/helpers.less +40 -0
  50. package/New Folder/architecture-viewer/src/style/index.css +224 -0
  51. package/New Folder/architecture-viewer/src/style/jquery.qtip.less +623 -0
  52. package/New Folder/architecture-viewer/src/sw.js +4 -0
  53. package/New Folder/architecture-viewer/src/template.html +15 -0
  54. package/New Folder/architecture-viewer/src/utils/dataValidator.js +333 -0
  55. package/New Folder/architecture-viewer/src/utils/parser.js +623 -0
  56. package/New Folder/architecture-viewer/src/utils/stepUtils.js +30 -0
  57. package/New Folder/architecture-viewer/tests/__mocks__/browserMocks.js +21 -0
  58. package/New Folder/architecture-viewer/tests/__mocks__/fileMocks.js +3 -0
  59. package/New Folder/architecture-viewer/tests/__mocks__/setupTests.js +6 -0
  60. package/New Folder/architecture-viewer/tests/parser.test.js +799 -0
  61. package/New Folder/architecture-viewer/tests/testfiles/aliased_participants.adoc +7 -0
  62. package/New Folder/architecture-viewer/tests/testfiles/bigspace.json +1 -0
  63. package/New Folder/architecture-viewer/tests/testfiles/dividers.adoc +18 -0
  64. package/New Folder/architecture-viewer/tests/testfiles/doubled_names.adoc +10 -0
  65. package/New Folder/architecture-viewer/tests/testfiles/empty.adoc +2 -0
  66. package/New Folder/architecture-viewer/tests/testfiles/meta.adoc +19 -0
  67. package/New Folder/architecture-viewer/tests/testfiles/notes_multiline.adoc +17 -0
  68. package/New Folder/architecture-viewer/tests/testfiles/notes_singleline.adoc +16 -0
  69. package/New Folder/architecture-viewer/tests/testfiles/parsefile.adoc +6 -0
  70. package/New Folder/architecture-viewer/tests/testfiles/participant_decl.adoc +6 -0
  71. package/New Folder/architecture-viewer/tests/testfiles/participant_info.adoc +7 -0
  72. package/New Folder/architecture-viewer/tests/testfiles/readme.adoc +7 -0
  73. package/New Folder/architecture-viewer/tests/testfiles/steps_aliased.adoc +9 -0
  74. package/New Folder/architecture-viewer/tests/testfiles/steps_group.adoc +16 -0
  75. package/New Folder/architecture-viewer/tests/testfiles/steps_group.json +1 -0
  76. package/New Folder/architecture-viewer/tests/testfiles/steps_group_mixed.adoc +16 -0
  77. package/New Folder/architecture-viewer/tests/testfiles/steps_group_mixed.json +1 -0
  78. package/New Folder/architecture-viewer/tests/testfiles/steps_loop.adoc +16 -0
  79. package/New Folder/architecture-viewer/tests/testfiles/steps_loop.json +1 -0
  80. package/New Folder/architecture-viewer/tests/testfiles/steps_mixed.adoc +9 -0
  81. package/New Folder/architecture-viewer/tests/testfiles/steps_steptest.adoc +17 -0
  82. package/New Folder/architecture-viewer/tests/testfiles/steps_unaliased.adoc +9 -0
  83. package/New Folder/architecture-viewer/tests/testfiles/supernodes.adoc +10 -0
  84. package/New Folder/architecture-viewer/tests/testfiles/unaliased_participants.adoc +6 -0
  85. package/New Folder/architecture-viewer/tests/testfiles/undeclaredparticipant.adoc +23 -0
  86. package/New Folder/architecture-viewer/tests/testfiles/xsstest.adoc +15 -0
  87. package/New Folder/architecture-viewer/tests/testfiles/zoned_participants.adoc +5 -0
  88. package/New Folder/architecture-viewer/tests/validator.test.js +63 -0
  89. package/New Folder/d_i.txt +1 -0
  90. package/New Folder/dependency_confution_npm.sh +70 -0
  91. package/New Folder/licenses.csv +40 -0
  92. package/New Folder/npm_sub.txt +0 -0
  93. package/New Folder/package.json.save +12 -0
  94. package/index.js +39 -0
  95. package/package.json +9 -3
  96. package/README.md +0 -5
@@ -0,0 +1,362 @@
1
+ /*
2
+ * Copyright 2017 Capital One Services, LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { h, Component } from 'preact';
18
+
19
+ // import cytoscape from './lib/cytoscape.min';
20
+ import cytoscape from 'cytoscape';
21
+
22
+ import cydagre from 'cytoscape-dagre';
23
+ import popper from 'cytoscape-popper';
24
+
25
+ import tippy from 'tippy.js';
26
+
27
+ // import undoRedo from 'cytoscape-undo-redo';
28
+
29
+ // import jquery from 'jquery';
30
+ // import expandCollapse from 'cytoscape-expand-collapse';
31
+
32
+ import { getCurrentStep } from '../utils/stepUtils'
33
+
34
+ cytoscape.use(cydagre);
35
+ cytoscape.use(popper);
36
+
37
+ // cydagre(cytoscape);
38
+
39
+ // undoRedo(cytoscape);
40
+ // expandCollapse(cytoscape, jquery);
41
+
42
+ export default class Diagram extends Component {
43
+
44
+ constructor(props) {
45
+ super(props);
46
+ this.renderDiagram = this.renderDiagram.bind(this);
47
+ this.processStep = this.processStep.bind(this);
48
+ this.transferStep = this.transferStep.bind(this);
49
+ this.curStep = 0;
50
+ this.highlighted_nodes = [];
51
+ }
52
+
53
+ componentDidMount() {
54
+ this.renderDiagram();
55
+ }
56
+
57
+ componentDidUpdate(prevProps, prevState) {
58
+ try {
59
+
60
+ const curGraphData = Object.assign({}, this.props.graphData);
61
+ const prevGraphData = Object.assign({},prevProps.graphData);
62
+
63
+ // console.log(curGraphData);
64
+
65
+ const extractNodeData = node => {
66
+ const selectAttrs = ({ id, fname, zone, parent, info }) => ({ id, fname, zone, parent, info });
67
+ node.data = selectAttrs(node.data);
68
+ return node;
69
+ };
70
+
71
+ const extractEdgeData = edge => {
72
+ const selectAttrs = ({ id, source, target }) => ({ id, source, target});
73
+ edge.data = selectAttrs(edge.data)
74
+ return edge;
75
+ }
76
+
77
+ curGraphData.nodes = curGraphData.nodes.map(extractNodeData);
78
+ curGraphData.edges = curGraphData.edges.map(extractEdgeData);
79
+
80
+ prevGraphData.nodes = prevGraphData.nodes.map(extractNodeData);
81
+ prevGraphData.edges = prevGraphData.edges.map(extractEdgeData);
82
+
83
+ const curGraphDataStr = JSON.stringify(curGraphData);
84
+ const prevGraphDataStr = JSON.stringify(prevGraphData);
85
+
86
+ // console.log(curGraphDataStr, "\n", prevGraphDataStr);
87
+ // console.log(previousGraphData);
88
+ if (curGraphDataStr !== prevGraphDataStr) {
89
+ this.renderDiagram();
90
+ } else {
91
+ this.transferStep(this.props.curStep);
92
+ }
93
+ } catch (e) {
94
+ // this.renderDiagram();
95
+ if (e instanceof TypeError) {
96
+
97
+ }
98
+ console.error(e);
99
+ }
100
+ }
101
+
102
+ renderDiagram() {
103
+ let that = this;
104
+
105
+ this.cy = null;
106
+ this.cy = cytoscape({
107
+ container: that.base,
108
+
109
+ boxSelectionEnabled: false,
110
+ autounselectify: true,
111
+ panningEnabled: true,
112
+ userPanningEnabled: true,
113
+ userZoomingEnabled: true,
114
+
115
+
116
+ layout: {
117
+ name: 'dagre',
118
+ directed: false,
119
+ rankDir: 'LR',
120
+ // ranker: 'tight-tree'
121
+ animate: true,
122
+ animationDuration: 0
123
+ },
124
+
125
+ style: [
126
+ {
127
+ selector: '[fname]',
128
+ style: {
129
+ 'height': 125,
130
+ 'width': 175,
131
+ 'background-color': 'data(zone)',
132
+ 'content': e => e.data('fname') ? e.data('fname') : '',
133
+ 'text-valign': 'center',
134
+ 'text-halign': 'center',
135
+ 'font-size': 25,
136
+ 'shape': 'roundrectangle',
137
+ 'border-width': '5px',
138
+ 'border-color': e => e.data('zone'),
139
+ 'text-wrap': 'wrap',
140
+ 'text-max-width': 175,
141
+ 'z-index': 20
142
+ }
143
+ },
144
+ {
145
+ selector: '$node > [fname]',
146
+ style: {
147
+ 'height': 125,
148
+ 'width': 175,
149
+ 'background-color': 'data(zone)',
150
+ 'content': e => e.data('fname') ? e.data('fname') : '',
151
+ 'text-valign': 'top',
152
+ 'text-halign': 'center',
153
+ 'font-size': 25,
154
+ 'shape': 'roundrectangle',
155
+ 'border-width': '5px',
156
+ 'border-color': e => e.data('zone'),
157
+ 'z-index': 20
158
+ }
159
+ },
160
+ {
161
+ selector: 'edge',
162
+ style: {
163
+ 'curve-style': 'bezier',
164
+ // 'haystack-radius': 0,
165
+ 'width': 10,
166
+ 'opacity': 0.5,
167
+ 'line-color': '#888',
168
+ 'target-arrow-shape': 'none',
169
+ 'target-arrow-color': '#888',
170
+ 'target-endpoint': 'inside-to-node',
171
+ 'source-arrow-shape': 'none',
172
+ 'source-arrow-color': '#888',
173
+ 'source-endpoint': 'inside-to-node',
174
+ 'z-index': 30
175
+ // 'mid-source-arrow-color': 'red',
176
+ // 'mid-source-arrow-fill': 'filled'
177
+ }
178
+ },
179
+ {
180
+ selector: '.highlighted',
181
+ style: {
182
+ 'border-color': '#248bca',
183
+ // 'line-color': '#61bffc',
184
+ 'transition-property': 'border-color',
185
+ 'transition-duration': '0.25s',
186
+ }
187
+ },
188
+ {
189
+ selector: '.highlighted-to-target',
190
+ style: {
191
+ 'border-color': '#248bca',
192
+ 'line-color': '#248bca',
193
+ 'transition-property': 'border-color, line-color, target-arrow-color',
194
+ 'transition-duration': '0.25s',
195
+ 'target-arrow-color': '#248bca',
196
+ // 'source-arrow-color': '#61bffc',
197
+ 'target-arrow-shape': 'triangle',
198
+ // 'source-arrow-shape': 'none',
199
+ 'target-endpoint': 'outside-to-node',
200
+ 'arrow-scale': 1.5,
201
+ 'opacity': 1
202
+ }
203
+ },
204
+ {
205
+ selector: '.highlighted-to-source',
206
+ style: {
207
+ 'border-color': '#248bca',
208
+ 'line-color': '#248bca',
209
+ 'transition-property': 'border-color, line-color, source-arrow-color',
210
+ 'transition-duration': '0.25s',
211
+ 'source-arrow-color': '#248bca',
212
+ // 'source-arrow-color': '#61bffc',
213
+ 'source-arrow-shape': 'triangle',
214
+ // 'source-arrow-shape': 'none',
215
+ 'source-endpoint': 'outside-to-node',
216
+ 'arrow-scale': 1.5,
217
+ 'opacity': 1
218
+ }
219
+ },
220
+ ],
221
+
222
+ elements: this.props.graphData
223
+ });
224
+
225
+ this.cy.fit(this.cy.elements(), 20);
226
+ this.cy.center();
227
+
228
+
229
+ let nodes = this.cy.filter((ele, i, eles) => {
230
+ return (ele.data('parent') != undefined);
231
+ })
232
+
233
+ let popperNodes = this.cy.filter((ele, i, eles) => {
234
+ return (ele.data('parent') != undefined) && (ele.data('info') != undefined && ele.data('info') != "");
235
+ });
236
+
237
+ let parents = this.cy.filter((ele, i, eles) => {
238
+ return (ele.data('parent') == undefined);
239
+ })
240
+
241
+ //if none of them have parents, that means no zones
242
+ if (nodes.length == 0) {
243
+ nodes = this.cy.filter((ele, i, eles) => {
244
+ return (ele.data('parent') == undefined);
245
+ })
246
+
247
+ popperNodes = this.cy.filter((ele, i, eles) => {
248
+ return (ele.data('parent') == undefined) && (ele.data('info') != undefined && ele.data('info') != "");
249
+ })
250
+ }
251
+
252
+ let tippyMap = {};
253
+
254
+ for (let i = 0; i < popperNodes.length; i++) {
255
+ let popperNode = popperNodes[i];
256
+
257
+ tippyMap[popperNode.data('id')] = tippy(popperNode.popperRef(), {
258
+ html: (() => {
259
+ let content = document.createElement('div');
260
+ content.innerHTML = popperNode.data('info');
261
+
262
+ return content;
263
+ })(),
264
+ trigger: 'manual'
265
+ }).tooltips[0];
266
+
267
+ // tippyMap[popperNode.data('id')].show();
268
+ }
269
+
270
+ nodes.on('click', function(evt) {
271
+ that.props.updateSelectedNode(evt.target.id());
272
+ // the only way I could get this tooltip to appear
273
+ // was with a timeout
274
+ // TODO: find a better way to do this
275
+ setTimeout(() => {
276
+ // console.log(tippyMap[evt.target.id()]);
277
+ tippyMap[evt.target.id()].show();
278
+ }, 250);
279
+ })
280
+
281
+ // console.log(this.props.curStep);
282
+ this.transferStep(this.props.curStep);
283
+ }
284
+
285
+ processStep(step) {
286
+ //a bit of debugging
287
+
288
+ let nodes = step.nodes.map(node => {
289
+ return this.cy.filter((ele, i, eles) => ele.data('id') === node)[0]
290
+ });
291
+
292
+ this.highlighted_nodes = this.highlighted_nodes.concat(nodes);
293
+
294
+ // console.log(nodes);
295
+
296
+ nodes[0].addClass('highlighted');
297
+
298
+ if (nodes.length == 1) {
299
+ return;
300
+ }
301
+
302
+ let edges = this.cy.filter((ele, i, eles) => {
303
+ if (ele.data('source') == step.nodes[0] &&
304
+ ele.data('target') == step.nodes[1] ||
305
+ ele.data('target') == step.nodes[0] &&
306
+ ele.data('source') == step.nodes[1]) {
307
+ return true;
308
+ }
309
+ });
310
+
311
+ this.highlighted_nodes = this.highlighted_nodes.concat(edges);
312
+
313
+ if (edges[0].data('source') == step.nodes[0]) {
314
+ edges[0].addClass('highlighted-to-target');
315
+ } else {
316
+ edges[0].addClass('highlighted-to-source');
317
+ }
318
+
319
+ nodes[1].addClass('highlighted');
320
+ }
321
+
322
+ transferStep(stepNum) {
323
+
324
+ //find the step
325
+ const stepStr = ""+(this.props.curStep);
326
+ const relevantStep = getCurrentStep(stepStr, this.props.stepData);
327
+
328
+ this.highlighted_nodes.map(node => {
329
+ node.removeClass('highlighted');
330
+ node.removeClass('highlighted-to-target');
331
+ node.removeClass('highlighted-to-source');
332
+ })
333
+
334
+ this.highlighted_nodes = [];
335
+
336
+ if (stepNum >= 0 && relevantStep != null) {
337
+
338
+ this.curStep = stepNum;
339
+ this.processStep(relevantStep);
340
+ }
341
+ }
342
+
343
+ render() {
344
+
345
+ let style = {
346
+ width: '100%',
347
+ height: '100%'
348
+ };
349
+
350
+ if (this.props.dims && this.props.dims.width) {
351
+ style.width = this.props.dims.width;
352
+ }
353
+
354
+ if (this.props.dims && this.props.dims.height) {
355
+ style.height = this.props.dims.height;
356
+ }
357
+
358
+ return (
359
+ <div id="cy" style={style} className="container-border"></div>
360
+ )
361
+ }
362
+ }
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright 2017 Capital One Services, LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { h, Component } from 'preact';
18
+
19
+ import Diagram from './diagram';
20
+ import ZoneLegend from './zoneLegend';
21
+
22
+ export default class DiagramArea extends Component {
23
+ constructor(props) {
24
+ super(props);
25
+ // console.log(props);
26
+ }
27
+
28
+ render() {
29
+
30
+ let dims = {};
31
+
32
+ //this is a hack but it's ok
33
+ if (this.props.stepData.length == 0 && window.self == window.top) {
34
+ dims.width = 'calc(80vw - 30px)';
35
+ } else if (this.props.stepData.length == 0 && window.self != window.top) {
36
+ dims.width = 'calc(70vw - 30px)'
37
+ } else {
38
+ dims.width = 'calc(60vw - 30px)'
39
+ }
40
+
41
+ let diagramAreaStyle = {
42
+ width: dims.width,
43
+ height: 'calc(100% - 20px)',
44
+ zIndex: '999'
45
+ };
46
+
47
+ let btnStyle = {
48
+ position: 'absolute',
49
+ left: '10px',
50
+ top: '10px',
51
+ zIndex: 1000
52
+ };
53
+
54
+ return <div style={diagramAreaStyle}>
55
+ <Diagram
56
+ graphData={this.props.graphData}
57
+ stepData={this.props.stepData}
58
+ curStep={this.props.curStep}
59
+ updateSelectedNode={this.props.updateSelectedNode}
60
+ zoneData={this.props.zoneData}
61
+ dims={dims}
62
+ ref={(d) => {this.diag = d; }}
63
+ />
64
+ <button style={btnStyle} onClick={() => {this.diag.renderDiagram();}}> redraw </button>
65
+ </div>
66
+ }
67
+ }
68
+
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright 2017 Capital One Services, LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { h, Component } from 'preact';
18
+
19
+ export default class Info extends Component {
20
+
21
+ render() {
22
+
23
+ let el;
24
+
25
+ if (!this.props.flowTitle) {
26
+ el = <div id="info" className="sub-container-border">
27
+ <h2> Invalid Title! </h2>
28
+ </div>
29
+ } else {
30
+ el = <div id="info" className="sub-container-border">
31
+ <h2> {this.props.flowTitle} </h2>
32
+ </div>
33
+ }
34
+
35
+ return el;
36
+ }
37
+ }
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright 2017 Capital One Services, LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { h, Component } from 'preact';
18
+
19
+ import Controls from './controls';
20
+ import TableOfContents from './tableOfContents';
21
+ import Info from './info';
22
+
23
+
24
+ export default class InfoArea extends Component {
25
+
26
+ render() {
27
+
28
+ let width;
29
+
30
+ if (this.props.stepData.length == 0 && window.self == window.top) {
31
+ width = 'calc(20% - 30px)'
32
+ } else if (this.props.stepData.length == 0 && window.self != window.top) {
33
+ width = 'calc(30% - 30px)';
34
+ } else {
35
+ width = 'calc(40% - 30px)'
36
+ }
37
+
38
+ let infoAreaStyle = {
39
+ width: width,
40
+ height: 'calc(100% - 20px)',
41
+ zIndex: '999',
42
+ display: 'flex',
43
+ flexDirection: 'column',
44
+ alignItems: 'center',
45
+ justifyContent: 'space-around'
46
+ }
47
+
48
+ const countSteps = (sum, step) => {
49
+ if (step.type == "single") {
50
+ return sum + 1;
51
+ } else if (step.type == "group") {
52
+ return step.steps.reduce(countSteps, sum);
53
+ }
54
+ }
55
+
56
+ let stepNum = this.props.stepData.reduce(countSteps, 0);
57
+
58
+ return (
59
+ <div id="infoArea" style={infoAreaStyle} className="container-border">
60
+ <Info flowTitle={this.props.flowTitle}></Info>
61
+ <TableOfContents updateStep={this.props.updateStep}
62
+ stepData={this.props.stepData}
63
+ curStep={this.props.curStep}
64
+ selectedNode={this.props.selectedNode}></TableOfContents>
65
+
66
+ <Controls curStep={this.props.curStep}
67
+ stepNum={stepNum}
68
+ updateStep={this.props.updateStep}
69
+ updateData={this.props.updateData}></Controls>
70
+ </div>
71
+ )
72
+ }
73
+ }
74
+
75
+ /*<div id="info" className="sub-container-border">info</div>*/
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright 2017 Capital One Services, LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { h, Component } from 'preact';
18
+
19
+ export default class Key extends Component {
20
+
21
+ constructor(props) {
22
+ super(props);
23
+ }
24
+
25
+ render() {
26
+
27
+ let keyStyle = {
28
+ width: 'calc(50% - 5px)',
29
+ backgroundColor: this.props.color,
30
+ padding: '5px',
31
+ border: '1px solid ' + this.props.color,
32
+ borderRadius: '3px',
33
+ margin: '5px'
34
+ }
35
+
36
+ return (
37
+ <div style={keyStyle}>
38
+ <span id="key-name">{this.props.name}</span>
39
+ </div>
40
+ )
41
+ }
42
+ }
@@ -0,0 +1,112 @@
1
+ /*
2
+ * Copyright 2017 Capital One Services, LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { h, Component } from 'preact';
18
+
19
+ import TocStep from './tocStep';
20
+
21
+ import { getCurrentStep } from '../utils/stepUtils'
22
+
23
+ export default class TableOfContents extends Component {
24
+
25
+ constructor(props) {
26
+ super(props);
27
+ }
28
+
29
+ render() {
30
+
31
+
32
+ let tableOfContentsStyle = {
33
+ overflowY: 'auto',
34
+ overflowX: 'hidden'
35
+ }
36
+
37
+ const stepStr = ""+(this.props.curStep);
38
+ const currentStep = getCurrentStep(stepStr, this.props.stepData);
39
+
40
+
41
+ const flattenSteps = (steps) => {
42
+ const flattened = [];
43
+
44
+ steps.forEach(s => {
45
+ if (s.type == "single") {
46
+ flattened.push(s);
47
+ } else if (s.type == "group") {
48
+ flattened.push(...flattenSteps(s.steps));
49
+ }
50
+ });
51
+
52
+ return flattened;
53
+ }
54
+ const flattenedSteps = flattenSteps(this.props.stepData);
55
+
56
+ const filterRelated = flattenedSteps.filter(step => this.props.selectedNode != null &&
57
+ step.nodes.includes(this.props.selectedNode)).length > 0;
58
+
59
+
60
+ const renderStep = (step) => {
61
+ if (step.type == "single") {
62
+ let matches = false;
63
+ let related = false;
64
+ if (this.props.selectedNode != null) {
65
+ related = step.nodes.includes(this.props.selectedNode);
66
+ }
67
+ matches = currentStep != null && step.id === currentStep.id;
68
+ return <TocStep matches={matches}
69
+ filterRelated={filterRelated}
70
+ related={related}
71
+ step={step}
72
+ updateStep={this.props.updateStep}>
73
+ </TocStep>
74
+ } else if (step.type == "group") {
75
+ return (
76
+ <li>
77
+ <span><i>({step.groupName})</i> {step.description}</span>
78
+ <ol class="custom-list">
79
+ {step.steps.map(renderStep)}
80
+ </ol>
81
+ </li>
82
+ );
83
+ }
84
+
85
+ }
86
+
87
+ const stepLi = this.props.stepData.map(renderStep);
88
+
89
+ let emptyMsg;
90
+ let msgStyle = {
91
+ textAlign: 'center'
92
+ };
93
+
94
+ if (stepLi.length == 0) {
95
+ emptyMsg = <p style={msgStyle}> add steps to the JSON file if you want to step through a flow</p>
96
+ } else {
97
+ emptyMsg = null;
98
+ }
99
+
100
+ return (
101
+ <div id="table-of-contents"
102
+ style={tableOfContentsStyle}
103
+ className="sub-container-border"
104
+ ref={(div) => { this.scrolldiv = div }}>
105
+ {emptyMsg}
106
+ <ol class="custom-list">
107
+ {stepLi}
108
+ </ol>
109
+ </div>
110
+ )
111
+ }
112
+ }