Files
baserow/web-frontend/modules/automation/components/sidebar/SidebarComponentAutomation.vue

106 lines
2.9 KiB
Vue

<template>
<div>
<SidebarApplication
ref="sidebarApplication"
:workspace="workspace"
:application="application"
>
<template #body>
<client-only>
<ul class="tree__subs">
<SidebarItemAutomation
v-for="workflow in orderedWorkflows"
:key="workflow.id"
v-sortable="{
id: workflow.id,
update: orderWorkflows,
marginTop: -1.5,
enabled: $hasPermission(
'automation.order_workflows',
application,
application.workspace.id
),
}"
:automation="application"
:workflow="workflow"
></SidebarItemAutomation>
</ul>
<a
v-if="
$hasPermission(
'automation.create_workflow',
application,
application.workspace.id
)
"
class="tree__sub-add"
@click="
whenMounted(() => $refs.createAutomationWorkflowModal.show())
"
>
<i class="tree__sub-add-icon iconoir-plus"></i>
{{ $t('sidebarComponentAutomation.createAutomationWorkflow') }}
</a>
<CreateAutomationWorkflowModal
ref="createAutomationWorkflowModal"
:automation="application"
:workspace="application.workspace"
></CreateAutomationWorkflowModal>
</client-only>
</template>
</SidebarApplication>
</div>
</template>
<script>
import SidebarApplication from '@baserow/modules/core/components/sidebar/SidebarApplication'
import SidebarItemAutomation from '@baserow/modules/automation/components/sidebar/SidebarItemAutomation'
import CreateAutomationWorkflowModal from '@baserow/modules/automation/components/workflow/CreateAutomationWorkflowModal'
import { mapGetters } from 'vuex'
import { notifyIf } from '@baserow/modules/core/utils/error'
import whenMounted from '@baserow/modules/core/mixins/whenMounted'
export default {
name: 'SidebarComponentAutomation',
components: {
SidebarApplication,
SidebarItemAutomation,
CreateAutomationWorkflowModal,
},
mixins: [whenMounted],
props: {
application: {
type: Object,
required: true,
},
workspace: {
type: Object,
required: true,
},
},
computed: {
...mapGetters({
getOrderedWorkflows: 'automationWorkflow/getOrderedWorkflows',
}),
orderedWorkflows() {
return this.getOrderedWorkflows(this.application)
},
},
methods: {
orderWorkflows(order, oldOrder) {
try {
this.$store.dispatch('automationWorkflow/order', {
automation: this.application,
order,
oldOrder,
})
} catch (error) {
notifyIf(error, 'automationWorkflow')
}
},
},
}
</script>