Browse Source

Add 'Organizations' page to user settings (#3587)

User is now able to view full list of organizations belongs to.
pull/3335/merge
Unknwon 8 years ago
parent
commit
7aa53635fe
No known key found for this signature in database
GPG Key ID: FB9F411CDD69BEC1
  1. 7
      cmd/web.go
  2. 4
      conf/locale/locale_en-US.ini
  3. 2
      gogs.go
  4. 4
      modules/bindata/bindata.go
  5. 10
      public/css/gogs.css
  6. 10
      public/less/_form.less
  7. 10
      public/less/_user.less
  8. 13
      routers/user/setting.go
  9. 2
      templates/.VERSION
  10. 17
      templates/user/settings/organizations.tmpl

7
cmd/web.go

@ -247,7 +247,12 @@ func runWeb(ctx *cli.Context) error {
m.Combo("/applications").Get(user.SettingsApplications). m.Combo("/applications").Get(user.SettingsApplications).
Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost) Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost)
m.Post("/applications/delete", user.SettingsDeleteApplication) m.Post("/applications/delete", user.SettingsDeleteApplication)
m.Get("/organizations", user.SettingsOrganizations)
m.Group("/organizations", func() {
m.Get("", user.SettingsOrganizations)
m.Post("/leave", user.SettingsLeaveOrganization)
})
m.Route("/delete", "GET,POST", user.SettingsDelete) m.Route("/delete", "GET,POST", user.SettingsDelete)
}, reqSignIn, func(ctx *context.Context) { }, reqSignIn, func(ctx *context.Context) {
ctx.Data["PageIsUserSettings"] = true ctx.Data["PageIsUserSettings"] = true

4
conf/locale/locale_en-US.ini

@ -337,7 +337,9 @@ access_token_deletion = Personal Access Token Deletion
access_token_deletion_desc = Delete this personal access token will remove all related accesses of application. Do you want to continue? access_token_deletion_desc = Delete this personal access token will remove all related accesses of application. Do you want to continue?
delete_token_success = Personal access token has been removed successfully! Don't forget to update your application as well. delete_token_success = Personal access token has been removed successfully! Don't forget to update your application as well.
orgs_none = You are not a member of any organizations. orgs.none = You are not a member of any organizations.
orgs.leave_title = Leave an organization
orgs.leave_desc = You will lose access to all repositories and teams after you left the organization. Do you want to continue?
delete_account = Delete Your Account delete_account = Delete Your Account
delete_prompt = The operation will delete your account permanently, and <strong>CANNOT</strong> be undone! delete_prompt = The operation will delete your account permanently, and <strong>CANNOT</strong> be undone!

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.9.121.0127" const APP_VER = "0.9.122.0127"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

10
public/css/gogs.css

@ -2658,6 +2658,16 @@ footer .ui.language .menu {
.user.settings .email.list .item:not(:first-child) .button { .user.settings .email.list .item:not(:first-child) .button {
margin-top: -10px; margin-top: -10px;
} }
.user.settings .orgs {
padding: 0;
}
.user.settings .orgs .item {
padding: 10px;
}
.user.settings .orgs .item .button {
margin-top: 5px;
margin-right: 8px;
}
.user.profile .ui.card .username { .user.profile .ui.card .username {
display: block; display: block;
} }

10
public/less/_form.less

@ -18,16 +18,6 @@
} }
} }
ui.attached.segment.orgs {
padding: 0px;
div .item {
padding: 11px;
.content {
font-weight: bold;
}
}
}
@create-page-form-input-padding: 250px !important; @create-page-form-input-padding: 250px !important;
#create-page-form { #create-page-form {
form { form {

10
public/less/_user.less

@ -19,6 +19,16 @@
} }
} }
} }
.orgs {
padding: 0;
.item {
padding: 10px;
.button {
margin-top: 5px;
margin-right: 8px;
}
}
}
} }
&.profile { &.profile {

13
routers/user/setting.go

@ -428,7 +428,7 @@ func SettingsOrganizations(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsOrganizations"] = true ctx.Data["PageIsSettingsOrganizations"] = true
orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned && ctx.User.IsAdmin) orgs, err := models.GetOrgsByUserID(ctx.User.ID, true)
if err != nil { if err != nil {
ctx.Handle(500, "GetOrgsByUserID", err) ctx.Handle(500, "GetOrgsByUserID", err)
return return
@ -438,6 +438,17 @@ func SettingsOrganizations(ctx *context.Context) {
ctx.HTML(200, SETTINGS_ORGANIZATIONS) ctx.HTML(200, SETTINGS_ORGANIZATIONS)
} }
func SettingsLeaveOrganization(ctx *context.Context) {
err := models.RemoveOrgUser(ctx.QueryInt64("id"), ctx.User.ID)
if models.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
}
ctx.JSON(200, map[string]interface{}{
"redirect": setting.AppSubUrl + "/user/settings/organizations",
})
}
func SettingsDelete(ctx *context.Context) { func SettingsDelete(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsDelete"] = true ctx.Data["PageIsSettingsDelete"] = true

2
templates/.VERSION

@ -1 +1 @@
0.9.121.0127 0.9.122.0127

17
templates/user/settings/organizations.tmpl

@ -17,7 +17,9 @@
{{range .Orgs}} {{range .Orgs}}
<div class="item"> <div class="item">
<div class="right floated content"> <div class="right floated content">
<div class="ui button">Leave</div> <button class="ui red tiny button inline text-thin delete-button" data-url="{{$.Link}}/leave" data-id="{{.ID}}">
{{$.i18n.Tr "org.members.leave"}}
</button>
</div> </div>
<img class="ui mini image" src="{{.RelAvatarLink}}"> <img class="ui mini image" src="{{.RelAvatarLink}}">
<div class="content"> <div class="content">
@ -27,11 +29,22 @@
{{end}} {{end}}
</div> </div>
{{else}} {{else}}
{{.i18n.Tr "settings.orgs_none"}} {{.i18n.Tr "settings.orgs.none"}}
{{end}} {{end}}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="ui small basic delete modal">
<div class="ui icon header">
<i class="trash icon"></i>
{{.i18n.Tr "settings.orgs.leave_title"}}
</div>
<div class="content">
<p>{{.i18n.Tr "settings.orgs.leave_desc"}}</p>
</div>
{{template "base/delete_modal_actions" .}}
</div>
{{template "base/footer" .}} {{template "base/footer" .}}

Loading…
Cancel
Save