|
|
|
@ -1,15 +1,14 @@
|
|
|
|
|
import React, { FC, useCallback, useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
import { Legend, LoadingPlaceholder } from '@grafana/ui'; |
|
|
|
|
import { useLocation } from 'react-router-dom'; |
|
|
|
|
|
|
|
|
|
// import logo from '../../img/logo.svg';
|
|
|
|
|
import PluginState, { PluginConnectedStatusResponse } from '../../plugin_state'; |
|
|
|
|
|
|
|
|
|
import ConfigurationForm from './parts/ConfigurationForm'; |
|
|
|
|
import RemoveCurrentConfigurationButton from './parts/RemoveCurrentConfigurationButton'; |
|
|
|
|
import StatusMessageBlock from './parts/StatusMessageBlock'; |
|
|
|
|
import { DataExporterPluginConfigPageProps } from 'types'; |
|
|
|
|
import { DataExporterPluginConfigPageProps } from '../../types'; |
|
|
|
|
|
|
|
|
|
import { Legend, LoadingPlaceholder } from '@grafana/ui'; |
|
|
|
|
import { useLocation } from 'react-router-dom'; |
|
|
|
|
|
|
|
|
|
import React, { FC, useCallback, useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
const PLUGIN_CONFIGURED_QUERY_PARAM = 'pluginConfigured'; |
|
|
|
|
const PLUGIN_CONFIGURED_QUERY_PARAM_TRUTHY_VALUE = 'true'; |
|
|
|
@ -71,14 +70,18 @@ export const PluginConfigPage: FC<DataExporterPluginConfigPageProps> = ({
|
|
|
|
|
|
|
|
|
|
const resetQueryParams = useCallback(() => removePluginConfiguredQueryParams(pluginIsEnabled), [pluginIsEnabled]); |
|
|
|
|
|
|
|
|
|
const checkConnection = useCallback(async () => { |
|
|
|
|
const checkConnection = useCallback( |
|
|
|
|
async (grafanaDataExporterUrl?: string) => { |
|
|
|
|
setCheckingIfPluginIsConnected(true); |
|
|
|
|
setPluginConnectionCheckError(null); |
|
|
|
|
if (!pluginMetaDataExporterApiUrl) { |
|
|
|
|
|
|
|
|
|
const backendUrl = grafanaDataExporterUrl || pluginMetaDataExporterApiUrl; |
|
|
|
|
|
|
|
|
|
if (!backendUrl) { |
|
|
|
|
setCheckingIfPluginIsConnected(false); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const pluginConnectionResponse = await PluginState.checkIfPluginIsConnected(pluginMetaDataExporterApiUrl); |
|
|
|
|
const pluginConnectionResponse = await PluginState.checkIfPluginIsConnected(backendUrl); |
|
|
|
|
|
|
|
|
|
if (typeof pluginConnectionResponse === 'string') { |
|
|
|
|
setPluginConnectionCheckError(pluginConnectionResponse); |
|
|
|
@ -88,7 +91,9 @@ export const PluginConfigPage: FC<DataExporterPluginConfigPageProps> = ({
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setCheckingIfPluginIsConnected(false); |
|
|
|
|
}, [pluginMetaDataExporterApiUrl]); |
|
|
|
|
}, |
|
|
|
|
[pluginMetaDataExporterApiUrl] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
useEffect(resetQueryParams, [resetQueryParams]); |
|
|
|
|
|
|
|
|
@ -166,10 +171,7 @@ export const PluginConfigPage: FC<DataExporterPluginConfigPageProps> = ({
|
|
|
|
|
<Legend>Configure DataExporter</Legend> |
|
|
|
|
{pluginIsConnected ? ( |
|
|
|
|
<> |
|
|
|
|
<p> |
|
|
|
|
Plugin is connected! Continue to DataExporter by clicking the{' '} |
|
|
|
|
{/* <img alt="DataExporter Logo" src={logo} width={18} /> icon over there 👈 */} |
|
|
|
|
</p> |
|
|
|
|
<p>Plugin is connected! You can now go to a dashboard and add the DataExporter panel there.</p> |
|
|
|
|
<StatusMessageBlock text={`Connected to DataExporter`} /> |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|