mirror of https://github.com/grafana/grafana
Chore: Remove alpha icon panel (#68573)
parent
bf75969794
commit
8390fcc80f
@ -1,90 +0,0 @@ |
||||
import React, { Component } from 'react'; |
||||
|
||||
import { PanelProps } from '@grafana/data'; |
||||
import { |
||||
ColorDimensionConfig, |
||||
ResourceDimensionConfig, |
||||
ScalarDimensionConfig, |
||||
ScaleDimensionConfig, |
||||
TextDimensionConfig, |
||||
} from '@grafana/schema'; |
||||
import { HorizontalConstraint, VerticalConstraint } from 'app/features/canvas'; |
||||
import { iconItem } from 'app/features/canvas/elements/icon'; |
||||
import { ElementState } from 'app/features/canvas/runtime/element'; |
||||
import { |
||||
DimensionContext, |
||||
getColorDimensionFromData, |
||||
getResourceDimensionFromData, |
||||
getScalarDimensionFromData, |
||||
getScaleDimensionFromData, |
||||
getTextDimensionFromData, |
||||
} from 'app/features/dimensions'; |
||||
|
||||
import { Options } from './models.gen'; |
||||
|
||||
interface Props extends PanelProps<Options> {} |
||||
|
||||
export class IconPanel extends Component<Props> { |
||||
private element: ElementState; |
||||
|
||||
constructor(props: Props) { |
||||
super(props); |
||||
this.element = this.initElement(props); |
||||
} |
||||
|
||||
initElement = (props: Props) => { |
||||
this.element = new ElementState(iconItem, props.options.root as any); |
||||
this.updateSize(props); |
||||
this.element.updateData(this.dims); |
||||
return this.element; |
||||
}; |
||||
|
||||
updateSize = (props: Props) => { |
||||
const { width, height } = props; |
||||
this.element.options.constraint = { |
||||
vertical: VerticalConstraint.Top, |
||||
horizontal: HorizontalConstraint.Left, |
||||
}; |
||||
this.element.options.placement = { |
||||
left: 0, |
||||
top: 0, |
||||
width, |
||||
height, |
||||
}; |
||||
}; |
||||
|
||||
dims: DimensionContext = { |
||||
getColor: (color: ColorDimensionConfig) => getColorDimensionFromData(this.props.data, color), |
||||
getScale: (scale: ScaleDimensionConfig) => getScaleDimensionFromData(this.props.data, scale), |
||||
getScalar: (scalar: ScalarDimensionConfig) => getScalarDimensionFromData(this.props.data, scalar), |
||||
getText: (text: TextDimensionConfig) => getTextDimensionFromData(this.props.data, text), |
||||
getResource: (res: ResourceDimensionConfig) => getResourceDimensionFromData(this.props.data, res), |
||||
getPanelData: () => this.props.data, |
||||
}; |
||||
|
||||
shouldComponentUpdate(nextProps: Props) { |
||||
const { width, height, data } = this.props; |
||||
let changed = false; |
||||
|
||||
if (width !== nextProps.width || height !== nextProps.height) { |
||||
this.updateSize(nextProps); |
||||
changed = true; |
||||
} |
||||
if (data !== nextProps.data) { |
||||
this.element.updateData(this.dims); |
||||
changed = true; |
||||
} |
||||
|
||||
// Reload the element when options change
|
||||
if (this.props.options?.root !== nextProps.options?.root) { |
||||
this.initElement(nextProps); |
||||
changed = true; |
||||
} |
||||
return changed; |
||||
} |
||||
|
||||
render() { |
||||
const { width, height } = this.props; |
||||
return <div style={{ width, height, overflow: 'hidden', position: 'relative' }}>{this.element.render()}</div>; |
||||
} |
||||
} |
||||
@ -1,3 +0,0 @@ |
||||
# Icon panel - Native Plugin |
||||
|
||||
The icon panel is **included** with Grafana. |
||||
|
Before Width: | Height: | Size: 629 B |
@ -1,26 +0,0 @@ |
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// NOTE: This file will be auto generated from models.cue
|
||||
// It is currenty hand written but will serve as the target for cuetsy
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
import { CanvasElementOptions } from 'app/features/canvas'; |
||||
import { IconConfig } from 'app/features/canvas/elements/icon'; |
||||
import { ResourceDimensionMode } from '@grafana/schema'; |
||||
|
||||
export interface Options { |
||||
root: Omit<CanvasElementOptions<IconConfig>, 'type' | 'name'>; // type is forced
|
||||
} |
||||
|
||||
export const defaultOptions: Options = { |
||||
root: { |
||||
config: { |
||||
path: { |
||||
mode: ResourceDimensionMode.Fixed, |
||||
fixed: 'img/icons/unicons/analysis.svg', |
||||
}, |
||||
fill: { |
||||
fixed: 'green' |
||||
} |
||||
}, |
||||
}, |
||||
}; |
||||
@ -1,36 +0,0 @@ |
||||
import { FieldConfigProperty, PanelPlugin } from '@grafana/data'; |
||||
import { CanvasElementOptions } from 'app/features/canvas'; |
||||
import { IconConfig, iconItem } from 'app/features/canvas/elements/icon'; |
||||
|
||||
import { optionBuilder } from '../canvas/editor/options'; |
||||
|
||||
import { IconPanel } from './IconPanel'; |
||||
import { defaultOptions, Options } from './models.gen'; |
||||
|
||||
export const plugin = new PanelPlugin<Options>(IconPanel) |
||||
.setNoPadding() // extend to panel edges
|
||||
.useFieldConfig({ |
||||
standardOptions: { |
||||
[FieldConfigProperty.Mappings]: { |
||||
settings: { |
||||
icon: true, |
||||
}, |
||||
}, |
||||
}, |
||||
}) |
||||
.setPanelOptions((builder) => { |
||||
builder.addNestedOptions<CanvasElementOptions<IconConfig>>({ |
||||
category: ['Icon'], |
||||
path: 'root', |
||||
|
||||
// Dynamically fill the selected element
|
||||
build: (builder, ctx) => { |
||||
iconItem.registerOptionsUI!(builder, ctx); |
||||
|
||||
optionBuilder.addBackground(builder, ctx); |
||||
optionBuilder.addBorder(builder, ctx); |
||||
}, |
||||
|
||||
defaultValue: defaultOptions.root as any, |
||||
}); |
||||
}); |
||||
@ -1,18 +0,0 @@ |
||||
{ |
||||
"type": "panel", |
||||
"name": "Icon", |
||||
"id": "icon", |
||||
"state": "alpha", |
||||
|
||||
"info": { |
||||
"description": "Show icon based on data", |
||||
"author": { |
||||
"name": "Grafana Labs", |
||||
"url": "https://grafana.com" |
||||
}, |
||||
"logos": { |
||||
"small": "img/icn-icon.svg", |
||||
"large": "img/icn-icon.svg" |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue