Skip to content

Commit

Permalink
Merge pull request #1670 from magento-arcticfoxes/MAGETWO-83013-Relea…
Browse files Browse the repository at this point in the history
…seNotification

[Arctic Foxes] Advanced Reporting and Release Notification Pull Request
  • Loading branch information
cpartica authored Nov 9, 2017
2 parents d521c40 + 268a655 commit fd8dcad
Show file tree
Hide file tree
Showing 309 changed files with 21,117 additions and 361 deletions.
24 changes: 24 additions & 0 deletions app/code/Magento/Analytics/Api/Data/LinkInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Api\Data;

/**
* Interface LinkInterface
*
* Represents link with collected data and initialized vector for decryption.
*/
interface LinkInterface
{
/**
* @return string
*/
public function getUrl();

/**
* @return string
*/
public function getInitializationVector();
}
17 changes: 17 additions & 0 deletions app/code/Magento/Analytics/Api/LinkProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Api;

/**
* Provides link to file with collected report data.
*/
interface LinkProviderInterface
{
/**
* @return \Magento\Analytics\Api\Data\LinkInterface
*/
public function get();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Block\Adminhtml\System\Config;

/**
* Provides field with additional information
*/
class AdditionalComment extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = '<div class="config-additional-comment-title">' . $element->getLabel() . '</div>';
$html .= '<div class="config-additional-comment-content">' . $element->getComment() . '</div>';
return $this->decorateRowHtml($element, $html);
}

/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param string $html
* @return string
*/
private function decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
{
return sprintf(
'<tr id="row_%s"><td colspan="3"><div class="config-additional-comment">%s</div></td></tr>',
$element->getHtmlId(),
$html
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Block\Adminhtml\System\Config;

/**
* Provides label with default Time Zone
*/
class CollectionTimeLabel extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Add default time zone to comment
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$timeZoneCode = $this->_localeDate->getConfigTimezone();
$getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName();
$element->setData(
'comment',
sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode)
);
return parent::render($element);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Block\Adminhtml\System\Config;

use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Backend\Block\Template\Context;

/**
* Class SubscriptionStatusLabel.
*
* Provides labels for subscription status
* Status can be reviewed in System Configuration
*/
class SubscriptionStatusLabel extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var SubscriptionStatusProvider
*/
private $subscriptionStatusProvider;

/**
* SubscriptionStatusLabel constructor.
*
* @param Context $context
* @param SubscriptionStatusProvider $labelStatusProvider
* @param array $data
*/
public function __construct(
Context $context,
SubscriptionStatusProvider $labelStatusProvider,
array $data = []
) {
parent::__construct($context, $data);
$this->subscriptionStatusProvider = $labelStatusProvider;
}

/**
* Add Subscription status to comment
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$element->setData(
'comment',
$this->prepareLabelValue()
);
return parent::render($element);
}

/**
* Prepare label for subscription status
*
* @return string
*/
private function prepareLabelValue()
{
return __('Subscription status') . ': ' . __($this->subscriptionStatusProvider->getStatus());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Block\Adminhtml\System\Config;

/**
* Provides vertical select with additional information and style customization
*/
class Vertical extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @inheritdoc
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = '<div class="config-vertical-title">' . $element->getHint() . '</div>';
$html .= '<div class="config-vertical-comment">' . $element->getComment() . '</div>';
return $this->decorateRowHtml($element, $html);
}

/**
* Decorates row HTML for custom element style
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @param string $html
* @return string
*/
private function decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html)
{
$rowHtml = sprintf('<tr><td colspan="4">%s</td></tr>', $html);
$rowHtml .= sprintf(
'<tr id="row_%s"><td class="label config-vertical-label">%s</td><td class="value">%s</td></tr>',
$element->getHtmlId(),
$element->getLabelHtml($element->getHtmlId(), "[WEBSITE]"),
$element->getElementHtml()
);
return $rowHtml;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Controller\Adminhtml\BIEssentials;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Class SignUp
*
* Provides link to BI Essentials signup
*/
class SignUp extends Action
{
/**
* Path to config value with URL to BI Essentials sign-up page.
*
* @var string
*/
private $urlBIEssentialsConfigPath = 'analytics/url/bi_essentials';

/**
* @var ScopeConfigInterface
*/
private $config;

/**
* @param Context $context
* @param ScopeConfigInterface $config
*/
public function __construct(
Context $context,
ScopeConfigInterface $config
) {
$this->config = $config;
parent::__construct($context);
}

/**
* Check admin permissions for this controller
*
* @return boolean
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Magento_Analytics::bi_essentials');
}

/**
* Provides link to BI Essentials signup
*
* @return \Magento\Framework\Controller\AbstractResult
*/
public function execute()
{
return $this->resultRedirectFactory->create()->setUrl(
$this->config->getValue($this->urlBIEssentialsConfigPath)
);
}
}
75 changes: 75 additions & 0 deletions app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Controller\Adminhtml\Reports;

use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Analytics\Model\ReportUrlProvider;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;

/**
* Provide redirect to resource with reports.
*/
class Show extends Action
{
/**
* @var ReportUrlProvider
*/
private $reportUrlProvider;

/**
* @param Context $context
* @param ReportUrlProvider $reportUrlProvider
*/
public function __construct(
Context $context,
ReportUrlProvider $reportUrlProvider
) {
$this->reportUrlProvider = $reportUrlProvider;
parent::__construct($context);
}

/**
* Check admin permissions for this controller.
*
* @return boolean
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings');
}

/**
* Redirect to resource with reports.
*
* @return Redirect $resultRedirect
*/
public function execute()
{
/** @var Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try {
$resultRedirect->setUrl($this->reportUrlProvider->getUrl());
} catch (SubscriptionUpdateException $e) {
$this->getMessageManager()->addNoticeMessage($e->getMessage());
$resultRedirect->setPath('adminhtml');
} catch (LocalizedException $e) {
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
$resultRedirect->setPath('adminhtml');
} catch (\Exception $e) {
$this->getMessageManager()->addExceptionMessage(
$e,
__('Sorry, there has been an error processing your request. Please try again later.')
);
$resultRedirect->setPath('adminhtml');
}

return $resultRedirect;
}
}
Loading

0 comments on commit fd8dcad

Please sign in to comment.