{{$.i18n.Tr "org.members.leave.detail" `` | Safe}}
+diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0a030b9b0..76536f2d4 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2176,12 +2176,15 @@ members.member_role = Member Role: members.owner = Owner members.member = Member members.remove = Remove +members.remove.detail = Remove %[1]s from %[2]s? members.leave = Leave +members.leave.detail = Leave %s? members.invite_desc = Add a new member to %s: members.invite_now = Invite Now teams.join = Join teams.leave = Leave +teams.leave.detail = Leave %s? teams.can_create_org_repo = Create repositories teams.can_create_org_repo_helper = Members can create new repositories in organization. Creator will get administrator access to the new repository. teams.read_access = Read Access diff --git a/routers/web/org/members.go b/routers/web/org/members.go index 84aaa28f6..ef5a69e15 100644 --- a/routers/web/org/members.go +++ b/routers/web/org/members.go @@ -99,14 +99,18 @@ func MembersAction(ctx *context.Context) { err = org.RemoveMember(uid) if models.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) - ctx.Redirect(ctx.Org.OrgLink + "/members") + ctx.JSON(http.StatusOK, map[string]interface{}{ + "redirect": ctx.Org.OrgLink + "/members", + }) return } case "leave": err = org.RemoveMember(ctx.User.ID) if models.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) - ctx.Redirect(ctx.Org.OrgLink + "/members") + ctx.JSON(http.StatusOK, map[string]interface{}{ + "redirect": ctx.Org.OrgLink + "/members", + }) return } } @@ -120,9 +124,12 @@ func MembersAction(ctx *context.Context) { return } - if ctx.Params(":action") != "leave" { - ctx.Redirect(ctx.Org.OrgLink + "/members") - } else { - ctx.Redirect(setting.AppSubURL + "/") + redirect := ctx.Org.OrgLink + "/members" + if ctx.Params(":action") == "leave" { + redirect = setting.AppSubURL + "/" } + + ctx.JSON(http.StatusOK, map[string]interface{}{ + "redirect": redirect, + }) } diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 4725f19b3..c93fcd062 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -66,6 +66,23 @@ func TeamsAction(ctx *context.Context) { err = ctx.Org.Team.AddMember(ctx.User.ID) case "leave": err = ctx.Org.Team.RemoveMember(ctx.User.ID) + if err != nil { + if models.IsErrLastOrgOwner(err) { + ctx.Flash.Error(ctx.Tr("form.last_org_owner")) + } else { + log.Error("Action(%s): %v", ctx.Params(":action"), err) + ctx.JSON(http.StatusOK, map[string]interface{}{ + "ok": false, + "err": err.Error(), + }) + return + } + } + ctx.JSON(http.StatusOK, + map[string]interface{}{ + "redirect": ctx.Org.OrgLink + "/teams/", + }) + return case "remove": if !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) @@ -73,6 +90,23 @@ func TeamsAction(ctx *context.Context) { } err = ctx.Org.Team.RemoveMember(uid) page = "team" + if err != nil { + if models.IsErrLastOrgOwner(err) { + ctx.Flash.Error(ctx.Tr("form.last_org_owner")) + } else { + log.Error("Action(%s): %v", ctx.Params(":action"), err) + ctx.JSON(http.StatusOK, map[string]interface{}{ + "ok": false, + "err": err.Error(), + }) + return + } + } + ctx.JSON(http.StatusOK, + map[string]interface{}{ + "redirect": ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName, + }) + return case "add": if !ctx.Org.IsOwner { ctx.Error(http.StatusNotFound) diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index 0952d1276..ecb535d57 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -54,14 +54,18 @@
{{$.i18n.Tr "org.members.leave.detail" `` | Safe}}
+{{$.i18n.Tr "org.members.remove.detail" `` `` | Safe}}
+{{$.i18n.Tr "org.members.remove.detail" `` `` | Safe}}
+{{$.i18n.Tr "org.teams.leave.detail" `` | Safe}}
+{{$.i18n.Tr "org.teams.leave.detail" `` | Safe}}
+