From e8a4c26d4b9c1f97b638078b1e3032de239ea3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Thu, 12 Dec 2024 15:17:19 +0100 Subject: [PATCH 01/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. --- config/services/twig.yaml | 20 +++++++++ src/Controller/Admin/Process/LaunchAction.php | 45 ++++++++++++++----- src/Manager/ProcessConfigurationsManager.php | 4 ++ src/Twig/Components/BootstrapModal.php | 20 +++++++++ src/Twig/Extension/ProcessExtension.php | 31 +++++++++++++ src/Twig/Runtime/ProcessExtensionRuntime.php | 27 +++++++++++ templates/admin/process/list.html.twig | 19 ++++++-- templates/components/BootstrapModal.html.twig | 37 +++++++++++++++ 8 files changed, 190 insertions(+), 13 deletions(-) create mode 100644 src/Twig/Components/BootstrapModal.php create mode 100644 src/Twig/Extension/ProcessExtension.php create mode 100644 src/Twig/Runtime/ProcessExtensionRuntime.php create mode 100644 templates/components/BootstrapModal.html.twig diff --git a/config/services/twig.yaml b/config/services/twig.yaml index 73ecf30..4f54954 100644 --- a/config/services/twig.yaml +++ b/config/services/twig.yaml @@ -17,6 +17,12 @@ services: tags: - { name: 'twig.extension' } + cleverage_ui_process.twig.process_extension: + class: CleverAge\UiProcessBundle\Twig\Extension\ProcessExtension + public: false + tags: + - { name: 'twig.extension' } + cleverage_ui_process.twig.log_level_extension_runtime: class: CleverAge\UiProcessBundle\Twig\Runtime\LogLevelExtensionRuntime public: false @@ -37,3 +43,17 @@ services: arguments: - '@cleverage_ui_process.repository.process_execution' - '@cleverage_ui_process.manager.process_configuration' + + cleverage_ui_process.twig.process_extension_runtime: + class: CleverAge\UiProcessBundle\Twig\Runtime\ProcessExtensionRuntime + public: false + tags: + - { name: 'twig.runtime' } + arguments: + - '@cleverage_ui_process.manager.process_configuration' + + cleverage_ui_process.twig.component.bootstrap_modal: + class: CleverAge\UiProcessBundle\Twig\Components\BootstrapModal + shared: false + tags: + - { name: 'twig.component', key: 'ui:BootstrapModal', template: '@CleverAgeUiProcess/components/BootstrapModal.html.twig' } \ No newline at end of file diff --git a/src/Controller/Admin/Process/LaunchAction.php b/src/Controller/Admin/Process/LaunchAction.php index 9c59c6f..149f92c 100644 --- a/src/Controller/Admin/Process/LaunchAction.php +++ b/src/Controller/Admin/Process/LaunchAction.php @@ -13,6 +13,7 @@ namespace CleverAge\UiProcessBundle\Controller\Admin\Process; +use CleverAge\ProcessBundle\Exception\MissingProcessException; use CleverAge\UiProcessBundle\Entity\User; use CleverAge\UiProcessBundle\Form\Type\LaunchType; use CleverAge\UiProcessBundle\Manager\ProcessConfigurationsManager; @@ -39,20 +40,36 @@ #[IsGranted('ROLE_USER')] class LaunchAction extends AbstractController { + public function __construct(private readonly MessageBusInterface $messageBus) + { + } + public function __invoke( RequestStack $requestStack, - MessageBusInterface $messageBus, string $uploadDirectory, ProcessConfigurationsManager $processConfigurationsManager, AdminContext $context, ): Response { - $uiOptions = $processConfigurationsManager->getUiOptions($requestStack->getMainRequest()?->get('process') ?? ''); + $processCode = $requestStack->getMainRequest()?->get('process'); + if (null === $processCode) { + throw new MissingProcessException(); + } + $uiOptions = $processConfigurationsManager->getUiOptions($processCode); + if (false === $uiOptions['input_context_launcher_form']) { + $this->dispatch($processCode); + $this->addFlash( + 'success', + 'Process has been added to queue. It will start as soon as possible' + ); + + return $this->redirectToRoute('process', ['routeName' => 'process_list']); + } $form = $this->createForm( LaunchType::class, null, [ 'constraints' => $uiOptions['constraints'] ?? [], - 'process_code' => $requestStack->getMainRequest()?->get('process'), + 'process_code' => $processCode, ] ); if (false === $form->isSubmitted()) { @@ -72,16 +89,11 @@ public function __invoke( (new Filesystem())->dumpFile($filename, $input->getContent()); $input = $filename; } - - $message = new ProcessExecuteMessage( + $this->dispatch( $form->getConfig()->getOption('process_code'), $input, - array_merge( - ['execution_user' => $this->getUser()?->getEmail()], - $form->get('context')->getData() - ) + $form->get('context')->getData() ); - $messageBus->dispatch($message); $this->addFlash( 'success', 'Process has been added to queue. It will start as soon as possible' @@ -99,6 +111,19 @@ public function __invoke( ); } + protected function dispatch(string $processCode, mixed $input = null, array $context = []): void + { + $message = new ProcessExecuteMessage( + $processCode, + $input, + array_merge( + ['execution_user' => $this->getUser()?->getEmail()], + $context + ) + ); + $this->messageBus->dispatch($message); + } + protected function getUser(): ?User { /** @var User $user */ diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 82dc3db..0347f1a 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -57,6 +57,8 @@ private function resolveUiOptions(array $options): array 'source' => null, 'target' => null, 'entrypoint_type' => 'text', + 'input_context_launcher_form' => false, + 'run_confirmation_modal' => false, 'constraints' => [], 'run' => null, 'default' => function (OptionsResolver $defaultResolver) { @@ -76,6 +78,8 @@ private function resolveUiOptions(array $options): array ); $uiResolver->setAllowedValues('entrypoint_type', ['text', 'file']); $uiResolver->setNormalizer('constraints', fn (Options $options, array $values): array => (new ConstraintLoader())->buildConstraints($values)); + $uiResolver->setAllowedTypes('input_context_launcher_form', ['bool']); + $uiResolver->setAllowedTypes('run_confirmation_modal', ['bool']); }); return $resolver->resolve($options); diff --git a/src/Twig/Components/BootstrapModal.php b/src/Twig/Components/BootstrapModal.php new file mode 100644 index 0000000..1e8c362 --- /dev/null +++ b/src/Twig/Components/BootstrapModal.php @@ -0,0 +1,20 @@ +processConfigurationsManager->getUiOptions($code) ?? []; + } +} diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index ca09098..417567b 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -21,6 +21,7 @@ {# @var process \CleverAge\ProcessBundle\Configuration\ProcessConfiguration #} {% for process in processes %} {% set lastExecution = get_last_execution_date(process.code) %} + {% set uiOptions = resolve_ui_options(process.code) %} {% set statusClass = '' %} {% if lastExecution is not null %} {% set statusClass = lastExecution.status.value == 'failed' ? 'danger' : 'success' %} @@ -32,9 +33,15 @@ {% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %} {% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %} - - - + {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} + + + + {% else %} + + + + {% endif %} + {% endfor %} {% endblock %} diff --git a/templates/components/BootstrapModal.html.twig b/templates/components/BootstrapModal.html.twig new file mode 100644 index 0000000..c7976d0 --- /dev/null +++ b/templates/components/BootstrapModal.html.twig @@ -0,0 +1,37 @@ +
+ +
\ No newline at end of file From 85f31454b0b9896022f75a441705c47b9e860b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 14:46:16 +0100 Subject: [PATCH 02/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. Update doc --- docs/index.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/index.md b/docs/index.md index 0966b94..e6d3950 100644 --- a/docs/index.md +++ b/docs/index.md @@ -33,6 +33,16 @@ Now you can access UI Process via http://your-domain.com/process ## Features +### Launch process via UI +From UI "Process List" menu entry you can run a process by clicking on "Rocket" action. +You can manage this behaviour by setting some ui options on process configuration ui option. + +| Options | Values | UI behaviour | +|----------------------------------|----------------|:---------:| +| input_context_launcher_form
run_confirmation_modal | false
false | Run process without any confirmation +| input_context_launcher_form
run_confirmation_modal | true
false | On click, open a form to set input and context execution +| input_context_launcher_form
run_confirmation_modal | false
true | On click, open confirmation model to confirm process execution + ### Launch process via http request You can launch a process via http post request First you need to generate a token via UI User edit form. The UiProcess generate for you a auth token (keep it in secured area, it will display once). From c9df4005b9414d15e6963fad4407450ac9dbb36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 15:02:55 +0100 Subject: [PATCH 03/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. Twig cs fixer --- templates/admin/process/list.html.twig | 2 +- templates/components/BootstrapModal.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index 417567b..e655794 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -33,7 +33,7 @@ {% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %} {% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %} - {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} + {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} diff --git a/templates/components/BootstrapModal.html.twig b/templates/components/BootstrapModal.html.twig index c7976d0..9c226de 100644 --- a/templates/components/BootstrapModal.html.twig +++ b/templates/components/BootstrapModal.html.twig @@ -34,4 +34,4 @@ {% endblock %} - \ No newline at end of file + From 1ee039bd429252b2a4ea1e9d3c91cbae9c5bc62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Fri, 13 Dec 2024 10:01:52 +0100 Subject: [PATCH 04/16] #14 Quality. Phpstan remove - '#type has no value type specified in iterable type#' - '#has parameter .* with no value type specified in iterable type#' - '#has no value type specified in iterable type array#' - '#configureOptions\(\) has no return type specified.#' - '#configure\(\) has no return type specified#' - '#process\(\) has no return type specified#' - '#should return Iterator but returns Traversable#' - '#Negated boolean expression is always false#' --- phpstan.neon | 8 -------- src/Admin/Filter/LogProcessFilter.php | 3 +++ src/Entity/ProcessExecution.php | 18 ++++++++++++++++- src/Entity/ProcessSchedule.php | 9 +++++++++ src/Entity/User.php | 3 +++ src/Http/Model/HttpProcessExecution.php | 3 +++ .../HttpProcessExecuteValueResolver.php | 3 +++ .../ProcessConfigurationValueResolver.php | 4 ++++ src/Manager/ProcessConfigurationsManager.php | 20 +++++++++++++++++++ src/Message/ProcessExecuteMessage.php | 3 +++ 10 files changed, 65 insertions(+), 9 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index fbfff5e..8b167d3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,14 +6,6 @@ parameters: excludePaths: - src/DependencyInjection/Configuration.php ignoreErrors: - - '#type has no value type specified in iterable type#' - - '#has parameter .* with no value type specified in iterable type#' - - '#has no value type specified in iterable type array#' - - '#configureOptions\(\) has no return type specified.#' - - '#configure\(\) has no return type specified#' - - '#process\(\) has no return type specified#' - - '#should return Iterator but returns Traversable#' - - '#Negated boolean expression is always false#' - identifier: missingType.generics - diff --git a/src/Admin/Filter/LogProcessFilter.php b/src/Admin/Filter/LogProcessFilter.php index c11c74e..15aac0e 100644 --- a/src/Admin/Filter/LogProcessFilter.php +++ b/src/Admin/Filter/LogProcessFilter.php @@ -26,6 +26,9 @@ class LogProcessFilter implements FilterInterface { use FilterTrait; + /** + * @param string[] $choices + */ public static function new( mixed $label, array $choices, diff --git a/src/Entity/ProcessExecution.php b/src/Entity/ProcessExecution.php index 2c51aa8..a924eda 100644 --- a/src/Entity/ProcessExecution.php +++ b/src/Entity/ProcessExecution.php @@ -40,9 +40,15 @@ class ProcessExecution implements \Stringable #[ORM\Column(type: Types::STRING, enumType: ProcessExecutionStatus::class)] public ProcessExecutionStatus $status = ProcessExecutionStatus::Started; + /** + * @var array + */ #[ORM\Column(type: Types::JSON)] private array $report = []; + /** + * @var array + */ #[ORM\Column(type: Types::JSON, nullable: true)] private ?array $context = []; @@ -51,9 +57,13 @@ public function getId(): ?int return $this->id; } + /** + * @param array $context + */ public function __construct( string $code, - #[ORM\Column(type: Types::STRING, length: 255)] public readonly string $logFilename, ?array $context = [], + #[ORM\Column(type: Types::STRING, length: 255)] public readonly string $logFilename, + ?array $context = [], ) { $this->code = (string) (new UnicodeString($code))->truncate(255); $this->startDate = \DateTimeImmutable::createFromMutable(new \DateTime()); @@ -104,11 +114,17 @@ public function getCode(): string return $this->code; } + /** + * @return array + */ public function getContext(): ?array { return $this->context; } + /** + * @param array $context + */ public function setContext(array $context): void { $this->context = $context; diff --git a/src/Entity/ProcessSchedule.php b/src/Entity/ProcessSchedule.php index 5eed3d6..0637a4a 100644 --- a/src/Entity/ProcessSchedule.php +++ b/src/Entity/ProcessSchedule.php @@ -48,6 +48,9 @@ class ProcessSchedule #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $input = null; + /** + * @var string|array + */ #[ORM\Column(type: Types::JSON)] private string|array $context = []; @@ -68,11 +71,17 @@ public function setProcess(string $process): static return $this; } + /** + * @return array + */ public function getContext(): array { return \is_array($this->context) ? $this->context : json_decode($this->context); } + /** + * @param array $context + */ public function setContext(array $context): void { $this->context = $context; diff --git a/src/Entity/User.php b/src/Entity/User.php index b59be10..a5f680c 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -37,6 +37,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $lastname = null; + /** + * @var string[] + */ #[ORM\Column(type: Types::JSON)] private array $roles = []; diff --git a/src/Http/Model/HttpProcessExecution.php b/src/Http/Model/HttpProcessExecution.php index d6fbeea..fc4272f 100644 --- a/src/Http/Model/HttpProcessExecution.php +++ b/src/Http/Model/HttpProcessExecution.php @@ -19,6 +19,9 @@ final readonly class HttpProcessExecution { + /** + * @param array $context + */ public function __construct( #[Sequentially(constraints: [new NotNull(message: 'Process code is required.'), new IsValidProcessCode()])] public ?string $code = null, diff --git a/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php b/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php index 13d5584..5e2aafe 100644 --- a/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php +++ b/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php @@ -28,6 +28,9 @@ public function __construct(private string $storageDir) { } + /** + * @return iterable + */ public function resolve(Request $request, ArgumentMetadata $argument): iterable { $input = $request->get('input', $request->files->get('input')); diff --git a/src/Http/ValueResolver/ProcessConfigurationValueResolver.php b/src/Http/ValueResolver/ProcessConfigurationValueResolver.php index 3290d9b..bf88b84 100644 --- a/src/Http/ValueResolver/ProcessConfigurationValueResolver.php +++ b/src/Http/ValueResolver/ProcessConfigurationValueResolver.php @@ -13,6 +13,7 @@ namespace CleverAge\UiProcessBundle\Http\ValueResolver; +use CleverAge\ProcessBundle\Configuration\ProcessConfiguration; use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Attribute\AsTargetedValueResolver; @@ -26,6 +27,9 @@ public function __construct(private ProcessConfigurationRegistry $registry) { } + /** + * @return iterable + */ public function resolve(Request $request, ArgumentMetadata $argument): iterable { return [$this->registry->getProcessConfiguration($request->get('process'))]; diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 0347f1a..b784e71 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -18,7 +18,19 @@ use CleverAge\ProcessBundle\Validator\ConstraintLoader; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraint; +/** + * @template UiOptions of array{ + * 'source': ?string, + * 'target': ?string, + * 'entrypoint_type': 'text|file', + * 'constraints': Constraint[], + * 'run': 'null|bool', + * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} + * } + * @template UiOptionList of array {'ui': UiOptions} + */ final readonly class ProcessConfigurationsManager { public function __construct(private ProcessConfigurationRegistry $registry) @@ -37,6 +49,9 @@ public function getPrivateProcesses(): array return array_filter($this->getConfigurations(), fn (ProcessConfiguration $cfg) => !$cfg->isPublic()); } + /** + * @return null|UiOptions + */ public function getUiOptions(string $processCode): ?array { if (false === $this->registry->hasProcessConfiguration($processCode)) { @@ -48,6 +63,11 @@ public function getUiOptions(string $processCode): ?array return $this->resolveUiOptions($configuration->getOptions())['ui']; } + /** + * @param array $options + * + * @return UiOptionList + */ private function resolveUiOptions(array $options): array { $resolver = new OptionsResolver(); diff --git a/src/Message/ProcessExecuteMessage.php b/src/Message/ProcessExecuteMessage.php index 397f0ae..84fddb0 100644 --- a/src/Message/ProcessExecuteMessage.php +++ b/src/Message/ProcessExecuteMessage.php @@ -15,6 +15,9 @@ readonly class ProcessExecuteMessage { + /** + * @param mixed[] $context + */ public function __construct(public string $code, public mixed $input, public array $context = []) { } From ccce788c39fff30d6b9ad95a70bf5f989c00d6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Fri, 13 Dec 2024 10:38:13 +0100 Subject: [PATCH 05/16] #14 Quality. Phpstan remove missingType.generics --- phpstan.neon | 2 -- src/Form/Type/LaunchType.php | 1 + src/Form/Type/ProcessContextType.php | 1 + src/Form/Type/ProcessUploadFileType.php | 1 + src/Manager/ProcessConfigurationsManager.php | 31 +++++++++++-------- .../ProcessExecutionExtensionRuntime.php | 1 + 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 8b167d3..030748e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,8 +6,6 @@ parameters: excludePaths: - src/DependencyInjection/Configuration.php ignoreErrors: - - - identifier: missingType.generics - identifier: doctrine.columnType reportUnmatchedIgnoredErrors: false diff --git a/src/Form/Type/LaunchType.php b/src/Form/Type/LaunchType.php index 5ca2489..9c2f964 100644 --- a/src/Form/Type/LaunchType.php +++ b/src/Form/Type/LaunchType.php @@ -25,6 +25,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +/** @template-extends AbstractType> */ class LaunchType extends AbstractType { public function __construct( diff --git a/src/Form/Type/ProcessContextType.php b/src/Form/Type/ProcessContextType.php index e8e2c2d..d95fd19 100644 --- a/src/Form/Type/ProcessContextType.php +++ b/src/Form/Type/ProcessContextType.php @@ -18,6 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints\NotBlank; +/** @template-extends AbstractType */ class ProcessContextType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/ProcessUploadFileType.php b/src/Form/Type/ProcessUploadFileType.php index 88b77c1..57619ff 100644 --- a/src/Form/Type/ProcessUploadFileType.php +++ b/src/Form/Type/ProcessUploadFileType.php @@ -17,6 +17,7 @@ use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\OptionsResolver\OptionsResolver; +/** @template-extends AbstractType */ class ProcessUploadFileType extends AbstractType { public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index b784e71..84393f2 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -20,17 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraint; -/** - * @template UiOptions of array{ - * 'source': ?string, - * 'target': ?string, - * 'entrypoint_type': 'text|file', - * 'constraints': Constraint[], - * 'run': 'null|bool', - * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} - * } - * @template UiOptionList of array {'ui': UiOptions} - */ final readonly class ProcessConfigurationsManager { public function __construct(private ProcessConfigurationRegistry $registry) @@ -50,7 +39,14 @@ public function getPrivateProcesses(): array } /** - * @return null|UiOptions + * @return null|array{ + * 'source': ?string, + * 'target': ?string, + * 'entrypoint_type': 'text|file', + * 'constraints': Constraint[], + * 'run': 'null|bool', + * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} + * } */ public function getUiOptions(string $processCode): ?array { @@ -66,7 +62,16 @@ public function getUiOptions(string $processCode): ?array /** * @param array $options * - * @return UiOptionList + * @return array{ + * 'ui': array{ + * 'source': ?string, + * 'target': ?string, + * 'entrypoint_type': 'text|file', + * 'constraints': Constraint[], + * 'run': 'null|bool', + * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} + * } + * } */ private function resolveUiOptions(array $options): array { diff --git a/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php b/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php index 592f1e4..60f8630 100644 --- a/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php +++ b/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php @@ -16,6 +16,7 @@ use CleverAge\UiProcessBundle\Entity\ProcessExecution; use CleverAge\UiProcessBundle\Manager\ProcessConfigurationsManager; use CleverAge\UiProcessBundle\Repository\ProcessExecutionRepository; +use Symfony\Component\Form\AbstractType; use Twig\Extension\RuntimeExtensionInterface; readonly class ProcessExecutionExtensionRuntime implements RuntimeExtensionInterface From 1173eee69b50db1710f6c16a0cee5f14e44a8b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Fri, 13 Dec 2024 10:40:50 +0100 Subject: [PATCH 06/16] #14 Quality. Phpstan 7 --- phpstan.neon | 2 +- src/Manager/ProcessConfigurationsManager.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 030748e..9f60d1c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 6 + level: 7 paths: - src - tests diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 84393f2..83f831f 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -106,8 +106,21 @@ private function resolveUiOptions(array $options): array $uiResolver->setAllowedTypes('input_context_launcher_form', ['bool']); $uiResolver->setAllowedTypes('run_confirmation_modal', ['bool']); }); + /** + * @var array{ + * 'ui': array{ + * 'source': ?string, + * 'target': ?string, + * 'entrypoint_type': 'text|file', + * 'constraints': Constraint[], + * 'run': 'null|bool', + * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} + * } + * } $options + */ + $options = $resolver->resolve($options); - return $resolver->resolve($options); + return $options; } /** @return ProcessConfiguration[] */ From fecf2a2fc14dc089af8fffbae4a62d2d5b145ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Fri, 13 Dec 2024 14:32:47 +0100 Subject: [PATCH 07/16] #14 Quality. Phpstan 8 --- phpstan.neon | 10 +--------- src/Entity/ProcessSchedule.php | 6 +++--- src/Entity/User.php | 4 ++-- src/Form/Type/LaunchType.php | 16 +++++++++------- src/Manager/ProcessConfigurationsManager.php | 4 ++-- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 9f60d1c..1cd333b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,13 +1,5 @@ parameters: - level: 7 + level: 8 paths: - src - tests - excludePaths: - - src/DependencyInjection/Configuration.php - ignoreErrors: - - - identifier: doctrine.columnType - reportUnmatchedIgnoredErrors: false - inferPrivatePropertyTypeFromConstructor: true - treatPhpDocTypesAsCertain: false diff --git a/src/Entity/ProcessSchedule.php b/src/Entity/ProcessSchedule.php index 0637a4a..4ffa00a 100644 --- a/src/Entity/ProcessSchedule.php +++ b/src/Entity/ProcessSchedule.php @@ -32,7 +32,7 @@ class ProcessSchedule #[ORM\Column(length: 255)] #[IsValidProcessCode] - private ?string $process = null; + private string $process; #[ORM\Column(length: 6)] private ProcessScheduleType $type; @@ -43,7 +43,7 @@ class ProcessSchedule #[Assert\When( expression: 'this.getType().value == "every"', constraints: [new EveryExpression()] )] - private ?string $expression = null; + private string $expression; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $input = null; @@ -109,7 +109,7 @@ public function getExpression(): ?string return $this->expression; } - public function setExpression(?string $expression): self + public function setExpression(string $expression): self { $this->expression = $expression; diff --git a/src/Entity/User.php b/src/Entity/User.php index a5f680c..11532f7 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -29,7 +29,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private ?int $id = null; #[ORM\Column(type: Types::STRING, length: 255, unique: true)] - private ?string $email = null; + private string $email; #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $firstname = null; @@ -98,7 +98,7 @@ public function setLastname(?string $lastname): self public function getUserIdentifier(): string { - if (null === $this->email || '' === $this->email || '0' === $this->email) { + if ('' === $this->email) { throw new \LogicException('The User class must have an email.'); } diff --git a/src/Form/Type/LaunchType.php b/src/Form/Type/LaunchType.php index 9c2f964..3c876bc 100644 --- a/src/Form/Type/LaunchType.php +++ b/src/Form/Type/LaunchType.php @@ -39,13 +39,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $code = $options['process_code']; $configuration = $this->registry->getProcessConfiguration($code); $uiOptions = $this->configurationsManager->getUiOptions($code); - $builder->add( - 'input', - 'file' === ($uiOptions['entrypoint_type'] ?? null) ? FileType::class : TextType::class, - [ - 'required' => $configuration->getEntryPoint() instanceof TaskConfiguration, - ] - ); + if (isset($uiOptions['entrypoint_type'])) { + $builder->add( + 'input', + 'file' === $uiOptions['entrypoint_type'] ? FileType::class : TextType::class, + [ + 'required' => $configuration->getEntryPoint() instanceof TaskConfiguration, + ] + ); + } $builder->add( 'context', CollectionType::class, diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 83f831f..485ef6a 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -42,7 +42,7 @@ public function getPrivateProcesses(): array * @return null|array{ * 'source': ?string, * 'target': ?string, - * 'entrypoint_type': 'text|file', + * 'entrypoint_type': string, * 'constraints': Constraint[], * 'run': 'null|bool', * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} @@ -66,7 +66,7 @@ public function getUiOptions(string $processCode): ?array * 'ui': array{ * 'source': ?string, * 'target': ?string, - * 'entrypoint_type': 'text|file', + * 'entrypoint_type': string, * 'constraints': Constraint[], * 'run': 'null|bool', * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} From 85cf872e295eac2953f0129d165d4891b93f59ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Fri, 13 Dec 2024 14:55:29 +0100 Subject: [PATCH 08/16] #14 Quality. PhpCs --- src/Entity/ProcessSchedule.php | 2 +- src/Twig/Runtime/ProcessExecutionExtensionRuntime.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Entity/ProcessSchedule.php b/src/Entity/ProcessSchedule.php index 4ffa00a..8eea928 100644 --- a/src/Entity/ProcessSchedule.php +++ b/src/Entity/ProcessSchedule.php @@ -80,7 +80,7 @@ public function getContext(): array } /** - * @param array $context + * @param array $context */ public function setContext(array $context): void { diff --git a/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php b/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php index 60f8630..592f1e4 100644 --- a/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php +++ b/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php @@ -16,7 +16,6 @@ use CleverAge\UiProcessBundle\Entity\ProcessExecution; use CleverAge\UiProcessBundle\Manager\ProcessConfigurationsManager; use CleverAge\UiProcessBundle\Repository\ProcessExecutionRepository; -use Symfony\Component\Form\AbstractType; use Twig\Extension\RuntimeExtensionInterface; readonly class ProcessExecutionExtensionRuntime implements RuntimeExtensionInterface From e996d47c70559c9ee6c30d04d07cad73845e3cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 14:18:42 +0100 Subject: [PATCH 09/16] #14 Quality. Phpstan use phpstan type to prevent duplicate definitions. --- src/Manager/ProcessConfigurationsManager.php | 41 +++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 485ef6a..aaf1a74 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -20,6 +20,16 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraint; +/** + * @phpstan-type UiOptions array{ + * 'source': ?string, + * 'target': ?string, + * 'entrypoint_type': string, + * 'constraints': Constraint[], + * 'run': 'null|bool', + * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} + * } + */ final readonly class ProcessConfigurationsManager { public function __construct(private ProcessConfigurationRegistry $registry) @@ -39,14 +49,7 @@ public function getPrivateProcesses(): array } /** - * @return null|array{ - * 'source': ?string, - * 'target': ?string, - * 'entrypoint_type': string, - * 'constraints': Constraint[], - * 'run': 'null|bool', - * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} - * } + * @return null|UiOptions */ public function getUiOptions(string $processCode): ?array { @@ -62,16 +65,7 @@ public function getUiOptions(string $processCode): ?array /** * @param array $options * - * @return array{ - * 'ui': array{ - * 'source': ?string, - * 'target': ?string, - * 'entrypoint_type': string, - * 'constraints': Constraint[], - * 'run': 'null|bool', - * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} - * } - * } + * @return array{'ui': UiOptions} */ private function resolveUiOptions(array $options): array { @@ -107,16 +101,7 @@ private function resolveUiOptions(array $options): array $uiResolver->setAllowedTypes('run_confirmation_modal', ['bool']); }); /** - * @var array{ - * 'ui': array{ - * 'source': ?string, - * 'target': ?string, - * 'entrypoint_type': 'text|file', - * 'constraints': Constraint[], - * 'run': 'null|bool', - * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} - * } - * } $options + * @var array{'ui': UiOptions} $options */ $options = $resolver->resolve($options); From 1911fbfe40f064263d8b6368f14591876194deab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 14:21:44 +0100 Subject: [PATCH 10/16] #14 Quality. Phpstan use phpstan type to prevent duplicate definitions. --- src/Manager/ProcessConfigurationsManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index aaf1a74..e3a9aae 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -49,7 +49,7 @@ public function getPrivateProcesses(): array } /** - * @return null|UiOptions + * @return UiOptions|null */ public function getUiOptions(string $processCode): ?array { From b1433dc148d326bc90a69547547b8c001629d7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Thu, 12 Dec 2024 15:17:19 +0100 Subject: [PATCH 11/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. --- templates/admin/process/list.html.twig | 2 +- templates/components/BootstrapModal.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index e655794..417567b 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -33,7 +33,7 @@ {% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %} {% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %} - {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} + {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} diff --git a/templates/components/BootstrapModal.html.twig b/templates/components/BootstrapModal.html.twig index 9c226de..c7976d0 100644 --- a/templates/components/BootstrapModal.html.twig +++ b/templates/components/BootstrapModal.html.twig @@ -34,4 +34,4 @@ {% endblock %} - + \ No newline at end of file From 65b20038391b125667cd1882bca7f3aea91dcb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 15:29:03 +0100 Subject: [PATCH 12/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. PhpStan --- src/Controller/Admin/Process/LaunchAction.php | 11 +++++++++-- src/Manager/ProcessConfigurationsManager.php | 2 ++ src/Twig/Runtime/ProcessExtensionRuntime.php | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Controller/Admin/Process/LaunchAction.php b/src/Controller/Admin/Process/LaunchAction.php index 149f92c..f828366 100644 --- a/src/Controller/Admin/Process/LaunchAction.php +++ b/src/Controller/Admin/Process/LaunchAction.php @@ -30,6 +30,7 @@ use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Uid\Uuid; +use Symfony\Component\Validator\Exception\MissingOptionsException; #[Route( '/process/launch', @@ -55,6 +56,9 @@ public function __invoke( throw new MissingProcessException(); } $uiOptions = $processConfigurationsManager->getUiOptions($processCode); + if (null === $uiOptions) { + throw new \InvalidArgumentException("Missing UI Options"); + } if (false === $uiOptions['input_context_launcher_form']) { $this->dispatch($processCode); $this->addFlash( @@ -68,12 +72,12 @@ public function __invoke( LaunchType::class, null, [ - 'constraints' => $uiOptions['constraints'] ?? [], + 'constraints' => $uiOptions['constraints'], 'process_code' => $processCode, ] ); if (false === $form->isSubmitted()) { - $default = $uiOptions['default'] ?? []; + $default = $uiOptions['default']; if (false === $form->get('input')->getConfig()->getType()->getInnerType() instanceof TextType && isset($default['input']) ) { @@ -111,6 +115,9 @@ public function __invoke( ); } + /** + * @param mixed[] $context + */ protected function dispatch(string $processCode, mixed $input = null, array $context = []): void { $message = new ProcessExecuteMessage( diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index e3a9aae..7d2caf7 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -24,6 +24,8 @@ * @phpstan-type UiOptions array{ * 'source': ?string, * 'target': ?string, + * 'input_context_launcher_form': bool, + * 'run_confirmation_modal': bool, * 'entrypoint_type': string, * 'constraints': Constraint[], * 'run': 'null|bool', diff --git a/src/Twig/Runtime/ProcessExtensionRuntime.php b/src/Twig/Runtime/ProcessExtensionRuntime.php index 3ae5777..e4f31ed 100644 --- a/src/Twig/Runtime/ProcessExtensionRuntime.php +++ b/src/Twig/Runtime/ProcessExtensionRuntime.php @@ -14,12 +14,18 @@ use CleverAge\UiProcessBundle\Manager\ProcessConfigurationsManager; use Twig\Extension\RuntimeExtensionInterface; +/** + * @phpstan-import-type UiOptions from ProcessConfigurationsManager + */ class ProcessExtensionRuntime implements RuntimeExtensionInterface { public function __construct(protected ProcessConfigurationsManager $processConfigurationsManager) { } + /** + * @return UiOptions|array{} + */ public function getUiOptions(string $code): array { return $this->processConfigurationsManager->getUiOptions($code) ?? []; From ad6d10a71f226cbb3a96a6a00fc5afce68778914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 15:42:21 +0100 Subject: [PATCH 13/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. Quality --- src/Controller/Admin/Process/LaunchAction.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Controller/Admin/Process/LaunchAction.php b/src/Controller/Admin/Process/LaunchAction.php index f828366..226ae5d 100644 --- a/src/Controller/Admin/Process/LaunchAction.php +++ b/src/Controller/Admin/Process/LaunchAction.php @@ -30,7 +30,6 @@ use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Security\Http\Attribute\IsGranted; use Symfony\Component\Uid\Uuid; -use Symfony\Component\Validator\Exception\MissingOptionsException; #[Route( '/process/launch', @@ -57,7 +56,7 @@ public function __invoke( } $uiOptions = $processConfigurationsManager->getUiOptions($processCode); if (null === $uiOptions) { - throw new \InvalidArgumentException("Missing UI Options"); + throw new \InvalidArgumentException('Missing UI Options'); } if (false === $uiOptions['input_context_launcher_form']) { $this->dispatch($processCode); From dd2e0990dccb61e490e210bc2d99878cf6c4a1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Mon, 16 Dec 2024 15:47:34 +0100 Subject: [PATCH 14/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. Quality --- templates/admin/process/list.html.twig | 2 +- templates/components/BootstrapModal.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index 417567b..e655794 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -33,7 +33,7 @@ {% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %} {% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %} - {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} + {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} diff --git a/templates/components/BootstrapModal.html.twig b/templates/components/BootstrapModal.html.twig index c7976d0..9c226de 100644 --- a/templates/components/BootstrapModal.html.twig +++ b/templates/components/BootstrapModal.html.twig @@ -34,4 +34,4 @@ {% endblock %} - \ No newline at end of file + From b103677dc91eae2722eff1e4b796da25319059d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Tue, 17 Dec 2024 09:58:46 +0100 Subject: [PATCH 15/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. Rework options names --- docs/index.md | 12 ++++++------ src/Controller/Admin/Process/LaunchAction.php | 2 +- src/Manager/ProcessConfigurationsManager.php | 8 +++----- templates/admin/field/report.html.twig | 4 +--- templates/admin/process/list.html.twig | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/docs/index.md b/docs/index.md index e6d3950..db90d03 100644 --- a/docs/index.md +++ b/docs/index.md @@ -35,13 +35,13 @@ Now you can access UI Process via http://your-domain.com/process ### Launch process via UI From UI "Process List" menu entry you can run a process by clicking on "Rocket" action. -You can manage this behaviour by setting some ui options on process configuration ui option. +You can manage this behaviour by setting some ui option `ui_launch_mode` -| Options | Values | UI behaviour | -|----------------------------------|----------------|:---------:| -| input_context_launcher_form
run_confirmation_modal | false
false | Run process without any confirmation -| input_context_launcher_form
run_confirmation_modal | true
false | On click, open a form to set input and context execution -| input_context_launcher_form
run_confirmation_modal | false
true | On click, open confirmation model to confirm process execution +| Value | UI behaviour | +|:---------------:|:--------------------------------------------------------------:| +| modal (default) | On click, open confirmation modal to confirm process execution | +| form | On click, open a form to set input and context execution | +| null | Run process without any confirmation | ### Launch process via http request You can launch a process via http post request diff --git a/src/Controller/Admin/Process/LaunchAction.php b/src/Controller/Admin/Process/LaunchAction.php index 226ae5d..8f6bed5 100644 --- a/src/Controller/Admin/Process/LaunchAction.php +++ b/src/Controller/Admin/Process/LaunchAction.php @@ -58,7 +58,7 @@ public function __invoke( if (null === $uiOptions) { throw new \InvalidArgumentException('Missing UI Options'); } - if (false === $uiOptions['input_context_launcher_form']) { + if (null === $uiOptions['ui_launch_mode'] || 'modal' === $uiOptions['ui_launch_mode']) { $this->dispatch($processCode); $this->addFlash( 'success', diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 7d2caf7..ff8b8de 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -24,7 +24,7 @@ * @phpstan-type UiOptions array{ * 'source': ?string, * 'target': ?string, - * 'input_context_launcher_form': bool, + * 'ui_launch_mode': ?string, * 'run_confirmation_modal': bool, * 'entrypoint_type': string, * 'constraints': Constraint[], @@ -78,8 +78,7 @@ private function resolveUiOptions(array $options): array 'source' => null, 'target' => null, 'entrypoint_type' => 'text', - 'input_context_launcher_form' => false, - 'run_confirmation_modal' => false, + 'ui_launch_mode' => 'modal', 'constraints' => [], 'run' => null, 'default' => function (OptionsResolver $defaultResolver) { @@ -99,8 +98,7 @@ private function resolveUiOptions(array $options): array ); $uiResolver->setAllowedValues('entrypoint_type', ['text', 'file']); $uiResolver->setNormalizer('constraints', fn (Options $options, array $values): array => (new ConstraintLoader())->buildConstraints($values)); - $uiResolver->setAllowedTypes('input_context_launcher_form', ['bool']); - $uiResolver->setAllowedTypes('run_confirmation_modal', ['bool']); + $uiResolver->setAllowedValues('ui_launch_mode', ['modal', null, 'form']); }); /** * @var array{'ui': UiOptions} $options diff --git a/templates/admin/field/report.html.twig b/templates/admin/field/report.html.twig index c24b268..745e19c 100644 --- a/templates/admin/field/report.html.twig +++ b/templates/admin/field/report.html.twig @@ -2,7 +2,5 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
    - {% for key, item in field.value %} -
  • {{ key }} : {{ item }}
  • - {% endfor %} + {{ field.value }}
diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index e655794..53c3c45 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -33,7 +33,7 @@ {% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %} {% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %} - {% if (false == uiOptions.input_context_launcher_form and true == uiOptions.run_confirmation_modal) %} + {% if ("modal" == uiOptions.ui_launch_mode) %} From 05c1878cf4bc6a7ddf41e9b05fcfb87496d1d7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tonon=20Gr=C3=A9gory?= Date: Tue, 17 Dec 2024 10:00:28 +0100 Subject: [PATCH 16/16] #13 ability to add modal confirmation or nothing instead of launch from of process run ui. Rework options names --- templates/admin/process/list.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index 53c3c45..083f821 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -33,7 +33,7 @@ {% if process.options.ui.source is defined %}{{ process.options.ui.source }}{% endif %} {% if process.options.ui.target is defined %}{{ process.options.ui.target }}{% endif %} - {% if ("modal" == uiOptions.ui_launch_mode) %} + {% if ('modal' == uiOptions.ui_launch_mode) %}