mirror of
https://github.com/grafana/grafana.git
synced 2026-08-14 07:04:57 -05:00
Connections: Simplify connections nav (#66813)
* Connections: Simplify connections nav * rename Connections pages everywhere --------- Co-authored-by: Miklós Tolnai <miklos.tolnai@grafana.com>
This commit is contained in:
co-authored by
Miklós Tolnai
parent
2316178565
commit
9614dc2446
+4
-4
@@ -126,11 +126,11 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
r.Get("/plugins/:id/edit", middleware.CanAdminPlugins(hs.Cfg), hs.Index) // deprecated
|
||||
r.Get("/plugins/:id/page/:page", middleware.CanAdminPlugins(hs.Cfg), hs.Index)
|
||||
|
||||
r.Get("/connections/your-connections/datasources", authorize(reqOrgAdmin, datasources.ConfigurationPageAccess), hs.Index)
|
||||
r.Get("/connections/your-connections/datasources/new", authorize(reqOrgAdmin, datasources.NewPageAccess), hs.Index)
|
||||
r.Get("/connections/your-connections/datasources/edit/*", authorize(reqOrgAdmin, datasources.EditPageAccess), hs.Index)
|
||||
r.Get("/connections/your-datasources", authorize(reqOrgAdmin, datasources.ConfigurationPageAccess), hs.Index)
|
||||
r.Get("/connections/your-datasources/new", authorize(reqOrgAdmin, datasources.NewPageAccess), hs.Index)
|
||||
r.Get("/connections/your-datasources/edit/*", authorize(reqOrgAdmin, datasources.EditPageAccess), hs.Index)
|
||||
r.Get("/connections", authorize(reqOrgAdmin, datasources.ConfigurationPageAccess), hs.Index)
|
||||
r.Get("/connections/connect-data", authorize(reqOrgAdmin, datasources.ConfigurationPageAccess), hs.Index)
|
||||
r.Get("/connections/add-new-connection", authorize(reqOrgAdmin, datasources.ConfigurationPageAccess), hs.Index)
|
||||
r.Get("/connections/datasources/:id", middleware.CanAdminPlugins(hs.Cfg), hs.Index)
|
||||
r.Get("/connections/datasources/:id/page/:page", middleware.CanAdminPlugins(hs.Cfg), hs.Index)
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ func TestAddAppLinks(t *testing.T) {
|
||||
AddToNav: true,
|
||||
},
|
||||
{
|
||||
Name: "Connect data",
|
||||
Path: "/connections/connect-data",
|
||||
Name: "Add new connection",
|
||||
Path: "/connections/add-new-connection",
|
||||
Type: "page",
|
||||
AddToNav: false,
|
||||
},
|
||||
@@ -296,7 +296,7 @@ func TestAddAppLinks(t *testing.T) {
|
||||
service.features = featuremgmt.WithFeatures(featuremgmt.FlagDataConnectionsConsole)
|
||||
service.navigationAppConfig = map[string]NavigationAppConfig{}
|
||||
service.navigationAppPathConfig = map[string]NavigationAppConfig{
|
||||
"/connections/connect-data": {SectionID: "connections"},
|
||||
"/connections/add-new-connection": {SectionID: "connections"},
|
||||
}
|
||||
|
||||
// Build nav-tree and check if the "Connections" page is there
|
||||
@@ -306,10 +306,10 @@ func TestAddAppLinks(t *testing.T) {
|
||||
require.NotNil(t, connectionsNode)
|
||||
require.Equal(t, "Connections", connectionsNode.Text)
|
||||
|
||||
// Check if the original "Connect data" page (served by core) is there until we add the standalone plugin page
|
||||
// Check if the original "Add new connection" page (served by core) is there until we add the standalone plugin page
|
||||
connectDataNode := connectionsNode.Children[0]
|
||||
require.Equal(t, "Connect data", connectDataNode.Text)
|
||||
require.Equal(t, "connections-connect-data", connectDataNode.Id)
|
||||
require.Equal(t, "Add new connection", connectDataNode.Text)
|
||||
require.Equal(t, "connections-add-new-connection", connectDataNode.Id)
|
||||
require.Equal(t, "", connectDataNode.PluginID)
|
||||
|
||||
// Check if the standalone plugin page appears under the section where we registered it and if it overrides the original page
|
||||
@@ -317,8 +317,8 @@ func TestAddAppLinks(t *testing.T) {
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Connections", connectionsNode.Text)
|
||||
require.Equal(t, "Connect data", connectDataNode.Text)
|
||||
require.Equal(t, "standalone-plugin-page-/connections/connect-data", connectDataNode.Id) // Overridden "Connect data" page
|
||||
require.Equal(t, "Add new connection", connectDataNode.Text)
|
||||
require.Equal(t, "standalone-plugin-page-/connections/add-new-connection", connectDataNode.Id) // Overridden "Add new connection" page
|
||||
require.Equal(t, "test-app3", connectDataNode.PluginID)
|
||||
|
||||
// Check if the standalone plugin page does not appear under the app section anymore
|
||||
@@ -342,12 +342,12 @@ func TestAddAppLinks(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// The original core page should exist under the section
|
||||
connectDataNode := treeRoot.FindById("connections-connect-data")
|
||||
require.Equal(t, "connections-connect-data", connectDataNode.Id)
|
||||
connectDataNode := treeRoot.FindById("connections-add-new-connection")
|
||||
require.Equal(t, "connections-add-new-connection", connectDataNode.Id)
|
||||
require.Equal(t, "", connectDataNode.PluginID)
|
||||
|
||||
// The standalone plugin page should not be found in the navtree at all (as we didn't configure it)
|
||||
standaloneConnectDataNode := treeRoot.FindById("standalone-plugin-page-/connections/connect-data")
|
||||
standaloneConnectDataNode := treeRoot.FindById("standalone-plugin-page-/connections/add-new-connection")
|
||||
require.Nil(t, standaloneConnectDataNode)
|
||||
|
||||
// Only the pages that have `AddToNav=true` appear under the plugin navigation
|
||||
|
||||
@@ -481,29 +481,22 @@ func (s *ServiceImpl) buildDataConnectionsNavLink(c *contextmodel.ReqContext) *n
|
||||
baseUrl := s.cfg.AppSubURL + "/connections"
|
||||
|
||||
if hasAccess(ac.ReqOrgAdmin, datasources.ConfigurationPageAccess) {
|
||||
// Connect data
|
||||
// Add new connection
|
||||
children = append(children, &navtree.NavLink{
|
||||
Id: "connections-connect-data",
|
||||
Text: "Connect data",
|
||||
SubTitle: "Browse and create new connections",
|
||||
IsSection: true,
|
||||
Url: s.cfg.AppSubURL + "/connections/connect-data",
|
||||
Children: []*navtree.NavLink{},
|
||||
Id: "connections-add-new-connection",
|
||||
Text: "Add new connection",
|
||||
SubTitle: "Browse and create new connections",
|
||||
Url: baseUrl + "/add-new-connection",
|
||||
Children: []*navtree.NavLink{},
|
||||
})
|
||||
|
||||
// Your connections
|
||||
// Your data sources
|
||||
children = append(children, &navtree.NavLink{
|
||||
Id: "connections-your-connections",
|
||||
Text: "Your connections",
|
||||
SubTitle: "Manage your existing connections",
|
||||
Url: baseUrl + "/your-connections",
|
||||
// Datasources
|
||||
Children: []*navtree.NavLink{{
|
||||
Id: "connections-your-connections-datasources",
|
||||
Text: "Data sources",
|
||||
SubTitle: "View and manage your connected data source connections",
|
||||
Url: baseUrl + "/your-connections/datasources",
|
||||
}},
|
||||
Id: "connections-your-datasources",
|
||||
Text: "Your data sources",
|
||||
SubTitle: "View and manage your connected data source connections",
|
||||
Url: baseUrl + "/your-datasources",
|
||||
Children: []*navtree.NavLink{},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user