mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Panel help view fixes
This commit is contained in:
parent
9fec202668
commit
60ea99078e
@ -164,6 +164,14 @@ func GetPluginMarkdown(c *m.ReqContext) Response {
|
||||
return Error(500, "Could not get markdown file", err)
|
||||
}
|
||||
|
||||
// fallback try readme
|
||||
if len(content) == 0 {
|
||||
content, err = plugins.GetPluginMarkdown(pluginID, "readme")
|
||||
if err != nil {
|
||||
return Error(501, "Could not get markdown file", err)
|
||||
}
|
||||
}
|
||||
|
||||
resp := Respond(200, content)
|
||||
resp.Header("Content-Type", "text/plain; charset=utf-8")
|
||||
return resp
|
||||
|
@ -3,10 +3,8 @@ package plugins
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-plugin-model/go/datasource"
|
||||
@ -29,7 +27,6 @@ type DataSourcePlugin struct {
|
||||
QueryOptions map[string]bool `json:"queryOptions,omitempty"`
|
||||
BuiltIn bool `json:"builtIn,omitempty"`
|
||||
Mixed bool `json:"mixed,omitempty"`
|
||||
HasQueryHelp bool `json:"hasQueryHelp,omitempty"`
|
||||
Routes []*AppPluginRoute `json:"routes"`
|
||||
|
||||
Backend bool `json:"backend,omitempty"`
|
||||
@ -48,15 +45,6 @@ func (p *DataSourcePlugin) Load(decoder *json.Decoder, pluginDir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// look for help markdown
|
||||
helpPath := filepath.Join(p.PluginDir, "QUERY_HELP.md")
|
||||
if _, err := os.Stat(helpPath); os.IsNotExist(err) {
|
||||
helpPath = filepath.Join(p.PluginDir, "query_help.md")
|
||||
}
|
||||
if _, err := os.Stat(helpPath); err == nil {
|
||||
p.HasQueryHelp = true
|
||||
}
|
||||
|
||||
DataSources[p.Id] = p
|
||||
return nil
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import Remarkable from 'remarkable';
|
||||
import { getBackendSrv } from '../../services/backend_srv';
|
||||
import { PluginMeta } from 'app/types';
|
||||
|
||||
interface Props {
|
||||
plugin: PluginMeta;
|
||||
plugin: {
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
type: string;
|
||||
}
|
||||
|
||||
@ -14,7 +16,7 @@ interface State {
|
||||
help: string;
|
||||
}
|
||||
|
||||
export default class PluginHelp extends PureComponent<Props, State> {
|
||||
export class PluginHelp extends PureComponent<Props, State> {
|
||||
state = {
|
||||
isError: false,
|
||||
isLoading: false,
|
||||
@ -25,24 +27,9 @@ export default class PluginHelp extends PureComponent<Props, State> {
|
||||
this.loadHelp();
|
||||
}
|
||||
|
||||
constructPlaceholderInfo = () => {
|
||||
const { plugin } = this.props;
|
||||
const markdown = new Remarkable();
|
||||
|
||||
const fallBack = markdown.render(
|
||||
`## ${plugin.name} \n by _${plugin.info.author.name} (<${plugin.info.author.url}>)_\n\n${
|
||||
plugin.info.description
|
||||
}\n\n${
|
||||
plugin.info.links
|
||||
? `### Links \n ${plugin.info.links.map(link => {
|
||||
return `${link.name}: <${link.url}>\n`;
|
||||
})}`
|
||||
: ''
|
||||
}`
|
||||
);
|
||||
|
||||
return fallBack;
|
||||
};
|
||||
constructPlaceholderInfo() {
|
||||
return 'No plugin help or readme markdown file was found';
|
||||
}
|
||||
|
||||
loadHelp = () => {
|
||||
const { plugin, type } = this.props;
|
@ -21,7 +21,7 @@ import config from 'app/core/config';
|
||||
import { PanelModel } from '../panel_model';
|
||||
import { DashboardModel } from '../dashboard_model';
|
||||
import { DataSourceSelectItem, DataQuery } from 'app/types';
|
||||
import PluginHelp from '../../../core/components/PanelHelp/PluginHelp';
|
||||
import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp';
|
||||
|
||||
interface Props {
|
||||
panel: PanelModel;
|
||||
@ -203,7 +203,6 @@ export class QueriesTab extends PureComponent<Props, State> {
|
||||
render() {
|
||||
const { panel } = this.props;
|
||||
const { currentDS, isAddingMixed } = this.state;
|
||||
const { hasQueryHelp } = currentDS.meta;
|
||||
|
||||
const queryInspector = {
|
||||
title: 'Query Inspector',
|
||||
@ -213,7 +212,6 @@ export class QueriesTab extends PureComponent<Props, State> {
|
||||
const dsHelp = {
|
||||
heading: 'Help',
|
||||
icon: 'fa fa-question',
|
||||
disabled: !hasQueryHelp,
|
||||
render: this.renderHelp,
|
||||
};
|
||||
|
||||
|
@ -3,12 +3,11 @@ import React, { PureComponent } from 'react';
|
||||
|
||||
// Utils & Services
|
||||
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
|
||||
import { getDatasourceSrv } from '../../plugins/datasource_srv';
|
||||
|
||||
// Components
|
||||
import { EditorTabBody } from './EditorTabBody';
|
||||
import { VizTypePicker } from './VizTypePicker';
|
||||
import PluginHelp from 'app/core/components/PanelHelp/PluginHelp';
|
||||
import { PluginHelp } from 'app/core/components/PluginHelp/PluginHelp';
|
||||
import { FadeIn } from 'app/core/components/Animations/FadeIn';
|
||||
import { PanelOptionSection } from './PanelOptionSection';
|
||||
|
||||
@ -16,7 +15,6 @@ import { PanelOptionSection } from './PanelOptionSection';
|
||||
import { PanelModel } from '../panel_model';
|
||||
import { DashboardModel } from '../dashboard_model';
|
||||
import { PanelPlugin } from 'app/types/plugins';
|
||||
import { DataSourceSelectItem } from 'app/types';
|
||||
|
||||
interface Props {
|
||||
panel: PanelModel;
|
||||
@ -27,7 +25,6 @@ interface Props {
|
||||
}
|
||||
|
||||
interface State {
|
||||
currentDataSource: DataSourceSelectItem;
|
||||
isVizPickerOpen: boolean;
|
||||
searchQuery: string;
|
||||
}
|
||||
@ -36,16 +33,13 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
||||
element: HTMLElement;
|
||||
angularOptions: AngularComponent;
|
||||
searchInput: HTMLElement;
|
||||
dataSources: DataSourceSelectItem[] = getDatasourceSrv().getMetricSources();
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const { panel } = props;
|
||||
|
||||
this.state = {
|
||||
isVizPickerOpen: false,
|
||||
searchQuery: '',
|
||||
currentDataSource: this.dataSources.find(datasource => datasource.value === panel.datasource),
|
||||
};
|
||||
}
|
||||
|
||||
@ -205,7 +199,7 @@ export class VisualizationTab extends PureComponent<Props, State> {
|
||||
}
|
||||
};
|
||||
|
||||
renderHelp = () => <PluginHelp plugin={this.state.currentDataSource.meta} type="help" />;
|
||||
renderHelp = () => <PluginHelp plugin={this.props.plugin} type="help" />;
|
||||
|
||||
render() {
|
||||
const { plugin } = this.props;
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Graph Panel - Native Plugin
|
||||
# Graph Panel
|
||||
|
||||
The Graph is the main graph panel and is **included** with Grafana. It provides a very rich set of graphing options.
|
||||
This is the main Graph panel and is **included** with Grafana. It provides a very rich set of graphing options.
|
||||
|
||||
Read more about it here:
|
||||
For full reference documentation:
|
||||
|
||||
[http://docs.grafana.org/reference/graph/](http://docs.grafana.org/reference/graph/)
|
||||
[http://docs.grafana.org/reference/graph/](http://docs.grafana.org/reference/graph/)
|
||||
|
Loading…
Reference in New Issue
Block a user