Overview

In the frontend, we have const { drupalSettings } = window; scattered throughout the codebase. Maybe we want to this for const { Drupal } = window as any; as well.

Proposed resolution

Consider creating hooks for drupalSettings and Drupal in /ui/src/hooks and refactor all usages to use the new hook so it's in one single place.

User interface changes

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

hooroomoo created an issue. See original summary.

hooroomoo’s picture

Title: Consider moving drupalSettings and Drupal to their own hooks » Consider moving drupalSettings and Drupal to their own hooks in the frontend
hooroomoo’s picture

Issue summary: View changes

hooroomoo’s picture

adding credit @balintbrews who suggested creating a hook for the baseUrl which inspired me to create this issue

hooroomoo’s picture

Priority: Normal » Minor
wim leers’s picture

balintbrews’s picture

Title: Consider moving drupalSettings and Drupal to their own hooks in the frontend » Move drupalSettings and Drupal to a utility module in the frontend
Status: Active » Needs work

I got started with this, because I needed it for efficiently mocking in tests I'm writing for #3516390: Compile Tailwind CSS globally for code components. I'm already using this code there in ui/src/features/code-editor/Preview.tsx, but everything else still need to be refactored.

I know I originally suggested to create React hooks, but I was wrong. 🙂 No need for React. This can live as a simple utility module.

hooroomoo’s picture

Assigned: Unassigned » hooroomoo
hooroomoo’s picture

Status: Needs work » Needs review
hooroomoo’s picture

Assigned: hooroomoo » Unassigned
bnjmnm’s picture

Status: Needs review » Needs work

Some FB in MR

hooroomoo’s picture

Assigned: Unassigned » bnjmnm
Status: Needs work » Needs review

jessebaker made their first commit to this issue’s fork.

jessebaker’s picture

Assigned: bnjmnm » Unassigned
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.