Browse Source

Setting orgs (#3587)

* Implement organizations listing in setting and allow user to create new organization.

* Implement organizations listing in setting and allow user to create new organization.

* Add space remove by mistake

* Remove unused part of the template

* Update display and behavior according to @Unknown remarks
pull/3335/merge
Rémy Boulanouar 8 years ago committed by 无闻
parent
commit
2ee0c61e62
  1. 1
      cmd/web.go
  2. 2
      conf/locale/locale_en-US.ini
  3. 10
      public/less/_form.less
  4. 35
      routers/user/setting.go
  5. 3
      templates/user/settings/navbar.tmpl
  6. 37
      templates/user/settings/organizations.tmpl

1
cmd/web.go

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

2
conf/locale/locale_en-US.ini

@ -337,6 +337,8 @@ 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?
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.
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

10
public/less/_form.less

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

35
routers/user/setting.go

@ -21,16 +21,17 @@ import (
)
const (
SETTINGS_PROFILE base.TplName = "user/settings/profile"
SETTINGS_AVATAR base.TplName = "user/settings/avatar"
SETTINGS_PASSWORD base.TplName = "user/settings/password"
SETTINGS_EMAILS base.TplName = "user/settings/email"
SETTINGS_SSH_KEYS base.TplName = "user/settings/sshkeys"
SETTINGS_SOCIAL base.TplName = "user/settings/social"
SETTINGS_APPLICATIONS base.TplName = "user/settings/applications"
SETTINGS_DELETE base.TplName = "user/settings/delete"
NOTIFICATION base.TplName = "user/notification"
SECURITY base.TplName = "user/security"
SETTINGS_PROFILE base.TplName = "user/settings/profile"
SETTINGS_AVATAR base.TplName = "user/settings/avatar"
SETTINGS_PASSWORD base.TplName = "user/settings/password"
SETTINGS_EMAILS base.TplName = "user/settings/email"
SETTINGS_SSH_KEYS base.TplName = "user/settings/sshkeys"
SETTINGS_SOCIAL base.TplName = "user/settings/social"
SETTINGS_APPLICATIONS base.TplName = "user/settings/applications"
SETTINGS_ORGANIZATIONS base.TplName = "user/settings/organizations"
SETTINGS_DELETE base.TplName = "user/settings/delete"
NOTIFICATION base.TplName = "user/notification"
SECURITY base.TplName = "user/security"
)
func Settings(ctx *context.Context) {
@ -423,6 +424,20 @@ func SettingsDeleteApplication(ctx *context.Context) {
})
}
func SettingsOrganizations(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsOrganizations"] = true
orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned && ctx.User.IsAdmin)
if err != nil {
ctx.Handle(500, "GetOrgsByUserID", err)
return
}
ctx.Data["Orgs"] = orgs
ctx.HTML(200, SETTINGS_ORGANIZATIONS)
}
func SettingsDelete(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsDelete"] = true

3
templates/user/settings/navbar.tmpl

@ -19,6 +19,9 @@
<a class="{{if .PageIsSettingsApplications}}active{{end}} item" href="{{AppSubUrl}}/user/settings/applications">
{{.i18n.Tr "settings.applications"}}
</a>
<a class="{{if .PageIsSettingsOrganizations}}active{{end}} item" href="{{AppSubUrl}}/user/settings/organizations">
{{.i18n.Tr "settings.orgs"}}
</a>
<a class="{{if .PageIsSettingsDelete}}active{{end}} item" href="{{AppSubUrl}}/user/settings/delete">
{{.i18n.Tr "settings.delete"}}
</a>

37
templates/user/settings/organizations.tmpl

@ -0,0 +1,37 @@
{{template "base/head" .}}
<div class="user settings organizations">
<div class="ui container">
<div class="ui grid">
{{template "user/settings/navbar" .}}
<div class="twelve wide column content">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.i18n.Tr "settings.orgs"}}
<div class="ui right">
<a class="ui blue tiny button" href="{{AppSubUrl}}/org/create">{{.i18n.Tr "new_org"}}</a>
</div>
</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">
<div class="ui button">Leave</div>
</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>
</div>
</div>
{{template "base/footer" .}}
Loading…
Cancel
Save