mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 21:32:22 +08:00
AppPlugins: Options to disable showing config page in nav (#31354)
* AppPlugins: Options to disable showing config page in nav * rename * Added autoEnabled * updated * Things are working sort of * Simplify
This commit is contained in:
@ -122,6 +122,10 @@
|
|||||||
"hiddenQueries": {
|
"hiddenQueries": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"autoEnabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Set to true for app plugins that should be enabled by default in all orgs"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Dependencies needed by the plugin.",
|
"description": "Dependencies needed by the plugin.",
|
||||||
|
@ -128,6 +128,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginsToPreload := []string{}
|
pluginsToPreload := []string{}
|
||||||
for _, app := range enabledPlugins.Apps {
|
for _, app := range enabledPlugins.Apps {
|
||||||
if app.Preload {
|
if app.Preload {
|
||||||
|
@ -117,13 +117,6 @@ func getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(appLink.Children) > 0 && c.OrgRole == models.ROLE_ADMIN {
|
|
||||||
appLink.Children = append(appLink.Children, &dtos.NavLink{Divider: true})
|
|
||||||
appLink.Children = append(appLink.Children, &dtos.NavLink{
|
|
||||||
Text: "Plugin Config", Icon: "cog", Url: setting.AppSubUrl + "/plugins/" + plugin.Id + "/",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(appLink.Children) > 0 {
|
if len(appLink.Children) > 0 {
|
||||||
appLinks = append(appLinks, appLink)
|
appLinks = append(appLinks, appLink)
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,11 @@ func GetPluginSettingByID(c *models.ReqContext) response.Response {
|
|||||||
SignatureOrg: def.SignatureOrg,
|
SignatureOrg: def.SignatureOrg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app, ok := plugins.Apps[def.Id]; ok {
|
||||||
|
dto.Enabled = app.AutoEnabled
|
||||||
|
dto.Pinned = app.AutoEnabled
|
||||||
|
}
|
||||||
|
|
||||||
query := models.GetPluginSettingByIdQuery{PluginId: pluginID, OrgId: c.OrgId}
|
query := models.GetPluginSettingByIdQuery{PluginId: pluginID, OrgId: c.OrgId}
|
||||||
if err := bus.Dispatch(&query); err != nil {
|
if err := bus.Dispatch(&query); err != nil {
|
||||||
if !errors.Is(err, models.ErrPluginSettingNotFound) {
|
if !errors.Is(err, models.ErrPluginSettingNotFound) {
|
||||||
|
@ -15,7 +15,8 @@ import (
|
|||||||
|
|
||||||
type AppPlugin struct {
|
type AppPlugin struct {
|
||||||
FrontendPluginBase
|
FrontendPluginBase
|
||||||
Routes []*AppPluginRoute `json:"routes"`
|
Routes []*AppPluginRoute `json:"routes"`
|
||||||
|
AutoEnabled bool `json:"autoEnabled"`
|
||||||
|
|
||||||
FoundChildPlugins []*PluginInclude `json:"-"`
|
FoundChildPlugins []*PluginInclude `json:"-"`
|
||||||
Pinned bool `json:"-"`
|
Pinned bool `json:"-"`
|
||||||
|
@ -30,9 +30,10 @@ func GetPluginSettings(orgId int64) (map[string]*models.PluginSettingInfoDTO, er
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// apps are disabled by default
|
// apps are disabled by default unless autoEnabled: true
|
||||||
if pluginDef.Type == PluginTypeApp {
|
if app, exists := Apps[pluginDef.Id]; exists {
|
||||||
opt.Enabled = false
|
opt.Enabled = app.AutoEnabled
|
||||||
|
opt.Pinned = app.AutoEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's included in app check app settings
|
// if it's included in app check app settings
|
||||||
|
@ -400,7 +400,7 @@ function getPluginTabsNav(
|
|||||||
if (plugin.angularConfigCtrl) {
|
if (plugin.angularConfigCtrl) {
|
||||||
pages.push({
|
pages.push({
|
||||||
text: 'Config',
|
text: 'Config',
|
||||||
icon: 'gicon gicon-cog',
|
icon: 'cog',
|
||||||
url: `${appSubUrl}${path}?page=${PAGE_ID_CONFIG_CTRL}`,
|
url: `${appSubUrl}${path}?page=${PAGE_ID_CONFIG_CTRL}`,
|
||||||
id: PAGE_ID_CONFIG_CTRL,
|
id: PAGE_ID_CONFIG_CTRL,
|
||||||
});
|
});
|
||||||
@ -426,7 +426,7 @@ function getPluginTabsNav(
|
|||||||
if (find(meta.includes, { type: PluginIncludeType.dashboard })) {
|
if (find(meta.includes, { type: PluginIncludeType.dashboard })) {
|
||||||
pages.push({
|
pages.push({
|
||||||
text: 'Dashboards',
|
text: 'Dashboards',
|
||||||
icon: 'gicon gicon-dashboard',
|
icon: 'apps',
|
||||||
url: `${appSubUrl}${path}?page=${PAGE_ID_DASHBOARDS}`,
|
url: `${appSubUrl}${path}?page=${PAGE_ID_DASHBOARDS}`,
|
||||||
id: PAGE_ID_DASHBOARDS,
|
id: PAGE_ID_DASHBOARDS,
|
||||||
});
|
});
|
||||||
|
@ -38,6 +38,7 @@ export class AppPageCtrl {
|
|||||||
this.navModel = this.navModelSrv.getNotFoundNav();
|
this.navModel = this.navModelSrv.getNotFoundNav();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.type !== 'app' || !app.enabled) {
|
if (app.type !== 'app' || !app.enabled) {
|
||||||
this.$rootScope.appEvent(AppEvents.alertError, ['Application Not Enabled']);
|
this.$rootScope.appEvent(AppEvents.alertError, ['Application Not Enabled']);
|
||||||
this.navModel = this.navModelSrv.getNotFoundNav();
|
this.navModel = this.navModelSrv.getNotFoundNav();
|
||||||
|
Reference in New Issue
Block a user