diff --git a/.github/app-projects-boards-automation.config.yaml b/.github/app-projects-boards-automation.config.yaml index 4810f7cfa69fe..a6d53770a4751 100644 --- a/.github/app-projects-boards-automation.config.yaml +++ b/.github/app-projects-boards-automation.config.yaml @@ -234,6 +234,18 @@ automations: - removeFromProject: [23] #['Pull Requests Dashboard'] - removeFromProject: [22] #['Community Dashboard'] + # 19. Whenever a pull request is marked as changes requested: + # a. the below labels must be removed from a pull request: "Progress: review" + # b. it must be moved to the "Changes Requested" column + - trigger: pull_request_review.submitted + conditions: + - ['review', 'eq', 'changes_requested'] + actions: + - removeLabels: ['Progress: review'] + - addLabels: ['Progress: needs update'] + - moveTo: [23, 'Changes Requested'] #['Pull Requests Dashboard', 'Changes Requested'] + - moveTo: [22, 'Changes Requested'] #['Community Dashboard', 'Changes Requested'] + ############################################################################################################ # Issues Automation # diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php index 2c9b6d68b0bbf..184c17c82a742 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php @@ -1,7 +1,7 @@ attributeRepository = $attributeRepository; $this->resourceModel = $resourceModel; + $this->optionResource = $optionResource ?: ObjectManager::getInstance()->get(Attribute\Option::class); } /** @@ -140,6 +150,12 @@ private function saveOption( $options['value'][$optionId][0] = $optionLabel; $options['order'][$optionId] = $option->getSortOrder(); $options['is_default'][$optionId] = $option->getIsDefault(); + + $existingLabels = $this->optionResource->getStoreLabelsByOptionId((int)$optionId); + foreach ($existingLabels as $storeId => $labelText) { + $options['value'][$optionId][$storeId] = $labelText; + } + if (is_array($option->getStoreLabels())) { foreach ($option->getStoreLabels() as $label) { $options['value'][$optionId][$label->getStoreId()] = $label->getLabel(); diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php index a7be59e2c05d5..4c77c75a1fb91 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php @@ -1,14 +1,12 @@ */ class Option extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { @@ -161,4 +159,22 @@ public function getFlatUpdateSelect( return $select; } + + /** + * Get all store labels for a given option ID + * + * @param int $optionId + * @return array [store_id => label] + */ + public function getStoreLabelsByOptionId(int $optionId): array + { + $connection = $this->getConnection(); + $table = $this->getTable('eav_attribute_option_value'); + + $select = $connection->select() + ->from($table, ['store_id', 'value']) + ->where('option_id = ?', $optionId); + + return $connection->fetchPairs($select); + } } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php index b36e2dd7d5d5b..3caefc014c9e0 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php @@ -1,7 +1,7 @@ attributeRepositoryMock = $this->createMock(AttributeRepository::class); - $this->resourceModelMock = - $this->createMock(Attribute::class); + $this->resourceModelMock = $this->createMock(Attribute::class); + $this->optionResourceMock = $this->createMock(Attribute\Option::class); $this->model = new OptionManagement( $this->attributeRepositoryMock, - $this->resourceModelMock + $this->resourceModelMock, + $this->optionResourceMock ); } @@ -255,6 +261,7 @@ public function testUpdate(string $label): void $optionId => [ 0 => $label, $storeId => $storeLabel, + 5 => 'otherLabelLabel' ], ], 'order' => [ @@ -265,8 +272,17 @@ public function testUpdate(string $label): void ] ]; + $this->optionResourceMock->expects($this->once()) + ->method('getStoreLabelsByOptionId') + ->with($optionId) + ->willReturn([ + 4 => 'oldLabelLabel', + 5 => 'otherLabelLabel' + ]); + $optionMock = $this->getAttributeOption(); - $labelMock = $this->getAttributeOptionLabel(); + $labelMock1 = $this->getAttributeOptionLabel(); + $labelMock2 = $this->getAttributeOptionLabel(); /** @var SourceInterface|MockObject $sourceMock */ $sourceMock = $this->createMock(EavAttributeSource::class); @@ -297,9 +313,11 @@ public function testUpdate(string $label): void $optionMock->method('getLabel')->willReturn($label); $optionMock->method('getSortOrder')->willReturn($sortOder); $optionMock->method('getIsDefault')->willReturn(true); - $optionMock->method('getStoreLabels')->willReturn([$labelMock]); - $labelMock->method('getStoreId')->willReturn($storeId); - $labelMock->method('getLabel')->willReturn($storeLabel); + $optionMock->method('getStoreLabels')->willReturn([$labelMock1, $labelMock2]); + $labelMock1->method('getStoreId')->willReturn($storeId); + $labelMock1->method('getLabel')->willReturn($storeLabel); + $labelMock2->method('getStoreId')->willReturn(5); + $labelMock2->method('getLabel')->willReturn('otherLabelLabel'); $this->resourceModelMock->expects($this->once())->method('save')->with($attributeMock); $this->assertEquals(