Skip to content

Commit 51e7035

Browse files
authored
Fix visibility of the Install button in packages grid (#16675)
### What does it do? Adds a new prop to provide a boolean indicator of a package's installed state. The prop utilizes the recently-introduced date formatter's `isEmpty` method, which more comprehensively determines whether the `installed` field contains a meaningful value. Note that this new prop still relies on a derived value. It would be much better IMO at some future point to persist this state in a new database field rather than basing it off of a date value. ### Why is it needed? Install button is currently missing in the grid. ### How to test Download, install, and uninstall a few packages to verify the install button appears as expected. ### Related issue(s)/PR(s) Resolves #16672
1 parent 66a9b79 commit 51e7035

File tree

2 files changed

+377
-325
lines changed

2 files changed

+377
-325
lines changed

core/src/Revolution/Processors/Workspace/Packages/GetList.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ public function getSortClassKey()
108108
*/
109109
public function prepareRow(xPDOObject $object)
110110
{
111-
if ($object->get('installed') === '0000-00-00 00:00:00') {
112-
$object->set('installed', null);
113-
}
114111
$packageArray = $object->toArray();
112+
113+
$isInstalled = !$this->formatter->isEmpty($packageArray['installed']);
114+
$packageArray['isInstalled'] = $isInstalled;
115115
$packageArray = $this->getVersionInfo($packageArray);
116116
$packageArray = $this->formatDates($packageArray);
117-
$packageArray['iconaction'] = empty($packageArray['installed']) ? 'icon-install' : 'icon-uninstall';
118-
$packageArray['textaction'] = empty($packageArray['installed']) ? $this->modx->lexicon('install') : $this->modx->lexicon('uninstall');
117+
$packageArray['iconaction'] = !$isInstalled ? 'icon-install' : 'icon-uninstall';
118+
$packageArray['textaction'] = !$isInstalled ? $this->modx->lexicon('install') : $this->modx->lexicon('uninstall');
119119
$packageArray = $this->getPackageMeta($object, $packageArray);
120120
$packageArray = $this->checkForUpdates($object, $packageArray);
121121

0 commit comments

Comments
 (0)