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

Cancel draft changes UI component doesn't show up for draft changes on owned models #2892

Closed
mfendeksilverstripe opened this issue Oct 9, 2023 · 1 comment

Comments

@mfendeksilverstripe
Copy link
Contributor

mfendeksilverstripe commented Oct 9, 2023

Cancel draft changes UI component doesn't show up for draft changes on owned models

Cancel draft changes action is a really useful UI component. Unfortunately, it doesn't work with any owned models such as but not limited to content blocks which arguably is the majority case.

Screenshot 2023-10-09 at 4 00 18 PM

Tested on CMS 4.13.

Thoughts on solution

The only issue with this component is the display condition otherwise the functionality is fine and will work with nested models.

$stagesDiffer = $this->stagesDiffer(); <--- change this to stagesDifferRecursive()


// "rollback"
if ($isOnDraft && $isPublished && $canEdit && $stagesDiffer) {
    $moreOptions->push(
        FormAction::create('rollback', _t(__CLASS__.'.BUTTONCANCELDRAFT', 'Cancel draft changes'))
            ->setDescription(_t(
                'SilverStripe\\CMS\\Model\\SiteTree.BUTTONCANCELDRAFTDESC',
                'Delete your draft and revert to the currently published page'
            ))
            ->addExtraClass('btn-secondary')
    );
}

Related PRs

silverstripe/silverstripe-versioned#328

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants