Browse Source

user/setting: reorder navbar

pull/4248/merge
Unknwon 8 years ago
parent
commit
497cdc9250
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 15
      cmd/web.go
  2. 6
      conf/locale/locale_en-US.ini
  3. 104
      routers/user/setting.go

15
cmd/web.go

@ -212,18 +212,17 @@ func runWeb(ctx *cli.Context) error {
m.Combo("/ssh").Get(user.SettingsSSHKeys). m.Combo("/ssh").Get(user.SettingsSSHKeys).
Post(bindIgnErr(form.AddSSHKey{}), user.SettingsSSHKeysPost) Post(bindIgnErr(form.AddSSHKey{}), user.SettingsSSHKeysPost)
m.Post("/ssh/delete", user.DeleteSSHKey) m.Post("/ssh/delete", user.DeleteSSHKey)
m.Combo("/applications").Get(user.SettingsApplications).
Post(bindIgnErr(form.NewAccessToken{}), user.SettingsApplicationsPost)
m.Post("/applications/delete", user.SettingsDeleteApplication)
m.Group("/organizations", func() {
m.Get("", user.SettingsOrganizations)
m.Post("/leave", user.SettingsLeaveOrganization)
})
m.Group("/repositories", func() { m.Group("/repositories", func() {
m.Get("", user.SettingsRepos) m.Get("", user.SettingsRepos)
m.Post("/leave", user.SettingsLeaveRepo) m.Post("/leave", user.SettingsLeaveRepo)
}) })
m.Group("/organizations", func() {
m.Get("", user.SettingsOrganizations)
m.Post("/leave", user.SettingsLeaveOrganization)
})
m.Combo("/applications").Get(user.SettingsApplications).
Post(bindIgnErr(form.NewAccessToken{}), user.SettingsApplicationsPost)
m.Post("/applications/delete", user.SettingsDeleteApplication)
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

6
conf/locale/locale_en-US.ini

@ -255,12 +255,10 @@ profile = Profile
password = Password password = Password
avatar = Avatar avatar = Avatar
ssh_keys = SSH Keys ssh_keys = SSH Keys
social = Social Accounts
applications = Applications
orgs = Organizations
repos = Repositories repos = Repositories
orgs = Organizations
applications = Applications
delete = Delete Account delete = Delete Account
uid = Uid
public_profile = Public Profile public_profile = Public Profile
profile_desc = Your email address is public and will be used for any account related notifications, and any web based operations made via the site. profile_desc = Your email address is public and will be used for any account related notifications, and any web based operations made via the site.

104
routers/user/setting.go

@ -390,6 +390,58 @@ func SettingsApplications(ctx *context.Context) {
ctx.HTML(200, SETTINGS_APPLICATIONS) ctx.HTML(200, SETTINGS_APPLICATIONS)
} }
func SettingsRepos(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsRepositories"] = true
repos, err := models.GetUserAndCollaborativeRepositories(ctx.User.ID)
if err != nil {
ctx.Handle(500, "GetUserAndCollaborativeRepositories", err)
return
}
if err = models.RepositoryList(repos).LoadAttributes(); err != nil {
ctx.Handle(500, "LoadAttributes", err)
return
}
ctx.Data["Repos"] = repos
ctx.HTML(200, SETTINGS_REPOSITORIES)
}
func SettingsLeaveOrganization(ctx *context.Context) {
err := models.RemoveOrgUser(ctx.QueryInt64("id"), ctx.User.ID)
if err != nil {
if models.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
} else {
ctx.Handle(500, "RemoveOrgUser", err)
return
}
}
ctx.JSON(200, map[string]interface{}{
"redirect": setting.AppSubUrl + "/user/settings/organizations",
})
}
func SettingsLeaveRepo(ctx *context.Context) {
repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetRepositoryByID", errors.IsRepoNotExist, err)
return
}
if err = repo.DeleteCollaboration(ctx.User.ID); err != nil {
ctx.Handle(500, "DeleteCollaboration", err)
return
}
ctx.Flash.Success(ctx.Tr("settings.repos.leave_success", repo.FullName()))
ctx.JSON(200, map[string]interface{}{
"redirect": setting.AppSubUrl + "/user/settings/repositories",
})
}
func SettingsApplicationsPost(ctx *context.Context, f form.NewAccessToken) { func SettingsApplicationsPost(ctx *context.Context, f form.NewAccessToken) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsApplications"] = true ctx.Data["PageIsSettingsApplications"] = true
@ -446,58 +498,6 @@ 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 err != nil {
if models.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
} else {
ctx.Handle(500, "RemoveOrgUser", err)
return
}
}
ctx.JSON(200, map[string]interface{}{
"redirect": setting.AppSubUrl + "/user/settings/organizations",
})
}
func SettingsRepos(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsRepositories"] = true
repos, err := models.GetUserAndCollaborativeRepositories(ctx.User.ID)
if err != nil {
ctx.Handle(500, "GetUserAndCollaborativeRepositories", err)
return
}
if err = models.RepositoryList(repos).LoadAttributes(); err != nil {
ctx.Handle(500, "LoadAttributes", err)
return
}
ctx.Data["Repos"] = repos
ctx.HTML(200, SETTINGS_REPOSITORIES)
}
func SettingsLeaveRepo(ctx *context.Context) {
repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
if err != nil {
ctx.NotFoundOrServerError("GetRepositoryByID", errors.IsRepoNotExist, err)
return
}
if err = repo.DeleteCollaboration(ctx.User.ID); err != nil {
ctx.Handle(500, "DeleteCollaboration", err)
return
}
ctx.Flash.Success(ctx.Tr("settings.repos.leave_success", repo.FullName()))
ctx.JSON(200, map[string]interface{}{
"redirect": setting.AppSubUrl + "/user/settings/repositories",
})
}
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

Loading…
Cancel
Save