| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | package api | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2016-09-23 18:29:53 +08:00
										 |  |  | 	"fmt" | 
					
						
							| 
									
										
										
										
											2022-04-15 20:01:58 +08:00
										 |  |  | 	"net/http" | 
					
						
							| 
									
										
										
										
											2022-02-05 01:14:53 +08:00
										 |  |  | 	"path" | 
					
						
							| 
									
										
										
										
											2019-11-15 16:28:55 +08:00
										 |  |  | 	"sort" | 
					
						
							| 
									
										
										
										
											2016-07-05 23:59:43 +08:00
										 |  |  | 	"strings" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-05 17:37:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/api/dtos" | 
					
						
							| 
									
										
										
										
											2021-10-05 21:54:26 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/api/navlinks" | 
					
						
							| 
									
										
										
										
											2020-03-04 19:57:20 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/models" | 
					
						
							| 
									
										
										
										
											2021-11-01 17:53:33 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/plugins" | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 	ac "github.com/grafana/grafana/pkg/services/accesscontrol" | 
					
						
							| 
									
										
										
										
											2022-08-26 18:27:28 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/correlations" | 
					
						
							| 
									
										
										
										
											2022-03-10 00:57:50 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/dashboards" | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/datasources" | 
					
						
							| 
									
										
										
										
											2022-01-27 01:44:20 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/featuremgmt" | 
					
						
							| 
									
										
										
										
											2022-08-10 17:56:48 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/org" | 
					
						
							| 
									
										
										
										
											2022-04-21 21:03:17 +08:00
										 |  |  | 	pref "github.com/grafana/grafana/pkg/services/preference" | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/services/star" | 
					
						
							| 
									
										
										
										
											2015-02-05 17:37:13 +08:00
										 |  |  | 	"github.com/grafana/grafana/pkg/setting" | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-22 16:50:00 +08:00
										 |  |  | const ( | 
					
						
							|  |  |  | 	// Themes
 | 
					
						
							|  |  |  | 	lightName = "light" | 
					
						
							|  |  |  | 	darkName  = "dark" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | func (hs *HTTPServer) getProfileNode(c *models.ReqContext) *dtos.NavLink { | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	// Only set login if it's different from the name
 | 
					
						
							|  |  |  | 	var login string | 
					
						
							|  |  |  | 	if c.SignedInUser.Login != c.SignedInUser.NameOrFallback() { | 
					
						
							|  |  |  | 		login = c.SignedInUser.Login | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	gravatarURL := dtos.GetGravatarUrl(c.Email) | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	children := []*dtos.NavLink{ | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2022-07-11 20:35:30 +08:00
										 |  |  | 			Text: "Preferences", Id: "profile/settings", Url: hs.Cfg.AppSubURL + "/profile", Icon: "sliders-v-alt", | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2020-11-21 00:01:10 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 19:03:04 +08:00
										 |  |  | 	children = append(children, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-07-26 17:11:40 +08:00
										 |  |  | 		Text: "Notification history", Id: "profile/notifications", Url: hs.Cfg.AppSubURL + "/profile/notifications", Icon: "bell", | 
					
						
							| 
									
										
										
										
											2022-05-26 19:03:04 +08:00
										 |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2022-04-20 17:42:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 00:01:10 +08:00
										 |  |  | 	if setting.AddChangePasswordLink() { | 
					
						
							|  |  |  | 		children = append(children, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-07-11 20:35:30 +08:00
										 |  |  | 			Text: "Change password", Id: "profile/password", Url: hs.Cfg.AppSubURL + "/profile/password", | 
					
						
							| 
									
										
										
										
											2021-08-31 17:37:51 +08:00
										 |  |  | 			Icon: "lock", | 
					
						
							| 
									
										
										
										
											2020-11-21 00:01:10 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-04-03 04:54:06 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-11-21 00:01:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	if !setting.DisableSignoutMenu { | 
					
						
							|  |  |  | 		// add sign out first
 | 
					
						
							|  |  |  | 		children = append(children, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:         "Sign out", | 
					
						
							|  |  |  | 			Id:           "sign-out", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:          hs.Cfg.AppSubURL + "/logout", | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			Icon:         "arrow-from-right", | 
					
						
							|  |  |  | 			Target:       "_self", | 
					
						
							|  |  |  | 			HideFromTabs: true, | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-07-05 23:59:43 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	return &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 		Text:       c.SignedInUser.NameOrFallback(), | 
					
						
							|  |  |  | 		SubTitle:   login, | 
					
						
							|  |  |  | 		Id:         "profile", | 
					
						
							|  |  |  | 		Img:        gravatarURL, | 
					
						
							|  |  |  | 		Url:        hs.Cfg.AppSubURL + "/profile", | 
					
						
							|  |  |  | 		Section:    dtos.NavSectionConfig, | 
					
						
							|  |  |  | 		SortWeight: dtos.WeightProfile, | 
					
						
							|  |  |  | 		Children:   children, | 
					
						
							| 
									
										
										
										
											2022-09-01 17:28:50 +08:00
										 |  |  | 		RoundIcon:  true, | 
					
						
							| 
									
										
										
										
											2016-09-23 18:29:53 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-09-23 18:29:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 14:02:49 +08:00
										 |  |  | func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error) { | 
					
						
							| 
									
										
										
										
											2022-07-08 19:24:09 +08:00
										 |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 	enabledPlugins, err := hs.enabledPlugins(c.Req.Context(), c.OrgID) | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2018-04-30 21:34:31 +08:00
										 |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	appLinks := []*dtos.NavLink{} | 
					
						
							| 
									
										
										
										
											2021-11-01 17:53:33 +08:00
										 |  |  | 	for _, plugin := range enabledPlugins[plugins.App] { | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		if !plugin.Pinned { | 
					
						
							|  |  |  | 			continue | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-09-07 22:19:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-08 19:24:09 +08:00
										 |  |  | 		if !hasAccess(ac.ReqSignedIn, | 
					
						
							|  |  |  | 			ac.EvalPermission(plugins.ActionAppAccess, plugins.ScopeProvider.GetResourceScope(plugin.ID))) { | 
					
						
							|  |  |  | 			continue | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		appLink := &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:       plugin.Name, | 
					
						
							| 
									
										
										
										
											2021-11-01 17:53:33 +08:00
										 |  |  | 			Id:         "plugin-page-" + plugin.ID, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			Img:        plugin.Info.Logos.Small, | 
					
						
							| 
									
										
										
										
											2022-06-16 17:48:38 +08:00
										 |  |  | 			Section:    dtos.NavSectionPlugin, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			SortWeight: dtos.WeightPlugin, | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 			appLink.Url = path.Join(hs.Cfg.AppSubURL, "a", plugin.ID) | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			appLink.Url = path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		for _, include := range plugin.Includes { | 
					
						
							|  |  |  | 			if !c.HasUserRole(include.Role) { | 
					
						
							|  |  |  | 				continue | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-05-01 14:40:13 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			if include.Type == "page" && include.AddToNav { | 
					
						
							|  |  |  | 				var link *dtos.NavLink | 
					
						
							|  |  |  | 				if len(include.Path) > 0 { | 
					
						
							|  |  |  | 					link = &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 						Url:  hs.Cfg.AppSubURL + include.Path, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 						Text: include.Name, | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 					if include.DefaultNav && !hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 						appLink.Url = link.Url // Overwrite the hardcoded page logic
 | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					link = &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2021-11-01 17:53:33 +08:00
										 |  |  | 						Url:  hs.Cfg.AppSubURL + "/plugins/" + plugin.ID + "/page/" + include.Slug, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 						Text: include.Name, | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2020-11-27 17:48:37 +08:00
										 |  |  | 				link.Icon = include.Icon | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 				appLink.Children = append(appLink.Children, link) | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-02-03 17:46:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			if include.Type == "dashboard" && include.AddToNav { | 
					
						
							| 
									
										
										
										
											2022-04-06 16:50:39 +08:00
										 |  |  | 				dboardURL := include.DashboardURLPath() | 
					
						
							|  |  |  | 				if dboardURL != "" { | 
					
						
							|  |  |  | 					link := &dtos.NavLink{ | 
					
						
							|  |  |  | 						Url:  path.Join(hs.Cfg.AppSubURL, dboardURL), | 
					
						
							|  |  |  | 						Text: include.Name, | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					appLink.Children = append(appLink.Children, link) | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if len(appLink.Children) > 0 { | 
					
						
							| 
									
										
										
										
											2021-12-13 21:06:15 +08:00
										 |  |  | 			// If we only have one child and it's the app default nav then remove it from children
 | 
					
						
							|  |  |  | 			if len(appLink.Children) == 1 && appLink.Children[0].Url == appLink.Url { | 
					
						
							|  |  |  | 				appLink.Children = []*dtos.NavLink{} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			appLinks = append(appLinks, appLink) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-04-02 15:21:38 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-07 17:08:47 +08:00
										 |  |  | 	if len(appLinks) > 0 { | 
					
						
							|  |  |  | 		sort.SliceStable(appLinks, func(i, j int) bool { | 
					
						
							|  |  |  | 			return appLinks[i].Text < appLinks[j].Text | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	return appLinks, nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-05 22:32:38 +08:00
										 |  |  | func enableServiceAccount(hs *HTTPServer, c *models.ReqContext) bool { | 
					
						
							| 
									
										
										
										
											2022-04-14 19:40:15 +08:00
										 |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							|  |  |  | 	return hasAccess(ac.ReqOrgAdmin, serviceAccountAccessEvaluator) | 
					
						
							| 
									
										
										
										
											2022-01-05 22:32:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 00:49:39 +08:00
										 |  |  | func (hs *HTTPServer) ReqCanAdminTeams(c *models.ReqContext) bool { | 
					
						
							| 
									
										
										
										
											2022-08-10 17:56:48 +08:00
										 |  |  | 	return c.OrgRole == org.RoleAdmin || (hs.Cfg.EditorsCanAdmin && c.OrgRole == org.RoleEditor) | 
					
						
							| 
									
										
										
										
											2022-01-05 22:32:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-14 22:15:09 +08:00
										 |  |  | //nolint:gocyclo
 | 
					
						
							| 
									
										
										
										
											2022-04-24 23:50:10 +08:00
										 |  |  | func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool, prefs *pref.Preference) ([]*dtos.NavLink, error) { | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | 	var navTree []*dtos.NavLink | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-02 16:57:32 +08:00
										 |  |  | 	if hasAccess(ac.ReqSignedIn, ac.EvalPermission(dashboards.ActionDashboardsRead)) { | 
					
						
							|  |  |  | 		starredItemsLinks, err := hs.buildStarredItemsNavLinks(c, prefs) | 
					
						
							|  |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			return nil, err | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-02 16:57:32 +08:00
										 |  |  | 		navTree = append(navTree, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:           "Starred", | 
					
						
							|  |  |  | 			Id:             "starred", | 
					
						
							|  |  |  | 			Icon:           "star", | 
					
						
							|  |  |  | 			SortWeight:     dtos.WeightSavedItems, | 
					
						
							|  |  |  | 			Section:        dtos.NavSectionCore, | 
					
						
							|  |  |  | 			Children:       starredItemsLinks, | 
					
						
							|  |  |  | 			EmptyMessageId: "starred-empty", | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2022-06-27 22:41:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-02 16:57:32 +08:00
										 |  |  | 		dashboardChildLinks := hs.buildDashboardNavLinks(c, hasEditPerm) | 
					
						
							| 
									
										
										
										
											2020-12-02 22:51:22 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-02 16:57:32 +08:00
										 |  |  | 		dashboardsUrl := "/dashboards" | 
					
						
							| 
									
										
										
										
											2016-03-10 23:38:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-07 16:24:10 +08:00
										 |  |  | 		dashboardLink := &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-08-02 16:57:32 +08:00
										 |  |  | 			Text:       "Dashboards", | 
					
						
							|  |  |  | 			Id:         "dashboards", | 
					
						
							|  |  |  | 			SubTitle:   "Manage dashboards and folders", | 
					
						
							|  |  |  | 			Icon:       "apps", | 
					
						
							|  |  |  | 			Url:        hs.Cfg.AppSubURL + dashboardsUrl, | 
					
						
							|  |  |  | 			SortWeight: dtos.WeightDashboard, | 
					
						
							|  |  |  | 			Section:    dtos.NavSectionCore, | 
					
						
							|  |  |  | 			Children:   dashboardChildLinks, | 
					
						
							| 
									
										
										
										
											2022-09-07 16:24:10 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 			dashboardLink.Id = "dashboards/browse" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		navTree = append(navTree, dashboardLink) | 
					
						
							| 
									
										
										
										
											2022-08-02 16:57:32 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-11-20 16:43:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-02 20:43:12 +08:00
										 |  |  | 	canExplore := func(context *models.ReqContext) bool { | 
					
						
							| 
									
										
										
										
											2022-08-10 17:56:48 +08:00
										 |  |  | 		return c.OrgRole == org.RoleAdmin || c.OrgRole == org.RoleEditor || setting.ViewersCanEdit | 
					
						
							| 
									
										
										
										
											2021-07-02 20:43:12 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	if setting.ExploreEnabled && hasAccess(canExplore, ac.EvalPermission(ac.ActionDatasourcesExplore)) { | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		navTree = append(navTree, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2019-11-15 16:28:55 +08:00
										 |  |  | 			Text:       "Explore", | 
					
						
							|  |  |  | 			Id:         "explore", | 
					
						
							|  |  |  | 			SubTitle:   "Explore your data", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:       "compass", | 
					
						
							| 
									
										
										
										
											2019-11-15 16:28:55 +08:00
										 |  |  | 			SortWeight: dtos.WeightExplore, | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 			Section:    dtos.NavSectionCore, | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:        hs.Cfg.AppSubURL + "/explore", | 
					
						
							| 
									
										
										
										
											2018-04-27 17:39:14 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-26 17:58:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 23:27:53 +08:00
										 |  |  | 	navTree = hs.addProfile(navTree, c) | 
					
						
							| 
									
										
										
										
											2017-08-16 02:24:16 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 	_, uaIsDisabledForOrg := hs.Cfg.UnifiedAlerting.DisabledOrgs[c.OrgID] | 
					
						
							| 
									
										
										
										
											2021-11-25 03:56:07 +08:00
										 |  |  | 	uaVisibleForOrg := hs.Cfg.UnifiedAlerting.IsEnabled() && !uaIsDisabledForOrg | 
					
						
							| 
									
										
										
										
											2021-10-21 16:04:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 	if setting.AlertingEnabled != nil && *setting.AlertingEnabled { | 
					
						
							| 
									
										
										
										
											2022-05-26 00:13:49 +08:00
										 |  |  | 		navTree = append(navTree, hs.buildLegacyAlertNavLinks(c)...) | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 	} else if uaVisibleForOrg { | 
					
						
							|  |  |  | 		navTree = append(navTree, hs.buildAlertNavLinks(c)...) | 
					
						
							| 
									
										
										
										
											2016-05-03 22:46:10 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-10 18:13:31 +08:00
										 |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagDataConnectionsConsole) { | 
					
						
							|  |  |  | 		navTree = append(navTree, hs.buildDataConnectionsNavLink(c)) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 14:02:49 +08:00
										 |  |  | 	appLinks, err := hs.getAppLinks(c) | 
					
						
							| 
									
										
										
										
											2015-12-03 23:43:55 +08:00
										 |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-07-22 16:42:41 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// When topnav is enabled we can test new information architecture where plugins live in Apps category
 | 
					
						
							|  |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 		navTree = append(navTree, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Apps", | 
					
						
							|  |  |  | 			Icon:        "apps", | 
					
						
							|  |  |  | 			Description: "App plugins", | 
					
						
							|  |  |  | 			Id:          "apps", | 
					
						
							|  |  |  | 			Children:    appLinks, | 
					
						
							|  |  |  | 			Section:     dtos.NavSectionCore, | 
					
						
							|  |  |  | 			Url:         hs.Cfg.AppSubURL + "/apps", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		navTree = append(navTree, appLinks...) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-11-11 14:30:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | 	configNodes, err := hs.setupConfigNodes(c) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return navTree, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagLivePipeline) { | 
					
						
							|  |  |  | 		liveNavLinks := []*dtos.NavLink{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		liveNavLinks = append(liveNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Status", Id: "live-status", Url: hs.Cfg.AppSubURL + "/live", Icon: "exchange-alt", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		liveNavLinks = append(liveNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Pipeline", Id: "live-pipeline", Url: hs.Cfg.AppSubURL + "/live/pipeline", Icon: "arrow-to-right", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		liveNavLinks = append(liveNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Cloud", Id: "live-cloud", Url: hs.Cfg.AppSubURL + "/live/cloud", Icon: "cloud-upload", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		navTree = append(navTree, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Id:           "live", | 
					
						
							|  |  |  | 			Text:         "Live", | 
					
						
							|  |  |  | 			SubTitle:     "Event streaming", | 
					
						
							|  |  |  | 			Icon:         "exchange-alt", | 
					
						
							|  |  |  | 			Url:          hs.Cfg.AppSubURL + "/live", | 
					
						
							|  |  |  | 			Children:     liveNavLinks, | 
					
						
							|  |  |  | 			Section:      dtos.NavSectionConfig, | 
					
						
							|  |  |  | 			HideFromTabs: true, | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var configNode *dtos.NavLink | 
					
						
							|  |  |  | 	var serverAdminNode *dtos.NavLink | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(configNodes) > 0 { | 
					
						
							|  |  |  | 		configNode = &dtos.NavLink{ | 
					
						
							|  |  |  | 			Id:         dtos.NavIDCfg, | 
					
						
							|  |  |  | 			Text:       "Configuration", | 
					
						
							|  |  |  | 			SubTitle:   "Organization: " + c.OrgName, | 
					
						
							|  |  |  | 			Icon:       "cog", | 
					
						
							|  |  |  | 			Url:        configNodes[0].Url, | 
					
						
							|  |  |  | 			Section:    dtos.NavSectionConfig, | 
					
						
							|  |  |  | 			SortWeight: dtos.WeightConfig, | 
					
						
							|  |  |  | 			Children:   configNodes, | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 			configNode.Url = "/admin" | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			configNode.Url = configNodes[0].Url | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | 		navTree = append(navTree, configNode) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	adminNavLinks := hs.buildAdminNavLinks(c) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(adminNavLinks) > 0 { | 
					
						
							|  |  |  | 		serverAdminNode = navlinks.GetServerAdminNode(adminNavLinks) | 
					
						
							|  |  |  | 		navTree = append(navTree, serverAdminNode) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 		// Move server admin into Configuration and rename to administration
 | 
					
						
							|  |  |  | 		if configNode != nil && serverAdminNode != nil { | 
					
						
							|  |  |  | 			configNode.Text = "Administration" | 
					
						
							| 
									
										
										
										
											2022-09-13 18:24:23 +08:00
										 |  |  | 			serverAdminNode.Url = "/admin/server" | 
					
						
							|  |  |  | 			serverAdminNode.HideFromTabs = false | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | 			configNode.Children = append(configNode.Children, serverAdminNode) | 
					
						
							|  |  |  | 			adminNodeIndex := len(navTree) - 1 | 
					
						
							|  |  |  | 			navTree = navTree[:adminNodeIndex] | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	navTree = hs.addHelpLinks(navTree, c) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return navTree, nil | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | func (hs *HTTPServer) setupConfigNodes(c *models.ReqContext) ([]*dtos.NavLink, error) { | 
					
						
							|  |  |  | 	var configNodes []*dtos.NavLink | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							| 
									
										
										
										
											2022-03-16 22:11:03 +08:00
										 |  |  | 	if hasAccess(ac.ReqOrgAdmin, datasources.ConfigurationPageAccess) { | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2021-03-30 02:30:11 +08:00
										 |  |  | 			Text:        "Data sources", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:        "database", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 			Description: "Add and configure data sources", | 
					
						
							|  |  |  | 			Id:          "datasources", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/datasources", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-26 18:27:28 +08:00
										 |  |  | 	if hasAccess(ac.ReqOrgAdmin, correlations.ConfigurationPageAccess) { | 
					
						
							|  |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Correlations", | 
					
						
							|  |  |  | 			Icon:        "gf-glue", | 
					
						
							|  |  |  | 			Description: "Add and configure correlations", | 
					
						
							|  |  |  | 			Id:          "correlations", | 
					
						
							|  |  |  | 			Url:         hs.Cfg.AppSubURL + "/datasources/correlations", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-13 21:40:32 +08:00
										 |  |  | 	if hasAccess(ac.ReqOrgAdmin, ac.EvalPermission(ac.ActionOrgUsersRead)) { | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Users", | 
					
						
							|  |  |  | 			Id:          "users", | 
					
						
							|  |  |  | 			Description: "Manage org members", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:        "user", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/org/users", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-08-15 20:49:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 00:49:39 +08:00
										 |  |  | 	if hasAccess(hs.ReqCanAdminTeams, teamsAccessEvaluator) { | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Teams", | 
					
						
							|  |  |  | 			Id:          "teams", | 
					
						
							|  |  |  | 			Description: "Manage org groups", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:        "users-alt", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/org/teams", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-05 01:28:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 15:44:50 +08:00
										 |  |  | 	// FIXME: while we don't have a permissions for listing plugins the legacy check has to stay as a default
 | 
					
						
							|  |  |  | 	if plugins.ReqCanAdminPlugins(hs.Cfg)(c) || hasAccess(plugins.ReqCanAdminPlugins(hs.Cfg), plugins.AdminAccessEvaluator) { | 
					
						
							| 
									
										
										
										
											2020-03-16 22:40:46 +08:00
										 |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Plugins", | 
					
						
							|  |  |  | 			Id:          "plugins", | 
					
						
							|  |  |  | 			Description: "View and configure plugins", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:        "plug", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/plugins", | 
					
						
							| 
									
										
										
										
											2020-03-16 22:40:46 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-11-18 21:10:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-16 22:40:46 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-18 21:10:38 +08:00
										 |  |  | 	if hasAccess(ac.ReqOrgAdmin, orgPreferencesAccessEvaluator) { | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Preferences", | 
					
						
							|  |  |  | 			Id:          "org-settings", | 
					
						
							|  |  |  | 			Description: "Organization preferences", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:        "sliders-v-alt", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/org", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-11-18 21:10:38 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 	hideApiKeys, _, _ := hs.kvStore.Get(c.Req.Context(), c.OrgID, "serviceaccounts", "hideApiKeys") | 
					
						
							| 
									
										
										
										
											2022-08-23 23:01:35 +08:00
										 |  |  | 	apiKeys, err := hs.apiKeyService.GetAllAPIKeys(c.Req.Context(), c.OrgID) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | 		return nil, err | 
					
						
							| 
									
										
										
										
											2022-08-23 23:01:35 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-06-16 22:03:00 +08:00
										 |  |  | 	apiKeysHidden := hideApiKeys == "1" && len(apiKeys) == 0 | 
					
						
							|  |  |  | 	if hasAccess(ac.ReqOrgAdmin, apiKeyAccessEvaluator) && !apiKeysHidden { | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2021-03-30 02:30:11 +08:00
										 |  |  | 			Text:        "API keys", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 			Id:          "apikeys", | 
					
						
							|  |  |  | 			Description: "Create & manage API keys", | 
					
						
							| 
									
										
											  
											
												@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3:  Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and  empty  list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on  main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
											
										 
											2020-04-08 20:33:31 +08:00
										 |  |  | 			Icon:        "key-skeleton-alt", | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/org/apikeys", | 
					
						
							| 
									
										
										
										
											2019-08-02 20:02:59 +08:00
										 |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2016-02-15 00:37:05 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-07-06 01:53:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-05 22:32:38 +08:00
										 |  |  | 	if enableServiceAccount(hs, c) { | 
					
						
							|  |  |  | 		configNodes = append(configNodes, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Service accounts", | 
					
						
							|  |  |  | 			Id:          "serviceaccounts", | 
					
						
							|  |  |  | 			Description: "Manage service accounts", | 
					
						
							| 
									
										
										
										
											2022-06-03 16:23:19 +08:00
										 |  |  | 			Icon:        "gf-service-account", | 
					
						
							| 
									
										
										
										
											2022-06-01 15:35:16 +08:00
										 |  |  | 			Url:         hs.Cfg.AppSubURL + "/org/serviceaccounts", | 
					
						
							| 
									
										
										
										
											2022-01-05 22:32:38 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-08-26 22:30:21 +08:00
										 |  |  | 	return configNodes, nil | 
					
						
							| 
									
										
										
										
											2022-03-29 23:27:53 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (hs *HTTPServer) addProfile(navTree []*dtos.NavLink, c *models.ReqContext) []*dtos.NavLink { | 
					
						
							|  |  |  | 	if setting.ProfileEnabled && c.IsSignedIn { | 
					
						
							|  |  |  | 		navTree = append(navTree, hs.getProfileNode(c)) | 
					
						
							| 
									
										
										
										
											2020-06-17 13:39:50 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-03-29 23:27:53 +08:00
										 |  |  | 	return navTree | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-06-17 13:39:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 23:27:53 +08:00
										 |  |  | func (hs *HTTPServer) addHelpLinks(navTree []*dtos.NavLink, c *models.ReqContext) []*dtos.NavLink { | 
					
						
							|  |  |  | 	if setting.HelpEnabled { | 
					
						
							|  |  |  | 		helpVersion := fmt.Sprintf(`%s v%s (%s)`, setting.ApplicationName, setting.BuildVersion, setting.BuildCommit) | 
					
						
							|  |  |  | 		if hs.Cfg.AnonymousHideVersion && !c.IsSignedIn { | 
					
						
							|  |  |  | 			helpVersion = setting.ApplicationName | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-16 21:03:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 23:27:53 +08:00
										 |  |  | 		navTree = append(navTree, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:       "Help", | 
					
						
							|  |  |  | 			SubTitle:   helpVersion, | 
					
						
							|  |  |  | 			Id:         "help", | 
					
						
							|  |  |  | 			Url:        "#", | 
					
						
							|  |  |  | 			Icon:       "question-circle", | 
					
						
							|  |  |  | 			SortWeight: dtos.WeightHelp, | 
					
						
							|  |  |  | 			Section:    dtos.NavSectionConfig, | 
					
						
							|  |  |  | 			Children:   []*dtos.NavLink{}, | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return navTree | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | func (hs *HTTPServer) buildStarredItemsNavLinks(c *models.ReqContext, prefs *pref.Preference) ([]*dtos.NavLink, error) { | 
					
						
							|  |  |  | 	starredItemsChildNavs := []*dtos.NavLink{} | 
					
						
							| 
									
										
										
										
											2022-03-17 20:07:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 	query := star.GetUserStarsQuery{ | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 		UserID: c.SignedInUser.UserID, | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	starredDashboardResult, err := hs.starService.GetByUser(c.Req.Context(), &query) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-03-17 20:07:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 	starredDashboards := []*models.Dashboard{} | 
					
						
							|  |  |  | 	starredDashboardsCounter := 0 | 
					
						
							|  |  |  | 	for dashboardId := range starredDashboardResult.UserStars { | 
					
						
							|  |  |  | 		// Set a loose limit to the first 50 starred dashboards found
 | 
					
						
							|  |  |  | 		if starredDashboardsCounter > 50 { | 
					
						
							|  |  |  | 			break | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		starredDashboardsCounter++ | 
					
						
							|  |  |  | 		query := &models.GetDashboardQuery{ | 
					
						
							|  |  |  | 			Id:    dashboardId, | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 			OrgId: c.OrgID, | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-07-07 02:42:39 +08:00
										 |  |  | 		err := hs.DashboardService.GetDashboard(c.Req.Context(), query) | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 		if err == nil { | 
					
						
							|  |  |  | 			starredDashboards = append(starredDashboards, query.Result) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(starredDashboards) > 0 { | 
					
						
							|  |  |  | 		sort.Slice(starredDashboards, func(i, j int) bool { | 
					
						
							|  |  |  | 			return starredDashboards[i].Title < starredDashboards[j].Title | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		for _, starredItem := range starredDashboards { | 
					
						
							|  |  |  | 			starredItemsChildNavs = append(starredItemsChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 				Id:   starredItem.Uid, | 
					
						
							|  |  |  | 				Text: starredItem.Title, | 
					
						
							|  |  |  | 				Url:  starredItem.GetUrl(), | 
					
						
							| 
									
										
										
										
											2022-03-17 20:07:20 +08:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-23 23:45:46 +08:00
										 |  |  | 	return starredItemsChildNavs, nil | 
					
						
							| 
									
										
										
										
											2022-03-17 20:07:20 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | func (hs *HTTPServer) buildDashboardNavLinks(c *models.ReqContext, hasEditPerm bool) []*dtos.NavLink { | 
					
						
							| 
									
										
										
										
											2022-06-10 21:26:00 +08:00
										 |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							|  |  |  | 	hasEditPermInAnyFolder := func(c *models.ReqContext) bool { | 
					
						
							|  |  |  | 		return hasEditPerm | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 	dashboardChildNavs := []*dtos.NavLink{} | 
					
						
							| 
									
										
										
										
											2022-09-07 16:24:10 +08:00
										 |  |  | 	if !hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 		dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Browse", Id: "dashboards/browse", Url: hs.Cfg.AppSubURL + "/dashboards", Icon: "sitemap", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 	dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-07-20 23:26:52 +08:00
										 |  |  | 		Text: "Playlists", Id: "dashboards/playlists", Url: hs.Cfg.AppSubURL + "/playlists", Icon: "presentation-play", | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.IsSignedIn { | 
					
						
							|  |  |  | 		dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Snapshots", | 
					
						
							| 
									
										
										
										
											2022-07-20 23:26:52 +08:00
										 |  |  | 			Id:   "dashboards/snapshots", | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 			Url:  hs.Cfg.AppSubURL + "/dashboard/snapshots", | 
					
						
							|  |  |  | 			Icon: "camera", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Library panels", | 
					
						
							| 
									
										
										
										
											2022-07-20 23:26:52 +08:00
										 |  |  | 			Id:   "dashboards/library-panels", | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 			Url:  hs.Cfg.AppSubURL + "/library-panels", | 
					
						
							|  |  |  | 			Icon: "library-panel", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-07 14:53:02 +08:00
										 |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagScenes) { | 
					
						
							|  |  |  | 		dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Scenes", | 
					
						
							|  |  |  | 			Id:   "scenes", | 
					
						
							|  |  |  | 			Url:  hs.Cfg.AppSubURL + "/scenes", | 
					
						
							|  |  |  | 			Icon: "apps", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-16 17:48:38 +08:00
										 |  |  | 	if hasEditPerm { | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 		dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Divider", Divider: true, Id: "divider", HideFromTabs: true, | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2022-06-10 21:26:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if hasAccess(hasEditPermInAnyFolder, ac.EvalPermission(dashboards.ActionDashboardsCreate)) { | 
					
						
							|  |  |  | 			dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-07-20 23:26:52 +08:00
										 |  |  | 				Text: "New dashboard", Icon: "plus", Url: hs.Cfg.AppSubURL + "/dashboard/new", HideFromTabs: true, Id: "dashboards/new", ShowIconInNavbar: true, | 
					
						
							| 
									
										
										
										
											2022-06-10 21:26:00 +08:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if hasAccess(ac.ReqOrgAdminOrEditor, ac.EvalPermission(dashboards.ActionFoldersCreate)) { | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 			dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-07-20 23:26:52 +08:00
										 |  |  | 				Text: "New folder", SubTitle: "Create a new folder to organize your dashboards", Id: "dashboards/folder/new", | 
					
						
							| 
									
										
										
										
											2022-04-12 21:51:40 +08:00
										 |  |  | 				Icon: "plus", Url: hs.Cfg.AppSubURL + "/dashboards/folder/new", HideFromTabs: true, ShowIconInNavbar: true, | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 			}) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-06-10 21:26:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if hasAccess(hasEditPermInAnyFolder, ac.EvalPermission(dashboards.ActionDashboardsCreate)) { | 
					
						
							|  |  |  | 			dashboardChildNavs = append(dashboardChildNavs, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-07-20 23:26:52 +08:00
										 |  |  | 				Text: "Import", SubTitle: "Import dashboard from file or Grafana.com", Id: "dashboards/import", Icon: "plus", | 
					
						
							| 
									
										
										
										
											2022-06-10 21:26:00 +08:00
										 |  |  | 				Url: hs.Cfg.AppSubURL + "/dashboard/import", HideFromTabs: true, ShowIconInNavbar: true, | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return dashboardChildNavs | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-26 00:13:49 +08:00
										 |  |  | func (hs *HTTPServer) buildLegacyAlertNavLinks(c *models.ReqContext) []*dtos.NavLink { | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 	var alertChildNavs []*dtos.NavLink | 
					
						
							|  |  |  | 	alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 		Text: "Alert rules", Id: "alert-list", Url: hs.Cfg.AppSubURL + "/alerting/list", Icon: "list-ul", | 
					
						
							|  |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2022-05-26 00:13:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 17:56:48 +08:00
										 |  |  | 	if c.HasRole(org.RoleEditor) { | 
					
						
							| 
									
										
										
										
											2022-05-26 00:13:49 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Notification channels", Id: "channels", Url: hs.Cfg.AppSubURL + "/alerting/notifications", | 
					
						
							|  |  |  | 			Icon: "comment-alt-share", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 	var alertNav = dtos.NavLink{ | 
					
						
							|  |  |  | 		Text:       "Alerting", | 
					
						
							|  |  |  | 		SubTitle:   "Alert rules and notifications", | 
					
						
							|  |  |  | 		Id:         "alerting-legacy", | 
					
						
							|  |  |  | 		Icon:       "bell", | 
					
						
							|  |  |  | 		Children:   alertChildNavs, | 
					
						
							|  |  |  | 		Section:    dtos.NavSectionCore, | 
					
						
							|  |  |  | 		SortWeight: dtos.WeightAlerting, | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 		alertNav.Url = hs.Cfg.AppSubURL + "/alerting" | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		alertNav.Url = hs.Cfg.AppSubURL + "/alerting/list" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return []*dtos.NavLink{&alertNav} | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (hs *HTTPServer) buildAlertNavLinks(c *models.ReqContext) []*dtos.NavLink { | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							|  |  |  | 	var alertChildNavs []*dtos.NavLink | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-19 21:22:26 +08:00
										 |  |  | 	if hasAccess(ac.ReqViewer, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleRead), ac.EvalPermission(ac.ActionAlertingRuleExternalRead))) { | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Alert rules", Id: "alert-list", Url: hs.Cfg.AppSubURL + "/alerting/list", Icon: "list-ul", | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-11-25 01:28:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 	if hasAccess(ac.ReqOrgAdminOrEditor, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingNotificationsRead), ac.EvalPermission(ac.ActionAlertingNotificationsExternalRead))) { | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Contact points", Id: "receivers", Url: hs.Cfg.AppSubURL + "/alerting/notifications", | 
					
						
							| 
									
										
										
										
											2022-09-06 22:25:07 +08:00
										 |  |  | 			Icon: "comment-alt-share", SubTitle: "Manage the settings of your contact points", | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 		}) | 
					
						
							|  |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Notification policies", Id: "am-routes", Url: hs.Cfg.AppSubURL + "/alerting/routes", Icon: "sitemap"}) | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-19 21:22:26 +08:00
										 |  |  | 	if hasAccess(ac.ReqViewer, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingInstanceRead), ac.EvalPermission(ac.ActionAlertingInstancesExternalRead))) { | 
					
						
							| 
									
										
										
										
											2021-11-25 01:28:19 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Silences", Id: "silences", Url: hs.Cfg.AppSubURL + "/alerting/silences", Icon: "bell-slash"}) | 
					
						
							|  |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{Text: "Alert groups", Id: "groups", Url: hs.Cfg.AppSubURL + "/alerting/groups", Icon: "layer-group"}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-10 17:56:48 +08:00
										 |  |  | 	if c.OrgRole == org.RoleAdmin { | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Admin", Id: "alerting-admin", Url: hs.Cfg.AppSubURL + "/alerting/admin", | 
					
						
							|  |  |  | 			Icon: "cog", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-16 17:48:38 +08:00
										 |  |  | 	if hasAccess(hs.editorInAnyFolder, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleCreate), ac.EvalPermission(ac.ActionAlertingRuleExternalWrite))) { | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Divider", Divider: true, Id: "divider", HideFromTabs: true, | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2022-04-15 17:32:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 		alertChildNavs = append(alertChildNavs, &dtos.NavLink{ | 
					
						
							| 
									
										
										
										
											2022-05-06 16:14:00 +08:00
										 |  |  | 			Text: "New alert rule", SubTitle: "Create an alert rule", Id: "alert", | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 			Icon: "plus", Url: hs.Cfg.AppSubURL + "/alerting/new", HideFromTabs: true, ShowIconInNavbar: true, | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2022-04-15 17:32:53 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 	if len(alertChildNavs) > 0 { | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 		var alertNav = dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:       "Alerting", | 
					
						
							|  |  |  | 			SubTitle:   "Alert rules and notifications", | 
					
						
							|  |  |  | 			Id:         "alerting", | 
					
						
							|  |  |  | 			Icon:       "bell", | 
					
						
							|  |  |  | 			Children:   alertChildNavs, | 
					
						
							|  |  |  | 			Section:    dtos.NavSectionCore, | 
					
						
							|  |  |  | 			SortWeight: dtos.WeightAlerting, | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-09-05 17:07:13 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if hs.Features.IsEnabled(featuremgmt.FlagTopnav) { | 
					
						
							|  |  |  | 			alertNav.Url = hs.Cfg.AppSubURL + "/alerting" | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			alertNav.Url = hs.Cfg.AppSubURL + "/alerting/list" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return []*dtos.NavLink{&alertNav} | 
					
						
							| 
									
										
										
										
											2022-03-19 00:58:50 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2021-11-02 19:19:18 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-10 18:13:31 +08:00
										 |  |  | func (hs *HTTPServer) buildDataConnectionsNavLink(c *models.ReqContext) *dtos.NavLink { | 
					
						
							|  |  |  | 	var children []*dtos.NavLink | 
					
						
							|  |  |  | 	var navLink *dtos.NavLink | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	baseId := "data-connections" | 
					
						
							|  |  |  | 	baseUrl := hs.Cfg.AppSubURL + "/" + baseId | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	children = append(children, &dtos.NavLink{ | 
					
						
							|  |  |  | 		Id:          baseId + "-datasources", | 
					
						
							|  |  |  | 		Text:        "Data sources", | 
					
						
							|  |  |  | 		Icon:        "database", | 
					
						
							|  |  |  | 		Description: "Add and configure data sources", | 
					
						
							|  |  |  | 		Url:         baseUrl + "/datasources", | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	children = append(children, &dtos.NavLink{ | 
					
						
							|  |  |  | 		Id:          baseId + "-plugins", | 
					
						
							|  |  |  | 		Text:        "Plugins", | 
					
						
							|  |  |  | 		Icon:        "plug", | 
					
						
							|  |  |  | 		Description: "Manage plugins", | 
					
						
							|  |  |  | 		Url:         baseUrl + "/plugins", | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	children = append(children, &dtos.NavLink{ | 
					
						
							|  |  |  | 		Id:          baseId + "-cloud-integrations", | 
					
						
							|  |  |  | 		Text:        "Cloud integrations", | 
					
						
							|  |  |  | 		Icon:        "bolt", | 
					
						
							|  |  |  | 		Description: "Manage your cloud integrations", | 
					
						
							|  |  |  | 		Url:         baseUrl + "/cloud-integrations", | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	navLink = &dtos.NavLink{ | 
					
						
							|  |  |  | 		Text:       "Data Connections", | 
					
						
							|  |  |  | 		Icon:       "link", | 
					
						
							|  |  |  | 		Id:         baseId, | 
					
						
							|  |  |  | 		Url:        baseUrl, | 
					
						
							|  |  |  | 		Children:   children, | 
					
						
							|  |  |  | 		Section:    dtos.NavSectionCore, | 
					
						
							|  |  |  | 		SortWeight: dtos.WeightDataConnections, | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return navLink | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | func (hs *HTTPServer) buildAdminNavLinks(c *models.ReqContext) []*dtos.NavLink { | 
					
						
							|  |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							| 
									
										
										
										
											2022-09-09 15:07:45 +08:00
										 |  |  | 	hasGlobalAccess := ac.HasGlobalAccess(hs.AccessControl, hs.accesscontrolService, c) | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 	adminNavLinks := []*dtos.NavLink{} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	if hasAccess(ac.ReqGrafanaAdmin, ac.EvalPermission(ac.ActionUsersRead, ac.ScopeGlobalUsersAll)) { | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 		adminNavLinks = append(adminNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Users", Id: "global-users", Url: hs.Cfg.AppSubURL + "/admin/users", Icon: "user", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-18 21:10:38 +08:00
										 |  |  | 	if hasGlobalAccess(ac.ReqGrafanaAdmin, orgsAccessEvaluator) { | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 		adminNavLinks = append(adminNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Orgs", Id: "global-orgs", Url: hs.Cfg.AppSubURL + "/admin/orgs", Icon: "building", | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-06-14 23:36:48 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	if hasAccess(ac.ReqGrafanaAdmin, ac.EvalPermission(ac.ActionSettingsRead)) { | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 		adminNavLinks = append(adminNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "Settings", Id: "server-settings", Url: hs.Cfg.AppSubURL + "/admin/settings", Icon: "sliders-v-alt", | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-06-14 23:36:48 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-06 01:53:41 +08:00
										 |  |  | 	if hasAccess(ac.ReqGrafanaAdmin, ac.EvalPermission(ac.ActionSettingsRead)) && hs.Features.IsEnabled(featuremgmt.FlagStorage) { | 
					
						
							|  |  |  | 		adminNavLinks = append(adminNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text:        "Storage", | 
					
						
							|  |  |  | 			Id:          "storage", | 
					
						
							|  |  |  | 			Description: "Manage file storage", | 
					
						
							|  |  |  | 			Icon:        "cube", | 
					
						
							|  |  |  | 			Url:         hs.Cfg.AppSubURL + "/admin/storage", | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-24 17:36:28 +08:00
										 |  |  | 	if hs.Cfg.LDAPEnabled && hasAccess(ac.ReqGrafanaAdmin, ac.EvalPermission(ac.ActionLDAPStatusRead)) { | 
					
						
							| 
									
										
										
										
											2021-04-22 18:19:41 +08:00
										 |  |  | 		adminNavLinks = append(adminNavLinks, &dtos.NavLink{ | 
					
						
							|  |  |  | 			Text: "LDAP", Id: "ldap", Url: hs.Cfg.AppSubURL + "/admin/ldap", Icon: "book", | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return adminNavLinks | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | func (hs *HTTPServer) editorInAnyFolder(c *models.ReqContext) bool { | 
					
						
							|  |  |  | 	hasEditPermissionInFoldersQuery := models.HasEditPermissionInFoldersQuery{SignedInUser: c.SignedInUser} | 
					
						
							| 
									
										
										
										
											2022-07-07 02:42:39 +08:00
										 |  |  | 	if err := hs.DashboardService.HasEditPermissionInFolders(c.Req.Context(), &hasEditPermissionInFoldersQuery); err != nil { | 
					
						
							| 
									
										
										
										
											2022-04-20 23:49:20 +08:00
										 |  |  | 		return false | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return hasEditPermissionInFoldersQuery.Result | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | func (hs *HTTPServer) setIndexViewData(c *models.ReqContext) (*dtos.IndexViewData, error) { | 
					
						
							| 
									
										
										
										
											2022-03-03 22:05:47 +08:00
										 |  |  | 	hasAccess := ac.HasAccess(hs.AccessControl, c) | 
					
						
							| 
									
										
										
										
											2022-05-04 22:12:09 +08:00
										 |  |  | 	hasEditPerm := hasAccess(hs.editorInAnyFolder, ac.EvalAny(ac.EvalPermission(dashboards.ActionDashboardsCreate), ac.EvalPermission(dashboards.ActionFoldersCreate))) | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	settings, err := hs.getFrontendSettingsMap(c) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	settings["dateFormats"] = hs.Cfg.DateFormats | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 	prefsQuery := pref.GetPreferenceWithDefaultsQuery{UserID: c.UserID, OrgID: c.OrgID, Teams: c.Teams} | 
					
						
							| 
									
										
										
										
											2022-04-21 21:03:17 +08:00
										 |  |  | 	prefs, err := hs.preferenceService.GetWithDefaults(c.Req.Context(), &prefsQuery) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-21 18:12:49 +08:00
										 |  |  | 	// Set locale to the preference, otherwise fall back to the accept language header.
 | 
					
						
							|  |  |  | 	// In practice, because the preference has configuration-backed default, the header
 | 
					
						
							|  |  |  | 	// shouldn't frequently be used
 | 
					
						
							|  |  |  | 	acceptLangHeader := c.Req.Header.Get("Accept-Language") | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	locale := "en-US" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-21 18:12:49 +08:00
										 |  |  | 	if hs.Features.IsEnabled(featuremgmt.FlagInternationalization) && prefs.JSONData.Locale != "" { | 
					
						
							|  |  |  | 		locale = prefs.JSONData.Locale | 
					
						
							|  |  |  | 	} else if len(acceptLangHeader) > 0 { | 
					
						
							|  |  |  | 		parts := strings.Split(acceptLangHeader, ",") | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		locale = parts[0] | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	appURL := setting.AppUrl | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 	appSubURL := hs.Cfg.AppSubURL | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// special case when doing localhost call from image renderer
 | 
					
						
							|  |  |  | 	if c.IsRenderCall && !hs.Cfg.ServeFromSubPath { | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 		appURL = fmt.Sprintf("%s://localhost:%s", hs.Cfg.Protocol, hs.Cfg.HTTPPort) | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		appSubURL = "" | 
					
						
							|  |  |  | 		settings["appSubUrl"] = "" | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-24 23:50:10 +08:00
										 |  |  | 	navTree, err := hs.getNavTree(c, hasEditPerm, prefs) | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, err | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-03 04:57:55 +08:00
										 |  |  | 	if c.IsPublicDashboardView { | 
					
						
							|  |  |  | 		settings["isPublicDashboardView"] = true | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	data := dtos.IndexViewData{ | 
					
						
							|  |  |  | 		User: &dtos.CurrentUser{ | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 			Id:                         c.UserID, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			IsSignedIn:                 c.IsSignedIn, | 
					
						
							|  |  |  | 			Login:                      c.Login, | 
					
						
							|  |  |  | 			Email:                      c.Email, | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 			ExternalUserId:             c.SignedInUser.ExternalAuthID, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			Name:                       c.Name, | 
					
						
							|  |  |  | 			OrgCount:                   c.OrgCount, | 
					
						
							| 
									
										
										
										
											2022-08-11 19:28:55 +08:00
										 |  |  | 			OrgId:                      c.OrgID, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			OrgName:                    c.OrgName, | 
					
						
							|  |  |  | 			OrgRole:                    c.OrgRole, | 
					
						
							|  |  |  | 			GravatarUrl:                dtos.GetGravatarUrl(c.Email), | 
					
						
							|  |  |  | 			IsGrafanaAdmin:             c.IsGrafanaAdmin, | 
					
						
							|  |  |  | 			LightTheme:                 prefs.Theme == lightName, | 
					
						
							|  |  |  | 			Timezone:                   prefs.Timezone, | 
					
						
							| 
									
										
										
										
											2021-10-18 21:27:14 +08:00
										 |  |  | 			WeekStart:                  prefs.WeekStart, | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 			Locale:                     locale, | 
					
						
							|  |  |  | 			HelpFlags1:                 c.HelpFlags1, | 
					
						
							|  |  |  | 			HasEditPermissionInFolders: hasEditPerm, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Settings:                settings, | 
					
						
							|  |  |  | 		Theme:                   prefs.Theme, | 
					
						
							|  |  |  | 		AppUrl:                  appURL, | 
					
						
							|  |  |  | 		AppSubUrl:               appSubURL, | 
					
						
							|  |  |  | 		GoogleAnalyticsId:       setting.GoogleAnalyticsId, | 
					
						
							|  |  |  | 		GoogleTagManagerId:      setting.GoogleTagManagerId, | 
					
						
							|  |  |  | 		BuildVersion:            setting.BuildVersion, | 
					
						
							|  |  |  | 		BuildCommit:             setting.BuildCommit, | 
					
						
							| 
									
										
										
										
											2022-01-31 23:06:16 +08:00
										 |  |  | 		NewGrafanaVersion:       hs.grafanaUpdateChecker.LatestVersion(), | 
					
						
							|  |  |  | 		NewGrafanaVersionExists: hs.grafanaUpdateChecker.UpdateAvailable(), | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		AppName:                 setting.ApplicationName, | 
					
						
							| 
									
										
										
										
											2022-01-08 04:11:23 +08:00
										 |  |  | 		AppNameBodyClass:        "app-grafana", | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 		FavIcon:                 "public/img/fav32.png", | 
					
						
							|  |  |  | 		AppleTouchIcon:          "public/img/apple-touch-icon.png", | 
					
						
							|  |  |  | 		AppTitle:                "Grafana", | 
					
						
							|  |  |  | 		NavTree:                 navTree, | 
					
						
							| 
									
										
										
										
											2020-11-12 19:29:43 +08:00
										 |  |  | 		Sentry:                  &hs.Cfg.Sentry, | 
					
						
							| 
									
										
										
										
											2021-01-12 14:42:32 +08:00
										 |  |  | 		Nonce:                   c.RequestNonce, | 
					
						
							| 
									
										
										
										
											2021-02-01 18:00:53 +08:00
										 |  |  | 		ContentDeliveryURL:      hs.Cfg.GetContentDeliveryURL(hs.License.ContentDeliveryPrefix()), | 
					
						
							| 
									
										
										
										
											2021-07-02 20:17:10 +08:00
										 |  |  | 		LoadingLogo:             "public/img/grafana_icon.svg", | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-25 16:42:09 +08:00
										 |  |  | 	if !hs.AccessControl.IsDisabled() { | 
					
						
							| 
									
										
										
										
											2022-08-24 19:29:17 +08:00
										 |  |  | 		userPermissions, err := hs.accesscontrolService.GetUserPermissions(c.Req.Context(), c.SignedInUser, ac.Options{ReloadCache: false}) | 
					
						
							| 
									
										
										
										
											2021-04-16 21:02:16 +08:00
										 |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			return nil, err | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-19 17:23:29 +08:00
										 |  |  | 		data.User.Permissions = ac.BuildPermissionsMap(userPermissions) | 
					
						
							| 
									
										
										
										
											2021-04-16 21:02:16 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	if setting.DisableGravatar { | 
					
						
							| 
									
										
										
										
											2021-03-10 19:41:29 +08:00
										 |  |  | 		data.User.GravatarUrl = hs.Cfg.AppSubURL + "/public/img/user_profile.png" | 
					
						
							| 
									
										
										
										
											2020-09-08 04:10:06 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(data.User.Name) == 0 { | 
					
						
							|  |  |  | 		data.User.Name = data.User.Login | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	themeURLParam := c.Query("theme") | 
					
						
							|  |  |  | 	if themeURLParam == lightName { | 
					
						
							|  |  |  | 		data.User.LightTheme = true | 
					
						
							|  |  |  | 		data.Theme = lightName | 
					
						
							|  |  |  | 	} else if themeURLParam == darkName { | 
					
						
							|  |  |  | 		data.User.LightTheme = false | 
					
						
							|  |  |  | 		data.Theme = darkName | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-27 16:24:44 +08:00
										 |  |  | 	hs.HooksService.RunIndexDataHooks(&data, c) | 
					
						
							| 
									
										
										
										
											2019-11-15 16:28:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-11 21:17:41 +08:00
										 |  |  | 	sort.SliceStable(data.NavTree, func(i, j int) bool { | 
					
						
							|  |  |  | 		return data.NavTree[i].SortWeight < data.NavTree[j].SortWeight | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-20 16:43:10 +08:00
										 |  |  | 	return &data, nil | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 19:57:20 +08:00
										 |  |  | func (hs *HTTPServer) Index(c *models.ReqContext) { | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	data, err := hs.setIndexViewData(c) | 
					
						
							| 
									
										
										
										
											2018-03-22 19:37:35 +08:00
										 |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2020-12-16 02:09:04 +08:00
										 |  |  | 		c.Handle(hs.Cfg, 500, "Failed to get settings", err) | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-04-15 20:01:58 +08:00
										 |  |  | 	c.HTML(http.StatusOK, "index", data) | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 19:57:20 +08:00
										 |  |  | func (hs *HTTPServer) NotFoundHandler(c *models.ReqContext) { | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 	if c.IsApiRequest() { | 
					
						
							| 
									
										
										
										
											2015-03-23 03:14:00 +08:00
										 |  |  | 		c.JsonApiErr(404, "Not found", nil) | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 23:47:43 +08:00
										 |  |  | 	data, err := hs.setIndexViewData(c) | 
					
						
							| 
									
										
										
										
											2018-03-22 19:37:35 +08:00
										 |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2020-12-16 02:09:04 +08:00
										 |  |  | 		c.Handle(hs.Cfg, 500, "Failed to get settings", err) | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | 		return | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-22 19:37:35 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	c.HTML(404, "index", data) | 
					
						
							| 
									
										
										
										
											2015-01-29 19:10:34 +08:00
										 |  |  | } |