From 6c1ef4bcbabd6850146d2a1c7f5e6e23045c2aa6 Mon Sep 17 00:00:00 2001 From: yingfeng Date: Thu, 19 Dec 2024 15:00:42 -0500 Subject: [PATCH] AMP-3303 - add/update get*Workflows logic to accommodate updated workflow APIs with published and in/active params --- src/components/unused/WorkflowFilter.vue | 2 +- src/components/unused/WorkflowSelection.vue | 6 +++--- src/components/workflow/SelectWorkflow.vue | 6 +++--- src/components/workflow/WorkflowList.vue | 4 ++-- src/service/workflow-service.js | 15 ++++++++++++--- .../components/workflows/workflowList.spec.js | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/components/unused/WorkflowFilter.vue b/src/components/unused/WorkflowFilter.vue index 51f9fd33..627bc0ac 100644 --- a/src/components/unused/WorkflowFilter.vue +++ b/src/components/unused/WorkflowFilter.vue @@ -111,7 +111,7 @@ export default { computed: { workflowDashboard: sync("workflowDashboard"), workflows: sync("workflowDashboard.searchResult.filters.workflows"), - getWorkflows() { + getPublishedWorkflows() { if (!this.workflows) return []; return this.workflows; }, diff --git a/src/components/unused/WorkflowSelection.vue b/src/components/unused/WorkflowSelection.vue index 4fc1a043..4a15040d 100644 --- a/src/components/unused/WorkflowSelection.vue +++ b/src/components/unused/WorkflowSelection.vue @@ -32,10 +32,10 @@ export default { parameters: sync("parameters"), }, methods: { - async getWorkflows() { + async getPublishedWorkflows() { let self = this; - this.workflowService.getWorkflows().then((response) => { + this.workflowService.getPublishedWorkflows().then((response) => { self.workflows = response.data; }); }, @@ -51,7 +51,7 @@ export default { }, mounted() { let self = this; - self.getWorkflows(); + self.getPublishedWorkflows(); }, }; diff --git a/src/components/workflow/SelectWorkflow.vue b/src/components/workflow/SelectWorkflow.vue index 2e7f8363..4164a304 100644 --- a/src/components/workflow/SelectWorkflow.vue +++ b/src/components/workflow/SelectWorkflow.vue @@ -446,9 +446,9 @@ export default { } } }, - async getWorkflows() { + async getPublishedWorkflows() { let self = this; - this.workflowService.getWorkflows().then((response) => { + this.workflowService.getPublishedWorkflows().then((response) => { let workflowResponse = response.data; self.workflows = self.sharedService.sortByAlphabatical( workflowResponse.rows @@ -898,7 +898,7 @@ export default { }, mounted() { let self = this; - self.getWorkflows(); + self.getPublishedWorkflows(); }, beforeDestroy() { const self = this; diff --git a/src/components/workflow/WorkflowList.vue b/src/components/workflow/WorkflowList.vue index 4dd48ebf..eaa3085a 100644 --- a/src/components/workflow/WorkflowList.vue +++ b/src/components/workflow/WorkflowList.vue @@ -268,7 +268,7 @@ export default { const annotations = searchFields.annotations; const tags = searchFields.tags; self.workflowService - .getFilteredWorkflows(name, creator, dateRange, annotations, tags) + .getActiveFilteredWorkflows(name, creator, dateRange, annotations, tags) .then((response) => { self.listOfWorkflows = self.sharedService.sortByAlphabatical( response.data.rows @@ -281,7 +281,7 @@ export default { getWorkflowList() { const self = this; self.workflowService - .getAllWorkflows() + .getActiveWorkflows() .then((response) => { self.listOfWorkflows = self.sharedService.sortByAlphabatical( response.data.rows diff --git a/src/service/workflow-service.js b/src/service/workflow-service.js index 58ccd3cc..afe5e80d 100644 --- a/src/service/workflow-service.js +++ b/src/service/workflow-service.js @@ -103,18 +103,27 @@ export default class WorkflowService extends BaseService { tempName = tempName.replace(/(^\w)|(\s+\w)/g, match => match.toUpperCase()); return tempName; } - getWorkflows() { + + getPublishedWorkflows() { return super.get_auth('/workflows?showPublished=true'); } - getAllWorkflows() { + getActiveWorkflows() { return super.get_auth('/workflows'); } - getFilteredWorkflows(name, creator, dateRange, annotations, tags) { + getInactiveWorkflows() { + return super.get_auth('/workflows?showHidden=true'); + } + + getActiveFilteredWorkflows(name, creator, dateRange, annotations, tags) { return super.get_auth(`/workflows?name=${name}&creator=${creator}&dateRange=${dateRange}&annotations=${annotations}&tags=${tags}`); } + getInactiveFilteredWorkflows(name, creator, dateRange, annotations, tags) { + return super.get_auth(`/workflows?showHidden=true&name=${name}&creator=${creator}&dateRange=${dateRange}&annotations=${annotations}&tags=${tags}`); + } + async getWorkflowDetails(id) { var tempParams = []; return await super.get_auth('/workflows/' + id).then(response => { diff --git a/tests/unit/components/workflows/workflowList.spec.js b/tests/unit/components/workflows/workflowList.spec.js index d9670ca8..80fd9a6c 100644 --- a/tests/unit/components/workflows/workflowList.spec.js +++ b/tests/unit/components/workflows/workflowList.spec.js @@ -28,7 +28,7 @@ jest.mock('../../../../src/service/workflow-service', return Promise.resolve({data: [{id:1, name: "TestName1", visible: true}, {id:2, name: "TestName2", visible: true}]}); }, - getAllWorkflows: ()=>{ + getActiveWorkflows: ()=>{ return Promise.resolve({data: { rows:[{id:1, name: "TestName1", visible: true, annotations: ['test']}, {id:2, name: "TestName2", visible: true, annotations: ['test']}] }}); },