From 77cd1cd052d2b771903f80997dc9f500a4cbfbba Mon Sep 17 00:00:00 2001 From: Enzo Candotti Date: Thu, 19 Aug 2021 16:59:45 -0300 Subject: [PATCH] Add filter button for orchestration steps This change adds a filter button to search a specific Step on Cloud Orchestration tab. Story: 2008931 Task: 43060 Signed-off-by: Enzo Candotti Change-Id: I3c4f81dfa5a34a3debbb841490798470902de3a3 --- .../dc_admin/dc_software_management/tables.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py index 1104b2d8..ebfd0c8c 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/tables.py @@ -239,6 +239,20 @@ class UpdateStepRow(tables.Row): return step +class StepFilterAction(tables.FilterAction): + def filter(self, table, steps, filter_string): + """Naive case-insensitive search.""" + q = filter_string.lower().strip() + + def comp(step): + if (q in step.state.lower() or + q in step.stage): + return True + return False + + return list(filter(comp, steps)) + + class CloudPatchStepsTable(tables.DataTable): cloud = tables.Column('cloud', verbose_name=_('Cloud')) stage = tables.Column('stage', verbose_name=_('Stage')) @@ -263,7 +277,8 @@ class CloudPatchStepsTable(tables.DataTable): multi_select = False status_columns = ['state', ] row_class = UpdateStepRow - table_actions = (CreateCloudPatchStrategy, ApplyCloudPatchStrategy, + table_actions = (StepFilterAction, + CreateCloudPatchStrategy, ApplyCloudPatchStrategy, AbortCloudPatchStrategy, DeleteCloudPatchStrategy) verbose_name = _("Steps") hidden_title = False