diff --git a/package.json b/package.json index d374cd524b4..31e80e3b47d 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "private": true, "author": { "name": "Torkel Ödegaard", "company": "Grafana Labs" @@ -178,5 +179,6 @@ "resolutions": { "caniuse-db": "1.0.30000772", "**/@types/react": "16.7.6" - } + }, + "workspaces": ["packages/grafana-ui"] } diff --git a/packages/grafana-ui/index.ts b/packages/grafana-ui/index.ts new file mode 100644 index 00000000000..4beb45d6fb3 --- /dev/null +++ b/packages/grafana-ui/index.ts @@ -0,0 +1,21 @@ +export class Google { + hello() { + return 'hello'; + } +} + +class Singleton { + constructor(private state) {} + + hello() { + return this.state; + } + + change() { + this.state = 'mod2'; + } +} + +const singletonSrv = new Singleton('hello'); + +export { singletonSrv }; diff --git a/packages/grafana-ui/package.json b/packages/grafana-ui/package.json new file mode 100644 index 00000000000..e3c407b500a --- /dev/null +++ b/packages/grafana-ui/package.json @@ -0,0 +1,11 @@ +{ + "name": "grafana-ui", + "version": "1.0.0", + "description": "", + "main": "index.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index a401505b787..ad15eca8654 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -7,6 +7,9 @@ import { DashboardModel } from '../dashboard_model'; import { PanelModel } from '../panel_model'; import classNames from 'classnames'; import sizeMe from 'react-sizeme'; +import { Google } from 'grafana-ui'; + +console.log(Google); let lastGridWidth = 1200; let ignoreNextWidthChange = false; diff --git a/public/app/features/plugins/plugin_loader.ts b/public/app/features/plugins/plugin_loader.ts index 8e0958f6c1b..97e35ab5631 100644 --- a/public/app/features/plugins/plugin_loader.ts +++ b/public/app/features/plugins/plugin_loader.ts @@ -26,6 +26,7 @@ import * as ticks from 'app/core/utils/ticks'; import impressionSrv from 'app/core/services/impression_srv'; import builtInPlugins from './built_in_plugins'; import * as d3 from 'd3'; +import * as grafanaUI from 'grafana-ui'; // rxjs import { Observable } from 'rxjs/Observable'; @@ -71,6 +72,7 @@ function exposeToPlugin(name: string, component: any) { }); } +exposeToPlugin('grafana-ui', grafanaUI); exposeToPlugin('lodash', _); exposeToPlugin('moment', moment); exposeToPlugin('jquery', jquery);