diff options
-rw-r--r-- | options/locale/locale_en-US.ini | 3 | ||||
-rw-r--r-- | routers/routes/routes.go | 1 | ||||
-rw-r--r-- | routers/user/setting.go | 14 | ||||
-rw-r--r-- | templates/user/settings/navbar.tmpl | 3 | ||||
-rw-r--r-- | templates/user/settings/organization.tmpl | 35 |
5 files changed, 56 insertions, 0 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index e369ee8b30..00b374835f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -298,6 +298,7 @@ orgs = Organizations delete = Delete Account twofa = Two-Factor Authentication account_link = External Accounts +organization = Organization uid = Uid public_profile = Public Profile @@ -431,6 +432,8 @@ remove_account_link = Remove linked account remove_account_link_desc = Removing this linked account will revoke all related access using this account. Do you want to continue? remove_account_link_success = Account link has been removed successfully! +orgs_none = You are not a member of any organizations. + delete_account = Delete Your Account delete_prompt = The operation will delete your account permanently, and <strong>CANNOT</strong> be undone! confirm_delete_account = Confirm Deletion diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 0781aef89d..ecb95e3785 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -223,6 +223,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/applications/delete", user.SettingsDeleteApplication) m.Route("/delete", "GET,POST", user.SettingsDelete) m.Combo("/account_link").Get(user.SettingsAccountLinks).Post(user.SettingsDeleteAccountLink) + m.Get("/organization", user.SettingsOrganization) m.Group("/two_factor", func() { m.Get("", user.SettingsTwoFactor) m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch) diff --git a/routers/user/setting.go b/routers/user/setting.go index 8fa9834167..f0cb9e7843 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -38,6 +38,7 @@ const ( tplSettingsTwofa base.TplName = "user/settings/twofa" tplSettingsTwofaEnroll base.TplName = "user/settings/twofa_enroll" tplSettingsAccountLink base.TplName = "user/settings/account_link" + tplSettingsOrganization base.TplName = "user/settings/organization" tplSettingsDelete base.TplName = "user/settings/delete" tplSecurity base.TplName = "user/security" ) @@ -771,3 +772,16 @@ func SettingsDelete(ctx *context.Context) { ctx.HTML(200, tplSettingsDelete) } + +// SettingsOrganization render all the organization of the user +func SettingsOrganization(ctx *context.Context) { + ctx.Data["Title"] = ctx.Tr("settings") + ctx.Data["PageIsSettingsOrganization"] = true + orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned) + if err != nil { + ctx.Handle(500, "GetOrgsByUserID", err) + return + } + ctx.Data["Orgs"] = orgs + ctx.HTML(200, tplSettingsOrganization) +} diff --git a/templates/user/settings/navbar.tmpl b/templates/user/settings/navbar.tmpl index 4aac9effb5..ab9b41666d 100644 --- a/templates/user/settings/navbar.tmpl +++ b/templates/user/settings/navbar.tmpl @@ -28,6 +28,9 @@ <a class="{{if .PageIsSettingsAccountLink}}active{{end}} item" href="{{AppSubUrl}}/user/settings/account_link"> {{.i18n.Tr "settings.account_link"}} </a> + <a class="{{if .PageIsSettingsOrganization}}active{{end}} item" href="{{AppSubUrl}}/user/settings/organization"> + {{.i18n.Tr "settings.organization"}} + </a> <a class="{{if .PageIsSettingsDelete}}active{{end}} item" href="{{AppSubUrl}}/user/settings/delete"> {{.i18n.Tr "settings.delete"}} </a> diff --git a/templates/user/settings/organization.tmpl b/templates/user/settings/organization.tmpl new file mode 100644 index 0000000000..2d357cb3b5 --- /dev/null +++ b/templates/user/settings/organization.tmpl @@ -0,0 +1,35 @@ +{{template "base/head" .}} +<div class="user settings account_link"> + {{template "user/settings/navbar" .}} + <div class="ui container"> + {{template "base/alert" .}} + <h4 class="ui top attached header"> + {{.i18n.Tr "settings.orgs"}} + {{if .SignedUser.CanCreateOrganization}} + <div class="ui right"> + <a class="ui black tiny button" href="{{AppSubUrl}}/org/create">{{.i18n.Tr "admin.orgs.new_orga"}}</a> + </div> + {{end}} + </h4> + <div class="ui attached segment orgs"> + {{if .Orgs}} + <div class="ui middle aligned divided list"> + {{range .Orgs}} + <div class="item"> + <div class="right floated content"> + <a class="ui blue small button" href="{{AppSubUrl}}/org/{{.Name}}/members/action/leave?uid={{.ID}}">{{$.i18n.Tr "org.members.leave"}}</a> + </div> + <img class="ui mini image" src="{{.RelAvatarLink}}"> + <div class="content"> + <a href="{{.HomeLink}}">{{.Name}}</a> + </div> + </div> + {{end}} + </div> + {{else}} + {{.i18n.Tr "settings.orgs_none"}} + {{end}} + </div> + </div> +</div> +{{template "base/footer" .}} |