From 6cee0cdbad3008737461916c8024aa97936d0422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Fri, 24 Feb 2023 08:24:31 +0100 Subject: [PATCH] elastic: remove most of xpack (#63460) elasticsearch: do not show the xpack toggle in datasource config --- .../configuration/ElasticDetails.tsx | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx index 93b1eaa2bae..1a1a1c90711 100644 --- a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx +++ b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx @@ -122,23 +122,13 @@ export const ElasticDetails = ({ value, onChange }: Props) => { /> - + includeFrozenIndicesOnChange(event.currentTarget.checked, value, onChange)} /> - - {value.jsonData.xpack && ( - - - - )} ); @@ -167,17 +157,20 @@ const jsonDataChangeHandler = }); }; -const jsonDataSwitchChangeHandler = - (key: keyof ElasticsearchOptions, value: Props['value'], onChange: Props['onChange']) => - (event: React.SyntheticEvent) => { - onChange({ - ...value, - jsonData: { - ...value.jsonData, - [key]: event.currentTarget.checked, - }, - }); - }; +const includeFrozenIndicesOnChange = (newValue: boolean, formValue: Props['value'], onChange: Props['onChange']) => { + const newJsonData = { ...formValue.jsonData }; + if (newValue) { + newJsonData.xpack = true; + newJsonData.includeFrozen = true; + } else { + delete newJsonData.xpack; + delete newJsonData.includeFrozen; + } + onChange({ + ...formValue, + jsonData: newJsonData, + }); +}; const intervalHandler = (value: Props['value'], onChange: Props['onChange']) => (option: SelectableValue) => {