Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
f7c55d39
Commit
f7c55d39
authored
Aug 21, 2019
by
Ryan McKinley
Committed by
Torkel Ödegaard
Aug 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plugins: better warning when plugins fail to load (#18671)
* better pluin feedback * add server side check for module.js
parent
c98c5c3c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
15 deletions
+44
-15
pkg/plugins/plugins.go
+11
-0
public/app/core/components/AlertBox/AlertBox.tsx
+4
-4
public/app/core/components/AppNotifications/AppNotificationItem.tsx
+1
-1
public/app/features/dashboard/containers/DashboardPage.tsx
+1
-1
public/app/features/dashboard/dashgrid/PanelPluginError.tsx
+24
-6
public/app/features/plugins/plugin_loader.ts
+3
-3
No files found.
pkg/plugins/plugins.go
View file @
f7c55d39
...
...
@@ -216,6 +216,17 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error {
}
loader
=
reflect
.
New
(
reflect
.
TypeOf
(
pluginGoType
))
.
Interface
()
.
(
PluginLoader
)
// External plugins need a module.js file for SystemJS to load
if
!
strings
.
HasPrefix
(
pluginJsonFilePath
,
setting
.
StaticRootPath
)
{
module
:=
filepath
.
Join
(
filepath
.
Dir
(
pluginJsonFilePath
),
"module.js"
)
if
_
,
err
:=
os
.
Stat
(
module
);
os
.
IsNotExist
(
err
)
{
plog
.
Warn
(
"Plugin missing module.js"
,
"name"
,
pluginCommon
.
Name
,
"warning"
,
"Missing module.js, If you loaded this plugin from git, make sure to compile it."
,
"path"
,
module
)
}
}
reader
.
Seek
(
0
,
0
)
return
loader
.
Load
(
jsonParser
,
currentDir
)
}
...
...
public/app/core/components/AlertBox/AlertBox.tsx
View file @
f7c55d39
import
React
,
{
FunctionComponent
}
from
'react'
;
import
React
,
{
FunctionComponent
,
ReactNode
}
from
'react'
;
import
{
AppNotificationSeverity
}
from
'app/types'
;
interface
Props
{
title
:
string
;
icon
?:
string
;
text
?:
string
;
body
?:
ReactNode
;
severity
:
AppNotificationSeverity
;
onClose
?:
()
=>
void
;
}
...
...
@@ -22,7 +22,7 @@ function getIconFromSeverity(severity: AppNotificationSeverity): string {
}
}
export
const
AlertBox
:
FunctionComponent
<
Props
>
=
({
title
,
icon
,
text
,
severity
,
onClose
})
=>
{
export
const
AlertBox
:
FunctionComponent
<
Props
>
=
({
title
,
icon
,
body
,
severity
,
onClose
})
=>
{
return
(
<
div
className=
{
`alert alert-${severity}`
}
>
<
div
className=
"alert-icon"
>
...
...
@@ -30,7 +30,7 @@ export const AlertBox: FunctionComponent<Props> = ({ title, icon, text, severity
</
div
>
<
div
className=
"alert-body"
>
<
div
className=
"alert-title"
>
{
title
}
</
div
>
{
text
&&
<
div
className=
"alert-text"
>
{
text
}
</
div
>
}
{
body
&&
<
div
className=
"alert-text"
>
{
body
}
</
div
>
}
</
div
>
{
onClose
&&
(
<
button
type=
"button"
className=
"alert-close"
onClick=
{
onClose
}
>
...
...
public/app/core/components/AppNotifications/AppNotificationItem.tsx
View file @
f7c55d39
...
...
@@ -26,7 +26,7 @@ export default class AppNotificationItem extends Component<Props> {
<
AlertBox
severity=
{
appNotification
.
severity
}
title=
{
appNotification
.
title
}
text
=
{
appNotification
.
text
}
body
=
{
appNotification
.
text
}
icon=
{
appNotification
.
icon
}
onClose=
{
()
=>
onClearNotification
(
appNotification
.
id
)
}
/>
...
...
public/app/features/dashboard/containers/DashboardPage.tsx
View file @
f7c55d39
...
...
@@ -245,7 +245,7 @@ export class DashboardPage extends PureComponent<Props, State> {
<
AlertBox
severity=
{
AppNotificationSeverity
.
Error
}
title=
{
initError
.
message
}
text
=
{
getMessageFromError
(
initError
.
error
)
}
body
=
{
getMessageFromError
(
initError
.
error
)
}
/>
</
div
>
);
...
...
public/app/features/dashboard/dashgrid/PanelPlugin
NotFound
.tsx
→
public/app/features/dashboard/dashgrid/PanelPlugin
Error
.tsx
View file @
f7c55d39
// Libraries
import
_
from
'lodash'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
,
ReactNode
}
from
'react'
;
// Components
import
{
AlertBox
}
from
'app/core/components/AlertBox/AlertBox'
;
// Types
import
{
AppNotificationSeverity
}
from
'app/types'
;
import
{
PanelProps
,
PanelPlugin
,
PluginType
}
from
'@grafana/ui'
;
import
{
PanelProps
,
PanelPlugin
,
PluginType
,
PanelPluginMeta
}
from
'@grafana/ui'
;
interface
Props
{
pluginId
:
string
;
title
:
string
;
text
?:
ReactNode
;
}
class
PanelPlugin
NotFound
extends
PureComponent
<
Props
>
{
class
PanelPlugin
Error
extends
PureComponent
<
Props
>
{
constructor
(
props
:
Props
)
{
super
(
props
);
}
...
...
@@ -28,16 +29,33 @@ class PanelPluginNotFound extends PureComponent<Props> {
return
(
<
div
style=
{
style
}
>
<
AlertBox
severity=
{
AppNotificationSeverity
.
Error
}
title=
{
`Panel plugin not found: ${this.props.pluginId}`
}
/>
<
AlertBox
severity=
{
AppNotificationSeverity
.
Error
}
{
...
this
.
props
}
/>
</
div
>
);
}
}
export
function
getPanelPluginLoadError
(
meta
:
PanelPluginMeta
,
err
:
any
):
PanelPlugin
{
const
NotFound
=
class
NotFound
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
(
NotFound
);
plugin
.
meta
=
meta
;
return
plugin
;
}
export
function
getPanelPluginNotFound
(
id
:
string
):
PanelPlugin
{
const
NotFound
=
class
NotFound
extends
PureComponent
<
PanelProps
>
{
render
()
{
return
<
PanelPlugin
NotFound
pluginId=
{
id
}
/>;
return
<
PanelPlugin
Error
title=
{
`Panel plugin not found: ${id}`
}
/>;
}
};
...
...
public/app/features/plugins/plugin_loader.ts
View file @
f7c55d39
...
...
@@ -199,7 +199,7 @@ export function importAppPlugin(meta: PluginMeta): Promise<AppPlugin> {
});
}
import
{
getPanelPluginNotFound
}
from
'../dashboard/dashgrid/PanelPluginNotFound
'
;
import
{
getPanelPluginNotFound
,
getPanelPluginLoadError
}
from
'../dashboard/dashgrid/PanelPluginError
'
;
interface
PanelCache
{
[
key
:
string
]:
PanelPlugin
;
...
...
@@ -233,7 +233,7 @@ export function importPanelPlugin(id: string): Promise<PanelPlugin> {
})
.
catch
(
err
=>
{
// TODO, maybe a different error plugin
console
.
log
(
'Error loading panel plugin'
,
err
);
return
getPanelPlugin
NotFound
(
id
);
console
.
warn
(
'Error loading panel plugin: '
+
id
,
err
);
return
getPanelPlugin
LoadError
(
meta
,
err
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment