Skip to content
Snippets Groups Projects

#3521811: Move drupalSettings and Drupal to a utility module in the frontend

Merged #3521811: Move drupalSettings and Drupal to a utility module in the frontend
6 unresolved threads
6 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 const { Drupal, drupalSettings } = window as any;
  • this is neat, one pattern I've seen in client React projects is adding a context provider for this and then useDrupal and useDrupalSettings hooks, something to consider?

  • That's what I suggested initially. I went with a simple module, because I thought there's no good reason to tie an API to React which has nothing do to with it. Adding hooks would mean a bit more refactoring, because they can only be used at top level of components (or in other hooks), no calls inside conditions etc. With that said, it's not a huge lift, and I don't feel strongly that we shouldn't do that — it's definitely a more elegant consumption of those values. :slight_smile:

    So I'm fine either way!

  • Harumi Jang changed this line in version 1 of the diff

    changed this line in version 1 of the diff

  • Please register or sign in to reply
  • Harumi Jang added 44 commits

    added 44 commits

    Compare with previous version

  • Harumi Jang added 3 commits

    added 3 commits

    Compare with previous version

  • Harumi Jang marked this merge request as ready

    marked this merge request as ready

  • Ben Mullins
  • 94 95 const store = makeStore({ configuration: appConfiguration });
    95 96
    96 97 // Make the store available to extensions.
    97 98 (drupalSettings as any).xb.store = store;
  • 28 29 drupalSettings?.xb.globalAssets.jsHeader + component.js_header;
    29 30
    30 31 const markup = component.default_markup;
    31 32 const base_url = window.location.origin + drupalSettings?.path.baseUrl;
  • 42 43 baseUrl: drupalSettings?.path?.baseUrl || import.meta.env.BASE_URL,
    43 44 entityType: drupalSettings?.xb?.entityType || 'node',
    44 45 entity: drupalSettings?.xb?.entity || '1',
    45 46 devMode: drupalSettings?.xb?.devMode || false,
  • 10 11
    11 12 const ExtensionsList: React.FC<ExtensionsPopoverProps> = () => {
    12 13 let extensionsList = [];
    13 14 if (drupalSettings && drupalSettings.xbExtension) {
    14 extensionsList = Object.values(drupalSettings.xbExtension).map((value) => {
    15 return {
    16 ...value,
    17 imgSrc:
    18 value.imgSrc ||
    19 `${drupalSettings.path.baseUrl}${drupalSettings.xb.xbModulePath}/ui/assets/icons/extension-default-abstract.svg`,
    20 name: value.name,
    21 description: value.description,
    22 };
    23 });
    15 extensionsList = Object.values(drupalSettings.xbExtension).map(
    16 (value: any) => {
  • Ben Mullins left review comments

    left review comments

  • Harumi Jang added 11 commits

    added 11 commits

    Compare with previous version

  • 1 export interface FormatType {
  • Harumi Jang requested review from @bnjmnm

    requested review from @bnjmnm

  • will fix the vitest fail

  • Harumi Jang added 1 commit

    added 1 commit

    Compare with previous version

  • Harumi Jang added 5 commits

    added 5 commits

    Compare with previous version

  • requested review from @balintbrews, @larowlan, and @jessebaker

  • Jesse Baker approved this merge request

    approved this merge request

  • Jesse Baker added 7 commits

    added 7 commits

    Compare with previous version

  • merged

  • Please register or sign in to reply
    Loading