Skip to content

Commit fd8dcad

Browse files
authored
Merge pull request #1670 from magento-arcticfoxes/MAGETWO-83013-ReleaseNotification
[Arctic Foxes] Advanced Reporting and Release Notification Pull Request
2 parents d521c40 + 268a655 commit fd8dcad

File tree

309 files changed

+21117
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+21117
-361
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Api\Data;
7+
8+
/**
9+
* Interface LinkInterface
10+
*
11+
* Represents link with collected data and initialized vector for decryption.
12+
*/
13+
interface LinkInterface
14+
{
15+
/**
16+
* @return string
17+
*/
18+
public function getUrl();
19+
20+
/**
21+
* @return string
22+
*/
23+
public function getInitializationVector();
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Api;
7+
8+
/**
9+
* Provides link to file with collected report data.
10+
*/
11+
interface LinkProviderInterface
12+
{
13+
/**
14+
* @return \Magento\Analytics\Api\Data\LinkInterface
15+
*/
16+
public function get();
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
7+
8+
/**
9+
* Provides field with additional information
10+
*/
11+
class AdditionalComment extends \Magento\Config\Block\System\Config\Form\Field
12+
{
13+
/**
14+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
15+
* @return string
16+
*/
17+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
18+
{
19+
$html = '<div class="config-additional-comment-title">' . $element->getLabel() . '</div>';
20+
$html .= '<div class="config-additional-comment-content">' . $element->getComment() . '</div>';
21+
return $this->decorateRowHtml($element, $html);
22+
}
23+
24+
/**
25+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
26+
* @param string $html
27+
* @return string
28+
*/
29+
private function decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
30+
{
31+
return sprintf(
32+
'<tr id="row_%s"><td colspan="3"><div class="config-additional-comment">%s</div></td></tr>',
33+
$element->getHtmlId(),
34+
$html
35+
);
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
7+
8+
/**
9+
* Provides label with default Time Zone
10+
*/
11+
class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
12+
{
13+
/**
14+
* Add default time zone to comment
15+
*
16+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
17+
* @return string
18+
*/
19+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
20+
{
21+
$timeZoneCode = $this->_localeDate->getConfigTimezone();
22+
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName();
23+
$element->setData(
24+
'comment',
25+
sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)
26+
);
27+
return parent::render($element);
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
7+
8+
use Magento\Analytics\Model\SubscriptionStatusProvider;
9+
use Magento\Backend\Block\Template\Context;
10+
11+
/**
12+
* Class SubscriptionStatusLabel.
13+
*
14+
* Provides labels for subscription status
15+
* Status can be reviewed in System Configuration
16+
*/
17+
class SubscriptionStatusLabel extends \Magento\Config\Block\System\Config\Form\Field
18+
{
19+
/**
20+
* @var SubscriptionStatusProvider
21+
*/
22+
private $subscriptionStatusProvider;
23+
24+
/**
25+
* SubscriptionStatusLabel constructor.
26+
*
27+
* @param Context $context
28+
* @param SubscriptionStatusProvider $labelStatusProvider
29+
* @param array $data
30+
*/
31+
public function __construct(
32+
Context $context,
33+
SubscriptionStatusProvider $labelStatusProvider,
34+
array $data = []
35+
) {
36+
parent::__construct($context, $data);
37+
$this->subscriptionStatusProvider = $labelStatusProvider;
38+
}
39+
40+
/**
41+
* Add Subscription status to comment
42+
*
43+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
44+
* @return string
45+
*/
46+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
47+
{
48+
$element->setData(
49+
'comment',
50+
$this->prepareLabelValue()
51+
);
52+
return parent::render($element);
53+
}
54+
55+
/**
56+
* Prepare label for subscription status
57+
*
58+
* @return string
59+
*/
60+
private function prepareLabelValue()
61+
{
62+
return __('Subscription status') . ': ' . __($this->subscriptionStatusProvider->getStatus());
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Block\Adminhtml\System\Config;
7+
8+
/**
9+
* Provides vertical select with additional information and style customization
10+
*/
11+
class Vertical extends \Magento\Config\Block\System\Config\Form\Field
12+
{
13+
/**
14+
* @inheritdoc
15+
*/
16+
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
17+
{
18+
$html = '<div class="config-vertical-title">' . $element->getHint() . '</div>';
19+
$html .= '<div class="config-vertical-comment">' . $element->getComment() . '</div>';
20+
return $this->decorateRowHtml($element, $html);
21+
}
22+
23+
/**
24+
* Decorates row HTML for custom element style
25+
*
26+
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
27+
* @param string $html
28+
* @return string
29+
*/
30+
private function decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
31+
{
32+
$rowHtml = sprintf('<tr><td colspan="4">%s</td></tr>', $html);
33+
$rowHtml .= sprintf(
34+
'<tr id="row_%s"><td class="label config-vertical-label">%s</td><td class="value">%s</td></tr>',
35+
$element->getHtmlId(),
36+
$element->getLabelHtml($element->getHtmlId(), "[WEBSITE]"),
37+
$element->getElementHtml()
38+
);
39+
return $rowHtml;
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Controller\Adminhtml\BIEssentials;
7+
8+
use Magento\Backend\App\Action;
9+
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
11+
12+
/**
13+
* Class SignUp
14+
*
15+
* Provides link to BI Essentials signup
16+
*/
17+
class SignUp extends Action
18+
{
19+
/**
20+
* Path to config value with URL to BI Essentials sign-up page.
21+
*
22+
* @var string
23+
*/
24+
private $urlBIEssentialsConfigPath = 'analytics/url/bi_essentials';
25+
26+
/**
27+
* @var ScopeConfigInterface
28+
*/
29+
private $config;
30+
31+
/**
32+
* @param Context $context
33+
* @param ScopeConfigInterface $config
34+
*/
35+
public function __construct(
36+
Context $context,
37+
ScopeConfigInterface $config
38+
) {
39+
$this->config = $config;
40+
parent::__construct($context);
41+
}
42+
43+
/**
44+
* Check admin permissions for this controller
45+
*
46+
* @return boolean
47+
*/
48+
protected function _isAllowed()
49+
{
50+
return $this->_authorization->isAllowed('Magento_Analytics::bi_essentials');
51+
}
52+
53+
/**
54+
* Provides link to BI Essentials signup
55+
*
56+
* @return \Magento\Framework\Controller\AbstractResult
57+
*/
58+
public function execute()
59+
{
60+
return $this->resultRedirectFactory->create()->setUrl(
61+
$this->config->getValue($this->urlBIEssentialsConfigPath)
62+
);
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Analytics\Controller\Adminhtml\Reports;
7+
8+
use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
9+
use Magento\Analytics\Model\ReportUrlProvider;
10+
use Magento\Backend\App\Action;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\Framework\Controller\Result\Redirect;
13+
use Magento\Framework\Controller\ResultFactory;
14+
use Magento\Framework\Exception\LocalizedException;
15+
16+
/**
17+
* Provide redirect to resource with reports.
18+
*/
19+
class Show extends Action
20+
{
21+
/**
22+
* @var ReportUrlProvider
23+
*/
24+
private $reportUrlProvider;
25+
26+
/**
27+
* @param Context $context
28+
* @param ReportUrlProvider $reportUrlProvider
29+
*/
30+
public function __construct(
31+
Context $context,
32+
ReportUrlProvider $reportUrlProvider
33+
) {
34+
$this->reportUrlProvider = $reportUrlProvider;
35+
parent::__construct($context);
36+
}
37+
38+
/**
39+
* Check admin permissions for this controller.
40+
*
41+
* @return boolean
42+
*/
43+
protected function _isAllowed()
44+
{
45+
return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings');
46+
}
47+
48+
/**
49+
* Redirect to resource with reports.
50+
*
51+
* @return Redirect $resultRedirect
52+
*/
53+
public function execute()
54+
{
55+
/** @var Redirect $resultRedirect */
56+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
57+
try {
58+
$resultRedirect->setUrl($this->reportUrlProvider->getUrl());
59+
} catch (SubscriptionUpdateException $e) {
60+
$this->getMessageManager()->addNoticeMessage($e->getMessage());
61+
$resultRedirect->setPath('adminhtml');
62+
} catch (LocalizedException $e) {
63+
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
64+
$resultRedirect->setPath('adminhtml');
65+
} catch (\Exception $e) {
66+
$this->getMessageManager()->addExceptionMessage(
67+
$e,
68+
__('Sorry, there has been an error processing your request. Please try again later.')
69+
);
70+
$resultRedirect->setPath('adminhtml');
71+
}
72+
73+
return $resultRedirect;
74+
}
75+
}

0 commit comments

Comments
 (0)