Skip to content

Commit 67377c4

Browse files
committed
show run action result
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent cace6cd commit 67377c4

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

ui/src/utils/plugins.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const pollJobPlugin = {
3232
* @param {String} [name='']
3333
* @param {String} [title='']
3434
* @param {String} [description='']
35+
* @param {Boolean} [showSuccessMessage=true]
3536
* @param {String} [successMessage=Success]
3637
* @param {Function} [successMethod=() => {}]
3738
* @param {String} [errorMessage=Error]
@@ -49,6 +50,7 @@ export const pollJobPlugin = {
4950
name = '',
5051
title = '',
5152
description = '',
53+
showSuccessMessage = true,
5254
successMessage = i18n.global.t('label.success'),
5355
successMethod = () => {},
5456
errorMessage = i18n.global.t('label.error'),
@@ -92,18 +94,20 @@ export const pollJobPlugin = {
9294
const result = json.queryasyncjobresultresponse
9395
eventBus.emit('update-job-details', { jobId, resourceId })
9496
if (result.jobstatus === 1) {
95-
var content = successMessage
96-
if (successMessage === 'Success' && action && action.label) {
97-
content = i18n.global.t(action.label)
98-
}
99-
if (name) {
100-
content = content + ' - ' + name
97+
if (showSuccessMessage) {
98+
var content = successMessage
99+
if (successMessage === 'Success' && action && action.label) {
100+
content = i18n.global.t(action.label)
101+
}
102+
if (name) {
103+
content = content + ' - ' + name
104+
}
105+
message.success({
106+
content,
107+
key: jobId,
108+
duration: 2
109+
})
101110
}
102-
message.success({
103-
content,
104-
key: jobId,
105-
duration: 2
106-
})
107111
store.dispatch('AddHeaderNotice', {
108112
key: jobId,
109113
title,

ui/src/views/extension/RunCustomAction.vue

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
</a-select-option>
4343
</a-select>
4444
</a-form-item>
45-
<a-card v-if="form.customactionid" style="margin-bottom: 10px;">
45+
<a-card v-if="form.customactionid && (!!currentDescription || !!currentParameters && currentParameters.length > 0)" style="margin-bottom: 10px;">
4646
<div v-if="!!currentDescription">
4747
{{ currentDescription }}
48-
<a-divider />
48+
<a-divider v-if="!!currentParameters && currentParameters.length > 0"/>
4949
</div>
5050
<div v-for="(field, fieldIndex) in currentParameters" :key="fieldIndex">
5151
<a-form-item :name="field.name" :ref="field.name">
@@ -99,7 +99,7 @@
9999
</template>
100100

101101
<script>
102-
import { ref, reactive, toRaw } from 'vue'
102+
import { ref, reactive, toRaw, h } from 'vue'
103103
import { api } from '@/api'
104104
import TooltipLabel from '@/components/widgets/TooltipLabel'
105105
import DetailsInput from '@/components/widgets/DetailsInput'
@@ -249,24 +249,40 @@ export default {
249249
jobId: response.runcustomactionresponse.jobid,
250250
title: this.currentAction.name || this.$t('label.run.custom.action'),
251251
description: this.currentAction.description || this.currentAction.name,
252+
showSuccessMessage: false,
252253
successMethod: (result) => {
253254
this.$emit('refresh-data')
254255
const actionResponse = result.jobresult?.customactionresult || {}
255256
const success = actionResponse.success || false
256-
const message = actionResponse?.result?.message || (success ? 'success' : 'fail')
257-
if (actionResponse.success) {
258-
this.$notification.success({
259-
message: this.currentAction.name || this.$t('label.run.custom.action'),
260-
description: message,
261-
duration: 0
262-
})
263-
} else {
264-
this.$notification.error({
265-
message: this.currentAction.name || this.$t('label.run.custom.action'),
266-
description: message,
267-
duration: 0
268-
})
269-
}
257+
const message = actionResponse?.result?.message || (success ? 'Success' : 'Failed')
258+
let details = actionResponse?.result?.details
259+
try {
260+
details = JSON.stringify(JSON.parse(details), null, 2)
261+
} catch (_) {}
262+
const modalType = success ? this.$success : this.$error
263+
modalType({
264+
title: this.currentAction.name || this.$t('label.run.custom.action'),
265+
content: h('div', [
266+
h('p', `${message}`),
267+
details
268+
? h('div', {
269+
style: {
270+
marginTop: '1em',
271+
maxHeight: '50vh',
272+
overflowY: 'auto',
273+
backgroundColor: '#f6f6f6',
274+
padding: '12px',
275+
borderRadius: '4px',
276+
fontFamily: 'monospace',
277+
whiteSpace: 'pre-wrap',
278+
wordBreak: 'break-word'
279+
}
280+
}, details)
281+
: null
282+
]),
283+
width: '700px',
284+
okText: this.$t('label.ok')
285+
})
270286
},
271287
errorMessage: this.currentAction.name || this.$t('label.run.custom.action'),
272288
loadingMessage: this.$t('message.running.custom.action'),

0 commit comments

Comments
 (0)