Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 2381194

Browse files
committed
fixes: wsk list poorly formatted for triggers, rules, and packages
Fixes #858
1 parent 41fc636 commit 2381194

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

app/content/js/repl.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ const formatOneListResult = options => (entity, idx, A) => {
137137
|| (() => self.pexec(`wsk ${entity.type} get "/${entity.namespace}/${entity.name}"`))
138138
}
139139

140+
const addKind = kind => addCell('entity-kind green-text', kind, 'deemphasize deemphasize-partial')
141+
const addVersion = () => entity.version && addCell('entity-version', entity.version, 'deemphasize')
142+
140143
//
141144
// case-specific cells
142145
//
@@ -147,18 +150,41 @@ const formatOneListResult = options => (entity, idx, A) => {
147150
// action-specific cells
148151
const kind = entity.annotations.find(({key}) => key === 'exec')
149152
if (kind || entity.prettyKind) {
150-
addCell('entity-kind green-text', entity.prettyKind || kind.value, 'deemphasize deemphasize-partial')
153+
addKind(entity.prettyKind || kind.value)
154+
}
155+
156+
if (entity.prettyType === 'sequence') {
157+
setTimeout(() => {
158+
repl.qexec(`wsk action get "/${entity.namespace}/${entity.name}"`)
159+
.then(action => {
160+
if (action.exec && action.exec.components) {
161+
const ns = new RegExp('^/' + namespace.current() + '/')
162+
addCell('entity-sequence-components',
163+
action.exec.components
164+
.map(_ => _.replace(ns, ''))
165+
.join(' \u27f6 ')) // ->
166+
167+
} else {
168+
addVersion()
169+
}
170+
})
171+
}, 0)
172+
173+
} else {
174+
addVersion()
151175
}
152-
addCell('entity-version', entity.version, 'deemphasize')
153176
} else if (entity.type === 'rules') {
154177
// rule-specific cells
155178
setTimeout(() => {
156179
repl.qexec(`wsk rule get "/${entity.namespace}/${entity.name}"`)
157180
.then(rule => {
158-
addCell(`entity-rule-status ${rule.status==='active' ? 'green-text' : 'red-text'}`, rule.status, 'deemphasize')
181+
addCell(`entity-rule-status ${rule.status==='active' ? 'green-text' : 'red-text'}`, rule.status, 'deemphasize deemphasize-partial')
159182
addCell('entity-rule-definition', `${rule.trigger.name} \u27fc ${rule.action.name}`)
160183
})
161184
}, 0)
185+
} else if (entity.type) {
186+
addKind(entity.prettyType || entity.type.replace(/s$/, ''))
187+
addVersion()
162188
}
163189

164190
return dom

0 commit comments

Comments
 (0)