Skip to content

Commit 8ad1009

Browse files
authored
ui: fix notification list reordering intermittently (apache#7609)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent a070227 commit 8ad1009

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

ui/src/components/header/HeaderNotice.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default {
109109
(state, getters) => getters.headerNotices,
110110
(newValue, oldValue) => {
111111
if (oldValue !== newValue && newValue !== undefined) {
112-
this.notices = newValue.reverse()
112+
this.notices = newValue
113113
}
114114
}
115115
)

ui/src/store/modules/user.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,13 @@ const user = {
348348
if (noticeIdx === -1) {
349349
noticeArray.push(noticeJson)
350350
} else {
351+
const existingNotice = noticeArray[noticeIdx]
352+
noticeJson.timestamp = existingNotice.timestamp
351353
noticeArray[noticeIdx] = noticeJson
352354
}
353-
355+
noticeArray.sort(function (a, b) {
356+
return new Date(b.timestamp) - new Date(a.timestamp)
357+
})
354358
commit('SET_HEADER_NOTICES', noticeArray)
355359
},
356360
ProjectView ({ commit }, projectid) {

ui/src/utils/plugins.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export const pollJobPlugin = {
6565
key: jobId,
6666
title,
6767
description,
68-
status: 'progress'
68+
status: 'progress',
69+
timestamp: new Date()
6970
})
7071

7172
eventBus.on('update-job-details', (args) => {
@@ -107,7 +108,8 @@ export const pollJobPlugin = {
107108
title,
108109
description,
109110
status: 'done',
110-
duration: 2
111+
duration: 2,
112+
timestamp: new Date()
111113
})
112114
eventBus.emit('update-job-details', { jobId, resourceId })
113115
// Ensure we refresh on the same / parent page
@@ -157,7 +159,8 @@ export const pollJobPlugin = {
157159
title,
158160
description: desc,
159161
status: 'failed',
160-
duration: 2
162+
duration: 2,
163+
timestamp: new Date()
161164
})
162165
eventBus.emit('update-job-details', { jobId, resourceId })
163166
// Ensure we refresh on the same / parent page

0 commit comments

Comments
 (0)