diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index c6a0d87734..3d5b9fcb5b 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -1096,10 +1096,11 @@ public function Breadcrumbs($unlinked = false) if (count($status) > 0) { $flags = ''; foreach ($status as $flag => $flagData) { + $titleAttrebute = sprintf(' title="%s"', Convert::raw2xml($flagData['title'])); $flags .= sprintf( '%s', 'status-' . Convert::raw2xml($flag), - (isset($flagData['title'])) ? sprintf(' title="%s"', Convert::raw2xml($flagData['title'])) : '', + (isset($flagData['title'])) ? $titleAttrebute : '', Convert::raw2xml($flagData['text']) ); } @@ -1119,31 +1120,9 @@ public function Breadcrumbs($unlinked = false) return $items; } - private function getStatusFlag($record) + private function getStatusFlag(SiteTree $record): array { - $flags = []; - if ($record->isOnLiveOnly()) { - $flags['removedfromdraft'] = [ - 'text' => _t(__CLASS__.'.ONLIVEONLYSHORT', 'On live only'), - 'title' => _t(__CLASS__.'.ONLIVEONLYSHORTHELP', 'Page is published, but has been deleted from draft'), - ]; - } elseif ($record->isArchived()) { - $flags['archived'] = [ - 'text' => _t(__CLASS__.'.ARCHIVEDPAGESHORT', 'Archived'), - 'title' => _t(__CLASS__.'.ARCHIVEDPAGEHELP', 'Page is removed from draft and live'), - ]; - } elseif ($record->isOnDraftOnly()) { - $flags['addedtodraft'] = [ - 'text' => _t(__CLASS__.'.ADDEDTODRAFTSHORT', 'Draft'), - 'title' => _t(__CLASS__.'.ADDEDTODRAFTHELP', 'Page has not been published yet') - ]; - } elseif ($record->isModifiedOnDraft() || $record->stagesDifferRecursive()) { - $flags['modified'] = [ - 'text' => _t(__CLASS__.'.MODIFIEDONDRAFTSHORT', 'Modified'), - 'title' => _t(__CLASS__.'.MODIFIEDONDRAFTHELP', 'Page has unpublished changes'), - ]; - } - + $flags = $record->getStatusFlags(); $this->extend('updateStatusFlags', $flags); return $flags; diff --git a/lang/en.yml b/lang/en.yml index 9dbbc7b2af..c482058eff 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -14,7 +14,6 @@ en: SilverStripe\CMS\Controllers\CMSMain: ACCESS: "Access to '{title}' section" ACCESS_HELP: 'Allow viewing of the section containing page tree and content. View and edit permissions can be handled through page specific dropdowns, as well as the separate "Content permissions".' - ADDEDTODRAFTSHORT: 'Draft' ADDEDTODRAFTHELP: 'Page has not been published yet' ARCHIVE: Archive ARCHIVEDPAGE: "Archived page '{title}'" diff --git a/tests/behat/features/page-with-versioned-objects.feature b/tests/behat/features/page-with-versioned-objects.feature new file mode 100644 index 0000000000..b39f44fa38 --- /dev/null +++ b/tests/behat/features/page-with-versioned-objects.feature @@ -0,0 +1,78 @@ +Feature: Publish a page + As a site owner + I want see versioned badge on page with draft and modified versioned child objects + + Background: + Given a "Test Page Versioned Object" "My Page" with "URLSegment"="my-page" + And the "Test Page Versioned Object" "My Page" is not published + And the "Versioned parent object" "My Versioned Parent Object" with "TestPageVersionedObject"="1" + And the "Non Versioned parent object" "My Non Versioned Parent Object" with "TestPageVersionedObject"="1" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" and "TEST_DATAOBJECT_EDIT" + And I am logged in as a member of "EDITOR" group + + Scenario: I should see versioned badge on page with draft and modified versioned child object + Given I go to "/admin/pages" + And I should see "My Page" in the tree + And I click on "My Page" in the tree + Then I should see "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + And I click on the "#tab-Root_VersionedParentObjects" element + And I should see "My Versioned Parent Object" in the "#Form_EditForm" element + And I should see "Draft" in the "#Form_EditForm" element + Then I click "My Versioned Parent Object" in the "#Form_EditForm_VersionedParentObjects" element + And I should see "My Versioned Parent Object" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + And I click "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + Then I click "My Versioned Parent Object" in the "#Form_EditForm_VersionedParentObjects" element + And I press the "Publish" button + And I should not see "Draft" in the ".breadcrumbs-wrapper" element + And I click "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + Then I click "My Versioned Parent Object" in the "#Form_EditForm_VersionedParentObjects" element + And I fill in "Name" with "My Versioned Parent Object with changes" + And I press the "Save" button + Then I should see "Modified" in the ".breadcrumbs-wrapper" element + And I click "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + Then I press the "Publish" button + And I should not see "Modified" in the ".breadcrumbs-wrapper" element + And I should not see "Modified" in the "#Form_EditForm" element + + Scenario: I should see versioned badge on page with draft and modified versioned grandchild object + Given I go to "/admin/pages" + And I should see "My Page" in the tree + And I click on "My Page" in the tree + Then I should see "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + And I click on the "#tab-Root_NonVersionedParentObjects" element + Then I click "My Non Versioned Parent Object" in the "#Form_EditForm_NonVersionedParentObjects" element + And I should not see "Draft" in the ".breadcrumbs-wrapper" element + Then I click "Versioned child objects" in the ".ui-tabs-nav" element + And I click "Add Versioned Child Object" in the "#Form_ItemEditForm_VersionedChildObjects" element + And I fill in "Name" with "My Versioned child object" + And I press the "Create" button + And I wait 2 seconds + And I should see "Draft" in the ".breadcrumbs-wrapper" element + Then I click "My Non Versioned Parent Object" in the ".breadcrumbs-wrapper" element + And I should see "Modified" in the ".breadcrumbs-wrapper" element + Then I click "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Draft" in the ".breadcrumbs-wrapper" element + And I should see "My Non Versioned Parent Object" in the "#Form_EditForm" element + And I should see "Modified" in the "#Form_EditForm" element + And I press the "Publish" button + Then I click "My Non Versioned Parent Object" in the "#Form_EditForm" element + Then I click "Versioned child objects" in the ".ui-tabs-nav" element + And I click "My Versioned child object" in the "#Form_ItemEditForm_VersionedChildObjects" element + And I fill in "Name" with "My Versioned child object with changes" + Then I press the "Save" button + And I should see "Modified" in the ".breadcrumbs-wrapper" element + Then I click "My Non Versioned Parent Object" in the ".breadcrumbs-wrapper" element + And I should see "Modified" in the ".breadcrumbs-wrapper" element + And I click "Versioned child objects" in the ".ui-tabs-nav" element + And I should see "Versioned child object with changes" in the "#Form_ItemEditForm_VersionedChildObjects" element + And I should see "Modified" in the "#Form_ItemEditForm_VersionedChildObjects" element + Then I click "My Page" in the ".breadcrumbs-wrapper" element + And I should see "Modified" in the ".breadcrumbs-wrapper" element + And I should see "My Non Versioned Parent Object" in the "#Form_EditForm" element + And I should see "Modified" in the "#Form_EditForm" element