From 0c4dec6de4dbf4a9cff09b0a117d045d52bcd9dc Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 7 Nov 2013 00:49:13 -0500 Subject: [PATCH 1/2] - Fix namespace drop down to save the namespace last selected (and validate) - Add a "can_create_repo" entry to the organization and have orgs grayed out in the new repo view if the user cannot create a repo - Fix the multiple-orgs bug in the model - Have the "create new repository" button disappear on landing if the org is selected and the user does not have create permissions for that org --- data/model.py | 2 +- endpoints/api.py | 6 ++-- static/css/quay.css | 20 +++++++++++++ static/directives/namespace-selector.html | 10 +++++-- static/js/app.js | 36 ++++++++++++++++++----- static/js/controllers.js | 17 +++++++++++ static/lib/angular-cookies.min.js | 7 +++++ static/partials/landing.html | 2 +- static/partials/new-repo.html | 2 +- templates/base.html | 1 + 10 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 static/lib/angular-cookies.min.js diff --git a/data/model.py b/data/model.py index 94c71e67e..cf0621463 100644 --- a/data/model.py +++ b/data/model.py @@ -322,7 +322,7 @@ def verify_user(username, password): def get_user_organizations(username): UserAlias = User.alias() - all_teams = User.select().join(Team).join(TeamMember) + all_teams = User.select().distinct().join(Team).join(TeamMember) with_user = all_teams.join(UserAlias, on=(UserAlias.id == TeamMember.user)) return with_user.where(User.organization == True, UserAlias.username == username) diff --git a/endpoints/api.py b/endpoints/api.py index 5a760137e..234e47563 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -84,7 +84,8 @@ def get_logged_in_user(): return { 'name': o.username, 'gravatar': compute_hash(o.email), - 'is_org_admin': admin_org.can() + 'is_org_admin': admin_org.can(), + 'can_create_repo': admin_org.can() or CreateRepositoryPermission(o.username).can() } if current_user.is_anonymous(): @@ -100,7 +101,8 @@ def get_logged_in_user(): 'email': user.email, 'gravatar': compute_hash(user.email), 'askForPassword': user.password_hash is None, - 'organizations': [org_view(o) for o in organizations] + 'organizations': [org_view(o) for o in organizations], + 'can_create_repo': True }) diff --git a/static/css/quay.css b/static/css/quay.css index 0fead2172..cb71fc79a 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -46,6 +46,26 @@ font-size: 14px; } +.namespace-selector-dropdown .namespace-item { + position: relative; +} + +.namespace-selector-dropdown .namespace-item .fa { + position: absolute; + right: 12px; + top: 12px; + color: #aaa; +} + +.namespace-selector-dropdown .namespace-item.disabled img { + -webkit-filter: grayscale(1); + opacity: 0.5; +} + +.namespace-selector-dropdown .namespace-item .tooltip-inner { + min-width: 200px; +} + .user-notification { background: red; } diff --git a/static/directives/namespace-selector.html b/static/directives/namespace-selector.html index bc8abc9a2..98d91394d 100644 --- a/static/directives/namespace-selector.html +++ b/static/directives/namespace-selector.html @@ -10,11 +10,17 @@ {{namespace}} @@ -45,6 +46,7 @@ 1 +
  • Organizations
  • Sign out
  • diff --git a/static/partials/new-organization.html b/static/partials/new-organization.html new file mode 100644 index 000000000..8fd32cd45 --- /dev/null +++ b/static/partials/new-organization.html @@ -0,0 +1 @@ +new org diff --git a/static/partials/organizations.html b/static/partials/organizations.html new file mode 100644 index 000000000..ec7e66928 --- /dev/null +++ b/static/partials/organizations.html @@ -0,0 +1,71 @@ +
    +
    + +
    + + + + +
    +

    Organizations

    + + +
    + + +
    + +
    +
    +
    Organizations
    +
    + Organizations in Quay provide unique features for businesses and other groups, such as team-based sharing and fine-grain permission controls. +
    +
    +
    + + +
    +
    + +
    +
    +
    Working in teams
    +
    + Organizations are designed for business blah blah blah +
    +
    +
    + +
    +
    + +
    +
    +
    Global and Local Permissions
    +
    + Organizations are designed for business blah blah blah +
    +
    +
    + +
    +
    diff --git a/static/partials/repo-list.html b/static/partials/repo-list.html index 94e381f08..3bb5bfb0c 100644 --- a/static/partials/repo-list.html +++ b/static/partials/repo-list.html @@ -4,14 +4,26 @@