Skip to content

Commit ae39ec8

Browse files
committed
feat(plugins): changed so that plugins can load css async via util function exposed from app/plugins/sdk
1 parent dfe0e25 commit ae39ec8

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"phantomjs": "^1.9.19",
5151
"reflect-metadata": "0.1.2",
5252
"rxjs": "5.0.0-beta.0",
53-
"systemjs": "0.19.6",
53+
"systemjs": "0.19.20",
5454
"zone.js": "0.5.10"
5555
},
5656
"engines": {
@@ -68,9 +68,9 @@
6868
"grunt-jscs": "~1.5.x",
6969
"grunt-sync": "^0.4.1",
7070
"karma-sinon": "^1.0.3",
71-
"lodash": "^2.4.1",
71+
"lodash": "^4.0.0",
7272
"sinon": "1.16.1",
73-
"systemjs-builder": "^0.14.15",
73+
"systemjs-builder": "^0.15.7",
7474
"tslint": "^3.2.1",
7575
"typescript": "^1.7.5"
7676
}

pkg/api/dtos/index.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ type IndexViewData struct {
77
AppSubUrl string
88
GoogleAnalyticsId string
99
GoogleTagManagerId string
10-
11-
PluginCss []*PluginCss
12-
PluginModules []string
13-
MainNavLinks []*NavLink
10+
MainNavLinks []*NavLink
1411
}
1512

1613
type PluginCss struct {

pkg/api/index.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
8181
}
8282

8383
for _, plugin := range enabledPlugins.Apps {
84-
if plugin.Css != nil {
85-
data.PluginCss = append(data.PluginCss, &dtos.PluginCss{Light: plugin.Css.Light, Dark: plugin.Css.Dark})
86-
}
87-
8884
if plugin.Pinned {
8985
pageLink := &dtos.NavLink{
9086
Text: plugin.Name,

pkg/plugins/app_plugin.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type AppIncludeInfo struct {
2828

2929
type AppPlugin struct {
3030
FrontendPluginBase
31-
Css *AppPluginCss `json:"css"`
3231
Pages []*AppPluginPage `json:"pages"`
3332
Routes []*AppPluginRoute `json:"routes"`
3433
Includes []*AppIncludeInfo `json:"-"`
@@ -68,11 +67,6 @@ func (app *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
6867
func (app *AppPlugin) initApp() {
6968
app.initFrontendPlugin()
7069

71-
if app.Css != nil {
72-
app.Css.Dark = evalRelativePluginUrlPath(app.Css.Dark, app.Id)
73-
app.Css.Light = evalRelativePluginUrlPath(app.Css.Light, app.Id)
74-
}
75-
7670
// check if we have child panels
7771
for _, panel := range Panels {
7872
if strings.HasPrefix(panel.PluginDir, app.PluginDir) {

public/app/plugins/sdk.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import {PanelCtrl} from 'app/features/panel/panel_ctrl';
22
import {MetricsPanelCtrl} from 'app/features/panel/metrics_panel_ctrl';
33
import {QueryCtrl} from 'app/features/panel/query_ctrl';
44

5+
import config from 'app/core/config';
6+
7+
export function loadPluginCss(options) {
8+
if (config.bootData.user.lightTheme) {
9+
System.import(options.light + '!css');
10+
} else {
11+
System.import(options.dark + '!css');
12+
}
13+
}
14+
515
export {
616
PanelCtrl,
717
MetricsPanelCtrl,

public/views/index.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@
1010

1111
[[if .User.LightTheme]]
1212
<link rel="stylesheet" href="[[.AppSubUrl]]/public/css/grafana.light.min.css">
13-
[[ range $css := .PluginCss ]]
14-
<link rel="stylesheet" href="[[$.AppSubUrl]]/[[ $css.Light ]]">
15-
[[ end ]]
1613
[[else]]
1714
<link rel="stylesheet" href="[[.AppSubUrl]]/public/css/grafana.dark.min.css">
18-
[[ range $css := .PluginCss ]]
19-
<link rel="stylesheet" href="[[$.AppSubUrl]]/[[ $css.Dark ]]">
20-
[[ end ]]
2115
[[end]]
2216

2317
<link rel="icon" type="image/png" href="[[.AppSubUrl]]/public/img/fav32.png">

0 commit comments

Comments
 (0)