From 8fcaa4997df37d79604ab86431420eff07b6d29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 12 Aug 2015 08:59:25 +0200 Subject: [PATCH] feat(admin): Deleting org from orgs list now works, will permanently delete dashboards, data sources, etc, closes #2457 --- pkg/api/api.go | 1 + pkg/api/org.go | 8 ++++++++ pkg/services/sqlstore/org.go | 1 + public/app/features/admin/adminListOrgsCtrl.js | 1 + public/app/features/admin/partials/users.html | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 2d010e2649a..ef89311bdd6 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -113,6 +113,7 @@ func Register(r *macaron.Macaron) { r.Group("/orgs/:orgId", func() { r.Get("/", wrap(GetOrgById)) r.Put("/", bind(m.UpdateOrgCommand{}), wrap(UpdateOrg)) + r.Delete("/", wrap(DeleteOrgById)) r.Get("/users", wrap(GetOrgUsers)) r.Post("/users", bind(m.AddOrgUserCommand{}), wrap(AddOrgUser)) r.Patch("/users/:userId", bind(m.UpdateOrgUserCommand{}), wrap(UpdateOrgUser)) diff --git a/pkg/api/org.go b/pkg/api/org.go index 746281c5138..c32a88eac44 100644 --- a/pkg/api/org.go +++ b/pkg/api/org.go @@ -77,6 +77,14 @@ func updateOrgHelper(cmd m.UpdateOrgCommand) Response { return ApiSuccess("Organization updated") } +// GET /api/orgs/:orgId +func DeleteOrgById(c *middleware.Context) Response { + if err := bus.Dispatch(&m.DeleteOrgCommand{Id: c.ParamsInt64(":orgId")}); err != nil { + return ApiError(500, "Failed to update organization", err) + } + return ApiSuccess("Organization deleted") +} + func SearchOrgs(c *middleware.Context) Response { query := m.SearchOrgsQuery{ Query: c.Query("query"), diff --git a/pkg/services/sqlstore/org.go b/pkg/services/sqlstore/org.go index 725a21d7fad..f132b056f39 100644 --- a/pkg/services/sqlstore/org.go +++ b/pkg/services/sqlstore/org.go @@ -130,6 +130,7 @@ func DeleteOrg(cmd *m.DeleteOrgCommand) error { "DELETE FROM data_source WHERE org_id = ?", "DELETE FROM org_user WHERE org_id = ?", "DELETE FROM org WHERE id = ?", + "DELETE FROM temp_user WHERE org_id = ?", } for _, sql := range deletes { diff --git a/public/app/features/admin/adminListOrgsCtrl.js b/public/app/features/admin/adminListOrgsCtrl.js index 380ce41faef..c3f727191fc 100644 --- a/public/app/features/admin/adminListOrgsCtrl.js +++ b/public/app/features/admin/adminListOrgsCtrl.js @@ -21,6 +21,7 @@ function (angular) { $scope.deleteOrg = function(org) { $scope.appEvent('confirm-modal', { title: 'Do you want to delete organization ' + org.name + '?', + text: 'All dashboards for this organization will be removed!', icon: 'fa-trash', yesText: 'Delete', onConfirm: function() { diff --git a/public/app/features/admin/partials/users.html b/public/app/features/admin/partials/users.html index 6d4f7a8671c..6f8365e75dd 100644 --- a/public/app/features/admin/partials/users.html +++ b/public/app/features/admin/partials/users.html @@ -1,6 +1,6 @@