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
1bcd4c04
Unverified
Commit
1bcd4c04
authored
Oct 24, 2018
by
Marcus Efraimsson
Committed by
GitHub
Oct 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13806 from bergquist/proviosioing_when_folder_is_deleted
Delete provisioning meta data when deleting Folder
parents
a6fc74e3
0a9bfc55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
pkg/services/sqlstore/dashboard.go
+6
-1
pkg/services/sqlstore/dashboard_provisioning_test.go
+30
-2
No files found.
pkg/services/sqlstore/dashboard.go
View file @
1bcd4c04
...
...
@@ -320,13 +320,18 @@ func DeleteDashboard(cmd *m.DeleteDashboardCommand) error {
"DELETE FROM dashboard WHERE id = ?"
,
"DELETE FROM playlist_item WHERE type = 'dashboard_by_id' AND value = ?"
,
"DELETE FROM dashboard_version WHERE dashboard_id = ?"
,
"DELETE FROM dashboard WHERE folder_id = ?"
,
"DELETE FROM annotation WHERE dashboard_id = ?"
,
"DELETE FROM dashboard_provisioning WHERE dashboard_id = ?"
,
}
if
dashboard
.
IsFolder
{
deletes
=
append
(
deletes
,
"DELETE FROM dashboard_provisioning WHERE dashboard_id in (select id from dashboard where folder_id = ?)"
)
deletes
=
append
(
deletes
,
"DELETE FROM dashboard WHERE folder_id = ?"
)
}
for
_
,
sql
:=
range
deletes
{
_
,
err
:=
sess
.
Exec
(
sql
,
dashboard
.
Id
)
if
err
!=
nil
{
return
err
}
...
...
pkg/services/sqlstore/dashboard_provisioning_test.go
View file @
1bcd4c04
...
...
@@ -13,17 +13,30 @@ func TestDashboardProvisioningTest(t *testing.T) {
Convey
(
"Testing Dashboard provisioning"
,
t
,
func
()
{
InitTestDB
(
t
)
saveDashboard
Cmd
:=
&
models
.
SaveDashboardCommand
{
folder
Cmd
:=
&
models
.
SaveDashboardCommand
{
OrgId
:
1
,
FolderId
:
0
,
IsFolder
:
true
,
Dashboard
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"id"
:
nil
,
"title"
:
"test dashboard"
,
}),
}
err
:=
SaveDashboard
(
folderCmd
)
So
(
err
,
ShouldBeNil
)
saveDashboardCmd
:=
&
models
.
SaveDashboardCommand
{
OrgId
:
1
,
IsFolder
:
false
,
FolderId
:
folderCmd
.
Result
.
Id
,
Dashboard
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"id"
:
nil
,
"title"
:
"test dashboard"
,
}),
}
Convey
(
"Saving dashboards with
extras
"
,
func
()
{
Convey
(
"Saving dashboards with
provisioning meta data
"
,
func
()
{
now
:=
time
.
Now
()
cmd
:=
&
models
.
SaveProvisionedDashboardCommand
{
...
...
@@ -67,6 +80,21 @@ func TestDashboardProvisioningTest(t *testing.T) {
So
(
err
,
ShouldBeNil
)
So
(
query
.
Result
,
ShouldBeFalse
)
})
Convey
(
"Deleteing folder should delete provision meta data"
,
func
()
{
deleteCmd
:=
&
models
.
DeleteDashboardCommand
{
Id
:
folderCmd
.
Result
.
Id
,
OrgId
:
1
,
}
So
(
DeleteDashboard
(
deleteCmd
),
ShouldBeNil
)
query
:=
&
models
.
IsDashboardProvisionedQuery
{
DashboardId
:
cmd
.
Result
.
Id
}
err
=
GetProvisionedDataByDashboardId
(
query
)
So
(
err
,
ShouldBeNil
)
So
(
query
.
Result
,
ShouldBeFalse
)
})
})
})
}
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