Skip to content

Commit 39d8f17

Browse files
authored
Add rerun to ticket action (#68)
1 parent 8136e56 commit 39d8f17

5 files changed

Lines changed: 63 additions & 5 deletions

File tree

frontend/src/components/DynamicForm.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ export default {
2222
components: {AFormItem, NumberInput, TextInput, SelectInput, CheckBoxInput},
2323
props: ['schema', 'value'],
2424
data () {
25-
return {
26-
formData: this.value || {}
25+
return {}
26+
},
27+
computed: {
28+
formData: function () {
29+
return this.value || {}
2730
}
2831
},
2932
methods: {
30-
updateForm (fieldName, value) {
31-
this.$set(this.formData, fieldName, value)
33+
updateForm (fieldName, v) {
34+
this.$set(this.formData, fieldName, v)
3235
this.$emit('input', this.formData)
3336
}
3437
}

frontend/src/components/FormWidgets/SelectInput.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export default {
3434
selectedValues: []
3535
}
3636
},
37+
watch: {
38+
value: function () {
39+
if (this.selectedValues.join(',') != this.value) {
40+
this.selectedValues = this.value.split(',')
41+
}
42+
}
43+
},
3744
methods: {
3845
handleInput (event) {
3946
let realValue = event.join()

frontend/src/components/HForm.vue

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
@submit="handleSubmit">
2121
<dynamic-form
2222
:schema="schema"
23+
:value="formData"
2324
@input="handleInput">
2425
</dynamic-form>
2526
<a-form-item
@@ -131,6 +132,38 @@ export default {
131132
HRequest.get('/api/action/' + this.actionName).then(
132133
(response) => this.formDefinitionHandler(response)
133134
)
135+
136+
const queryParams = this.$route.query
137+
if (queryParams.backfill && Number(queryParams.backfill) > 0) {
138+
const notificationTitle = "Rerun ticket " + queryParams.backfill + " error"
139+
HRequest.get('/api/ticket/' + queryParams.backfill).then(
140+
(response) => {
141+
const ticketsLen = response.data.data.tickets.length
142+
if (ticketsLen == 1) {
143+
const isTheSameAction = this.$route.path.endsWith(response.data.data.tickets[0].provider_object)
144+
const ticket = response.data.data.tickets[0]
145+
if (isTheSameAction) {
146+
this.handleInput(ticket.params)
147+
} else {
148+
this.errorAsNotification(
149+
notificationTitle,
150+
"The backfill ticket should be the same action ticket, but ticket " + queryParams.backfill + "'s action was: " + ticket.provider_object
151+
)
152+
}
153+
} else {
154+
this.errorAsNotification(
155+
"Rerun ticket " + queryParams.backfill + " error",
156+
"Expect exactly 1 ticket info but got " + ticketsLen + "item(s)"
157+
)
158+
}
159+
}
160+
).catch((error) => {
161+
this.errorAsNotification(
162+
notificationTitle,
163+
error.response.data.data.description
164+
)
165+
})
166+
}
134167
},
135168
resetForm () {
136169
this.form.resetFields()
@@ -223,7 +256,16 @@ export default {
223256
},
224257
gotoTicketDetail () {
225258
this.$router.push({ name: 'HTicketDetail', params: { id: this.submitResponse.ticket.id }})
226-
}
259+
},
260+
errorAsNotification (title, rawMsg) {
261+
const msg = rawMsg.length > 300 ? rawMsg.slice(0, 300) + '... ' : rawMsg
262+
this.$notification.title = rawMsg
263+
this.$notification.open({
264+
message: title,
265+
description: msg,
266+
duration: 0
267+
})
268+
},
227269
},
228270
229271
mounted () {

frontend/src/components/HTicketDetail.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<a-button @click="onApprove" type="primary">Approve</a-button>
8787
</a-button-group>
8888
<a-button v-show="showResultButton" :style="{ marginLeft: '16px' }" @click="toggleResult">{{resultButtonText}}</a-button>
89+
<a-button v-show="showResultButton" :style="{ marginLeft: '5px' }" @click="rerunTicket">Rerun</a-button>
8990
<a-button v-show="resultVisible" :style="{ marginLeft: '5px' }" @click="loadTResult">Refresh</a-button>
9091

9192
<a-switch v-show="resultVisible" :style="{ marginLeft: '5px' }"
@@ -288,6 +289,9 @@ export default {
288289
this.loadTickets()
289290
this.$refs.ticketResult.loadResult(callback)
290291
},
292+
rerunTicket () {
293+
this.$router.push({ name: 'FormView', params: { name: this.ticketInfo.provider_object }, query: { backfill: this.ticketInfo.id }})
294+
},
291295
isTicketEndStatus() {
292296
const ticketStatus = this.ticketInfo.status
293297
return (ticketStatus

frontend/src/components/HTicketList.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
</span>
5353

5454
<a :href="record.url">detail</a>
55+
<a-divider type="vertical" />
56+
<router-link :to="{ name: 'FormView', params: { name: record.provider_object }, query: { backfill: record.id }}">rerun</router-link>
5557
</span>
5658
</a-table>
5759
<a-modal

0 commit comments

Comments
 (0)