Skip to content

Commit

Permalink
Allow to see update jobs for maintainer
Browse files Browse the repository at this point in the history
- display roles on user grid
  • Loading branch information
vtsykun committed Mar 29, 2020
1 parent e769f58 commit 3efa123
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ security:
- { path: (^(/change-password|/profile/|/search|/logout|/packages/|/versions/))+, role: ROLE_USER }
- { path: (^(/packages.json$|/p/|/zipball/|/downloads/))+, role: ROLE_USER }
- { path: (^(/api/webhook-invoke/))+, role: ROLE_USER }
- { path: (^(/explore))+, role: ROLE_USER }
- { path: ^/$, role: ROLE_USER }

# Maintainers
- { path: (^(/users/(.+)/packages))+, role: ROLE_MAINTAINER }
- { path: (^(/users/(.+)/favorites))+, role: ROLE_MAINTAINER }
- { path: (^(/explore|/jobs/))+, role: ROLE_MAINTAINER }

# Secured part of the site
# This config requires being logged for the whole site and having the admin role for the admin part.
Expand Down
2 changes: 1 addition & 1 deletion src/Packagist/WebBundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function listAction(Request $request)
$paginator->setMaxPerPage(6);

$csrfForm = $this->createFormBuilder([])->getForm();

/** @var User[] $paginator */
$paginator->setCurrentPage($page, false, true);
return [
'users' => $paginator,
Expand Down
29 changes: 29 additions & 0 deletions src/Packagist/WebBundle/Resources/public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,35 @@ input:focus:invalid:focus, textarea:focus:invalid:focus, select:focus:invalid:fo
border-radius: 4px;
}

.s-flex {
display: flex;
}
.link-gray-dark {
color: #24292e!important;
}
.link-gray {
color: #586069!important;
}

.no-underline {
text-decoration: none!important;
}
.user-grid .package-item {
border: 1px solid #d1d5da;
}
.role-name {
display: inline-block;
padding: 2px 6px;
color: rgba(27,31,35,.6);
background-color: #eaf5ff;
border-radius: 3px;
font-size: 12px;
white-space: nowrap;
}
.user-grid .role-container {
margin: 10px;
}

.packages .selected .package-item {
padding: 4px 14px;
border: 1px solid #0c71d0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@
<div class="details col-xs-12 col-sm-6 col-md-12">
<p class="maintainers">
{% for maintainer in package.maintainers -%}
<a href="{{ path('user_profile', {'name': maintainer.username}) }}"><img width="48" height="48" title="{{ maintainer.username }}" src="https://www.gravatar.com/avatar/{{ maintainer.email|gravatar_hash }}?s=48&amp;d=identicon" srcset="https://www.gravatar.com/avatar/{{ maintainer.email|gravatar_hash }}?s=96&amp;d=identicon 2x"></a>
{% if is_granted('ROLE_ADMIN') %}
<a href="{{ path('user_profile', {'name': maintainer.username}) }}">
{% endif %}
<img width="48" height="48" title="{{ maintainer.username }}" src="https://www.gravatar.com/avatar/{{ maintainer.email|gravatar_hash }}?s=48&amp;d=identicon" srcset="https://www.gravatar.com/avatar/{{ maintainer.email|gravatar_hash }}?s=96&amp;d=identicon 2x">
{% if is_granted('ROLE_ADMIN') %}</a>
{% endif %}
{% endfor %}
{% if addMaintainerForm is defined or removeMaintainerForm is defined %}
{% if removeMaintainerForm is defined %}<a title="Remove Maintainer" id="remove-maintainer" href="{{ path('remove_maintainer', {'name': package.name}) }}"><i class="glyphicon glyphicon-remove"></i></a>{% endif %}
Expand Down
44 changes: 21 additions & 23 deletions src/Packagist/WebBundle/Resources/views/User/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@
<a class="btn btn-default" href="{{ path('users_create') }}">Create user</a>
</div>
<section class="row">
<ul class="packages list-unstyled">
<ul class="packages user-grid list-unstyled">
{% for user in users %}
{% set packageUrl = path('user_profile', { 'name' : user.username }) %}
<li data-url="{{ packageUrl }}" class="row">
{% set userUrl = path('user_profile', { 'name' : user.username }) %}
<li data-url="{{ userUrl }}" class="row">
<div class="col-xs-12 package-item">
<div class="row">
<div class="col-sm-9 col-lg-11">
<div>
{% if user.enabled %}
<div class="tab-cell badge-enabled"><i class="fa fa-unlock"></i> Enable</div>
{% else %}
<div class="tab-cell badge-disable"><i class="fa fa-lock"></i> Disable</div>
<div class="row" style="margin: 6px 12px;">

<div class="s-flex">
<a href="{{ userUrl }}" class="s-flex no-underline link-gray-dark">
<img width="40" height="40" title="{{ user.email }}" alt="{{ user.email }}" src="https://www.gravatar.com/avatar/{{ user.email|gravatar_hash }}?s=48&amp;d=identicon">
<h4 class="tab-cell">{{ user.username }}</h4>
{% if user.roles|length > 0 %}
<div class="role-container">
<span class="role-name">{{ user.roles|join(', ') }}</span>
</div>
{% endif %}
<h4 class="tab-cell font-bold"><a href="{{ packageUrl }}">{{ user.username }}</a></h4>
</div>
<p>Expires at:{% if user.expiresAt %} {{ user.expiresAt|date('Y-m-d') }} {% else %} N/A {% endif %}</p>
</div>
<div class="col-sm-3 col-lg-1">
<div style="font-size: 1.5em">
<ul class="nav">
<li class="launcher-item">
<a href="{{ path('users_update', {name: user.username}) }}">
<i class="fa fa-pencil-alt"></i>
</a>
</li>
</ul>
</a>

<div style="width: 90%; margin-top: 10px">
<a href="{{ path('users_update', {name: user.username}) }}" style="float: right; padding: 5px 14px;" class="btn btn-primary">Edit</a>
</div>
</div>
<p class="link-gray" style="font-size: 12px">
Active: {{ user.enabled ? 'Yes' : 'No' }}<br>
Expires at: {{ user.expiresAt ? user.expiresAt|date('Y-m-d') : 'N/A' }}
</p>
</div>
</div>
</li>
Expand Down
16 changes: 8 additions & 8 deletions src/Packagist/WebBundle/Resources/views/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@

<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
{%- if is_granted('ROLE_MAINTAINER') %}
<li>
<a href="{{ path('browse') }}">{{ 'menu.browse'|trans }}</a>
</li>
<li>
<a href="{{ path('submit') }}">{{ 'menu.submit'|trans }}</a>
</li>
{%- endif %}
{%- if is_granted('ROLE_ADMIN') %}
<li class="nav-user">
<section>
Expand All @@ -60,14 +68,6 @@
</section>
</li>
{%- endif %}
{%- if is_granted('ROLE_MAINTAINER') %}
<li>
<a href="{{ path('browse') }}">{{ 'menu.browse'|trans }}</a>
</li>
<li>
<a href="{{ path('submit') }}">{{ 'menu.submit'|trans }}</a>
</li>
{%- endif %}

{%- if app.user %}
<li class="nav-user">
Expand Down

0 comments on commit 3efa123

Please sign in to comment.