Skip to content

Commit

Permalink
Fix visibility of the Install button in packages grid (#16675)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
smg6511 authored Jan 21, 2025
1 parent 66a9b79 commit 51e7035
Show file tree
Hide file tree
Showing 2 changed files with 377 additions and 325 deletions.
10 changes: 5 additions & 5 deletions core/src/Revolution/Processors/Workspace/Packages/GetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ public function getSortClassKey()
*/
public function prepareRow(xPDOObject $object)
{
if ($object->get('installed') === '0000-00-00 00:00:00') {
$object->set('installed', null);
}
$packageArray = $object->toArray();

$isInstalled = !$this->formatter->isEmpty($packageArray['installed']);
$packageArray['isInstalled'] = $isInstalled;
$packageArray = $this->getVersionInfo($packageArray);
$packageArray = $this->formatDates($packageArray);
$packageArray['iconaction'] = empty($packageArray['installed']) ? 'icon-install' : 'icon-uninstall';
$packageArray['textaction'] = empty($packageArray['installed']) ? $this->modx->lexicon('install') : $this->modx->lexicon('uninstall');
$packageArray['iconaction'] = !$isInstalled ? 'icon-install' : 'icon-uninstall';
$packageArray['textaction'] = !$isInstalled ? $this->modx->lexicon('install') : $this->modx->lexicon('uninstall');
$packageArray = $this->getPackageMeta($object, $packageArray);
$packageArray = $this->checkForUpdates($object, $packageArray);

Expand Down
Loading

0 comments on commit 51e7035

Please sign in to comment.