mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Geomap: make the geomap panel beta and label alpha layers (#36894)
This commit is contained in:
parent
ecd2c320ba
commit
d4fa2529c8
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DataFrame, DataTransformerInfo, PluginState } from '../types';
|
import { DataFrame, DataTransformerInfo } from '../types';
|
||||||
import { Registry, RegistryItem } from '../utils/Registry';
|
import { Registry, RegistryItem } from '../utils/Registry';
|
||||||
|
|
||||||
export interface TransformerUIProps<T> {
|
export interface TransformerUIProps<T> {
|
||||||
@ -20,11 +20,6 @@ export interface TransformerRegistryItem<TOptions> extends RegistryItem {
|
|||||||
*/
|
*/
|
||||||
transformation: DataTransformerInfo<TOptions>;
|
transformation: DataTransformerInfo<TOptions>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional feature state
|
|
||||||
*/
|
|
||||||
state?: PluginState;
|
|
||||||
|
|
||||||
/** Markdown with more detailed description and help */
|
/** Markdown with more detailed description and help */
|
||||||
help?: string;
|
help?: string;
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { PluginState } from '../types';
|
||||||
import { SelectableValue } from '../types/select';
|
import { SelectableValue } from '../types/select';
|
||||||
|
|
||||||
export interface RegistryItem {
|
export interface RegistryItem {
|
||||||
@ -11,6 +12,11 @@ export interface RegistryItem {
|
|||||||
* like: 'all' and 'any' matchers;
|
* like: 'all' and 'any' matchers;
|
||||||
*/
|
*/
|
||||||
excludeFromPicker?: boolean;
|
excludeFromPicker?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional feature state
|
||||||
|
*/
|
||||||
|
state?: PluginState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegistryItemWithOptions<TOptions = any> extends RegistryItem {
|
export interface RegistryItemWithOptions<TOptions = any> extends RegistryItem {
|
||||||
@ -105,6 +111,10 @@ export class Registry<T extends RegistryItem> {
|
|||||||
description: ext.description,
|
description: ext.description,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ext.state === PluginState.alpha) {
|
||||||
|
option.label += ' (alpha)';
|
||||||
|
}
|
||||||
|
|
||||||
select.options.push(option);
|
select.options.push(option);
|
||||||
if (currentOptions[ext.id]) {
|
if (currentOptions[ext.id]) {
|
||||||
currentOptions[ext.id] = option;
|
currentOptions[ext.id] = option;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { config, GrafanaBootConfig } from '@grafana/runtime';
|
import { config, GrafanaBootConfig } from '@grafana/runtime';
|
||||||
|
import { PluginState } from '../../../packages/grafana-data/src';
|
||||||
// Legacy binding paths
|
// Legacy binding paths
|
||||||
export { config, GrafanaBootConfig as Settings };
|
export { config, GrafanaBootConfig as Settings };
|
||||||
|
|
||||||
@ -16,3 +17,6 @@ export const updateConfig = (update: Partial<GrafanaBootConfig>) => {
|
|||||||
...update,
|
...update,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The `enable_alpha` flag is no exposed directly, this is equivolant
|
||||||
|
export const hasAlphaPanels = Boolean(config.panels?.debug?.state === PluginState.alpha);
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { StandardEditorProps, MapLayerOptions } from '@grafana/data';
|
import { StandardEditorProps, MapLayerOptions, MapLayerRegistryItem, PluginState } from '@grafana/data';
|
||||||
import { GeomapPanelOptions } from '../types';
|
import { GeomapPanelOptions } from '../types';
|
||||||
import { LayerEditor } from './LayerEditor';
|
import { LayerEditor } from './LayerEditor';
|
||||||
|
import { hasAlphaPanels } from 'app/core/config';
|
||||||
|
|
||||||
|
function baseMapFilter(layer: MapLayerRegistryItem): boolean {
|
||||||
|
if (!layer.isBaseMap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (layer.state === PluginState.alpha) {
|
||||||
|
return hasAlphaPanels;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export const BaseLayerEditor: FC<StandardEditorProps<MapLayerOptions, any, GeomapPanelOptions>> = ({
|
export const BaseLayerEditor: FC<StandardEditorProps<MapLayerOptions, any, GeomapPanelOptions>> = ({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
context,
|
context,
|
||||||
}) => {
|
}) => {
|
||||||
return <LayerEditor options={value} data={context.data} onChange={onChange} filter={(v) => Boolean(v.isBaseMap)} />;
|
return <LayerEditor options={value} data={context.data} onChange={onChange} filter={baseMapFilter} />;
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { StandardEditorProps, MapLayerOptions } from '@grafana/data';
|
import { StandardEditorProps, MapLayerOptions, PluginState, MapLayerRegistryItem } from '@grafana/data';
|
||||||
import { GeomapPanelOptions } from '../types';
|
import { GeomapPanelOptions } from '../types';
|
||||||
import { LayerEditor } from './LayerEditor';
|
import { LayerEditor } from './LayerEditor';
|
||||||
|
import { hasAlphaPanels } from 'app/core/config';
|
||||||
|
|
||||||
|
function dataLayerFilter(layer: MapLayerRegistryItem): boolean {
|
||||||
|
if (layer.isBaseMap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (layer.state === PluginState.alpha) {
|
||||||
|
return hasAlphaPanels;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// For now this supports a *single* data layer -- eventually we should support more than one
|
// For now this supports a *single* data layer -- eventually we should support more than one
|
||||||
export const DataLayersEditor: FC<StandardEditorProps<MapLayerOptions[], any, GeomapPanelOptions>> = ({
|
export const DataLayersEditor: FC<StandardEditorProps<MapLayerOptions[], any, GeomapPanelOptions>> = ({
|
||||||
@ -17,7 +28,7 @@ export const DataLayersEditor: FC<StandardEditorProps<MapLayerOptions[], any, Ge
|
|||||||
console.log('Change overlays:', cfg);
|
console.log('Change overlays:', cfg);
|
||||||
onChange([cfg]);
|
onChange([cfg]);
|
||||||
}}
|
}}
|
||||||
filter={(v) => !v.isBaseMap}
|
filter={dataLayerFilter}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { MapLayerRegistryItem, MapLayerOptions, MapLayerHandler, PanelData, GrafanaTheme2 } from '@grafana/data';
|
import { MapLayerRegistryItem, MapLayerOptions, MapLayerHandler, PanelData, GrafanaTheme2, PluginState } from '@grafana/data';
|
||||||
import Map from 'ol/Map';
|
import Map from 'ol/Map';
|
||||||
import VectorLayer from 'ol/layer/Vector';
|
import VectorLayer from 'ol/layer/Vector';
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
@ -24,6 +24,7 @@ export const geojsonMapper: MapLayerRegistryItem<GeoJSONMapperConfig> = {
|
|||||||
name: 'Map values to GeoJSON file',
|
name: 'Map values to GeoJSON file',
|
||||||
description: 'color features based on query results',
|
description: 'color features based on query results',
|
||||||
isBaseMap: false,
|
isBaseMap: false,
|
||||||
|
state: PluginState.alpha,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that configures transformation and returns a transformer
|
* Function that configures transformation and returns a transformer
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { MapLayerRegistryItem, MapLayerOptions, MapLayerHandler, PanelData, GrafanaTheme2 } from '@grafana/data';
|
import { MapLayerRegistryItem, MapLayerOptions, MapLayerHandler, PanelData, GrafanaTheme2, PluginState } from '@grafana/data';
|
||||||
import Map from 'ol/Map';
|
import Map from 'ol/Map';
|
||||||
import Feature from 'ol/Feature';
|
import Feature from 'ol/Feature';
|
||||||
import * as style from 'ol/style';
|
import * as style from 'ol/style';
|
||||||
@ -20,6 +20,7 @@ export const lastPointTracker: MapLayerRegistryItem<LastPointConfig> = {
|
|||||||
description: 'Show an icon at the last point',
|
description: 'Show an icon at the last point',
|
||||||
isBaseMap: false,
|
isBaseMap: false,
|
||||||
showLocation: true,
|
showLocation: true,
|
||||||
|
state: PluginState.alpha,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that configures transformation and returns a transformer
|
* Function that configures transformation and returns a transformer
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"type": "panel",
|
"type": "panel",
|
||||||
"name": "Geomap",
|
"name": "Geomap",
|
||||||
"id": "geomap",
|
"id": "geomap",
|
||||||
"state": "alpha",
|
"state": "beta",
|
||||||
|
|
||||||
"info": {
|
"info": {
|
||||||
"description": "Geomap panel",
|
"description": "Geomap panel",
|
||||||
|
Loading…
Reference in New Issue
Block a user