mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 15:45:43 -06:00
Merge branch 'master' of github.com:grafana/grafana
This commit is contained in:
commit
342aa0ad01
@ -5,7 +5,7 @@
|
||||
"company": "Grafana Labs"
|
||||
},
|
||||
"name": "grafana",
|
||||
"version": "6.0.0-prebeta2",
|
||||
"version": "6.0.0-pre3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/grafana/grafana.git"
|
||||
|
@ -44,8 +44,8 @@ describe('colors', () => {
|
||||
});
|
||||
|
||||
describe('getColorFromHexRgbOrName', () => {
|
||||
it('returns undefined for unknown color', () => {
|
||||
expect(() => getColorFromHexRgbOrName('aruba-sunshine')).toThrow();
|
||||
it('returns black for unknown color', () => {
|
||||
expect(getColorFromHexRgbOrName('aruba-sunshine')).toBe("#000000");
|
||||
});
|
||||
|
||||
it('returns dark hex variant for known color if theme not specified', () => {
|
||||
@ -64,5 +64,9 @@ describe('colors', () => {
|
||||
expect(getColorFromHexRgbOrName('rgb(0,0,0)')).toBe('rgb(0,0,0)');
|
||||
expect(getColorFromHexRgbOrName('rgba(0,0,0,1)')).toBe('rgba(0,0,0,1)');
|
||||
});
|
||||
|
||||
it('returns hex for named color that is not a part of named colors palette', () => {
|
||||
expect(getColorFromHexRgbOrName('lime')).toBe('#00ff00');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { flatten } from 'lodash';
|
||||
import { GrafanaThemeType } from '../types';
|
||||
import tinycolor from 'tinycolor2';
|
||||
|
||||
type Hue = 'green' | 'yellow' | 'red' | 'blue' | 'orange' | 'purple';
|
||||
|
||||
@ -106,7 +107,7 @@ export const getColorFromHexRgbOrName = (color: string, theme?: GrafanaThemeType
|
||||
const colorDefinition = getColorByName(color);
|
||||
|
||||
if (!colorDefinition) {
|
||||
throw new Error('Unknown color');
|
||||
return new tinycolor(color).toHexString();
|
||||
}
|
||||
|
||||
return theme ? colorDefinition.variants[theme] : colorDefinition.variants.dark;
|
||||
|
@ -28,7 +28,7 @@ interface RenderProps {
|
||||
export interface Props {
|
||||
datasource: string | null;
|
||||
queries: any[];
|
||||
panelId?: number;
|
||||
panelId: number;
|
||||
dashboardId?: number;
|
||||
isVisible?: boolean;
|
||||
timeRange?: TimeRange;
|
||||
@ -50,7 +50,6 @@ export interface State {
|
||||
export class DataPanel extends Component<Props, State> {
|
||||
static defaultProps = {
|
||||
isVisible: true,
|
||||
panelId: 1,
|
||||
dashboardId: 1,
|
||||
};
|
||||
|
||||
|
@ -149,6 +149,7 @@ export class PanelChrome extends PureComponent<Props, State> {
|
||||
this.renderPanel(false, panel.snapshotData, width, height)
|
||||
) : (
|
||||
<DataPanel
|
||||
panelId={panel.id}
|
||||
datasource={datasource}
|
||||
queries={targets}
|
||||
timeRange={timeRange}
|
||||
|
Loading…
Reference in New Issue
Block a user