From 5b151894cfe0c1c3398b3f6dec569f9b2acbf8eb Mon Sep 17 00:00:00 2001 From: Isabella Siu Date: Mon, 18 Apr 2022 18:05:34 -0400 Subject: [PATCH] CloudWatch: add generic filter component to variable editor --- .../components/Select/DropdownIndicator.tsx | 6 +- .../src/components/Select/SelectBase.tsx | 3 +- .../grafana-ui/src/components/Select/types.ts | 1 + .../VariableQueryEditor/MultiFilter.test.tsx | 87 +++++++++++++++++++ .../VariableQueryEditor/MultiFilter.tsx | 63 ++++++++++++++ .../VariableQueryEditor/MultiFilterItem.tsx | 76 ++++++++++++++++ .../VariableQueryEditor.test.tsx | 42 ++++++++- .../VariableQueryEditor.tsx | 77 ++++++++++++---- .../VariableQueryField.tsx | 4 +- .../datasource/cloudwatch/migration.test.ts | 17 +++- .../datasource/cloudwatch/migrations.ts | 20 ++++- .../plugins/datasource/cloudwatch/types.ts | 8 +- .../datasource/cloudwatch/variables.test.ts | 6 +- .../datasource/cloudwatch/variables.ts | 12 +-- 14 files changed, 376 insertions(+), 46 deletions(-) create mode 100644 public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilter.test.tsx create mode 100644 public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilter.tsx create mode 100644 public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilterItem.tsx diff --git a/packages/grafana-ui/src/components/Select/DropdownIndicator.tsx b/packages/grafana-ui/src/components/Select/DropdownIndicator.tsx index 0a9fc619deb..90bd977cd99 100644 --- a/packages/grafana-ui/src/components/Select/DropdownIndicator.tsx +++ b/packages/grafana-ui/src/components/Select/DropdownIndicator.tsx @@ -4,9 +4,13 @@ import { Icon } from '../Icon/Icon'; interface DropdownIndicatorProps { isOpen: boolean; + hidden?: boolean; } -export const DropdownIndicator: React.FC = ({ isOpen }) => { +export const DropdownIndicator: React.FC = ({ isOpen, hidden = false }) => { + if (hidden) { + return <>; + } const icon = isOpen ? 'angle-up' : 'angle-down'; return ; }; diff --git a/packages/grafana-ui/src/components/Select/SelectBase.tsx b/packages/grafana-ui/src/components/Select/SelectBase.tsx index d6ab426a6cb..1d21a3068f9 100644 --- a/packages/grafana-ui/src/components/Select/SelectBase.tsx +++ b/packages/grafana-ui/src/components/Select/SelectBase.tsx @@ -102,6 +102,7 @@ export function SelectBase({ formatCreateLabel, getOptionLabel, getOptionValue, + hideIndicator, inputValue, invalid, isClearable = false, @@ -332,7 +333,7 @@ export function SelectBase({ ); }, DropdownIndicator(props: any) { - return ; + return