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 @@