Skip to content

Commit f8a388b

Browse files
committed
Introduce Search feature for embedded workflows
1 parent 14b0168 commit f8a388b

File tree

5 files changed

+124
-27
lines changed

5 files changed

+124
-27
lines changed

src/dialog-editor/components/modal-field/field.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h4 class="modal-title" id="myModalLabel" translate>Edit Field Details</h4>
66
</div>
77

88
<div class="modal-body">
9-
<div class="dialog-editor-tab-notification" ng-if="vm.modalNotification().error">
9+
<div class="dialog-editor-tab-notification error" ng-if="vm.modalNotification().error">
1010
<i class="pficon pficon-error-circle-o"></i>
1111
{{vm.modalNotification().message}}
1212
</div>

src/dialog-editor/components/modal-field/modalFieldComponent.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ModalFieldController extends ModalController {
1919
public treeOptions: any;
2020
public modalData: any;
2121
public validation: any;
22+
public searchQuery: string = '';
2223

2324
public $onInit() {
2425

@@ -41,6 +42,8 @@ class ModalFieldController extends ModalController {
4142
workflow: 'embedded_workflow',
4243
},
4344
emsWorkflowsEnabled: emsWorkflowsEnabled,
45+
searchQuery: '',
46+
filteredWorkflows: [],
4447

4548
/** Function to reset the modalData while changin the Automation Type. */
4649
onAutomationTypeChange: () => {
@@ -86,13 +89,37 @@ class ModalFieldController extends ModalController {
8689
this.treeOptions.data = data.resources.filter((item: any) => item.payload);
8790
const workflow = this.treeOptions.data.find((item) => item.id === this.modalData.resource_action.configuration_script_id);
8891
this.treeOptions.selected = workflow ? workflow.name : null;
92+
this.treeOptions.filteredWorkflows = this.treeOptions.data;
8993
});
9094
}
9195
},
9296

9397
/** Function to handle the onclick event of an item in tree. */
9498
onSelect: (node) => {
9599
this.treeSelectorSelect(node, this.modalData);
100+
},
101+
102+
/** Function to filter the API results with Repository or Workflow Name. */
103+
filterResults: () => {
104+
if ( this.treeOptions.searchQuery.length === 0) {
105+
this.treeOptions.filteredWorkflows = this.treeOptions.data;
106+
} else {
107+
const query = this.treeOptions.searchQuery.toLowerCase().trim();
108+
this.treeOptions.filteredWorkflows = this.treeOptions.data.filter((workflow) =>
109+
(workflow.configuration_script_source && workflow.configuration_script_source.name
110+
? workflow.configuration_script_source.name.toLowerCase().includes(query)
111+
: false) ||
112+
(workflow.name
113+
? workflow.name.toLowerCase().includes(query)
114+
: false)
115+
);
116+
}
117+
},
118+
119+
/** Function to clear the search text and reset the list. */
120+
clearSearchQuery: () => {
121+
this.treeOptions.searchQuery = '';
122+
this.treeOptions.filteredWorkflows = this.treeOptions.data;
96123
}
97124
};
98125
}

src/dialog-editor/components/tree-selector/tree-selector.html

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,37 @@
4242
</div>
4343
<div ng-if="$ctrl.treeOptions.automationType==$ctrl.treeOptions.automationTypes.workflow">
4444
<div ng-if="$ctrl.treeOptions.data">
45-
<ul class="nav nav-list workflows_list_wrapper">
46-
<li class="workflows_list_header">
45+
<div class="nav nav-list workflows_list_wrapper">
46+
<div class="list_search_wrapper">
47+
<span class="pficon pficon-search"></span>
48+
<input type="text" class="form-control"
49+
ng-model="$ctrl.treeOptions.searchQuery"
50+
placeholder="Search by Repository or Workflow Name"
51+
ng-change="$ctrl.treeOptions.filterResults()"/>
52+
<span class="pficon pficon-close"
53+
ng-if="$ctrl.treeOptions.searchQuery"
54+
title="Clear"
55+
ng-click="$ctrl.treeOptions.clearSearchQuery()"></span>
56+
</div>
57+
<div class="workflows_list_header">
4758
<div class="col-md-6">Repository</div>
4859
<div class="col-md-6">Workflow Name</div>
49-
</li>
50-
<li class="workflow_item" ng-repeat="workflow in $ctrl.treeOptions.data">
51-
<div class="workflow_item_row" ng-click="$ctrl.treeOptions.onSelect(workflow)">
52-
<div class="col-md-6">{{workflow.configuration_script_source.name}}</div>
53-
<div class="col-md-6">{{workflow.name}}</div>
60+
</div>
61+
<div class="workflow_list_content">
62+
<div class="workflow_list_content_notification" ng-if="$ctrl.treeOptions.filteredWorkflows.length === 0">
63+
<div class="dialog-editor-tab-notification info">
64+
<i class="pficon pficon-info"></i>
65+
No records found
66+
</div>
5467
</div>
55-
</li>
56-
</ul>
68+
<div class="workflow_item" ng-repeat="workflow in $ctrl.treeOptions.filteredWorkflows">
69+
<div class="workflow_item_row" ng-click="$ctrl.treeOptions.onSelect(workflow)">
70+
<div class="col-md-6">{{workflow.configuration_script_source.name}}</div>
71+
<div class="col-md-6">{{workflow.name}}</div>
72+
</div>
73+
</div>
74+
75+
</div>
5776
</div>
5877
</div>
5978
</div>

src/styles/dialog-editor-boxes.scss

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,38 +190,80 @@ l.nav.nav-list.workflows {
190190
flex-direction: column;
191191
padding: 10px;
192192

193-
ul.workflows_list_wrapper {
193+
.workflows_list_wrapper {
194194
display: flex;
195195
flex-direction: column;
196196
border: 1px solid lightgray;
197197

198-
li.workflows_list_header {
198+
.list_search_wrapper {
199+
display: flex;
200+
flex-direction: row;
201+
202+
span {
203+
border: 0;
204+
width: 30px;
205+
height: 30px;
206+
display: flex;
207+
align-items: center;
208+
justify-content: center;
209+
210+
&.pficon-search {
211+
color: gray;
212+
}
213+
&.pficon-close {
214+
color: #000;
215+
cursor: pointer;
216+
}
217+
}
218+
219+
input {
220+
border: 0;
221+
flex-grow: 1;
222+
box-shadow: none;
223+
height: 30px;
224+
}
225+
}
226+
227+
.workflows_list_header {
199228
background: lightgray;
200229
padding: 10px 0;
201230
font-weight: bold;
202231
}
203232

204-
li.workflow_item {
233+
.workflow_list_content {
205234
display: flex;
206235
flex-grow: 1;
207-
padding: 5px;
208-
border-bottom: 1px solid lightgray;
236+
overflow-y: auto;
237+
max-height: 400px;
238+
flex-direction: column;
209239

210-
&:last-child {
211-
border-bottom: 0 !important;
240+
.workflow_list_content_notification {
241+
padding: 20px;
242+
display: flex;
243+
justify-content: center;
212244
}
213245

214-
.workflow_item_row {
246+
.workflow_item {
215247
display: flex;
216248
flex-grow: 1;
217-
margin-left: -5px;
249+
padding: 5px;
250+
border-bottom: 1px solid lightgray;
251+
252+
&:last-child {
253+
border-bottom: 0 !important;
254+
}
255+
256+
.workflow_item_row {
257+
display: flex;
258+
flex-grow: 1;
259+
margin-left: -5px;
260+
}
261+
262+
&:hover {
263+
background: #e4e5e6;
264+
cursor: pointer;
265+
}
218266
}
219-
220-
&:hover {
221-
background: #e4e5e6;
222-
cursor: pointer;
223-
}
224-
225267
}
226268
}
227269
}

src/styles/ui-components.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@
88
.dialog-editor-tab-notification {
99
color: #363636;
1010
font-weight: bold;
11-
background: #ffe6e7;
12-
border: 1px solid #cd0000;
1311
padding: 10px;
1412
margin-bottom: 10px;
1513
display: flex;
1614
align-items: center;
1715
gap: 10px;
16+
flex-grow: 1;
1817

1918
i {
2019
font-size: 16px;
2120
}
21+
22+
&.error {
23+
background: #ffe6e7;
24+
border: 1px solid #cd0000;
25+
}
26+
27+
&.info {
28+
background: lightgray;
29+
border: 1px solid gray;
30+
}
2231
}
2332

2433
.dialog-editor-tab-list {

0 commit comments

Comments
 (0)