Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination breaks history viewer #104

Open
2 tasks done
mfendeksilverstripe opened this issue Sep 1, 2024 · 1 comment
Open
2 tasks done

Pagination breaks history viewer #104

mfendeksilverstripe opened this issue Sep 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mfendeksilverstripe
Copy link
Collaborator

mfendeksilverstripe commented Sep 1, 2024

Module version(s) affected

3.x-dev

Description

History viewer will break as long as the versions list has more than 30 items.

How to reproduce

  • install this module into your project setup
  • create a new page
  • keep making edits until you have at least 31 versioned history items
  • navigate to the history tab

Expected behaviour:

I want to see the history list the same way as I see this list when I have 30 or less items.

Screenshot 2024-09-02 at 11 08 02 AM

Actual behaviour:

I don't see the history viewer at all.

Screenshot 2024-09-02 at 11 15 38 AM

Error observed:

Screenshot 2024-09-02 at 11 14 31 AM

Possible Solution

Likely caused by a regression on how pagination is handled during CMS 5 upgrade. Temporary workaround can be applied by limiting the number of items to 30.

<?php

namespace App\Snapshots\Extensions;

use SilverStripe\Core\Extension;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Snapshots\SnapshotPublishable;

/**
 * TODO remove this once module issue is resolved
 * https://github.com/silverstripe/silverstripe-versioned-snapshot-admin/issues/104
 *
 * @method DataObject getOwner()
 */
class PaginationWorkaroundExtension extends Extension
{
    /**
     * Extension point in @see SnapshotPublishable::getRelevantSnapshots()
     *
     * @param DataList $result
     * @return void
     */
    public function updateRelevantSnapshots(DataList &$result): void
    {
        $owner = $this->getOwner();

        // Not relevant for this model
        if (!$owner->hasExtension(SnapshotPublishable::class)) {
            return;
        }

        // Limit the number of items in the history viewer to work around the pagination issue
        // https://github.com/silverstripe/silverstripe-versioned-snapshot-admin/issues/104
        $result = $result->limit(30);
    }
}

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@mfendeksilverstripe mfendeksilverstripe added the bug Something isn't working label Sep 1, 2024
@Jianbinzhu
Copy link
Contributor

@mfendeksilverstripe the pagination is broken by the upgrade of react-griddle library, the old GridPagination vs the new Pagination has a completely different structure.

https://github.com/silverstripe/silverstripe-versioned-snapshot-admin/blob/master/client/src/components/HistoryViewer/HistoryViewer.js#L314 will need to be updated to use the new structure of the component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants