-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/cc-34041/dev-quick-sight-mvp' into feature/cc-3…
…4041/cc-34137-extend-user-transfer
- Loading branch information
Showing
12 changed files
with
393 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,3 @@ | ||
"Author: A user who can create data sources, datasets, analyses, and dashboards. <br/>Reader: A user who has read-only access to dashboards.","Autor: Ein Benutzer, der Datenquellen, Datensätze, Analysen und Dashboards erstellen kann. <br/>Leser: Ein Benutzer, der nur Lesezugriff auf Dashboards hat." | ||
"Select user role","Benutzerrolle auswählen" | ||
Analytics,Analytics |
This file contains 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,3 @@ | ||
"Author: A user who can create data sources, datasets, analyses, and dashboards. <br/>Reader: A user who has read-only access to dashboards.","Author: A user who can create data sources, datasets, analyses, and dashboards. <br/>Reader: A user who has read-only access to dashboards." | ||
"Select user role","Select user role" | ||
Analytics,Analytics |
This file contains 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 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
51 changes: 51 additions & 0 deletions
51
...kerEco/Zed/AmazonQuicksight/Communication/DataProvider/QuicksightUserFormDataProvider.php
This file contains 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,51 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Communication\DataProvider; | ||
|
||
use SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig; | ||
|
||
class QuicksightUserFormDataProvider implements QuicksightUserFormDataProviderInterface | ||
{ | ||
/** | ||
* @var \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig | ||
*/ | ||
protected AmazonQuicksightConfig $amazonQuicksightConfig; | ||
|
||
/** | ||
* @param \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig $amazonQuicksightConfig | ||
*/ | ||
public function __construct(AmazonQuicksightConfig $amazonQuicksightConfig) | ||
{ | ||
$this->amazonQuicksightConfig = $amazonQuicksightConfig; | ||
} | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getQuicksightUserRoleChoices(): array | ||
{ | ||
$quicksightUserRoles = $this->amazonQuicksightConfig->getQuicksightUserRoles(); | ||
|
||
return array_combine( | ||
$this->formatQuicksightUserRoleChoiceLabels($quicksightUserRoles), | ||
$quicksightUserRoles, | ||
); | ||
} | ||
|
||
/** | ||
* @param list<string> $quicksightUserRoles | ||
* | ||
* @return list<string> | ||
*/ | ||
protected function formatQuicksightUserRoleChoiceLabels(array $quicksightUserRoles): array | ||
{ | ||
return array_map(function ($quicksightUserRole) { | ||
return ucfirst(strtolower($quicksightUserRole)); | ||
}, $quicksightUserRoles); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...d/AmazonQuicksight/Communication/DataProvider/QuicksightUserFormDataProviderInterface.php
This file contains 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,16 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Communication\DataProvider; | ||
|
||
interface QuicksightUserFormDataProviderInterface | ||
{ | ||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getQuicksightUserRoleChoices(): array; | ||
} |
105 changes: 105 additions & 0 deletions
105
src/SprykerEco/Zed/AmazonQuicksight/Communication/Expander/QuicksightUserFormExpander.php
This file contains 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,105 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Communication\Expander; | ||
|
||
use SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig; | ||
use SprykerEco\Zed\AmazonQuicksight\Communication\DataProvider\QuicksightUserFormDataProviderInterface; | ||
use Symfony\Component\Form\DataTransformerInterface; | ||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Form\FormEvent; | ||
use Symfony\Component\Form\FormEvents; | ||
|
||
class QuicksightUserFormExpander implements QuicksightUserFormExpanderInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected const FIELD_QUICKSIGHT_USER_ROLE = 'quicksight_user_role'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const PLACEHOLDER_QUICKSIGHT_USER_ROLE = 'Select user role'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const HELP_MESSAGE_QUICKSIGHT_USER_ROLE = 'Author: A user who can create data sources, datasets, analyses, and dashboards. <br/>Reader: A user who has read-only access to dashboards.'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const TEMPLATE_PATH_QUICKSIGHT_USER_ROLE = '@AmazonQuicksight/_partials/user-form-quicksight-user-role-field.twig'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const KEY_QUICKSIGHT_USER = 'quicksight_user'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const KEY_ROLE = 'role'; | ||
|
||
/** | ||
* @var \Symfony\Component\Form\DataTransformerInterface<array<string, mixed>, array<string, mixed>> | ||
*/ | ||
protected DataTransformerInterface $quicksightUserRoleDataTransformer; | ||
|
||
/** | ||
* @var \SprykerEco\Zed\AmazonQuicksight\Communication\DataProvider\QuicksightUserFormDataProviderInterface | ||
*/ | ||
protected QuicksightUserFormDataProviderInterface $quicksightUserFormDataProvider; | ||
|
||
/** | ||
* @var \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig | ||
*/ | ||
protected AmazonQuicksightConfig $amazonQuicksightConfig; | ||
|
||
/** | ||
* @param \Symfony\Component\Form\DataTransformerInterface<array<string, mixed>, array<string, mixed>> $quicksightUserRoleDataTransformer | ||
* @param \SprykerEco\Zed\AmazonQuicksight\Communication\DataProvider\QuicksightUserFormDataProviderInterface $quicksightUserFormDataProvider | ||
* @param \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig $amazonQuicksightConfig | ||
*/ | ||
public function __construct( | ||
DataTransformerInterface $quicksightUserRoleDataTransformer, | ||
QuicksightUserFormDataProviderInterface $quicksightUserFormDataProvider, | ||
AmazonQuicksightConfig $amazonQuicksightConfig | ||
) { | ||
$this->quicksightUserRoleDataTransformer = $quicksightUserRoleDataTransformer; | ||
$this->quicksightUserFormDataProvider = $quicksightUserFormDataProvider; | ||
$this->amazonQuicksightConfig = $amazonQuicksightConfig; | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\Form\FormBuilderInterface $builder | ||
* | ||
* @return void | ||
*/ | ||
public function expandForm(FormBuilderInterface $builder): void | ||
{ | ||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { | ||
$data = $event->getData(); | ||
$quicksightUserRole = $data[static::KEY_QUICKSIGHT_USER][static::KEY_ROLE] ?? null; | ||
|
||
$event->getForm()->add(static::FIELD_QUICKSIGHT_USER_ROLE, ChoiceType::class, [ | ||
'required' => false, | ||
'choices' => $this->quicksightUserFormDataProvider->getQuicksightUserRoleChoices(), | ||
'placeholder' => static::PLACEHOLDER_QUICKSIGHT_USER_ROLE, | ||
'attr' => [ | ||
'template_path' => static::TEMPLATE_PATH_QUICKSIGHT_USER_ROLE, | ||
'disabled' => $quicksightUserRole && !$this->amazonQuicksightConfig->isQuicksightUserRoleUpdateEnabled(), | ||
], | ||
'help' => static::HELP_MESSAGE_QUICKSIGHT_USER_ROLE, | ||
]); | ||
}); | ||
|
||
$builder->addModelTransformer($this->quicksightUserRoleDataTransformer); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...erEco/Zed/AmazonQuicksight/Communication/Expander/QuicksightUserFormExpanderInterface.php
This file contains 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,20 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Communication\Expander; | ||
|
||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
interface QuicksightUserFormExpanderInterface | ||
{ | ||
/** | ||
* @param \Symfony\Component\Form\FormBuilderInterface<string, \Symfony\Component\Form\FormBuilderInterface> $builder | ||
* | ||
* @return void | ||
*/ | ||
public function expandForm(FormBuilderInterface $builder): void; | ||
} |
37 changes: 37 additions & 0 deletions
37
...d/AmazonQuicksight/Communication/Plugin/User/QuicksightUserRoleUserFormExpanderPlugin.php
This file contains 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,37 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Communication\Plugin\User; | ||
|
||
use Spryker\Zed\Kernel\Communication\AbstractPlugin; | ||
use Spryker\Zed\UserExtension\Dependency\Plugin\UserFormExpanderPluginInterface; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
/** | ||
* @method \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig getConfig() | ||
* @method \SprykerEco\Zed\AmazonQuicksight\Business\AmazonQuicksightFacadeInterface getFacade() | ||
* @method \SprykerEco\Zed\AmazonQuicksight\Communication\AmazonQuicksightCommunicationFactory getFactory() | ||
*/ | ||
class QuicksightUserRoleUserFormExpanderPlugin extends AbstractPlugin implements UserFormExpanderPluginInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
* - Expands user form with Quicksight user role field. | ||
* | ||
* @api | ||
* | ||
* @param \Symfony\Component\Form\FormBuilderInterface $builder | ||
* | ||
* @return void | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder): void | ||
{ | ||
$this->getFactory() | ||
->createQuicksightUserFormExpander() | ||
->expandForm($builder); | ||
} | ||
} |
Oops, something went wrong.