-
Notifications
You must be signed in to change notification settings - Fork 12
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
OEL-2002: Preserve Drupal links. #270
Conversation
b83a263
to
b438c8e
Compare
'class' => $item['in_active_trail'] ? ['active'] : [], | ||
]), | ||
]; | ||
$menu_preprocess = \Drupal::classResolver(MenuPreprocess::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this is actually needed with this class, we could just instantiate with new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, I want to add a new test for it, or change the link pattern render test where we cover all possible scenarios of urls, anchors, external links, full internal urls, uris, url objects whatever else.
4549cd7
to
1b23ac4
Compare
+{% if _icon_markup is defined %} | ||
+ {%- set _label -%} | ||
+ {%- if _icon_position == 'before' -%} | ||
+ {{ _icon_markup|raw }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the |raw needed? I tried locally and it seems it wasn't. When we set rendered html to a variable in a twig file, it gets set as safe markup.
modules/oe_bootstrap_theme_helper/src/TwigExtension/TwigExtension.php
Outdated
Show resolved
Hide resolved
'id' => 'id-bar', | ||
], | ||
], | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we miss a scenario with external url.
$this->assertElementExists($selector, $crawler); | ||
$class = $crawler->filter($selector)->attr('class'); | ||
|
||
self::assertNotNull($class, \sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: no backslashes.
protected function assertBaseElements(string $html, string $variant): void { | ||
$crawler = new Crawler($html); | ||
|
||
$this->assertElementExists('a', $crawler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do 'body > a' to check that it's first level.
* The crawler. | ||
*/ | ||
protected function assertIcon(string $expected, Crawler $crawler): void { | ||
$svg = $crawler->filter('svg'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should body > a > svg
to check that it's rendered inside.
*/ | ||
protected function assertSettings(array $expected, Crawler $crawler): void { | ||
if (!empty($expected['disabled'])) { | ||
$this->assertElementHasClass('disabled', 'a', $crawler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we don't need this method at all. Since we know there's only one a
tag, we can simply assert that a.disabled
exists.
$this->assertElementAttribute('true', 'a', 'aria-disabled', $crawler); | ||
} | ||
else { | ||
$this->assertElementNotHasClass('disabled', 'a', $crawler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This the same as above, but asserting that doesn't exist.
src/MenuPreprocess.php
Outdated
public function prepareLocalTasks(array $local_tasks): array { | ||
$links = []; | ||
foreach ($local_tasks as $link) { | ||
if ($link['#access']->isForbidden()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core handles this differently: see build/core/lib/Drupal/Core/Render/Renderer.php:226.
Basically access is granted only if access is set to allowed, or to true.
In our case we will always have objects (\Drupal\Core\Menu\LocalTaskManager::getTasksBuild()).
], | ||
'#active' => FALSE, | ||
'#weight' => 0, | ||
'#access' => $access_forbidden, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a case where access is neutral. Also in that case the access should be prevented.
8da1459
to
39d8812
Compare
Jira issue(s):