mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
87c3a2b790
* PluginManager: Make Plugins and DataSources non-global Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix integration tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Replace outdated command Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * DashboardService: Ensure it gets constructed with necessary parameters Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix build Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * DashboardService: Ensure it gets constructed with necessary parameters Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Remove dead code Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Remove FocusConvey Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Remove dead code Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Undo interface changes Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Backend: Move tsdbifaces.RequestHandler to plugins.DataRequestHandler Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Rename to DataSourceCount Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Consolidate dashboard interfaces into one Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix dashboard integration tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
89 lines
1.9 KiB
Go
89 lines
1.9 KiB
Go
package models
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// Typed errors
|
|
var (
|
|
ErrFolderNotFound = errors.New("folder not found")
|
|
ErrFolderVersionMismatch = errors.New("the folder has been changed by someone else")
|
|
ErrFolderTitleEmpty = errors.New("folder title cannot be empty")
|
|
ErrFolderWithSameUIDExists = errors.New("a folder/dashboard with the same uid already exists")
|
|
ErrFolderSameNameExists = errors.New("a folder or dashboard in the general folder with the same name already exists")
|
|
ErrFolderFailedGenerateUniqueUid = errors.New("failed to generate unique folder ID")
|
|
ErrFolderAccessDenied = errors.New("access denied to folder")
|
|
)
|
|
|
|
type Folder struct {
|
|
Id int64
|
|
Uid string
|
|
Title string
|
|
Url string
|
|
Version int
|
|
|
|
Created time.Time
|
|
Updated time.Time
|
|
|
|
UpdatedBy int64
|
|
CreatedBy int64
|
|
HasAcl bool
|
|
}
|
|
|
|
// UpdateDashboardModel updates an existing model from command into model for update
|
|
func (cmd *UpdateFolderCommand) UpdateDashboardModel(dashFolder *Dashboard, orgId int64, userId int64) {
|
|
dashFolder.OrgId = orgId
|
|
dashFolder.Title = strings.TrimSpace(cmd.Title)
|
|
dashFolder.Data.Set("title", dashFolder.Title)
|
|
|
|
if cmd.Uid != "" {
|
|
dashFolder.SetUid(cmd.Uid)
|
|
}
|
|
|
|
dashFolder.SetVersion(cmd.Version)
|
|
dashFolder.IsFolder = true
|
|
|
|
if userId == 0 {
|
|
userId = -1
|
|
}
|
|
|
|
dashFolder.UpdatedBy = userId
|
|
dashFolder.UpdateSlug()
|
|
}
|
|
|
|
//
|
|
// COMMANDS
|
|
//
|
|
|
|
type CreateFolderCommand struct {
|
|
Uid string `json:"uid"`
|
|
Title string `json:"title"`
|
|
|
|
Result *Folder
|
|
}
|
|
|
|
type UpdateFolderCommand struct {
|
|
Uid string `json:"uid"`
|
|
Title string `json:"title"`
|
|
Version int `json:"version"`
|
|
Overwrite bool `json:"overwrite"`
|
|
|
|
Result *Folder
|
|
}
|
|
|
|
//
|
|
// QUERIES
|
|
//
|
|
|
|
type HasEditPermissionInFoldersQuery struct {
|
|
SignedInUser *SignedInUser
|
|
Result bool
|
|
}
|
|
|
|
type HasAdminPermissionInFoldersQuery struct {
|
|
SignedInUser *SignedInUser
|
|
Result bool
|
|
}
|