From c980655f08a152c781ca27972d02279506b8ef14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Fri, 20 May 2022 17:42:12 +0200 Subject: [PATCH] elastic: config: hide access-mode selector when not needed (#49246) --- .../elasticsearch/configuration/ConfigEditor.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx b/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx index df512e5b7e0..eb288ebc49d 100644 --- a/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx +++ b/public/app/plugins/datasource/elasticsearch/configuration/ConfigEditor.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useRef } from 'react'; import { SIGV4ConnectionConfig } from '@grafana/aws-sdk'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; @@ -16,6 +16,12 @@ import { coerceOptions, isValidOptions } from './utils'; export type Props = DataSourcePluginOptionsEditorProps; export const ConfigEditor = (props: Props) => { + // we decide on whether to show access options or not at the point when the config page opens. + // whatever happens while the page is open, this decision does not change. + // (we do this to avoid situations where you switch access-mode and suddenly + // the access-mode-select-box vanishes) + const showAccessOptions = useRef(props.options.access === 'direct'); + const { options: originalOptions, onOptionsChange } = props; const options = coerceOptions(originalOptions); @@ -45,7 +51,7 @@ export const ConfigEditor = (props: Props) => { }