Skip to content

Commit

Permalink
Add enable and export actions to list workflow items
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmyMay authored and Fajfa committed Dec 19, 2023
1 parent 99fd973 commit 5b5b82f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
14 changes: 12 additions & 2 deletions client/web/workflow/src/components/Export.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<b-button
variant="light"
size="lg"
:variant="variant"
:size="size"
@click="jsonExport(workflows)"
>
{{ $t('general:export') }}
Expand All @@ -22,6 +22,16 @@ export default {
type: String,
default: 'workflows-export',
},
size: {
type: String,
default: 'md',
},
variant: {
type: String,
default: 'light',
},
},
methods: {
Expand Down
1 change: 1 addition & 0 deletions client/web/workflow/src/components/WorkflowEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
data-test-id="button-export-workflow"
:workflows="[workflow.workflowID]"
:file-name="workflow.meta.name || workflow.handle"
size="lg"
class="ml-1"
/>

Expand Down
6 changes: 6 additions & 0 deletions client/web/workflow/src/components/faIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import {
faAngleLeft,
faEllipsisV,
faBars,
faFileExport,
faToggleOn,
faToggleOff,
} from '@fortawesome/free-solid-svg-icons'

import {
Expand Down Expand Up @@ -62,4 +65,7 @@ library.add(
faAngleLeft,
faEllipsisV,
faBars,
faFileExport,
faToggleOn,
faToggleOff,
)
40 changes: 39 additions & 1 deletion client/web/workflow/src/views/Workflow/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@import="importJSON"
/>

<export />
<export size="lg" />

<c-permissions-button
v-if="canGrant"
Expand Down Expand Up @@ -164,6 +164,28 @@
/>
</b-dropdown-item>

<b-dropdown-item>
<font-awesome-icon
:icon="['fas', 'file-export']"
/>

<export
data-test-id="button-export-workflow"
:workflows="([w.workflowID])"
:file-name="w.meta.name || w.handle"
variant="link"
size="md"
class="text-decoration-none p-0 ml-1"
/>
</b-dropdown-item>

<b-dropdown-item-button @click="handleStatusChange(w)">
<font-awesome-icon
:icon="['fas', w.enabled ? 'toggle-off' : 'toggle-on']"
/>
{{ statusText(w) }}
</b-dropdown-item-button>

<c-input-confirm
v-if="w.canDeleteWorkflow && !w.deletedAt"
borderless
Expand Down Expand Up @@ -368,6 +390,22 @@ export default {
})
.catch(this.toastErrorHandler(this.$t(`notification:${event}.failed`)))
},
statusText (w) {
return w.enabled ? this.$t('general:disable') : this.$t('general:enable')
},
handleStatusChange ({ workflowID, enabled }) {
enabled = !enabled
const notificationKey = enabled ? 'enable' : 'disable'
this.$AutomationAPI.workflowRead({ workflowID }).then((w) => {
return this.$AutomationAPI.workflowUpdate({ ...w, enabled }).then((w) => {
this.toastSuccess(this.$t(`notification:list.${notificationKey}.success`))
this.filterList()
})
}).catch(this.toastErrorHandler(this.$t(`notification:list.${notificationKey}.failed`)))
},
},
}
</script>
4 changes: 4 additions & 0 deletions lib/vue/src/components/input/CInputConfirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:icon="icon"
:class="iconClass"
/>

<span
v-if="text"
:class="textClass"
Expand All @@ -34,6 +35,7 @@
</slot>
</b-button>
</template>

<template v-else>
<b-button
data-test-id="button-delete-confirm"
Expand All @@ -52,6 +54,7 @@
/>
</slot>
</b-button>

<b-button
data-test-id="button-delete-cancel"
:variant="variantCancel"
Expand All @@ -71,6 +74,7 @@
</template>
</div>
</template>

<script lang="js">
export default {
props: {
Expand Down
2 changes: 2 additions & 0 deletions locale/en/corteza-webapp-workflow/general.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
clear: Clear
description: Description
enabled: Enabled
enable: Enable
disable: Disable
error: Error
error-expression: Error message (expression)
export: Export
Expand Down
6 changes: 6 additions & 0 deletions locale/en/corteza-webapp-workflow/notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ general:
list:
load:
error: Failed to fetch workflows
enable:
success: Workflow enabled
failed: Failed to enable workflow
disable:
success: Workflow disabled
failed: Failed to disable workflow
import:
'failed-import': Failed to import
'imported-workflows': Workflows imported
Expand Down

0 comments on commit 5b5b82f

Please sign in to comment.