mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 04:22:13 +08:00
fix(plugins): only add app nav link if it has any pages/dashboards with role matching current user, fixes #4784
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -37,6 +39,26 @@ func (r RoleType) Includes(other RoleType) bool {
|
||||
return r == other
|
||||
}
|
||||
|
||||
func (r *RoleType) UnmarshalJSON(data []byte) error {
|
||||
var str string
|
||||
err := json.Unmarshal(data, &str)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*r = RoleType(str)
|
||||
|
||||
if (*r).IsValid() == false {
|
||||
if (*r) != "" {
|
||||
return errors.New(fmt.Sprintf("JSON validation error: invalid role value: %s", *r))
|
||||
}
|
||||
|
||||
*r = ROLE_VIEWER
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type OrgUser struct {
|
||||
Id int64
|
||||
OrgId int64
|
||||
|
Reference in New Issue
Block a user