Skip to content

Commit e38f40e

Browse files
authored
Investigate infinite page loading (#76)
* initial refactoring to improve grid and compact table performance. Will reenable graph in a later commit. * More refactoring to make code easier to read. * refactoring and fixing breaking changes. * removing and passing down props to children * fixing bugs from refactor * adding simple toggle for graph to help with initial page performance. * adding changes from other branch. * adding sticky config for toggle graph * renaming files to match coding standards * adding jest for unit testing. * adding more tests * more tests * adding tests * adding more tests and refactoring injection code * adding more tests * adding more tests * adding tests * 3.6.0-beta.2 * need to declair props that are unused otherwise it pollutes the dom * putting in extra protections so tests dont fail. * adding more saftey checks * tweaking show graph so that it allows url param to control value * temporary fix for glitchy graphing library * fixing tests by setting showGraph in query params * fixing more tests * fixing tests * 3.6.0-beta.3 * fixing timestamp bug. removing TODOs. fixed bug when timeline isnt created and destroy called. * changes ready for PR * getting code ready for PR * refactoring * refactoring * refactoring * refactoring * fixing null equals bug * fixing null and undefined bug * fixing tests * fixing router to pass props to specific children views correctly. * adding end-of-file space * adding undefined check for double equals null check * 3.6.0-beta.4 * 3.6.0
1 parent d733d1d commit e38f40e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2266
-933
lines changed

.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [[
3+
"env",
4+
{
5+
"targets": {
6+
"node": "current"
7+
}
8+
}
9+
]]
10+
}

client/constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const jsonKeys = ['result', 'input', 'details', 'data', 'Error'];
2+
export const preKeys = jsonKeys.concat(['stackTrace', 'details.stackTrace']);
3+
4+
export const MAXIMUM_JSON_CHARACTER_LIMIT = 5000;
5+
export const MAXIMUM_JSON_MESSAGE = '\n ... to see more open full screen mode from top right arrow.';

client/helpers/__mocks__/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const getKeyValuePairs = jest.fn().mockImplementation(() => 'kvpsMock');
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import getStringElipsis from './get-string-elipsis';
2+
3+
const getJsonStringObject = (value) => {
4+
const jsonStringFull = value ? JSON.stringify(value, null, 2) : '';
5+
const jsonStringDisplay = value ? getStringElipsis(jsonStringFull) : '';
6+
return {
7+
jsonStringDisplay,
8+
jsonStringFull,
9+
};
10+
};
11+
12+
export default getJsonStringObject;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import {
2+
jsonKeys,
3+
preKeys,
4+
} from '../constants';
5+
import moment from 'moment';
6+
import getJsonStringObject from './get-json-string-object';
7+
8+
const getKeyValuePairs = event => {
9+
const kvps = [];
10+
const flatten = (prefix, obj, root) => {
11+
Object.entries(obj).forEach(([k, value]) => {
12+
if (value === null || value === undefined) {
13+
return;
14+
}
15+
const key = prefix ? `${prefix}.${k}` : k;
16+
17+
if (value.routeLink) {
18+
kvps.push({
19+
key,
20+
routeLink: value.routeLink,
21+
value: value.text,
22+
});
23+
} else if (typeof value === 'object' && !jsonKeys.includes(key)) {
24+
flatten(key, value, root);
25+
} else if (key === 'newExecutionRunId') {
26+
kvps.push({
27+
key,
28+
routeLink: {
29+
name: 'execution/summary',
30+
params: {
31+
runId: value,
32+
},
33+
},
34+
value,
35+
});
36+
} else if (key === 'parentWorkflowExecution.runId') {
37+
kvps.push({
38+
key,
39+
routeLink: {
40+
name: 'execution/summary',
41+
params: {
42+
domain: root.parentWorkflowDomain,
43+
runId: value,
44+
workflowId: root.parentWorkflowExecution.workflowId,
45+
},
46+
},
47+
value,
48+
});
49+
} else if (key === 'workflowExecution.runId') {
50+
kvps.push({
51+
key,
52+
routeLink: {
53+
name: 'execution/summary',
54+
params: {
55+
domain: root.domain,
56+
runId: value,
57+
workflowId: root.workflowExecution.workflowId,
58+
},
59+
},
60+
value,
61+
});
62+
} else if (key === 'taskList.name' || key === 'Tasklist') {
63+
kvps.push({
64+
key,
65+
routeLink: {
66+
name: 'task-list',
67+
params: {
68+
taskList: value,
69+
},
70+
},
71+
value,
72+
});
73+
} else if (/.+TimeoutSeconds/.test(key)) {
74+
kvps.push({
75+
key: key.replace(/Seconds$/, ''),
76+
value: moment.duration(value, 'seconds').format(),
77+
});
78+
} else if (preKeys.includes(k)) {
79+
kvps.push({
80+
key,
81+
value: getJsonStringObject(value),
82+
});
83+
} else {
84+
kvps.push({
85+
key,
86+
value,
87+
});
88+
}
89+
});
90+
};
91+
92+
flatten('', event || {}, event);
93+
return kvps;
94+
};
95+
96+
export default getKeyValuePairs;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {
2+
MAXIMUM_JSON_CHARACTER_LIMIT,
3+
MAXIMUM_JSON_MESSAGE,
4+
} from '../constants';
5+
6+
const getStringElipsis = input =>
7+
input.length < MAXIMUM_JSON_CHARACTER_LIMIT
8+
? input
9+
: input.substring(0, MAXIMUM_JSON_CHARACTER_LIMIT) + MAXIMUM_JSON_MESSAGE;
10+
11+
export default getStringElipsis;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import getStringElipsis from './get-string-elipsis';
2+
import {
3+
MAXIMUM_JSON_CHARACTER_LIMIT,
4+
MAXIMUM_JSON_MESSAGE,
5+
} from '../constants';
6+
7+
describe('getStringElipsis', () => {
8+
describe('when passed a string that has a length less than MAXIMUM_JSON_CHARACTER_LIMIT', () => {
9+
it('should return the original string', () => {
10+
const input = 'a-short-string';
11+
const output = getStringElipsis(input);
12+
expect(output).toEqual('a-short-string');
13+
});
14+
});
15+
describe('when passed a string that has a length equal to MAXIMUM_JSON_CHARACTER_LIMIT', () => {
16+
it('should return a substring of the original string up until the limit and display a message.', () => {
17+
const input = ''.padEnd(MAXIMUM_JSON_CHARACTER_LIMIT, '_');
18+
const output = getStringElipsis(input);
19+
expect(output).toEqual(input + MAXIMUM_JSON_MESSAGE);
20+
});
21+
});
22+
});

client/helpers/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export { default as getJsonStringObject } from './get-json-string-object';
2+
export { default as getKeyValuePairs } from './get-key-value-pairs';
3+
export { default as getStringElipsis } from './get-string-elipsis';
4+
export { default as injectMomentDurationFormat } from './inject-moment-duration-format';
5+
export { default as jsonTryParse } from './json-try-parse';
6+
export { default as mapDomainDescription } from './map-domain-description';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import moment from 'moment';
2+
3+
const injectMomentDurationFormat = () => {
4+
Object.getPrototypeOf(moment.duration(2, 'seconds')).format = function () {
5+
return this.toString().toLowerCase()
6+
.replace(/[pt]/g, '')
7+
.replace(/([hmd])/g, '$1 ')
8+
.replace(/\.\d{1,3}s/, 's')
9+
.replace('0d ', '')
10+
.trim();
11+
};
12+
};
13+
14+
export default injectMomentDurationFormat;

client/helpers/json-try-parse.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function jsonTryParse() {
2+
try {
3+
return JSON.parse.apply(this, arguments)
4+
} catch (e) { }
5+
};
6+
7+
export default jsonTryParse;

0 commit comments

Comments
 (0)