Skip to content
Snippets Groups Projects
Commit 2bc2dec4 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Fix a race condition in the process configuration page

parent 15fc66fd
No related branches found
No related tags found
1 merge request!1587Fix a race condition in the process configuration page
......@@ -318,21 +318,8 @@ export default {
workerActivity: true,
useGPU: false
}),
async mounted () {
await this.getProcess()
if (['dataset', 'workers'].includes(this.process?.mode)) {
if (this.hasAdminAccess) this.listWorkerRuns({ processId: this.id })
} else if (this.process?.started) {
/*
* This process has started: replace this route with the process status page,
* unless we were coming from the status page or one of the process configuration pages.
*/
if (['process-details', 'process-filter', 'process-configure', 'process-datasets'].includes(this.$route.redirectedFrom?.name)) this.$router.back()
else this.$router.replace({ name: 'process-details', params: { id: this.process.id } })
} else {
this.$router.replace({ name: 'not-found' })
}
mounted () {
this.getProcess()
},
computed: {
...mapVuexState('process', [
......@@ -349,7 +336,7 @@ export default {
return this.process?.corpus
},
hasAdminAccess () {
if (this.process) return this.canAdmin(this.corpus)
if (this.process && this.corpusId) return this.canAdmin(this.corpus)
return true
},
isReadOnly () {
......@@ -513,6 +500,26 @@ export default {
}
},
watch: {
process: {
immediate: true,
async handler (newValue, oldValue) {
if (!newValue || newValue.id === oldValue?.id) return
if (['dataset', 'workers'].includes(newValue.mode)) {
// Make sure we have the corpora available before checking for access
await this.$store.dispatch('corpora/list')
if (this.hasAdminAccess) this.listWorkerRuns({ processId: newValue.id })
} else if (newValue.started) {
/*
* This process has started: replace this route with the process status page,
* unless we were coming from the status page or one of the process configuration pages.
*/
if (['process-details', 'process-filter', 'process-configure', 'process-datasets'].includes(this.$route.redirectedFrom?.name)) this.$router.back()
else this.$router.replace({ name: 'process-details', params: { id: newValue.id } })
} else {
this.$router.replace({ name: 'not-found' })
}
}
},
currentProcessWorkerRuns: {
immediate: true,
handler (newRuns, oldRuns = []) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment