Skip to content

Commit b7d0027

Browse files
committed
Merge remote-tracking branch 'l3/MC-40329' into PR-01-21
2 parents 2c8aa0f + 058adc9 commit b7d0027

File tree

15 files changed

+356
-46
lines changed

15 files changed

+356
-46
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Block\Adminhtml\Form\Element\Address;
9+
10+
/**
11+
* Customer Address Widget Form File Element Block
12+
*/
13+
class File extends \Magento\Customer\Block\Adminhtml\Form\Element\File
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
protected function _getPreviewUrl()
19+
{
20+
return $this->_adminhtmlData->getUrl(
21+
'customer/address/viewfile',
22+
['file' => $this->urlEncoder->encode($this->getValue())]
23+
);
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Block\Adminhtml\Form\Element\Address;
9+
10+
/**
11+
* Customer Address Widget Form Image Element Block
12+
*/
13+
class Image extends \Magento\Customer\Block\Adminhtml\Form\Element\Image
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
protected function _getPreviewUrl()
19+
{
20+
return $this->_adminhtmlData->getUrl(
21+
'customer/address/viewfile',
22+
['file' => $this->urlEncoder->encode($this->getValue())]
23+
);
24+
}
25+
}

app/code/Magento/Customer/Block/Adminhtml/Form/Element/Image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function _getPreviewUrl()
7373
{
7474
return $this->_adminhtmlData->getUrl(
7575
'customer/index/viewfile',
76-
['image' => $this->urlEncoder->encode($this->getValue())]
76+
['file' => $this->urlEncoder->encode($this->getValue())]
7777
);
7878
}
7979
}

app/code/Magento/Customer/Controller/Adminhtml/Address/Viewfile.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Customer\Controller\Adminhtml\Address;
99

1010
use Magento\Customer\Api\AddressMetadataInterface;
11+
use Magento\Framework\App\ResponseInterface;
1112
use Magento\Framework\Exception\NotFoundException;
1213
use Magento\Framework\App\Filesystem\DirectoryList;
1314
use Magento\Framework\Controller\Result\RawFactory;
@@ -92,7 +93,7 @@ public function __construct(
9293
/**
9394
* Customer address view file action
9495
*
95-
* @return ResultInterface|void
96+
* @return ResultInterface|ResponseInterface|void
9697
* @throws NotFoundException
9798
*/
9899
public function execute()
@@ -142,7 +143,7 @@ public function execute()
142143
return $resultRaw;
143144
} else {
144145
$name = $pathInfo['basename'];
145-
$this->fileFactory->create(
146+
return $this->fileFactory->create(
146147
$name,
147148
['type' => 'filename', 'value' => $fileName],
148149
DirectoryList::MEDIA

app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Magento\Customer\Api\Data\AddressInterfaceFactory;
1515
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
1616
use Magento\Customer\Model\Address\Mapper;
17+
use Magento\Framework\App\ResponseInterface;
18+
use Magento\Framework\Controller\ResultInterface;
1719
use Magento\Framework\Exception\NotFoundException;
1820
use Magento\Framework\App\Filesystem\DirectoryList;
1921
use Magento\Framework\DataObjectFactory;
@@ -130,7 +132,7 @@ public function __construct(
130132
/**
131133
* Customer view file action
132134
*
133-
* @return \Magento\Framework\Controller\ResultInterface|void
135+
* @return ResultInterface|ResponseInterface|void
134136
* @throws NotFoundException
135137
*/
136138
public function execute()
@@ -181,7 +183,7 @@ public function execute()
181183
} else {
182184
// phpcs:ignore Magento2.Functions.DiscouragedFunction
183185
$name = pathinfo($path, PATHINFO_BASENAME);
184-
$this->_fileFactory->create(
186+
return $this->_fileFactory->create(
185187
$name,
186188
['type' => 'filename', 'value' => $fileName],
187189
DirectoryList::MEDIA

app/code/Magento/Customer/Model/FileProcessor.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class FileProcessor
2929
*/
3030
const TMP_DIR = 'tmp';
3131

32+
private const CUSTOMER_FILE_URL_PATH = 'customer/index/viewfile';
33+
34+
private const CUSTOMER_ADDRESS_FILE_URL_PATH = 'customer/address/viewfile';
35+
3236
/**
3337
* @var WriteInterface
3438
*/
@@ -64,6 +68,16 @@ class FileProcessor
6468
*/
6569
private $mime;
6670

71+
/**
72+
* @var string
73+
*/
74+
private $customerFileUrlPath;
75+
76+
/**
77+
* @var string
78+
*/
79+
private $customerAddressFileUrlPath;
80+
6781
/**
6882
* @param Filesystem $filesystem
6983
* @param UploaderFactory $uploaderFactory
@@ -72,6 +86,8 @@ class FileProcessor
7286
* @param string $entityTypeCode
7387
* @param Mime $mime
7488
* @param array $allowedExtensions
89+
* @param string $customerFileUrlPath
90+
* @param string $customerAddressFileUrlPath
7591
*/
7692
public function __construct(
7793
Filesystem $filesystem,
@@ -80,7 +96,9 @@ public function __construct(
8096
EncoderInterface $urlEncoder,
8197
$entityTypeCode,
8298
Mime $mime,
83-
array $allowedExtensions = []
99+
array $allowedExtensions = [],
100+
string $customerFileUrlPath = self::CUSTOMER_FILE_URL_PATH,
101+
string $customerAddressFileUrlPath = self::CUSTOMER_ADDRESS_FILE_URL_PATH
84102
) {
85103
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
86104
$this->uploaderFactory = $uploaderFactory;
@@ -89,6 +107,8 @@ public function __construct(
89107
$this->entityTypeCode = $entityTypeCode;
90108
$this->mime = $mime;
91109
$this->allowedExtensions = $allowedExtensions;
110+
$this->customerFileUrlPath = $customerFileUrlPath;
111+
$this->customerAddressFileUrlPath = $customerAddressFileUrlPath;
92112
}
93113

94114
/**
@@ -159,14 +179,14 @@ public function getViewUrl($filePath, $type)
159179

160180
if ($this->entityTypeCode == AddressMetadataInterface::ENTITY_TYPE_ADDRESS) {
161181
$viewUrl = $this->urlBuilder->getUrl(
162-
'customer/address/viewfile',
182+
$this->customerAddressFileUrlPath,
163183
[$type => $this->urlEncoder->encode(ltrim($filePath, '/'))]
164184
);
165185
}
166186

167187
if ($this->entityTypeCode == CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER) {
168188
$viewUrl = $this->urlBuilder->getUrl(
169-
'customer/index/viewfile',
189+
$this->customerFileUrlPath,
170190
[$type => $this->urlEncoder->encode(ltrim($filePath, '/'))]
171191
);
172192
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontCustomerAddressFormCheckDefaultShippingActionGroup">
12+
<annotations>
13+
<description>Check default chipping address checkbox.</description>
14+
</annotations>
15+
<checkOption selector="{{StorefrontCustomerAddressFormSection.useAsDefaultShippingAddressCheckBox}}" stepKey="checkUseAsDefaultShippingAddressCheckBox"/>
16+
</actionGroup>
17+
</actionGroups>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontFillCustomerAddressFormActionGroup">
12+
<annotations>
13+
<description>Fills address data in storefront customer address edit form.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="Address"/>
17+
</arguments>
18+
<fillField userInput="{{Address.firstname}}" selector="{{StorefrontCustomerAddressFormSection.firstName}}" stepKey="fillFirstName"/>
19+
<fillField userInput="{{Address.lastname}}" selector="{{StorefrontCustomerAddressFormSection.lastName}}" stepKey="fillLastName"/>
20+
<fillField userInput="{{Address.company}}" selector="{{StorefrontCustomerAddressFormSection.company}}" stepKey="fillCompanyName"/>
21+
<fillField userInput="{{Address.telephone}}" selector="{{StorefrontCustomerAddressFormSection.phoneNumber}}" stepKey="fillPhoneNumber"/>
22+
<fillField userInput="{{Address.street[0]}}" selector="{{StorefrontCustomerAddressFormSection.streetAddress}}" stepKey="fillStreetAddress"/>
23+
<fillField userInput="{{Address.city}}" selector="{{StorefrontCustomerAddressFormSection.city}}" stepKey="fillCity"/>
24+
<selectOption userInput="{{Address.state}}" selector="{{StorefrontCustomerAddressFormSection.state}}" stepKey="selectState"/>
25+
<fillField userInput="{{Address.postcode}}" selector="{{StorefrontCustomerAddressFormSection.zip}}" stepKey="fillZip"/>
26+
<selectOption userInput="{{Address.country}}" selector="{{StorefrontCustomerAddressFormSection.country}}" stepKey="selectCountry"/>
27+
</actionGroup>
28+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontOpenNewCustomerAddressFormActionGroup">
12+
<annotations>
13+
<description>Open new customer address form on storefront.</description>
14+
</annotations>
15+
<amOnPage url="customer/address/new/" stepKey="OpenCustomerAddNewAddress"/>
16+
<waitForPageLoad stepKey="waitForCustomerAddNewAddress"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection/StoreFrontCustomerAdvancedAttributesSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
<element name="attributeLabel" type="text" selector="//span[text()='{{attributeLabel}}']" parameterized="true"/>
2323
<element name="fileAttribute" type="file" selector="//input[@type='file' and @name='{{attributeCode}}']" parameterized="true" timeout="30"/>
2424
<element name="customFileAttributeUploadButton" type="input" selector=".file-uploader-area input[name='{{attributeCode}}'] ~ .file-uploader-button" parameterized="true"/>
25+
<element name="fileUploaderPreviewLink" type="block" selector="//input[@type='file' and @name='{{attributeCode}}']/ancestor::div[contains(@class, 'file-uploader')]//div[contains(@class, 'file-uploader-preview')]//a[contains(@class, 'preview-link')]" parameterized="true"/>
26+
<element name="fileUploaderPreviewImage" type="block" selector="//input[@type='file' and @name='{{attributeCode}}']/ancestor::div[contains(@class, 'file-uploader')]//div[contains(@class, 'file-uploader-preview')]//img" parameterized="true"/>
2527
</section>
2628
</sections>

0 commit comments

Comments
 (0)