mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'data-source-instance-to-react' of https://github.com/grafana/grafana into data-source-instance-to-react
This commit is contained in:
commit
707446170d
@ -17,18 +17,21 @@ func GetDataSources(c *m.ReqContext) Response {
|
|||||||
return Error(500, "Failed to query datasources", err)
|
return Error(500, "Failed to query datasources", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
permissions := map[int64]m.DsPermissionType{}
|
dsFilterQuery := m.DatasourcesPermissionFilterQuery{
|
||||||
permissionsQuery := m.GetDataSourcePermissionsForUserQuery{User: c.SignedInUser}
|
User: c.SignedInUser,
|
||||||
if err := bus.Dispatch(&permissionsQuery); err != nil {
|
Datasources: query.Result,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := bus.Dispatch(&dsFilterQuery); err != nil {
|
||||||
if err != bus.ErrHandlerNotFound {
|
if err != bus.ErrHandlerNotFound {
|
||||||
return Error(500, "failed to read datasource permissions", err)
|
return Error(500, "Could not get datasources", err)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
permissions = permissionsQuery.Result
|
dsFilterQuery.Result = query.Result
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(dtos.DataSourceList, 0)
|
result := make(dtos.DataSourceList, 0)
|
||||||
for _, ds := range query.Result {
|
for _, ds := range dsFilterQuery.Result {
|
||||||
dsItem := dtos.DataSourceListItemDTO{
|
dsItem := dtos.DataSourceListItemDTO{
|
||||||
OrgId: ds.OrgId,
|
OrgId: ds.OrgId,
|
||||||
Id: ds.Id,
|
Id: ds.Id,
|
||||||
@ -45,13 +48,6 @@ func GetDataSources(c *m.ReqContext) Response {
|
|||||||
ReadOnly: ds.ReadOnly,
|
ReadOnly: ds.ReadOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
if permission, ok := permissions[ds.Id]; ok {
|
|
||||||
c.Logger.Info("Found permission", "permission", permission)
|
|
||||||
if permission == m.DsPermissionNoAccess {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if plugin, exists := plugins.DataSources[ds.Type]; exists {
|
if plugin, exists := plugins.DataSources[ds.Type]; exists {
|
||||||
dsItem.TypeLogoUrl = plugin.Info.Logos.Small
|
dsItem.TypeLogoUrl = plugin.Info.Logos.Small
|
||||||
} else {
|
} else {
|
||||||
|
@ -217,3 +217,9 @@ type GetDataSourcePermissionsForUserQuery struct {
|
|||||||
User *SignedInUser
|
User *SignedInUser
|
||||||
Result map[int64]DsPermissionType
|
Result map[int64]DsPermissionType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DatasourcesPermissionFilterQuery struct {
|
||||||
|
User *SignedInUser
|
||||||
|
Datasources []*DataSource
|
||||||
|
Result []*DataSource
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user