Feature: clone workflows
This commit is contained in:
parent
045b62ca66
commit
38aa288133
@ -1549,7 +1549,7 @@
|
|||||||
</context-group>
|
</context-group>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
|
||||||
<context context-type="linenumber">38</context>
|
<context context-type="linenumber">41</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="6338800642797811873" datatype="html">
|
<trans-unit id="6338800642797811873" datatype="html">
|
||||||
@ -2215,7 +2215,7 @@
|
|||||||
</context-group>
|
</context-group>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">97</context>
|
<context context-type="linenumber">115</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="1980187861066369604" datatype="html">
|
<trans-unit id="1980187861066369604" datatype="html">
|
||||||
@ -2554,7 +2554,7 @@
|
|||||||
</context-group>
|
</context-group>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">99</context>
|
<context context-type="linenumber">117</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="857903183180440990" datatype="html">
|
<trans-unit id="857903183180440990" datatype="html">
|
||||||
@ -7817,53 +7817,60 @@
|
|||||||
<context context-type="linenumber">30</context>
|
<context context-type="linenumber">30</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="5834780181397311898" datatype="html">
|
||||||
|
<source>Clone</source>
|
||||||
|
<context-group purpose="location">
|
||||||
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
|
||||||
|
<context context-type="linenumber">38</context>
|
||||||
|
</context-group>
|
||||||
|
</trans-unit>
|
||||||
<trans-unit id="1624023882313260402" datatype="html">
|
<trans-unit id="1624023882313260402" datatype="html">
|
||||||
<source>No workflows defined.</source>
|
<source>No workflows defined.</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.html</context>
|
||||||
<context context-type="linenumber">46</context>
|
<context context-type="linenumber">49</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="4200688335642457098" datatype="html">
|
<trans-unit id="4200688335642457098" datatype="html">
|
||||||
<source>Saved workflow "<x id="PH" equiv-text="newWorkflow.name"/>".</source>
|
<source>Saved workflow "<x id="PH" equiv-text="newWorkflow.name"/>".</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">79</context>
|
<context context-type="linenumber">78</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="7593065565369163325" datatype="html">
|
<trans-unit id="7593065565369163325" datatype="html">
|
||||||
<source>Error saving workflow.</source>
|
<source>Error saving workflow.</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">87</context>
|
<context context-type="linenumber">86</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="563460864902055482" datatype="html">
|
<trans-unit id="563460864902055482" datatype="html">
|
||||||
<source>Confirm delete workflow</source>
|
<source>Confirm delete workflow</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">95</context>
|
<context context-type="linenumber">113</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="6874008462443189248" datatype="html">
|
<trans-unit id="6874008462443189248" datatype="html">
|
||||||
<source>This operation will permanently delete this workflow.</source>
|
<source>This operation will permanently delete this workflow.</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">96</context>
|
<context context-type="linenumber">114</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="1848226135059921165" datatype="html">
|
<trans-unit id="1848226135059921165" datatype="html">
|
||||||
<source>Deleted workflow</source>
|
<source>Deleted workflow</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">105</context>
|
<context context-type="linenumber">123</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="3177411222429626224" datatype="html">
|
<trans-unit id="3177411222429626224" datatype="html">
|
||||||
<source>Error deleting workflow.</source>
|
<source>Error deleting workflow.</source>
|
||||||
<context-group purpose="location">
|
<context-group purpose="location">
|
||||||
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
<context context-type="sourcefile">src/app/components/manage/workflows/workflows.component.ts</context>
|
||||||
<context context-type="linenumber">110</context>
|
<context context-type="linenumber">128</context>
|
||||||
</context-group>
|
</context-group>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="2649252321173430744" datatype="html">
|
<trans-unit id="2649252321173430744" datatype="html">
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
<button *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Workflow }" class="btn btn-sm btn-outline-secondary" type="button" (click)="editWorkflow(workflow)">
|
<button *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Workflow }" class="btn btn-sm btn-outline-secondary" type="button" (click)="editWorkflow(workflow)">
|
||||||
<i-bs width="1em" height="1em" name="pencil"></i-bs> <ng-container i18n>Edit</ng-container>
|
<i-bs width="1em" height="1em" name="pencil"></i-bs> <ng-container i18n>Edit</ng-container>
|
||||||
</button>
|
</button>
|
||||||
|
<button *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.Workflow }" class="btn btn-sm btn-outline-secondary" type="button" (click)="cloneWorkflow(workflow)">
|
||||||
|
<i-bs width="1em" height="1em" name="files"></i-bs> <ng-container i18n>Clone</ng-container>
|
||||||
|
</button>
|
||||||
<button *pngxIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Workflow }" class="btn btn-sm btn-outline-danger" type="button" (click)="deleteWorkflow(workflow)">
|
<button *pngxIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Workflow }" class="btn btn-sm btn-outline-danger" type="button" (click)="deleteWorkflow(workflow)">
|
||||||
<i-bs width="1em" height="1em" name="trash"></i-bs> <ng-container i18n>Delete</ng-container>
|
<i-bs width="1em" height="1em" name="trash"></i-bs> <ng-container i18n>Delete</ng-container>
|
||||||
</button>
|
</button>
|
||||||
|
@ -26,6 +26,7 @@ import {
|
|||||||
import { WorkflowActionType } from 'src/app/data/workflow-action'
|
import { WorkflowActionType } from 'src/app/data/workflow-action'
|
||||||
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
|
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
|
||||||
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
|
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'
|
||||||
|
import { EditDialogMode } from '../../common/edit-dialog/edit-dialog.component'
|
||||||
|
|
||||||
const workflows: Workflow[] = [
|
const workflows: Workflow[] = [
|
||||||
{
|
{
|
||||||
@ -173,6 +174,19 @@ describe('WorkflowsComponent', () => {
|
|||||||
expect(reloadSpy).toHaveBeenCalled()
|
expect(reloadSpy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should support clone', () => {
|
||||||
|
let modal: NgbModalRef
|
||||||
|
modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
|
||||||
|
|
||||||
|
const cloneButton = fixture.debugElement.queryAll(By.css('button'))[4]
|
||||||
|
cloneButton.triggerEventHandler('click')
|
||||||
|
|
||||||
|
expect(modal).not.toBeUndefined()
|
||||||
|
const editDialog = modal.componentInstance as WorkflowEditDialogComponent
|
||||||
|
expect(editDialog.object.name).toEqual(workflows[0].name + ' (copy)')
|
||||||
|
expect(editDialog.dialogMode).toEqual(EditDialogMode.CREATE)
|
||||||
|
})
|
||||||
|
|
||||||
it('should support delete, show notification on error / success', () => {
|
it('should support delete, show notification on error / success', () => {
|
||||||
let modal: NgbModalRef
|
let modal: NgbModalRef
|
||||||
modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
|
modalService.activeInstances.subscribe((m) => (modal = m[m.length - 1]))
|
||||||
@ -180,7 +194,7 @@ describe('WorkflowsComponent', () => {
|
|||||||
const deleteSpy = jest.spyOn(workflowService, 'delete')
|
const deleteSpy = jest.spyOn(workflowService, 'delete')
|
||||||
const reloadSpy = jest.spyOn(component, 'reload')
|
const reloadSpy = jest.spyOn(component, 'reload')
|
||||||
|
|
||||||
const deleteButton = fixture.debugElement.queryAll(By.css('button'))[4]
|
const deleteButton = fixture.debugElement.queryAll(By.css('button'))[5]
|
||||||
deleteButton.triggerEventHandler('click')
|
deleteButton.triggerEventHandler('click')
|
||||||
|
|
||||||
expect(modal).not.toBeUndefined()
|
expect(modal).not.toBeUndefined()
|
||||||
|
@ -57,14 +57,13 @@ export class WorkflowsComponent
|
|||||||
.join(', ')
|
.join(', ')
|
||||||
}
|
}
|
||||||
|
|
||||||
editWorkflow(workflow: Workflow) {
|
editWorkflow(workflow: Workflow, clone: boolean = false) {
|
||||||
const modal = this.modalService.open(WorkflowEditDialogComponent, {
|
const modal = this.modalService.open(WorkflowEditDialogComponent, {
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
size: 'xl',
|
size: 'xl',
|
||||||
})
|
})
|
||||||
modal.componentInstance.dialogMode = workflow
|
modal.componentInstance.dialogMode =
|
||||||
? EditDialogMode.EDIT
|
workflow && !clone ? EditDialogMode.EDIT : EditDialogMode.CREATE
|
||||||
: EditDialogMode.CREATE
|
|
||||||
if (workflow) {
|
if (workflow) {
|
||||||
// quick "deep" clone so original doesn't get modified
|
// quick "deep" clone so original doesn't get modified
|
||||||
const clone = Object.assign({}, workflow)
|
const clone = Object.assign({}, workflow)
|
||||||
@ -88,6 +87,25 @@ export class WorkflowsComponent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cloneWorkflow(workflow: Workflow) {
|
||||||
|
const clone = Object.assign({}, workflow)
|
||||||
|
clone.id = null
|
||||||
|
clone.name = `${workflow.name} (copy)`
|
||||||
|
clone.actions = [
|
||||||
|
...workflow.actions.map((a) => {
|
||||||
|
a.id = null
|
||||||
|
return a
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
clone.triggers = [
|
||||||
|
...workflow.triggers.map((t) => {
|
||||||
|
t.id = null
|
||||||
|
return t
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
this.editWorkflow(clone, true)
|
||||||
|
}
|
||||||
|
|
||||||
deleteWorkflow(workflow: Workflow) {
|
deleteWorkflow(workflow: Workflow) {
|
||||||
const modal = this.modalService.open(ConfirmDialogComponent, {
|
const modal = this.modalService.open(ConfirmDialogComponent, {
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user