Merge branch 'orgs' of ssh://bitbucket.org/yackob03/quay into orgs

This commit is contained in:
yackob03 2013-11-07 12:55:35 -05:00
commit 2663a534d7
15 changed files with 244 additions and 26 deletions

View file

@ -326,7 +326,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)

View file

@ -74,7 +74,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():
@ -90,7 +91,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
})

View file

@ -58,6 +58,11 @@ def guide():
return index('')
@app.route('/organizations/')
@app.route('/organizations/new/')
def organizations():
return index('')
@app.route('/user/')
def user():
return index('')

View file

@ -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;
}
@ -930,6 +950,20 @@ p.editable:hover i {
margin-bottom: 40px;
}
.repo-list .button-bar-right {
float: right;
}
.repo-list .section-header {
padding: 10px;
border-bottom: 1px solid #eee;
margin-bottom: 10px;
}
.repo-list .button-bar-right button {
margin-right: 10px;
}
.repo-listing {
display: block;
margin-bottom: 20px;
@ -1559,6 +1593,24 @@ p.editable:hover i {
display: inline-block;
}
.org-list h2 {
margin-bottom: 20px;
}
.org-list .button-bar-right {
text-align: right;
}
.org-list .organization-listing {
font-size: 18px;
padding: 10px;
}
.org-list .organization-listing img {
margin-left: 10px;
margin-right: 16px;
}
.plan-manager-element .plans-table thead td {
color: #aaa;
font-weight: bold;

View file

@ -10,11 +10,17 @@
{{namespace}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="org in user.organizations">
<li class="namespace-item" ng-repeat="org in user.organizations"
ng-class="(requireCreate && !namespaces[org.name].can_create_repo) ? 'disabled' : ''">
<a class="namespace" href="javascript:void(0)" ng-click="setNamespace(org)">
<img src="//www.gravatar.com/avatar/{{ org.gravatar }}?s=24&d=identicon" />
<span class="namespace-name">{{ org.name }}</span>
<span class="namespace-name">{{ org.name }}</span>
</a>
<i class="fa fa-exclamation-triangle" ng-show="requireCreate && !namespaces[org.name].can_create_repo"
title="You do not have permission to create repositories for this organization"
data-placement="right"
bs-tooltip="tooltip.title"></i>
</li>
<li class="divider"></li>
<li>

View file

@ -47,7 +47,7 @@ function getMarkedDown(string) {
}
// Start the application code itself.
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel', '$strap.directives'], function($provide) {
quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel', '$strap.directives', 'ngCookies'], function($provide) {
$provide.factory('UserService', ['Restangular', 'PlanService', function(Restangular, PlanService) {
var userResponse = {
verified: false,
@ -279,12 +279,15 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
when('/repository/:namespace/:name/image/:image', {templateUrl: '/static/partials/image-view.html', controller: ImageViewCtrl}).
when('/repository/:namespace/:name/admin', {templateUrl: '/static/partials/repo-admin.html', controller:RepoAdminCtrl}).
when('/repository/', {title: 'Repositories', templateUrl: '/static/partials/repo-list.html', controller: RepoListCtrl}).
when('/user/', {title: 'User Admin', templateUrl: '/static/partials/user-admin.html', controller: UserAdminCtrl}).
when('/guide/', {title: 'User Guide', templateUrl: '/static/partials/guide.html', controller: GuideCtrl}).
when('/user/', {title: 'Account Settings', templateUrl: '/static/partials/user-admin.html', controller: UserAdminCtrl}).
when('/guide/', {title: 'Guide', templateUrl: '/static/partials/guide.html', controller: GuideCtrl}).
when('/plans/', {title: 'Plans and Pricing', templateUrl: '/static/partials/plans.html', controller: PlansCtrl}).
when('/signin/', {title: 'Signin', templateUrl: '/static/partials/signin.html', controller: SigninCtrl}).
when('/signin/', {title: 'Sign In', templateUrl: '/static/partials/signin.html', controller: SigninCtrl}).
when('/new/', {title: 'Create new repository', templateUrl: '/static/partials/new-repo.html', controller: NewRepoCtrl}).
when('/organizations/', {title: 'Organizations', templateUrl: '/static/partials/organizations.html', controller: OrgsCtrl}).
when('/organizations/new/', {title: 'New Organization', templateUrl: '/static/partials/new-organization.html', controller: NewOrgCtrl}).
when('/organization/:orgname', {templateUrl: '/static/partials/org-view.html', controller: OrgViewCtrl}).
when('/organization/:orgname/admin', {templateUrl: '/static/partials/org-admin.html', controller: OrgAdminCtrl}).
when('/organization/:orgname/teams/:teamname', {templateUrl: '/static/partials/team-view.html', controller: TeamViewCtrl}).
@ -639,20 +642,44 @@ quayApp.directive('namespaceSelector', function () {
restrict: 'C',
scope: {
'user': '=user',
'namespace': '=namespace'
'namespace': '=namespace',
'requireCreate': '=requireCreate'
},
controller: function($scope, $element) {
controller: function($scope, $element, $cookieStore) {
$scope.namespaces = {};
$scope.initialize = function(user) {
var namespaces = {};
namespaces[user.username] = user;
if (user.organizations) {
for (var i = 0; i < user.organizations.length; ++i) {
namespaces[user.organizations[i].name] = user.organizations[i];
}
}
var initialNamespace = $cookieStore.get('quay.currentnamespace') || $scope.user.username;
$scope.namespaces = namespaces;
$scope.setNamespace($scope.namespaces[initialNamespace]);
};
$scope.setNamespace = function(namespaceObj) {
if (!namespaceObj) {
namespaceObj = {'name': '', 'gravatar': ''};
namespaceObj = $scope.namespaces[$scope.user.username];
}
if ($scope.requireCreate && !namespaceObj.can_create_repo) {
namespaceObj = $scope.namespaces[$scope.user.username];
}
var newNamespace = namespaceObj.name || namespaceObj.username;
$scope.namespaceObj = namespaceObj;
$scope.namespace = namespaceObj.name || namespaceObj.username;
$scope.namespace = newNamespace;
$cookieStore.put('quay.currentnamespace', newNamespace);
};
$scope.setNamespace($scope.user);
$scope.$watch('user', function(user) {
$scope.setNamespace(user);
$scope.user = user;
$scope.initialize(user);
});
}
};

View file

@ -155,9 +155,9 @@ function RepoListCtrl($scope, Restangular, UserService) {
$scope.loading = true;
$scope.public_repositories = null;
$scope.user_repositories = null;
$scope.user_repositories = [];
var loadMyRepos = function(namespace) {
var loadMyRepos = function(namespace) {
if (!$scope.user || $scope.user.anonymous || !namespace) {
return;
}
@ -230,6 +230,23 @@ function LandingCtrl($scope, $timeout, $location, Restangular, UserService, KeyS
});
};
$scope.canCreateRepo = function(namespace) {
if (!$scope.user) { return false; }
if (namespace == $scope.user.username) {
return true;
}
for (var i = 0; i < $scope.user.organizations.length; ++i) {
var org = $scope.user.organizations[i];
if (org.name == namespace) {
return org.can_create_repo;
}
}
return false;
};
var loadMyRepos = function(namespace) {
if (!$scope.user || $scope.user.anonymous || !namespace) {
return;
@ -1252,4 +1269,19 @@ function TeamViewCtrl($rootScope, $scope, Restangular, $routeParams) {
loadOrganization();
loadMembers();
}
function OrgsCtrl($scope, UserService) {
$scope.loading = true;
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
$scope.user = currentUser;
$scope.loading = false;
}, true);
browserchrome.update();
}
function NewOrgCtrl($scope, UserService) {
}

7
static/lib/angular-cookies.min.js vendored Normal file
View file

@ -0,0 +1,7 @@
/*
AngularJS v1.2.0-ed8640b
(c) 2010-2012 Google, Inc. http://angularjs.org
License: MIT
*/
(function(p,f,n){'use strict';f.module("ngCookies",["ng"]).factory("$cookies",["$rootScope","$browser",function(d,b){var c={},g={},h,k=!1,l=f.copy,m=f.isUndefined;b.addPollFn(function(){var a=b.cookies();h!=a&&(h=a,l(a,g),l(a,c),k&&d.$apply())})();k=!0;d.$watch(function(){var a,e,d;for(a in g)m(c[a])&&b.cookies(a,n);for(a in c)(e=c[a],f.isString(e))?e!==g[a]&&(b.cookies(a,e),d=!0):f.isDefined(g[a])?c[a]=g[a]:delete c[a];if(d)for(a in e=b.cookies(),c)c[a]!==e[a]&&(m(e[a])?delete c[a]:c[a]=e[a])});
return c}]).factory("$cookieStore",["$cookies",function(d){return{get:function(b){return(b=d[b])?f.fromJson(b):b},put:function(b,c){d[b]=f.toJson(c)},remove:function(b){delete d[b]}}}])})(window,window.angular);

View file

@ -17,6 +17,7 @@
<li><a ng-href="/repository/" target="{{ appLinkTarget() }}">Repositories</a></li>
<li><a ng-href="/guide/" target="{{ appLinkTarget() }}">User Guide</a></li>
<li><a ng-href="/plans/" target="{{ appLinkTarget() }}">Plans &amp; Pricing</a></li>
<li><a ng-href="/organizations/" target="{{ appLinkTarget() }}">Organizations</a></li>
</ul>
@ -45,6 +46,7 @@
<span class="badge user-notification" ng-show="user.askForPassword">1</span>
</a>
</li>
<li><a ng-href="/organizations/" target="{{ appLinkTarget() }}">Organizations</a></li>
<li><a href="javascript:void(0)" ng-click="signout()">Sign out</a></li>
</ul>
</li>

View file

@ -29,7 +29,7 @@
<div class="options">
<a class="btn btn-primary" href="/repository/">Browse all repositories</a>
<a class="btn btn-success" href="/new/">Create a new repository</a>
<a class="btn btn-success" href="/new/" ng-show="canCreateRepo(namespace)">Create a new repository</a>
</div>
</div>
</div>

View file

@ -0,0 +1 @@
new org

View file

@ -29,7 +29,7 @@
<div class="section">
<div class="new-header">
<span style="color: #444;">
<span class="namespace-selector" user="user" namespace="repo.namespace"></span>
<span class="namespace-selector" user="user" namespace="repo.namespace" require-create="true"></span>
<span style="color: #ccc">/</span>
<span class="name-container">
<input id="repoName" name="repoName" type="text" class="form-control" placeholder="Repository Name" ng-model="repo.name" required autofocus data-trigger="manual" data-content="{{ createError }}" data-placement="right">

View file

@ -0,0 +1,71 @@
<div class="container org-list">
<div class="loading" ng-show="loading">
<i class="fa fa-spinner fa-spin fa-3x"></i>
</div>
<div class="button-bar-right">
<a href="/organizations/new/" title="Starts the process to create a new organization" bs-tooltip="tooltip.title">
<button class="btn btn-success">
<i class="fa fa-plus"></i>
Create New Organization
</button>
</a>
<a href="/user/?migrate" ng-show="!user.anonymous" title="Starts the process to convert this account into an organization" bs-tooltip="tooltip.title">
<button class="btn btn-primary">
<i class="fa fa-caret-square-o-right"></i>
Convert account
</button>
</a>
</div>
<!-- Organizations -->
<div ng-show="user.organizations.length > 0">
<h2>Organizations</h2>
<div class="organization-listing" ng-repeat="organization in user.organizations">
<img class="gravatar" src="//www.gravatar.com/avatar/{{ organization.gravatar }}?s=32&amp;d=identicon">
<a class="org-title" href="/organization/{{ organization.name }}">{{ organization.name }}</a>
</div>
</div>
<!-- Organization Help/Tour -->
<div class="product-tour" ng-show="!user.organizations || user.organizations.length == 0">
<div class="tour-section row">
<div class="col-md-12">
<div class="tour-section-title">Organizations</div>
<div class="tour-section-description">
Organizations in Quay provide unique features for businesses and other groups, such as team-based sharing and fine-grain permission controls.
</div>
</div>
</div>
<div class="tour-section row">
<div class="col-md-7">
<img src="/static/img/user-home.png" title="Organization Overview"
data-screenshot-url="https://quay.io/organization/myorg/" class="img-responsive">
</div>
<div class="col-md-5">
<div class="tour-section-title">Working in teams</div>
<div class="tour-section-description">
Organizations are designed for business blah blah blah
</div>
</div>
</div>
<div class="tour-section row">
<div class="col-md-7">
<img src="/static/img/user-home.png" title=""
data-screenshot-url="https://quay.io/organization/myorg/" class="img-responsive">
</div>
<div class="col-md-5">
<div class="tour-section-title">Global and Local Permissions</div>
<div class="tour-section-description">
Organizations are designed for business blah blah blah
</div>
</div>
</div>
</div>
</div>

View file

@ -4,14 +4,26 @@
<div class="container ready-indicator" ng-show="!loading" data-status="{{ loading ? '' : 'ready' }}">
<div class="repo-list" ng-show="!user.anonymous">
<a href="/new/">
<button class="btn btn-success" style="float: right">
<i class="fa fa-upload user-tool" title="Create new repository"></i>
Create Repository
</button>
</a>
<div ng-class="user.organizations.length ? 'section-header' : ''">
<div class="button-bar-right">
<a href="/new/">
<button class="btn btn-success">
<i class="fa fa-upload user-tool" title="Create new repository"></i>
Create Repository
</button>
</a>
<a href="/organization/{{ namespace }}" ng-show="namespace != user.username">
<button class="btn btn-default">
<i class="fa fa-group user-tool"></i>
View Organization
</button>
</a>
</div>
<span class="namespace-selector" user="user" namespace="namespace" ng-show="user.organizations"></span>
</div>
<span class="namespace-selector" user="user" namespace="namespace" ng-show="user.organizations"></span>
<h3 ng-show="namespace == user.username">Your Repositories</h3>
<h3 ng-show="namespace != user.username">Repositories</h3>

View file

@ -47,6 +47,7 @@
<script src="static/lib/angulartics-mixpanel.js"></script>
<script src="static/lib/angular-moment.min.js"></script>
<script src="static/lib/angular-cookies.min.js"></script>
<script src="static/lib/typeahead.min.js"></script>