diff --git a/endpoints/api.py b/endpoints/api.py index 495981145..80faa58be 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -578,6 +578,26 @@ def get_organization_prototype_permissions(orgname): abort(403) +def log_prototype_action(action_kind, orgname, prototype, **kwargs): + username = current_user.db_user().username + log_params = { + 'prototypeid': prototype.uuid, + 'username': username, + 'activating_username': prototype.activating_user.username, + 'role': prototype.role.name + } + + for key, value in kwargs.items(): + log_params[key] = value + + if prototype.delegate_user: + log_params['delegate_user'] = prototype.delegate_user.username + elif prototype.delegate_team: + log_params['delegate_team'] = prototype.delegate_team.name + + log_action(action_kind, orgname, log_params) + + @app.route('/api/organization//prototypes', methods=['POST']) @api_login_required def create_organization_prototype_permission(orgname): @@ -609,7 +629,9 @@ def create_organization_prototype_permission(orgname): abort(400) role_name = details['role'] + prototype = model.add_prototype_permission(org, role_name, activating_user, delegate_user, delegate_team) + log_prototype_action('create_prototype_permission', orgname, prototype) return jsonify(prototype_view(prototype)) abort(403) @@ -629,6 +651,8 @@ def delete_organization_prototype_permission(orgname, prototypeid): if not prototype: abort(404) + log_prototype_action('delete_prototype_permission', orgname, prototype) + return make_response('Deleted', 204) abort(403) @@ -644,12 +668,18 @@ def update_organization_prototype_permission(orgname, prototypeid): except model.InvalidOrganizationException: abort(404) + existing = model.get_prototype_permission(org, prototypeid) + if not existing: + abort(404) + details = request.get_json() role_name = details['role'] prototype = model.update_prototype_permission(org, prototypeid, role_name) if not prototype: abort(404) + log_prototype_action('modify_prototype_permission', orgname, prototype, original_role = existing.role.name) + return jsonify(prototype_view(prototype)) abort(403) @@ -672,7 +702,8 @@ def get_organization_members(orgname): members = model.get_organization_members_with_teams(org) for member in members: if not member.user.username in members_dict: - members_dict[member.user.username] = {'username': member.user.username, + members_dict[member.user.username] = {'name': member.user.username, + 'kind': 'user', 'is_robot': member.user.robot, 'teams': []} @@ -697,7 +728,8 @@ def get_organization_member(orgname, membername): member_teams = model.get_organization_members_with_teams(org, membername=membername) for member in member_teams: if not member_dict: - member_dict = {'username': member.user.username, + member_dict = {'name': member.user.username, + 'kind': 'user', 'is_robot': member.user.robot, 'teams': []} @@ -741,7 +773,8 @@ def get_organization_private_allowed(orgname): def member_view(member): return { - 'username': member.username, + 'name': member.username, + 'kind': 'user', 'is_robot': member.robot, } @@ -2064,7 +2097,8 @@ def log_view(log): if log.performer: view['performer'] = { - 'username': log.performer.username, + 'kind': 'user', + 'name': log.performer.username, 'is_robot': log.performer.robot, } diff --git a/initdb.py b/initdb.py index 137cac79b..2c2c2eb19 100644 --- a/initdb.py +++ b/initdb.py @@ -154,9 +154,9 @@ def initialize_database(): LogEntryKind.create(name='org_set_team_description') LogEntryKind.create(name='org_set_team_role') - LogEntryKind.create(name='org_create_prototype_permission') - LogEntryKind.create(name='org_modify_prototype_permission') - LogEntryKind.create(name='org_delete_prototype_permission') + LogEntryKind.create(name='create_prototype_permission') + LogEntryKind.create(name='modify_prototype_permission') + LogEntryKind.create(name='delete_prototype_permission') def wipe_database(): diff --git a/static/css/quay.css b/static/css/quay.css index af18ca590..3d7b5a4c4 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -77,10 +77,17 @@ position: relative; } -.entity-search-element .entity-icon { - position: absolute; +.entity-search-element .entity-reference { + position: absolute !important; top: 0px; - left: 8px; + left: 8px; + right: 36px; + z-index: 0; + pointer-events: none; +} + +.entity-search-element .entity-reference .entity-name { + display: none; } .entity-search-element input { @@ -89,6 +96,7 @@ .entity-search-element.persistent input { padding-left: 28px; + padding-right: 28px; } .entity-search-element .twitter-typeahead { @@ -155,6 +163,26 @@ i.toggle-icon:hover { color: #aaa; } +.entity-reference.block-reference { + position: relative; + display: block; +} + +.entity-reference.block-reference .entity-reference-element { + display: block; +} + +.entity-reference.block-reference i.fa-exclamation-triangle { + position: absolute; + right: 10px; + top: 4px; +} + +.entity-reference-element i.fa-exclamation-triangle { + color: #c09853; + margin-left: 10px; +} + .entity-reference-element i.fa-user { margin-left: 2px; margin-right: 7px; @@ -299,7 +327,15 @@ i.toggle-icon:hover { height: 12px; border-radius: 50%; margin-right: 6px; + margin-top: 6px; vertical-align: middle; + float: left; +} + +.logs-view-element .log .log-description { + margin-left: 20px; + display: block; + line-height: 25px; } .billing-options-element .current-card { @@ -1127,7 +1163,7 @@ form input.ng-valid.ng-dirty, .entity-mini-listing i.fa-exclamation-triangle { position: absolute; - right: -16px; + right: -14px; top: 4px; color: #c09853; } diff --git a/static/directives/entity-reference.html b/static/directives/entity-reference.html index 509f4b03c..adde12400 100644 --- a/static/directives/entity-reference.html +++ b/static/directives/entity-reference.html @@ -1,8 +1,19 @@ - - - - {{team}} - {{team}} - {{getPrefix(name)}}{{getShortenedName(name)}} + + + + {{entity.name}} + {{entity.name}} + + + + + + + {{getPrefix(entity.name)}}{{getShortenedName(entity.name)}} + + + + diff --git a/static/directives/entity-search.html b/static/directives/entity-search.html index 63b64070c..e87f3e2c3 100644 --- a/static/directives/entity-search.html +++ b/static/directives/entity-search.html @@ -1,12 +1,5 @@ - - - - - +