Fix web dequeue of post items

This is a partial revert of 6c1c91f8ba
which relied on change.id being absent in the case that a queue item
was for a non-change ref; however, all queue items have an id.  This
reverts that section of code back to the previous regex-based
heuristic.

Change-Id: I07ff7c2925b44a7e85529491755b2f3d3f73eaf8
This commit is contained in:
James E. Blair 2024-03-15 07:37:24 -07:00
parent 4680c58a27
commit c92b2c2221
1 changed files with 16 additions and 8 deletions

View File

@ -75,7 +75,16 @@ class Item extends React.Component {
let refRef = ref.ref
this.setState(() => ({ showDequeueModal: false }))
// post-merge
if (refId !== 'N/A') {
if (/^[0-9a-f]{40}$/.test(refId)) {
dequeue_ref(tenant.apiPrefix, projectName, pipeline.name, refRef)
.then(() => {
this.props.dispatch(fetchStatusIfNeeded(tenant))
})
.catch(error => {
this.props.dispatch(addDequeueError(error))
})
// pre-merge, ie we have a change id
} else if (refId !== 'N/A') {
dequeue(tenant.apiPrefix, projectName, pipeline.name, refId)
.then(() => {
this.props.dispatch(fetchStatusIfNeeded(tenant))
@ -84,13 +93,12 @@ class Item extends React.Component {
this.props.dispatch(addDequeueError(error))
})
} else {
dequeue_ref(tenant.apiPrefix, projectName, pipeline.name, refRef)
.then(() => {
this.props.dispatch(fetchStatusIfNeeded(tenant))
})
.catch(error => {
this.props.dispatch(addDequeueError(error))
})
this.props.dispatch(addNotification({
url: null,
status: 'Invalid change ' + refRef + ' on project ' + projectName,
text: '',
type: 'error',
}))
}
}