Skip to content
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

Merged
merged 39 commits into from
Oct 12, 2022
Merged

OEL-2002: Preserve Drupal links. #270

merged 39 commits into from
Oct 12, 2022

Conversation

drishu
Copy link
Contributor

@drishu drishu commented Sep 12, 2022

Jira issue(s):

@drishu drishu changed the title Oel 2002 OEL-2002: Preserve Drupal links. Sep 12, 2022
@drishu drishu force-pushed the OEL-2002 branch 4 times, most recently from b83a263 to b438c8e Compare September 14, 2022 13:57
'class' => $item['in_active_trail'] ? ['active'] : [],
]),
];
$menu_preprocess = \Drupal::classResolver(MenuPreprocess::class);
Copy link
Contributor Author

@drishu drishu Sep 14, 2022

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

Copy link
Contributor Author

@drishu drishu left a 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.

@drishu drishu force-pushed the OEL-2002 branch 2 times, most recently from 4549cd7 to 1b23ac4 Compare September 26, 2022 14:35
+{% if _icon_markup is defined %}
+ {%- set _label -%}
+ {%- if _icon_position == 'before' -%}
+ {{ _icon_markup|raw }}
Copy link
Contributor

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.

tests/src/PatternAssertion/LinkPatternAssert.php Outdated Show resolved Hide resolved
'id' => 'id-bar',
],
],
],
Copy link
Contributor

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(
Copy link
Contributor

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);
Copy link
Contributor

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');
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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.

public function prepareLocalTasks(array $local_tasks): array {
$links = [];
foreach ($local_tasks as $link) {
if ($link['#access']->isForbidden()) {
Copy link
Contributor

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,
Copy link
Contributor

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.

@drishu drishu force-pushed the OEL-2002 branch 5 times, most recently from 8da1459 to 39d8812 Compare October 7, 2022 06:51
@brummbar brummbar merged commit f5b0c71 into 1.x Oct 12, 2022
@brummbar brummbar deleted the OEL-2002 branch October 12, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants