Skip to content

Commit 73f1e0c

Browse files
authored
Merge pull request #6 from yokai-php/render-on-actions-option
Added render_actions option to avoid menu to be rendered on all actions
2 parents aa50aba + 1115ea0 commit 73f1e0c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ services:
132132
public: true
133133
arguments:
134134
- '@workflow.registry'
135-
- workflow_name: pull_request
135+
- render_actions: [show]
136+
workflow_name: pull_request
136137
no_transition_label: No transition for pull request
137138
no_transition_icon: fa fa-times
138139
dropdown_transitions_label: Pull request transitions
@@ -155,6 +156,7 @@ sonata_admin:
155156

156157
What are these options ?
157158

159+
- `render_actions` : Admin action names on which the extension should render its menu (defaults to `[show, edit]`)
158160
- `workflow_name` : The name of the Workflow to handle (defaults to `null`)
159161
- `no_transition_display` : Whether or not to display a button when no transition is enabled (defaults to `false`)
160162
- `no_transition_label` : The button label when no transition is enabled (defaults to `workflow_transitions_empty`)

src/Admin/Extension/WorkflowExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public function configureSideMenu(
7272
$action,
7373
AdminInterface $childAdmin = null
7474
) {
75+
if (!in_array($action, $this->options['render_actions'], true)) {
76+
return;
77+
}
78+
7579
$subject = $admin->getSubject();
7680
if (null === $subject) {
7781
return;
@@ -111,6 +115,7 @@ protected function configureOptions(OptionsResolver $resolver)
111115
{
112116
$resolver
113117
->setDefaults([
118+
'render_actions' => ['edit', 'show'],
114119
'workflow_name' => null,
115120
'no_transition_display' => false,
116121
'no_transition_label' => 'workflow_transitions_empty',
@@ -120,6 +125,7 @@ protected function configureOptions(OptionsResolver $resolver)
120125
'transitions_default_icon' => null,
121126
'transitions_icons' => [],
122127
])
128+
->setAllowedTypes('render_actions', ['string[]'])
123129
->setAllowedTypes('workflow_name', ['string', 'null'])
124130
->setAllowedTypes('no_transition_display', ['bool'])
125131
->setAllowedTypes('no_transition_label', ['string'])

0 commit comments

Comments
 (0)