mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
86 lines
1.9 KiB
TypeScript
86 lines
1.9 KiB
TypeScript
// Libraries
|
|
import _ from 'lodash';
|
|
import React, { PureComponent, ReactNode } from 'react';
|
|
|
|
// Types
|
|
import { AppNotificationSeverity } from 'app/types';
|
|
import { Alert } from '@grafana/ui';
|
|
import { PanelProps, PanelPlugin, PluginType, PanelPluginMeta } from '@grafana/data';
|
|
|
|
interface Props {
|
|
title: string;
|
|
text?: ReactNode;
|
|
}
|
|
|
|
class PanelPluginError extends PureComponent<Props> {
|
|
constructor(props: Props) {
|
|
super(props);
|
|
}
|
|
|
|
render() {
|
|
const style = {
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
height: '100%',
|
|
};
|
|
|
|
return (
|
|
<div style={style}>
|
|
<Alert severity={AppNotificationSeverity.Error} {...this.props} />
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export function getPanelPluginLoadError(meta: PanelPluginMeta, err: any): PanelPlugin {
|
|
const LoadError = class LoadError extends PureComponent<PanelProps> {
|
|
render() {
|
|
const text = (
|
|
<>
|
|
Check the server startup logs for more information. <br />
|
|
If this plugin was loaded from git, make sure it was compiled.
|
|
</>
|
|
);
|
|
return <PanelPluginError title={`Error loading: ${meta.id}`} text={text} />;
|
|
}
|
|
};
|
|
const plugin = new PanelPlugin(LoadError);
|
|
plugin.meta = meta;
|
|
plugin.loadError = true;
|
|
return plugin;
|
|
}
|
|
|
|
export function getPanelPluginNotFound(id: string): PanelPlugin {
|
|
const NotFound = class NotFound extends PureComponent<PanelProps> {
|
|
render() {
|
|
return <PanelPluginError title={`Panel plugin not found: ${id}`} />;
|
|
}
|
|
};
|
|
|
|
const plugin = new PanelPlugin(NotFound);
|
|
plugin.meta = {
|
|
id: id,
|
|
name: id,
|
|
sort: 100,
|
|
type: PluginType.panel,
|
|
module: '',
|
|
baseUrl: '',
|
|
info: {
|
|
author: {
|
|
name: '',
|
|
},
|
|
description: '',
|
|
links: [],
|
|
logos: {
|
|
large: '',
|
|
small: '',
|
|
},
|
|
screenshots: [],
|
|
updated: '',
|
|
version: '',
|
|
},
|
|
};
|
|
return plugin;
|
|
}
|