-
Notifications
You must be signed in to change notification settings - Fork 24
Feed the Symfony dashboard's Zone One hook with KPIs and a chart, add a settings page #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicosomb
wants to merge
7
commits into
dev
Choose a base branch
from
feature/41971-zone-one-poc
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b8dbacb
Feed the Symfony dashboard's Zone One hook with KPIs and a chart, add…
nicosomb 6343bc4
Mark the module as configurable in config.xml, now that it has a sett…
nicosomb e3c46a4
Reset phpVersion in PHPStan config to avoid crashing on CI's PHP 8.5 …
nicosomb 2cf5306
Use the Card/ChartCard Twig components instead of the dashboard partials
nicosomb b3c65c6
Bump to 3.0.0, replace @DemoRestricted with a manual demo-mode check
nicosomb 7cd5fb9
Fix the abandoned cart delay unit (minutes, not hours), rename the up…
nicosomb 0a8b3a8
Correct the legacy abandoned cart default and show hour equivalents i…
nicosomb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
| /** | ||
| * Copyright since 2007 PrestaShop SA and Contributors | ||
| * PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
| * | ||
| * NOTICE OF LICENSE | ||
| * | ||
| * This source file is subject to the Academic Free License 3.0 (AFL-3.0) | ||
| * that is bundled with this package in the file LICENSE.md. | ||
| * It is also available through the world-wide-web at this URL: | ||
| * https://opensource.org/licenses/AFL-3.0 | ||
| * If you did not receive a copy of the license and are unable to | ||
| * obtain it through the world-wide-web, please send an email | ||
| * to license@prestashop.com so we can send you a copy immediately. | ||
| * | ||
| * DISCLAIMER | ||
| * | ||
| * Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
| * versions in the future. If you wish to customize PrestaShop for your | ||
| * needs please refer to https://devdocs.prestashop.com/ for more information. | ||
| * | ||
| * @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
| * @copyright Since 2007 PrestaShop SA and Contributors | ||
| * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) | ||
| */ | ||
| header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
| header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
|
|
||
| header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
| header('Cache-Control: post-check=0, pre-check=0', false); | ||
| header('Pragma: no-cache'); | ||
|
|
||
| header('Location: ../'); | ||
| exit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| dashactivity_configuration: | ||
| path: /dashactivity/configuration | ||
| methods: [GET, POST] | ||
| defaults: | ||
| _controller: PrestaShop\Module\DashActivity\Controller\ConfigurationController::indexAction | ||
| _legacy_controller: AdminDashactivityConfiguration | ||
| _legacy_link: AdminDashactivityConfiguration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| services: | ||
| PrestaShop\Module\DashActivity\Controller\ConfigurationController: | ||
| public: true | ||
| autowire: true | ||
| autoconfigure: true | ||
|
|
||
| PrestaShop\Module\DashActivity\Type\ConfigurationType: | ||
| autowire: true | ||
| autoconfigure: true | ||
| tags: ['form.type'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| <?php | ||
| /** | ||
| * Copyright since 2007 PrestaShop SA and Contributors | ||
| * PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
| * | ||
| * This source file is subject to the Academic Free License 3.0 (AFL-3.0) | ||
| * that is bundled with this package in the file LICENSE.md. | ||
| * It is also available through the world-wide-web at this URL: | ||
| * https://opensource.org/licenses/AFL-3.0 | ||
| * | ||
| * @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
| * @copyright Since 2007 PrestaShop SA and Contributors | ||
| * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PrestaShop\Module\DashActivity\Controller; | ||
|
|
||
| use Configuration; | ||
| use PrestaShop\Module\DashActivity\Type\ConfigurationType; | ||
| // FrameworkBundleAdminController is deprecated since 9.0 in favor of PrestaShopAdminController, | ||
| // which doesn't exist on PS 8.2 — kept for the module's declared 8.2+ compatibility. | ||
| use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; | ||
| use PrestaShopBundle\Security\Annotation\AdminSecurity; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class ConfigurationController extends FrameworkBundleAdminController | ||
| { | ||
| private const FIELDS = [ | ||
| 'DASHACTIVITY_CART_ACTIVE', | ||
| 'DASHACTIVITY_VISITOR_ONLINE', | ||
| 'DASHACTIVITY_CART_ABANDONED_MIN', | ||
| 'DASHACTIVITY_CART_ABANDONED_MAX', | ||
| ]; | ||
|
|
||
| // Every install() before 3.0.0 set these two exact values, meant as hours (the free-text | ||
| // field's own former label) though always read back as minutes — never anything else, since | ||
| // no UI let a merchant change them before this settings page existed. | ||
| private const LEGACY_ABANDONED_CART_MIN_DEFAULT = 24; | ||
| private const LEGACY_ABANDONED_CART_MAX_DEFAULT = 48; | ||
|
|
||
| /** | ||
| * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") | ||
| */ | ||
| public function indexAction(Request $request): Response | ||
|
mattgoud marked this conversation as resolved.
|
||
| { | ||
| $data = []; | ||
| foreach (self::FIELDS as $field) { | ||
| $data[$field] = (int) Configuration::get($field); | ||
| } | ||
|
|
||
| // Correct the known pre-3.0.0 default to what it always meant (1440 min = 24h, 2880 min | ||
| // = 48h) for display only: nothing is written back unless the merchant saves the form. | ||
| if (self::LEGACY_ABANDONED_CART_MIN_DEFAULT === $data['DASHACTIVITY_CART_ABANDONED_MIN']) { | ||
| $data['DASHACTIVITY_CART_ABANDONED_MIN'] = 1440; | ||
| } | ||
| if (self::LEGACY_ABANDONED_CART_MAX_DEFAULT === $data['DASHACTIVITY_CART_ABANDONED_MAX']) { | ||
| $data['DASHACTIVITY_CART_ABANDONED_MAX'] = 2880; | ||
| } | ||
|
|
||
| $form = $this->createForm(ConfigurationType::class, $data); | ||
| $form->handleRequest($request); | ||
|
|
||
| if ($form->isSubmitted() && $form->isValid()) { | ||
| $this->denyAccessUnlessGranted('update', $request->attributes->get('_legacy_controller')); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment than here : PrestaShop/dashproducts#78 (comment) |
||
|
|
||
| // No @DemoRestricted attribute here: its listener only recognizes the PHP 8 | ||
| // attribute form (PrestaShopBundle\Security\Attribute\DemoRestricted), which | ||
| // doesn't exist on PS 8.2 — this module's declared minimum version. | ||
| if ($this->isDemoModeEnabled()) { | ||
| $this->addFlash('error', $this->trans('This functionality has been disabled.', 'Admin.Notifications.Error')); | ||
|
|
||
| return $this->redirectToRoute('dashactivity_configuration'); | ||
| } | ||
|
|
||
| foreach ($form->getData() as $field => $value) { | ||
| Configuration::updateValue($field, (int) $value); | ||
| } | ||
| $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); | ||
|
|
||
| return $this->redirectToRoute('dashactivity_configuration'); | ||
| } | ||
|
|
||
| return $this->render('@Modules/dashactivity/views/templates/admin/configuration.html.twig', [ | ||
| 'configurationForm' => $form->createView(), | ||
| 'enableSidebar' => true, | ||
| 'help_link' => $this->generateSidebarLink('AdminDashactivityConfiguration'), | ||
| ]); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.