Serviceaccounts: feat - tabview for serviceaccounts (#43573)

This commit is contained in:
Eric Leijonmarck
2022-01-05 15:32:38 +01:00
committed by GitHub
parent 5c88acd5aa
commit 0aa905bb1f
16 changed files with 435 additions and 5 deletions
+20 -1
View File
@@ -142,6 +142,14 @@ func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error)
return appLinks, nil
}
func enableServiceAccount(hs *HTTPServer, c *models.ReqContext) bool {
return c.OrgRole == models.ROLE_ADMIN && hs.Cfg.IsServiceAccountEnabled() && hs.serviceAccountsService.Migrated(c.Req.Context(), c.OrgId)
}
func enableTeams(hs *HTTPServer, c *models.ReqContext) bool {
return c.OrgRole == models.ROLE_ADMIN || (hs.Cfg.EditorsCanAdmin && c.OrgRole == models.ROLE_EDITOR)
}
func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool) ([]*dtos.NavLink, error) {
hasAccess := ac.HasAccess(hs.AccessControl, c)
navTree := []*dtos.NavLink{}
@@ -253,7 +261,7 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool) ([]*dto
})
}
if c.OrgRole == models.ROLE_ADMIN || (hs.Cfg.EditorsCanAdmin && c.OrgRole == models.ROLE_EDITOR) {
if enableTeams(hs, c) {
configNodes = append(configNodes, &dtos.NavLink{
Text: "Teams",
Id: "teams",
@@ -292,6 +300,17 @@ func (hs *HTTPServer) getNavTree(c *models.ReqContext, hasEditPerm bool) ([]*dto
Url: hs.Cfg.AppSubURL + "/org/apikeys",
})
}
// needs both feature flag and migration to be able to show service accounts
if enableServiceAccount(hs, c) {
configNodes = append(configNodes, &dtos.NavLink{
Text: "Service accounts",
Id: "serviceaccounts",
Description: "Manage service accounts",
// TODO: change icon to "key-skeleton-alt" when it's available
Icon: "key-skeleton-alt",
Url: hs.Cfg.AppSubURL + "/org/serviceaccounts",
})
}
if hs.Cfg.FeatureToggles["live-pipeline"] {
liveNavLinks := []*dtos.NavLink{}