Skip to content

Commit 6feb68e

Browse files
committed
Add redirect for packages without any published versions
Signed-off-by: Tim Goudriaan <tim@codedmonkey.com>
1 parent 4ea3bbc commit 6feb68e

4 files changed

Lines changed: 41 additions & 6 deletions

File tree

src/Controller/Dashboard/DashboardPackagesInfoController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public function info(string $packageName): Response
3232
$package = $this->packageRepository->findOneBy(['name' => $packageName]);
3333
$version = $package->getLatestVersion();
3434

35+
if (!$version) {
36+
return $this->redirectToRoute('dashboard_packages_versions', ['packageName' => $packageName]);
37+
}
38+
3539
return $this->versionInfo($packageName, $version->getNormalizedVersion());
3640
}
3741

templates/dashboard/packages/_package_header.html.twig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
<ul class="nav nav-pills nav-justified d-grid d-md-flex gap-1 pb-3 mb-3 border-bottom">
66
<li class="nav-item">
7-
{% set packageInfoUrl = path('dashboard_packages_info', {packageName: package.name}) %}
8-
<a {{ (currentPage == 'info' ? attrActive : attr)|raw }} href="{{ packageInfoUrl }}">{{ 'Info'|trans }}</a>
7+
{% if package.versions|length > 0 %}
8+
{% set packageInfoUrl = path('dashboard_packages_info', {packageName: package.name}) %}
9+
<a {{ (currentPage == 'info' ? attrActive : attr)|raw }} href="{{ packageInfoUrl }}">{{ 'Info'|trans }}</a>
10+
{% else %}
11+
<span class="nav-link disabled">{{ 'Info'|trans }}</span>
12+
{% endif %}
913
</li>
1014
<li class="nav-item">
1115
{% set packageVersionsUrl = path('dashboard_packages_versions', {packageName: package.name}) %}

templates/dashboard/packages/package_versions.html.twig

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,35 @@
55
{% block page_content %}
66
{{ include('dashboard/packages/_package_header.html.twig', {currentPage: 'versions'}) }}
77

8-
{{ _self.versionList('Latest versions', package.activeVersions) }}
9-
{{ _self.versionList('Development versions', package.devVersions) }}
10-
{{ _self.versionList('Historical versions', package.historicalVersions) }}
11-
{{ _self.versionList('Development branch versions', package.devBranchVersions) }}
8+
{% if package.versions|length > 0 %}
9+
{{ _self.versionList('Latest versions', package.activeVersions) }}
10+
{{ _self.versionList('Development versions', package.devVersions) }}
11+
{{ _self.versionList('Historical versions', package.historicalVersions) }}
12+
{{ _self.versionList('Development branch versions', package.devBranchVersions) }}
13+
{% else %}
14+
<table class="table datagrid datagrid-empty">
15+
<tbody>
16+
{% for i in 1..14 %}
17+
<tr class="empty-row">
18+
<td><span></span></td>
19+
<td><span></span></td>
20+
<td><span></span></td>
21+
<td><span></span></td>
22+
<td><span></span></td>
23+
<td><span></span></td>
24+
</tr>
25+
26+
{% if 3 == loop.index %}
27+
<tr class="no-results">
28+
<td colspan="100">
29+
{{ 'No published versions found'|trans }}
30+
</td>
31+
</tr>
32+
{% endif %}
33+
{% endfor %}
34+
</tbody>
35+
</table>
36+
{% endif %}
1237
{% endblock %}
1338

1439
{% macro versionList(title, versions) %}

translations/messages.en.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Providers: Providers
5252
Statistics: Statistics
5353
Suggesters: Suggesters
5454

55+
No published versions found: No published versions found.
56+
5557
# Package labels (Statistics)
5658
Daily installations: Daily installations
5759
Daily installations per version: Daily installations per version

0 commit comments

Comments
 (0)