Overview

See https://git.drupalcode.org/project/canvas/-/merge_requests/378#note_634033

GenerateComponentConfigTrait is no longer necessary, because it can be replaced with a single line:

$this->container->get(ComponentSourceManager::class)->generateComponents();

Proposed resolution

Remove all uses of GenerateComponentConfigTrait, replacing calls to it with the line I just mentioned. Then remove the trait itself.

User interface changes

None.

Issue fork canvas-3561270

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Issue summary: View changes
wim leers’s picture

Issue tags: +maintainability, +Novice
garvitasakhrani’s picture

Assigned: Unassigned » garvitasakhrani

I am working on this issue.

penyaskito’s picture

penyaskito’s picture

Title: [PP-1] Remove GenerateComponentConfigTrait » Remove GenerateComponentConfigTrait
Status: Postponed » Active
sujal kshatri’s picture

Assigned: Unassigned » sujal kshatri

I am working on this

sujal kshatri’s picture

Hello maintainers,
While merging, the validate test and testing are failing.
I’m looking into it and trying to understand what is happening and what should be the next step.

In this MR, I removed the GenerateComponentConfigTrait file and removed all
trait usages from the tests.
I also replaced calls to
`$this->generateComponentConfig()` with
`$this->container->get(ComponentSourceManager::class)->generateComponents()`.

Additionally, in JsComponentTest there was an overridden
`generateComponentConfig()` method. Previously this method was calling
`parent::generateComponentConfig()`, which relied on the removed trait. I have
updated it to directly call
`$this->container->get(ComponentSourceManager::class)->generateComponents()`
instead.

If you have any guidance on the preferred way to handle this in tests, that
would be really helpful.

Thanks!

phenaproxima’s picture

Status: Active » Needs work

The linter is complaining about lines like https://git.drupalcode.org/issue/canvas-3561270/-/blob/1.x/tests/src/Ker...

The problem is that you need to have that use the qualified class name. So for example, it needs to be:

$this->container->get(ComponentSourceManager::class)->generateComponents();

Not:

$this->container->get($this->container->get(\Drupal\canvas\ComponentSource\ComponentSourceManager::class)->generateComponents();

And you need to have a use Drupal\canvas\ComponentSource\ComponentSourceManager; at the top of the file, where other classes are being imported.

sujal kshatri’s picture

working on it

wim leers’s picture

MR 412 contains 1 commit and seems to delete and remove every line in the codebase 😅 Something went quite wrong here.

wim leers’s picture

Oh, I think this is simply a matter of having created the MR from the wrong branch? https://git.drupalcode.org/issue/canvas-3561270/-/compare/1.x...sujal-us... needs to get an MR, not the 1.x branch that's been pushed up!

sujal kshatri’s picture

I was so scared that why it looks like I have changed the entire code base 😭, for past 2 days I was finding a way as toh how to take my MR back to orginal form, but was not able to do so
Thank you so much for closing it

sujal kshatri’s picture

That could indeed be the case,
I did the MR from the wrong base branch, which would explain why the diff looked so off.
Thanks a lot for opening the correct MR

wim leers’s picture

wim leers’s picture

Issue tags: +technical debt
isholgueras’s picture

Assigned: Unassigned » isholgueras
Status: Needs work » Active

isholgueras’s picture

Assigned: isholgueras » Unassigned
Status: Active » Needs review
phenaproxima’s picture

One question on the MR, approved otherwise.

wim leers’s picture

Assigned: Unassigned » isholgueras
Status: Needs review » Needs work
Issue tags: -Needs reroll

This is looking great!. I echo @phenaproxima's question, have 2 additional questions, and AFAICT we can trivially simplify this MR even more: https://git.drupalcode.org/project/canvas/-/merge_requests/721#note_720933

wim leers’s picture

Priority: Normal » Major
Issue tags: -Novice