Skip to content
Snippets Groups Projects
Commit 6916d4e7 authored by Joshua Sedler's avatar Joshua Sedler :cartwheel_tone2:
Browse files

Issue #3265220: Remove unnecessary blocks in the Homebox Dashboard Settings Page

parent 10bc2667
No related branches found
No related tags found
1 merge request!5Issue #3264557: Plan for 2.0.0-alpha1 bugfix release
......@@ -44,7 +44,7 @@ homebox.settings_form:
_entity_access: 'homebox.settings'
homebox.block.admin_library:
path: '/admin/structure/homebox/block/library/{homebox}'
path: '/admin/structure/homebox/block/library/{theme}/{homebox}'
defaults:
_controller: '\Drupal\homebox\Controller\HomeboxLayoutController::listBlocks'
_title: 'Place block'
......
......@@ -165,17 +165,15 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
* @param string $theme
* Theme key of the block list.
* @param string $homebox
* Homebox id.
*
* @return array
* A render array as expected by the renderer.
*/
public function listBlocks(Request $request, $homebox) {
// Only add blocks which work without any available context.
$definitions = $this->blockManager->getDefinitions();
// Order by category, and then by admin label.
$definitions = $this->blockManager->getSortedDefinitions($definitions);
public function listBlocks(Request $request, $theme, $homebox) {
// Since modals do not render any other part of the page, we need to render
// them manually as part of this listing.
......@@ -191,6 +189,20 @@ class HomeboxLayoutController extends ControllerBase implements ContainerInjecti
$region = $request->query->get('region');
$weight = $request->query->get('weight');
// Only add blocks which work without any available context.
$definitions = $this->blockManager->getFilteredDefinitions('block_ui', $this->contextRepository->getAvailableContexts(), [
'theme' => $theme,
'region' => $region,
]);
// Order by category, and then by admin label.
$definitions = $this->blockManager->getSortedDefinitions($definitions);
// Filter out definitions that are not intended to be placed by the UI.
$definitions = array_filter($definitions, function (array $definition) {
return empty($definition['_block_ui_hidden']);
});
$rows = [];
foreach ($definitions as $plugin_id => $plugin_definition) {
$row = [];
......
......@@ -320,7 +320,7 @@ class HomeboxSettingsForm extends EntityForm {
'#prefix' => $region,
'#type' => 'link',
'#title' => $this->t('Place block <span class="visually-hidden">in the @region region</span>', ['@region' => $title['label']]),
'#url' => Url::fromRoute('homebox.block.admin_library', ['homebox' => $homebox->id()], ['query' => ['region' => $region]]),
'#url' => Url::fromRoute('homebox.block.admin_library', ['theme' => $this->themeManager->getActiveTheme()->getName(), 'homebox' => $homebox->id()], ['query' => ['region' => $region]]),
'#wrapper_attributes' => [
'colspan' => 5,
],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment