Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5b35a21d
Commit
5b35a21d
authored
Jun 16, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dashboard_folders' of github.com:grafana/grafana into dashboard_folders
parents
0ad4a0fa
dd02bf7c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
pkg/api/dashboard.go
+4
-0
pkg/api/dashboard_test.go
+20
-0
pkg/models/dashboards.go
+6
-5
No files found.
pkg/api/dashboard.go
View file @
5b35a21d
...
...
@@ -194,6 +194,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
return
ApiError
(
403
,
"Does not have permission to save this dashboard"
,
nil
)
}
if
dash
.
IsFolder
&&
dash
.
ParentId
>
0
{
return
ApiError
(
400
,
m
.
ErrDashboardFolderCannotHaveParent
.
Error
(),
nil
)
}
// Check if Title is empty
if
dash
.
Title
==
""
{
return
ApiError
(
400
,
m
.
ErrDashboardTitleEmpty
.
Error
(),
nil
)
...
...
pkg/api/dashboard_test.go
View file @
5b35a21d
...
...
@@ -132,6 +132,26 @@ func TestDashboardApiEndpoint(t *testing.T) {
CallPostDashboard
(
sc
)
So
(
sc
.
resp
.
Code
,
ShouldEqual
,
200
)
})
Convey
(
"When saving a dashboard folder in another folder"
,
func
()
{
bus
.
AddHandler
(
"test"
,
func
(
query
*
models
.
GetDashboardQuery
)
error
{
query
.
Result
=
fakeDash
query
.
Result
.
IsFolder
=
true
return
nil
})
invalidCmd
:=
models
.
SaveDashboardCommand
{
Dashboard
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"parentId"
:
fakeDash
.
ParentId
,
"title"
:
fakeDash
.
Title
,
}),
}
Convey
(
"Should return an error"
,
func
()
{
postDashboardScenario
(
"When calling POST on"
,
"/api/dashboards"
,
"/api/dashboards"
,
role
,
invalidCmd
,
func
(
sc
*
scenarioContext
)
{
CallPostDashboard
(
sc
)
So
(
sc
.
resp
.
Code
,
ShouldEqual
,
400
)
})
})
})
})
})
...
...
pkg/models/dashboards.go
View file @
5b35a21d
...
...
@@ -11,11 +11,12 @@ import (
// Typed errors
var
(
ErrDashboardNotFound
=
errors
.
New
(
"Dashboard not found"
)
ErrDashboardSnapshotNotFound
=
errors
.
New
(
"Dashboard snapshot not found"
)
ErrDashboardWithSameNameExists
=
errors
.
New
(
"A dashboard with the same name already exists"
)
ErrDashboardVersionMismatch
=
errors
.
New
(
"The dashboard has been changed by someone else"
)
ErrDashboardTitleEmpty
=
errors
.
New
(
"Dashboard title cannot be empty"
)
ErrDashboardNotFound
=
errors
.
New
(
"Dashboard not found"
)
ErrDashboardSnapshotNotFound
=
errors
.
New
(
"Dashboard snapshot not found"
)
ErrDashboardWithSameNameExists
=
errors
.
New
(
"A dashboard with the same name already exists"
)
ErrDashboardVersionMismatch
=
errors
.
New
(
"The dashboard has been changed by someone else"
)
ErrDashboardTitleEmpty
=
errors
.
New
(
"Dashboard title cannot be empty"
)
ErrDashboardFolderCannotHaveParent
=
errors
.
New
(
"A Dashboard Folder cannot be added to another folder"
)
)
type
UpdatePluginDashboardError
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment