Skip to content

Commit 0fed04f

Browse files
committed
Migrate package list to grid view
see #6181
1 parent 549f8ed commit 0fed04f

File tree

8 files changed

+280
-141
lines changed

8 files changed

+280
-141
lines changed

wcfsetup/install/files/acp/js/WCF.ACP.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ WCF.ACP.Package.Uninstallation = WCF.ACP.Package.Installation.extend({
474474
this._elements = elements;
475475
this._packageID = 0;
476476

477-
if (this._elements !== undefined && this._elements.length) {
477+
//if (this._elements !== undefined && this._elements.length) {
478478
this._super(0, 'UninstallPackage');
479-
}
479+
//}
480480
},
481481

482482
/**
@@ -498,7 +498,15 @@ WCF.ACP.Package.Uninstallation = WCF.ACP.Package.Installation.extend({
498498
* @see WCF.ACP.Package.Installation.init()
499499
*/
500500
_init: function() {
501-
this._elements.click($.proxy(this._showConfirmationDialog, this));
501+
//this._elements.click($.proxy(this._showConfirmationDialog, this));
502+
503+
require(['WoltLabSuite/Core/Helper/Selector'], ({ wheneverFirstSeen }) => {
504+
wheneverFirstSeen(".jsUninstallButton", (button) => {
505+
button.addEventListener('click', (event) => {
506+
this._showConfirmationDialog(event);
507+
});
508+
});
509+
});
502510
},
503511

504512
/**

wcfsetup/install/files/acp/templates/packageList.tpl

Lines changed: 4 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<header class="contentHeader">
2222
<div class="contentHeaderTitle">
23-
<h1 class="contentTitle">{lang}wcf.acp.package.list{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
23+
<h1 class="contentTitle">{lang}wcf.acp.package.list{/lang} <span class="badge badgeInverse">{#$gridView->countRows()}</span></h1>
2424
</div>
2525

2626
{hascontent}
@@ -72,85 +72,8 @@
7272
{/if}
7373
{/if}
7474

75-
{hascontent}
76-
<div class="paginationTop">
77-
{content}{pages print=true assign=pagesLinks controller='PackageList' link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}{/content}
78-
</div>
79-
{/hascontent}
80-
81-
{if $objects|count}
82-
<div class="section tabularBox">
83-
<table class="table">
84-
<thead>
85-
<tr>
86-
<th colspan="2" class="columnID{if $sortField == 'packageID'} active {@$sortOrder}{/if}"><a href="{link controller='PackageList'}pageNo={@$pageNo}&sortField=packageID&sortOrder={if $sortField == 'packageID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
87-
<th class="columnTitle{if $sortField == 'packageNameI18n'} active {@$sortOrder}{/if}"><a href="{link controller='PackageList'}pageNo={@$pageNo}&sortField=packageNameI18n&sortOrder={if $sortField == 'packageNameI18n' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.package.name{/lang}</a></th>
88-
<th class="columnText{if $sortField == 'author'} active {@$sortOrder}{/if}"><a href="{link controller='PackageList'}pageNo={@$pageNo}&sortField=author&sortOrder={if $sortField == 'author' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.package.author{/lang}</a></th>
89-
<th class="columnText">{lang}wcf.acp.package.version{/lang}</th>
90-
<th class="columnDate{if $sortField == 'updateDate'} active {@$sortOrder}{/if}"><a href="{link controller='PackageList'}pageNo={@$pageNo}&sortField=updateDate&sortOrder={if $sortField == 'updateDate' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.package.updateDate{/lang}</a></th>
91-
92-
{event name='columnHeads'}
93-
</tr>
94-
</thead>
95-
96-
<tbody>
97-
{foreach from=$objects item=$package}
98-
<tr class="jsPackageRow" data-package="{$package->package}">
99-
<td class="columnIcon">
100-
{if $package->canUninstall()}
101-
<button type="button" class="jsUninstallButton jsTooltip" title="{lang}wcf.acp.package.button.uninstall{/lang}" data-object-id="{@$package->packageID}" data-confirm-message="{lang __encode=true}wcf.acp.package.uninstallation.confirm{/lang}" data-is-required="{if $package->isRequired()}true{else}false{/if}" data-is-application="{if $package->isApplication}true{else}false{/if}">
102-
{icon name='xmark'}
103-
</button>
104-
{else}
105-
<span class="disabled" title="{lang}wcf.acp.package.button.uninstall{/lang}">
106-
{icon name='xmark'}
107-
</span>
108-
{/if}
109-
110-
{event name='rowButtons'}
111-
</td>
112-
<td class="columnID">{@$package->packageID}</td>
113-
<td id="packageName{@$package->packageID}" class="columnTitle" title="{$package->getDescription()}">
114-
<a href="{link controller='Package' id=$package->packageID}{/link}"><span>{$package}</span></a>
115-
{if $taintedApplications[$package->packageID]|isset}
116-
<span class="jsTooltip" title="{lang taintedApplication=null}wcf.acp.package.application.isTainted{/lang}">
117-
{icon name='triangle-exclamation'}
118-
</span>
119-
{/if}
120-
</td>
121-
<td class="columnText">{if $package->authorURL}<a href="{$package->authorURL}" class="externalURL"{if EXTERNAL_LINK_TARGET_BLANK} target="_blank" rel="noopener"{/if}>{$package->author}</a>{else}{$package->author}{/if}</td>
122-
<td class="columnText">{$package->packageVersion}</td>
123-
<td class="columnDate">{@$package->updateDate|time}</td>
124-
125-
{event name='columns'}
126-
</tr>
127-
{/foreach}
128-
</tbody>
129-
</table>
130-
131-
</div>
132-
133-
<footer class="contentFooter">
134-
{hascontent}
135-
<div class="paginationBottom">
136-
{content}{@$pagesLinks}{/content}
137-
</div>
138-
{/hascontent}
139-
140-
{hascontent}
141-
<nav class="contentFooterNavigation">
142-
<ul>
143-
{content}
144-
{if $__wcf->session->getPermission('admin.configuration.package.canInstallPackage')}
145-
<li><a href="{link controller='PackageStartInstall'}action=install{/link}" class="button">{icon name='plus'} <span>{lang}wcf.acp.package.startInstall{/lang}</span></a></li>
146-
{/if}
147-
148-
{event name='contentFooterNavigation'}
149-
{/content}
150-
</ul>
151-
</nav>
152-
{/hascontent}
153-
</footer>
154-
{/if}
75+
<div class="section">
76+
{unsafe:$gridView->render()}
77+
</div>
15578

15679
{include file='footer'}

wcfsetup/install/files/lib/acp/page/PackageListPage.class.php

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
namespace wcf\acp\page;
44

5-
use wcf\data\package\I18nPackageList;
65
use wcf\data\package\update\server\PackageUpdateServer;
7-
use wcf\page\SortablePage;
6+
use wcf\page\AbstractGridViewPage;
87
use wcf\system\application\ApplicationHandler;
8+
use wcf\system\gridView\admin\PackageGridView;
99
use wcf\system\language\LanguageFactory;
1010
use wcf\system\WCF;
1111

1212
/**
1313
* Shows a list of all installed packages.
1414
*
15-
* @author Marcel Werk
16-
* @copyright 2001-2019 WoltLab GmbH
17-
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15+
* @author Marcel Werk
16+
* @copyright 2001-2025 WoltLab GmbH
17+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
1818
*
19-
* @extends SortablePage<I18nPackageList>
19+
* @extends AbstractGridViewPage<PackageGridView>
2020
*/
21-
class PackageListPage extends SortablePage
21+
final class PackageListPage extends AbstractGridViewPage
2222
{
2323
/**
2424
* @inheritDoc
@@ -33,47 +33,13 @@ class PackageListPage extends SortablePage
3333
'admin.configuration.package.canUninstallPackage',
3434
];
3535

36-
/**
37-
* @inheritDoc
38-
*/
39-
public $itemsPerPage = 50;
40-
41-
/**
42-
* @inheritDoc
43-
*/
44-
public $defaultSortField = 'packageType';
45-
46-
/**
47-
* @inheritDoc
48-
*/
49-
public $defaultSortOrder = 'DESC';
50-
51-
/**
52-
* @inheritDoc
53-
*/
54-
public $validSortFields = [
55-
'packageID',
56-
'package',
57-
'packageDir',
58-
'packageNameI18n',
59-
'packageDescription',
60-
'packageDate',
61-
'packageURL',
62-
'isApplication',
63-
'author',
64-
'authorURL',
65-
'installDate',
66-
'updateDate',
67-
];
68-
69-
/**
70-
* @inheritDoc
71-
*/
72-
public $objectListClassName = I18nPackageList::class;
36+
#[\Override]
37+
protected function createGridView(): PackageGridView
38+
{
39+
return new PackageGridView();
40+
}
7341

74-
/**
75-
* @inheritDoc
76-
*/
42+
#[\Override]
7743
public function assignVariables()
7844
{
7945
parent::assignVariables();
@@ -94,14 +60,4 @@ public function assignVariables()
9460
'upgradeOverrideEnabled' => PackageUpdateServer::isUpgradeOverrideEnabled(),
9561
]);
9662
}
97-
98-
/**
99-
* @inheritDoc
100-
*/
101-
protected function readObjects()
102-
{
103-
$this->sqlOrderBy = ($this->sortField == 'packageNameI18n' ? '' : 'package.') . ($this->sortField == 'packageType' ? 'isApplication ' . $this->sortOrder : $this->sortField . ' ' . $this->sortOrder) . ($this->sortField != 'packageNameI18n' ? ', packageNameI18n ASC' : '');
104-
105-
parent::readObjects();
106-
}
10763
}

wcfsetup/install/files/lib/data/package/Package.class.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use wcf\acp\page\PackagePage;
66
use wcf\data\DatabaseObject;
77
use wcf\data\ILinkableObject;
8+
use wcf\system\application\ApplicationHandler;
89
use wcf\system\package\PackageInstallationDispatcher;
910
use wcf\system\request\IRouteController;
1011
use wcf\system\request\LinkHandler;
@@ -460,4 +461,21 @@ public static function writeConfigFile($packageID)
460461

461462
\file_put_contents($packageDir . PackageInstallationDispatcher::CONFIG_FILE, $content);
462463
}
464+
465+
/**
466+
* @since 6.2
467+
*/
468+
public function isTainted(): bool
469+
{
470+
if (!$this->isApplication) {
471+
return false;
472+
}
473+
474+
$package = ApplicationHandler::getInstance()->getApplicationByID($this->packageID);
475+
if ($package === null) {
476+
return false;
477+
}
478+
479+
return $package->isTainted;
480+
}
463481
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace wcf\event\gridView\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\gridView\admin\PackageGridView;
7+
8+
/**
9+
* Indicates that the package grid view has been initialized.
10+
*
11+
* @author marcel Werk
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class PackageGridViewInitialized implements IPsr14Event
17+
{
18+
public function __construct(public readonly PackageGridView $gridView) {}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace wcf\event\interaction\admin;
4+
5+
use wcf\event\IPsr14Event;
6+
use wcf\system\interaction\admin\PackageInteractions;
7+
8+
/**
9+
* Indicates that the provider for packages is collecting interactions.
10+
*
11+
* @author Marcel Werk
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class PackageInteractionCollecting implements IPsr14Event
17+
{
18+
public function __construct(public readonly PackageInteractions $provider) {}
19+
}

0 commit comments

Comments
 (0)