Skip to content

Commit

Permalink
Merge branch '5.x' into 5.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/web/assets/cp/dist/cp.js
#	src/web/assets/cp/dist/cp.js.map
  • Loading branch information
brandonkelly committed May 2, 2024
2 parents 4464969 + 292b9c6 commit 4d71923
Showing 8 changed files with 48 additions and 31 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,9 +5,14 @@
- Fixed a bug where disclosure menus weren’t releasing their `scroll` and `resize` event listeners on hide. ([#14911](https://github.com/craftcms/cms/pull/14911]), [#14510](https://github.com/craftcms/cms/issues/14510))
- Fixed a bug where it was possible to delete entries from Matrix fields which were configured to display nested entries statically. ([#14904](https://github.com/craftcms/cms/issues/14904), [#14915](https://github.com/craftcms/cms/pull/14915))
- Fixed an error that could occur when creating a nested entry in a Matrix field. ([#14915](https://github.com/craftcms/cms/pull/14915))
- Fixed a bug where nested entry draft data could get corrupted when a draft was created for the owner element.
- Fixed a bug where Matrix and Addresses fields could show drafts of their nested elements when in card view.
- Fixed a bug where nested elements’ breadcrumbs could include the draft label, styled like it was part of the element’s title.
- Fixed a bug where action buttons might not work for nested entries in Matrix fields set to card view. ([#14915](https://github.com/craftcms/cms/pull/14915))
- Fixed the styling of tag chips within Tags fields. ([#14916](https://github.com/craftcms/cms/issues/14916))
- Fixed a bug where field layout component settings slideouts’ footers had extra padding.
- Fixed a bug where MySQL backups weren’t restorable on certain environments. ([#14925](https://github.com/craftcms/cms/pull/14925))
- Fixed a bug where `app/resource-js` requests weren’t working for guest requests. ([#14908](https://github.com/craftcms/cms/issues/14908))

## 5.1.0 - 2024-04-30

6 changes: 5 additions & 1 deletion src/base/Element.php
Original file line number Diff line number Diff line change
@@ -3132,7 +3132,11 @@ public function getCrumbs(): array
if ($owner) {
return [
...$owner->getCrumbs(),
['html' => Cp::elementChipHtml($owner)],
[
'html' => Cp::elementChipHtml($owner, [
'showDraftName' => false,
]),
],
];
}
}
1 change: 1 addition & 0 deletions src/controllers/AppController.php
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ class AppController extends Controller
'migrate' => self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE,
'broken-image' => self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE,
'health-check' => self::ALLOW_ANONYMOUS_LIVE,
'resource-js' => self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE,
];

/**
2 changes: 1 addition & 1 deletion src/db/mysql/Schema.php
Original file line number Diff line number Diff line change
@@ -201,7 +201,7 @@ public function getDefaultBackupCommand(?array $ignoreTables = null): string
$commandFromConfig = Craft::$app->getConfig()->getGeneral()->backupCommand;

// https://bugs.mysql.com/bug.php?id=109685
$useSingleTransaction = $isMySQL8 && version_compare($serverVersion, '8.0.32', '>=');
$useSingleTransaction = $isMySQL8 && version_compare($serverVersion, '8.0.32', '<');

if ($useSingleTransaction) {
$baseCommand->addArg('--single-transaction');
29 changes: 20 additions & 9 deletions src/elements/NestedElementManager.php
Original file line number Diff line number Diff line change
@@ -383,7 +383,7 @@ function(string $id, array $config, $attribute, &$settings) use ($owner) {
]);

/** @var NestedElementInterface[] $elements */
$elements = $this->getValue($owner, true)->all();
$elements = $this->getValue($owner)->all();
$this->setOwnerOnNestedElements($owner, $elements);

if (!empty($elements)) {
@@ -695,14 +695,25 @@ private function saveNestedElements(ElementInterface $owner): void
$element->setSortOrder($sortOrder);
$elementsService->saveElement($element, false);

// If this is a draft, we can shed the draft data now
if ($element->getIsDraft()) {
$canonicalElementId = $element->getCanonicalId();
Craft::$app->getDrafts()->removeDraftData($element);
Db::delete(Table::ELEMENTS_OWNERS, [
'elementId' => $canonicalElementId,
'ownerId' => $owner->id,
]);
// If this element's primary owner is $owner, and it’s a draft of another element whose owner is
// $owner's canonical (e.g. a draft entry created by Matrix::_createEntriesFromSerializedData()),
// we can shed its draft data and relation with the canonical owner now
if (
$element->getPrimaryOwnerId() === $owner->id &&
$element->getIsDraft() &&
!$element->getIsUnpublishedDraft() &&
$owner->getIsDraft() &&
!$owner->getIsUnpublishedDraft()
) {
/** @var NestedElementInterface $canonical */
$canonical = $element->getCanonical(true);
if ($canonical->getPrimaryOwnerId() === $owner->getCanonicalId()) {
Craft::$app->getDrafts()->removeDraftData($element);
Db::delete(Table::ELEMENTS_OWNERS, [
'elementId' => $canonical->id,
'ownerId' => $owner->id,
]);
}
}
} elseif ((int)$element->getSortOrder() !== $sortOrder) {
// Just update its sortOrder
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions src/web/assets/cp/src/js/NestedElementManager.js
Original file line number Diff line number Diff line change
@@ -398,26 +398,22 @@ Craft.NestedElementManager = Garnish.Base.extend(
const disclosureMenu = $actionMenuBtn
.disclosureMenu()
.data('disclosureMenu');
const $actionMenu = disclosureMenu.$container;

if (Garnish.hasAttr($element, 'data-deletable')) {
$('<hr/>', {class: 'padded'}).appendTo($actionMenu);
const $ul = $('<ul/>').appendTo($actionMenu);
const $li = $('<li/>').appendTo($ul);
const $a = $('<a/>', {
class: 'error',
type: 'button',
role: 'button',
'data-icon': 'trash',
'aria-label': this.settings.deleteLabel || Craft.t('app', 'Delete'),
text: this.settings.deleteLabel || Craft.t('app', 'Delete'),
}).appendTo($li);
this.addListener($a, 'activate', (ev) => {
disclosureMenu.hide();
if (confirm(this.settings.deleteConfirmationMessage)) {
this.deleteElement($element);
}
});
const ul = disclosureMenu.addGroup();
disclosureMenu.addItem(
{
icon: 'trash',
label: this.settings.deleteLabel || Craft.t('app', 'Delete'),
destructive: true,
onActivate: () => {
if (confirm(this.settings.deleteConfirmationMessage)) {
this.deleteElement($element);
}
},
},
ul
);
}
},

0 comments on commit 4d71923

Please sign in to comment.