]> source.dussan.org Git - gitea.git/commitdiff
Implementation of all repositories of a user from user->settings (#1740)
authorRémy Boulanouar <rboulanouar@gmail.com>
Thu, 14 Sep 2017 11:46:14 +0000 (13:46 +0200)
committerLauris BH <lauris@nix.lv>
Thu, 14 Sep 2017 11:46:14 +0000 (14:46 +0300)
* Implementation of all repositories of a user from user->settings

* Update message when no repository found

* Update according to comments

* Change UI to have a better look

* improved user repositories UI

options/locale/locale_en-US.ini
public/css/index.css
public/less/_user.less
routers/routes/routes.go
routers/user/setting.go
templates/user/settings/navbar.tmpl
templates/user/settings/repos.tmpl [new file with mode: 0644]

index 949f560a33e19df3b50da34b8d5df575ec6cf495..2e4520a7a3eeadeb179b3651a3e3d698573a2d2c 100644 (file)
@@ -308,6 +308,7 @@ ssh_gpg_keys = SSH / GPG Keys
 social = Social Accounts
 applications = Applications
 orgs = Organizations
+repos = Repositories
 delete = Delete Account
 twofa = Two-Factor Authentication
 account_link = External Accounts
@@ -446,6 +447,7 @@ remove_account_link_desc = Removing this linked account will revoke all related
 remove_account_link_success = Account link has been removed successfully!
 
 orgs_none = You are not a member of any organizations.
+repos_none = You do not own any repositories
 
 delete_account = Delete Your Account
 delete_prompt = The operation will delete your account permanently, and <strong>CANNOT</strong> be undone!
index d09490adbe96ec3f0f53c45deca53f91f5bf181d..ebf8cd1a51613e52d2d0137ef5bf5a4117c4722e 100644 (file)
@@ -2877,6 +2877,9 @@ footer .ui.language .menu {
   padding-top: 15px;
   padding-bottom: 5px;
 }
+.user.settings .iconFloat {
+  float: left;
+}
 .dashboard {
   padding-top: 15px;
   padding-bottom: 80px;
index a3e6852994b7d6aa4f14b7be91e0a5382c1ca870..7b6294448dd59035159a9d43a88a533edb3fbe48 100644 (file)
         padding-top: 15px;
         padding-bottom: 5px;
     }
+    &.settings {
+        .iconFloat {
+            float: left;
+        }
+    }
 }
index 067bf6a7f6b17f56762ca96d62040143baeb642d..a0684c84787ae9b8a899d54b6f4d354f0692806a 100644 (file)
@@ -237,6 +237,7 @@ func RegisterRoutes(m *macaron.Macaron) {
                m.Route("/delete", "GET,POST", user.SettingsDelete)
                m.Combo("/account_link").Get(user.SettingsAccountLinks).Post(user.SettingsDeleteAccountLink)
                m.Get("/organization", user.SettingsOrganization)
+               m.Get("/repos", user.SettingsRepos)
                m.Group("/two_factor", func() {
                        m.Get("", user.SettingsTwoFactor)
                        m.Post("/regenerate_scratch", user.SettingsTwoFactorRegenerateScratch)
index 2c951eaf5fe3f628f0dd0f878b1436c65528fcab..b71b29ba21cb3211ac4b53b6dee25b86b1140ab7 100644 (file)
@@ -39,6 +39,7 @@ const (
        tplSettingsTwofaEnroll  base.TplName = "user/settings/twofa_enroll"
        tplSettingsAccountLink  base.TplName = "user/settings/account_link"
        tplSettingsOrganization base.TplName = "user/settings/organization"
+       tplSettingsRepositories base.TplName = "user/settings/repos"
        tplSettingsDelete       base.TplName = "user/settings/delete"
        tplSecurity             base.TplName = "user/security"
 )
@@ -785,3 +786,37 @@ func SettingsOrganization(ctx *context.Context) {
        ctx.Data["Orgs"] = orgs
        ctx.HTML(200, tplSettingsOrganization)
 }
+
+// SettingsRepos display a list of all repositories of the user
+func SettingsRepos(ctx *context.Context) {
+       ctx.Data["Title"] = ctx.Tr("settings")
+       ctx.Data["PageIsSettingsRepos"] = true
+       ctxUser := ctx.User
+
+       var err error
+       if err = ctxUser.GetRepositories(1, setting.UI.User.RepoPagingNum); err != nil {
+               ctx.Handle(500, "GetRepositories", err)
+               return
+       }
+       repos := ctxUser.Repos
+
+       for i := range repos {
+               if repos[i].IsFork {
+                       err := repos[i].GetBaseRepo()
+                       if err != nil {
+                               ctx.Handle(500, "GetBaseRepo", err)
+                               return
+                       }
+                       err = repos[i].BaseRepo.GetOwner()
+                       if err != nil {
+                               ctx.Handle(500, "GetOwner", err)
+                               return
+                       }
+               }
+       }
+
+       ctx.Data["Owner"] = ctxUser
+       ctx.Data["Repos"] = repos
+
+       ctx.HTML(200, tplSettingsRepositories)
+}
index ab9b41666d46c058eea317907a2a16d5f85f7b39..b0a3c9fcc32529fb1499f37b9b30d34954e2d05d 100644 (file)
@@ -30,6 +30,8 @@
        </a>
        <a class="{{if .PageIsSettingsOrganization}}active{{end}} item" href="{{AppSubUrl}}/user/settings/organization">
                {{.i18n.Tr "settings.organization"}}
+       <a class="{{if .PageIsSettingsRepos}}active{{end}} item" href="{{AppSubUrl}}/user/settings/repos">
+               {{.i18n.Tr "settings.repos"}}
        </a>
        <a class="{{if .PageIsSettingsDelete}}active{{end}} item" href="{{AppSubUrl}}/user/settings/delete">
                {{.i18n.Tr "settings.delete"}}
diff --git a/templates/user/settings/repos.tmpl b/templates/user/settings/repos.tmpl
new file mode 100644 (file)
index 0000000..39d98c6
--- /dev/null
@@ -0,0 +1,53 @@
+{{template "base/head" .}}\r
+<div class="user settings">\r
+       {{template "user/settings/navbar" .}}\r
+       <div class="ui container">\r
+               {{template "base/alert" .}}\r
+               <h4 class="ui top attached header">\r
+                       {{.i18n.Tr "settings.repos"}}\r
+               </h4>\r
+               <div class="ui attached segment">\r
+                       {{if .Repos}}\r
+                               <div class="ui middle aligned divided list">\r
+                                       {{range .Repos}}\r
+                                       <div class="item">\r
+                                               <div class="content">\r
+                                                       {{if .IsPrivate}}\r
+                                                               <span class="text gold iconFloat"><i class="octicon octicon-lock"></i></span>\r
+                                                       {{else if .IsFork}}\r
+                                                               <span class="iconFloat"><i class="octicon octicon-repo-forked"></i></span>\r
+                                                       {{else if .IsMirror}}\r
+                                                               <span class="iconFloat"><i class="octicon octicon-repo-clone"></i></span>\r
+                                                       {{else}}\r
+                                                               <span class="iconFloat"><i class="octicon octicon-repo"></i></span>\r
+                                                       {{end}}\r
+                                                       <a class="name" href="{{AppSubUrl}}/{{$.Owner.Name}}/{{.Name}}">{{$.Owner.Name}}/{{.Name}}</a>\r
+                                                       <span>{{SizeFmt .Size}}</span>\r
+                                                       {{if .IsFork}}\r
+                                                               {{$.i18n.Tr "repo.forked_from"}}\r
+                                                               <span><a href="{{AppSubUrl}}/{{.BaseRepo.Owner.Name}}/{{.BaseRepo.Name}}">{{.BaseRepo.Owner.Name}}/{{.BaseRepo.Name}}</a></span>\r
+                                                       {{end}}\r
+                                                       </div>\r
+                                               </div>\r
+                                       {{end}}\r
+                               </div>\r
+                       {{else}}\r
+                               <div class="item">\r
+                                       {{.i18n.Tr "settings.repos_none"}}\r
+                               </div>\r
+                       {{end}}\r
+               </div>\r
+       </div>\r
+</div>\r
+\r
+<div class="ui small basic delete modal">\r
+       <div class="ui icon header">\r
+               <i class="trash icon"></i>\r
+               {{.i18n.Tr "settings.remove_account_link"}}\r
+       </div>\r
+       <div class="content">\r
+               <p>{{.i18n.Tr "settings.remove_account_link_desc"}}</p>\r
+       </div>\r
+       {{template "base/delete_modal_actions" .}}\r
+</div>\r
+{{template "base/footer" .}}\r