diff --git a/cmd/web.go b/cmd/web.go index bb4653654..d3ce68d37 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -206,6 +206,8 @@ func runWeb(*cli.Context) { r.Post("/:org/teams/new", bindIgnErr(auth.CreateTeamForm{}), org.NewTeamPost) r.Get("/:org/teams/:team/edit", org.EditTeam) + r.Get("/:org/team/:team",org.SingleTeam) + r.Get("/:org/settings", org.Settings) r.Post("/:org/settings", bindIgnErr(auth.OrgSettingForm{}), org.SettingsPost) r.Post("/:org/settings/delete", org.DeletePost) diff --git a/models/user.go b/models/user.go index 13c914847..a46232427 100644 --- a/models/user.go +++ b/models/user.go @@ -297,10 +297,12 @@ func ChangeUserName(user *User, newUserName string) (err error) { } for j := range accesses { - accesses[j].UserName = newUserName - accesses[j].RepoName = newUserName + "/" + repos[i].LowerName - if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil { - return err + // if the access is not the user's access (already updated above) + if accesses[j].UserName != user.LowerName { + accesses[j].RepoName = newUserName + "/" + repos[i].LowerName + if err = UpdateAccessWithSession(sess, &accesses[j]); err != nil { + return err + } } } } diff --git a/public/css/gogs.css b/public/css/gogs.css index 690ccdc3f..c6554b780 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -408,28 +408,33 @@ body { #repo-hooks-list .remove-hook { color: #DD4B39; } -#repo-collab-form .dropdown-menu { +#repo-collab-form .dropdown-menu, +#org-team-content .header .dropdown-menu { margin-left: 15px; margin-top: 4px; padding: 0; } -#repo-collab-form .dropdown-menu li { +#repo-collab-form .dropdown-menu li, +#org-team-content .header .dropdown-menu li { padding: 0 1em; line-height: 36px; cursor: pointer; font-weight: bold; } -#repo-collab-form .dropdown-menu li:hover { +#repo-collab-form .dropdown-menu li:hover, +#org-team-content .header .dropdown-menu li:hover { background-color: #e8f0ff; } -#repo-collab-form .dropdown-menu img { +#repo-collab-form .dropdown-menu img, +#org-team-content .header .dropdown-menu img { width: 28px; height: 28px; margin-right: 1em; vertical-align: middle; margin-top: -3px; } -#repo-collab-form .dropdown-menu ul { +#repo-collab-form .dropdown-menu ul, +#org-team-content .header .dropdown-menu ul { margin-bottom: 0; } #repo-hooks-list li { @@ -1446,8 +1451,7 @@ body { #footer { background: #fff; -webkit-box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05); - box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05); - ; + box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);; height: 100px; } #footer .footer-wrap { @@ -1677,31 +1681,39 @@ body { #org-members { margin-right: 30px; } -#org-members .member .avatar img { +#org-members .member .avatar img, +#org-team-members .member .avatar img { width: 50px; height: 50px; } -#org-members .member { +#org-members .member, +#org-team-members .member { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid #DDD; height: 70px; } -#org-members .member .name { +#org-members .member .name, +#org-team-members .member .name { padding-top: 4px; } -#org-members .member .nick { +#org-members .member .nick, +#org-team-members .member .nick { display: block; color: #888; } -#org-members .member .name a { +#org-members .member .name a, +#org-team-members .member .name a { color: #444; } -#org-members .member .name strong { +#org-members .member .name strong, +#org-team-members .member .name strong { font-size: 1.2em; } #org-members .status, -#org-members .role { +#org-members .role, +#org-team-members .status, +#org-team-members .role { line-height: 48px; text-align: right; } @@ -1727,4 +1739,44 @@ body { } #org-teams .org-team { border-bottom: none; +} +#org-team-card { + border: 1px solid #CCC; + background-color: #FFF; +} +#org-team-card .meta .num { + font-weight: bold; + color: #444; + font-size: 1.2em; +} +#org-team-card .meta > div { + margin-bottom: 12px; +} +#org-team-card .meta a:hover { + text-decoration: none; + font-weight: bold; +} +#org-team-card .action a { + margin-right: 12px; +} +#org-team-card .action a:hover { + text-decoration: none; +} +#org-team-content .header { + height: 50px; +} +#org-team-content .header > form { + padding-right: 0; +} +#org-team-repos .repo{ + padding-bottom: 20px; + margin-bottom: 20px; + border-bottom: 1px solid #DDD; + padding-left: 15px; +} +#org-team-repos .repo-name{ + font-size: 1.2em; + color: #444; + font-weight: bold; + line-height: 30px; } \ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index 6edade445..4c376ea08 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -301,6 +301,26 @@ var Gogits = {}; }).addClass("js-copy-bind"); } + // api working + Gogits.getUsers = function (val, $target) { + $.ajax({ + url: '/api/v1/users/search?q=' + val, + dataType: "json", + success: function (json) { + if (json.ok && json.data.length) { + var html = ''; + $.each(json.data, function (i, item) { + html += '
  • ' + item.username + '
  • '; + }); + $target.toggleShow(); + $target.find('ul').html(html); + } else { + $target.toggleHide(); + } + } + }); + } + })(jQuery); // ajax utils @@ -733,22 +753,23 @@ function initRepoSetting() { $this.next().toggleHide(); return; } - $.ajax({ - url: '/api/v1/users/search?q=' + $this.val(), - dataType: "json", - success: function (json) { - if (json.ok && json.data.length) { - var html = ''; - $.each(json.data, function (i, item) { - html += '
  • ' + item.username + '
  • '; - }); - $this.next().toggleShow(); - $this.next().find('ul').html(html); - } else { - $this.next().toggleHide(); - } - } - }); + Gogits.getUsers($this.val(), $this.next()); + /*$.ajax({ + url: '/api/v1/users/search?q=' + $this.val(), + dataType: "json", + success: function (json) { + if (json.ok && json.data.length) { + var html = ''; + $.each(json.data, function (i, item) { + html += '
  • ' + item.username + '
  • '; + }); + $this.next().toggleShow(); + $this.next().find('ul').html(html); + } else { + $this.next().toggleHide(); + } + } + });*/ }).on('focus', function () { if (!$(this).val()) { $(this).next().toggleHide(); @@ -771,14 +792,43 @@ function initRepoCreating() { $(this).addClass("checked"); } // set button group to show clicked owner - $('#repo-owner-avatar').attr("src",$(this).find('img').attr("src")); + $('#repo-owner-avatar').attr("src", $(this).find('img').attr("src")); $('#repo-owner-name').text($(this).text().trim()); - console.log("set repo owner to uid :",uid,$(this).text().trim()); + console.log("set repo owner to uid :", uid, $(this).text().trim()); }); }()); console.log("init repo-creating scripts"); } +function initOrganization() { + (function(){ + $('#org-team-add-user').on('keyup', function () { + var $this = $(this); + if (!$this.val()) { + $this.next().toggleHide(); + return; + } + Gogits.getUsers($this.val(), $this.next()); + }).on('focus', function () { + if (!$(this).val()) { + $(this).next().toggleHide(); + } + }).next().on("click", 'li', function () { + $('#org-team-add-user').val($(this).text()); + $('#org-team-add-user-form').submit(); + }).toggleHide(); + console.log("init script : add user to team"); + }()); + + (function(){ + $('#org-team-add-repo').next().toggleHide(); + console.log("init script : add repository to team"); + }()); + + + console.log("init script : organization done"); +} + (function ($) { $(function () { initCore(); @@ -804,6 +854,9 @@ function initRepoCreating() { if ($('#repo-create').length) { initRepoCreating(); } + if ($('#body-nav').hasClass("org-nav")) { + initOrganization(); + } }); })(jQuery); diff --git a/routers/org/teams.go b/routers/org/teams.go index 492739250..0b17f4636 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -129,3 +129,8 @@ func EditTeam(ctx *middleware.Context, params martini.Params) { ctx.Data["Title"] = "Organization " + params["org"] + " Edit Team" ctx.HTML(200, "org/edit_team") } + +func SingleTeam(ctx *middleware.Context,params martini.Params){ + ctx.Data["Title"] = "single-team"+params["org"] + ctx.HTML(200,"org/team") +} diff --git a/templates/org/team.tmpl b/templates/org/team.tmpl new file mode 100644 index 000000000..aab42f3e7 --- /dev/null +++ b/templates/org/team.tmpl @@ -0,0 +1,106 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +
    +
    +
    + + +
    +

    Organization Name

    +
    +
    +
    +
    +
    +
    +
    +
    +

    Team name

    +

    team description

    +
    +
    + + +
    +
    + +
    +

    This team grants Push, Read & Clone access: members can read from and push to the team's repositories.

    +
    +
    +
    +
    + +
    +
    + + + +
    +
    +
    +
      +
    + +
    + + Remove +
    +
    + +
    +
    + +
    +
    + + + +
    +
    +
    + +
    +
    +
    +
    +
    +{{template "base/footer" .}}