Skip to content
Snippets Groups Projects
Commit 83cf5f80 authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Erwan Rouchet
Browse files

Add separator + confirm modals in the process status actions

parent 4e91cded
No related branches found
No related tags found
1 merge request!1683Add separator + confirm modals in the process status actions
...@@ -33,36 +33,38 @@ ...@@ -33,36 +33,38 @@
<div class="dropdown-menu"> <div class="dropdown-menu">
<div class="dropdown-content"> <div class="dropdown-content">
<template v-if="finishedProcess"> <template v-if="finishedProcess">
<router-link
v-if="process.element"
class="dropdown-item"
:to="{ name: 'element-details', params: { id: process.element.id } }"
>
<i class="icon-arrow-right"></i>
View element
</router-link>
<a <a
class="dropdown-item" class="dropdown-item"
:class="!hasAdminAccess ? 'is-disabled' : ''" :class="!hasAdminAccess ? 'is-disabled' : ''"
v-if="isVerified" v-if="isVerified"
v-on:click="retry" v-on:click="retryAction"
:title="hasAdminAccess ? 'Retry this entire process' : 'An admin access is required to retry this process'" :title="hasAdminAccess ? 'Retry this entire process' : 'An admin access is required to retry this process'"
> >
<i class="icon-undo"></i> <i class="icon-undo"></i>
Retry process Retry process
</a> </a>
<hr class="navbar-divider" />
<router-link
v-if="process.element"
class="dropdown-item"
:to="{ name: 'element-details', params: { id: process.element.id } }"
>
<i class="icon-arrow-right"></i>
View element
</router-link>
</template> </template>
<template v-else-if="activeProcess"> <template v-else-if="activeProcess">
<a <a
class="dropdown-item has-text-danger" class="dropdown-item has-text-danger"
:class="!isVerified ? 'is-disabled' : ''" :class="!isVerified ? 'is-disabled' : ''"
v-if="isVerified" v-if="isVerified"
v-on:click="stop" v-on:click="stopAction"
:title="hasAdminAccess ? 'Stop this process' : 'An admin access is required to stop this process'" :title="hasAdminAccess ? 'Stop this process' : 'An admin access is required to stop this process'"
> >
<i class="icon-minus"></i> <i class="icon-minus"></i>
Stop process Stop process
</a> </a>
<hr class="navbar-divider" />
</template> </template>
<router-link <router-link
:to="hasActivities ? { name: 'process-workers-activity', params: { processId: process.id } } : ''" :to="hasActivities ? { name: 'process-workers-activity', params: { processId: process.id } } : ''"
...@@ -148,6 +150,24 @@ ...@@ -148,6 +150,24 @@
:selected-run="selectedRun" :selected-run="selectedRun"
/> />
</template> </template>
<Modal v-model="confirmModal" :title="confirmModalTitle">
<span>
Are you sure you want to <strong>{{ confirmAction }}</strong> process {{ truncateShort(process.name) || process.id }}?
</span>
<br />
<span>This action is irreversible.</span>
<template v-slot:footer="{ close }">
<button class="button" v-on:click="close">Cancel</button>
<button
class="button"
:class="{ 'is-loading': loading, 'is-danger': confirmAction === 'stop', 'is-primary': confirmAction === 'retry' }"
v-on:click="confirmedAction"
>
{{ confirmAction }}
</button>
</template>
</Modal>
</main> </main>
</template> </template>
...@@ -161,17 +181,19 @@ import { ...@@ -161,17 +181,19 @@ import {
PROCESS_STATE_COLORS, PROCESS_STATE_COLORS,
PROCESS_FINAL_STATES PROCESS_FINAL_STATES
} from '@/config' } from '@/config'
import { corporaMixin } from '@/mixins' import { corporaMixin, truncateMixin } from '@/mixins'
import { errorParser } from '@/helpers' import { errorParser } from '@/helpers'
import ItemId from '@/components/ItemId' import ItemId from '@/components/ItemId'
import NameField from '@/components/Process/Status/NameField' import NameField from '@/components/Process/Status/NameField'
import Run from '@/components/Process/Status/Run' import Run from '@/components/Process/Status/Run'
import TemplateCreation from '@/components/Process/TemplateCreation' import TemplateCreation from '@/components/Process/TemplateCreation'
import Modal from '@/components/Modal.vue'
export default { export default {
mixins: [ mixins: [
corporaMixin corporaMixin,
truncateMixin
], ],
props: { props: {
id: { id: {
...@@ -187,13 +209,16 @@ export default { ...@@ -187,13 +209,16 @@ export default {
ItemId, ItemId,
NameField, NameField,
Run, Run,
TemplateCreation TemplateCreation,
Modal
}, },
data: () => ({ data: () => ({
PENDING_ACTIVITY_STATE: 'pending', PENDING_ACTIVITY_STATE: 'pending',
READY_ACTIVITY_STATE: 'ready', READY_ACTIVITY_STATE: 'ready',
loading: false, loading: false,
error: '' error: '',
confirmModal: false,
confirmAction: ''
}), }),
mounted () { mounted () {
if ('Notification' in window) Notification.requestPermission() if ('Notification' in window) Notification.requestPermission()
...@@ -205,6 +230,25 @@ export default { ...@@ -205,6 +230,25 @@ export default {
...mapActions('process', ['startPolling']), ...mapActions('process', ['startPolling']),
...mapMutations('process', ['setProcesses', 'stopPolling']), ...mapMutations('process', ['setProcesses', 'stopPolling']),
...mapMutations('notifications', ['notify']), ...mapMutations('notifications', ['notify']),
retryAction () {
this.confirmModal = true
this.confirmAction = 'retry'
},
stopAction () {
this.confirmModal = true
this.confirmAction = 'stop'
},
async confirmedAction () {
if (this.confirmAction === 'stop') {
await this.stop()
this.confirmModal = false
this.confirmAction = ''
} else if (this.confirmAction === 'retry') {
await this.retry()
this.confirmModal = false
this.confirmAction = ''
} else this.notify({ type: 'error', text: `Unknown action ${this.confirmAction}` })
},
async retry () { async retry () {
if (!this.hasAdminAccess || !this.process.id || this.loading) return if (!this.hasAdminAccess || !this.process.id || this.loading) return
try { try {
...@@ -320,6 +364,10 @@ export default { ...@@ -320,6 +364,10 @@ export default {
createTemplateTitle () { createTemplateTitle () {
if (!this.canCreateTemplate) return 'Templates can only be created from worker or dataset processes' if (!this.canCreateTemplate) return 'Templates can only be created from worker or dataset processes'
return 'Create a template based on this process' return 'Create a template based on this process'
},
confirmModalTitle () {
const capitalizedAction = this.confirmAction.charAt(0).toUpperCase() + this.confirmAction.slice(1)
return `${capitalizedAction} process ${this.truncateShort(this.process.name) || this.process.id}`
} }
}, },
watch: { watch: {
......
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