Skip to content

Commit 3f54f42

Browse files
authored
refactor getKeyValuePairs helper for pending tasks change (#271)
1 parent a7ba81f commit 3f54f42

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

client/components/domain-navigation.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ export default {
111111
this.validation = 'pending';
112112
this.domainDescRequest = this.getDomainDesc(newDomain)
113113
.then(
114-
desc => {
114+
item => {
115115
this.domainDescName = newDomain;
116116
this.domainDesc = {
117-
kvps: getKeyValuePairs(desc),
117+
kvps: getKeyValuePairs({ item }),
118118
};
119119
120120
return 'valid';
@@ -151,10 +151,10 @@ export default {
151151
.catch(res => ({
152152
error: `${res.statusText || res.message} ${res.status}`,
153153
}))
154-
.then(desc => {
154+
.then(item => {
155155
if (this.domainDescName === d) {
156156
this.domainDesc = {
157-
kvps: getKeyValuePairs(desc),
157+
kvps: getKeyValuePairs({ item }),
158158
};
159159
this.domainDescRequest = null;
160160
}

client/helpers/get-key-value-pairs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import moment from 'moment';
2323
import getJsonStringObject from './get-json-string-object';
2424
import { jsonKeys, preKeys } from '~constants';
2525

26-
const getKeyValuePairs = event => {
26+
const getKeyValuePairs = ({ excludes = [], item }) => {
2727
const kvps = [];
2828
const flatten = (prefix, obj, root) => {
2929
Object.entries(obj).forEach(([k, value]) => {
@@ -33,6 +33,10 @@ const getKeyValuePairs = event => {
3333

3434
const key = prefix ? `${prefix}.${k}` : k;
3535

36+
if (excludes.includes(key)) {
37+
return;
38+
}
39+
3640
if (value.routeLink) {
3741
kvps.push({
3842
key,
@@ -108,7 +112,7 @@ const getKeyValuePairs = event => {
108112
});
109113
};
110114

111-
flatten('', event || {}, event);
115+
flatten('', item || {}, item);
112116

113117
return kvps;
114118
};

client/routes/domain/domain-settings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default {
4040
.then(
4141
r => {
4242
const domainConfig = mapDomainDescription(r);
43-
const kvps = getKeyValuePairs(domainConfig);
43+
const kvps = getKeyValuePairs({ item: domainConfig });
4444
4545
this.domainConfig = { ...domainConfig, kvps };
4646
},

client/routes/workflow/helpers/get-event-details.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ const getEventDetails = ({
3232
const { kvps, isHighlighted } = getEventKvpsHighlight({
3333
eventType,
3434
kvps: getKeyValuePairs({
35-
timestamp: timeStampDisplay,
36-
eventId,
37-
...details,
35+
item: {
36+
timestamp: timeStampDisplay,
37+
eventId,
38+
...details,
39+
},
3840
}),
3941
workflowHistoryEventHighlightList,
4042
workflowHistoryEventHighlightListEnabled,

client/routes/workflow/helpers/get-event-full-details.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const getEventFullDetails = ({
4343

4444
const { kvps, isHighlighted } = getEventKvpsHighlight({
4545
eventType,
46-
kvps: getKeyValuePairs(item),
46+
kvps: getKeyValuePairs({ item }),
4747
workflowHistoryEventHighlightList,
4848
workflowHistoryEventHighlightListEnabled,
4949
});

client/routes/workflow/helpers/get-event-summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const getEventSummary = event => {
4040
? maps[event.eventType](event.details)
4141
: event.details;
4242

43-
const kvps = getKeyValuePairs(item);
43+
const kvps = getKeyValuePairs({ item });
4444

4545
return {
4646
...item,

client/routes/workflow/helpers/get-summary.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const getSummary = ({ events, isWorkflowRunning, workflow }) => {
2727
const formattedWorkflow = workflow.pendingActivities
2828
? {
2929
...workflow,
30-
pendingActivities: workflow.pendingActivities.map(pendingActivity => ({
31-
...pendingActivity,
32-
kvps: getKeyValuePairs(pendingActivity),
30+
pendingActivities: workflow.pendingActivities.map(item => ({
31+
...item,
32+
kvps: getKeyValuePairs({ item }),
3333
})),
3434
}
3535
: workflow;

0 commit comments

Comments
 (0)