🇮🇳India @anand.toshniwal93

Account created on 5 November 2015, about 9 years ago
  • Sr. Full Stack Developer at QED42 
#

Recent comments

🇮🇳India anand.toshniwal93

Moving this to needs work as I have just updated the script and not other parts of issue.

🇮🇳India anand.toshniwal93

Assigning this to me as per conversation with @jacobadeutsch

🇮🇳India anand.toshniwal93

I have updated script as per the below comment

https://www.drupal.org/project/demo_design_system/issues/3469495#comment... 📌 Decide if SDDS SDCs should include props from included components Needs review

🇮🇳India anand.toshniwal93

Will get this fixed today.. must have missed some case.. thanks for testing.

🇮🇳India anand.toshniwal93
  1. Remove default values from enum. - Fixed
  2. Remove libraryOverrides - Fixed
  3. Capitalize component name - Fixed
  4. Fix issues related to yamllint - Fixed
  5. Add empty line before slot when there are no props properties - Fixed

Pending
The point regarding the include variables is still pending, as we are waiting for the final decision on it.

🇮🇳India anand.toshniwal93

In the button component, the yml file was generated with a null default for this var:

  type:
      type: string
      title: Type
      description: 'Button type: primary, secondary, tertiary.'
      default: null
      enum:
      - primary
      - secondary
      - tertiary

I think it's getting that from here:
{% set type = type in ['primary', 'secondary', 'tertiary'] ? type : null %}

Should it just not have a default in this instance? Maybe default: null is right here, I'm not really sure.

@jacobadeutsch You're right, it's picking up from the set type snippet you mentioned. The script checks the variable set statements and determines if there's any default or in case of condition any value is being set in else block.

As per the above set type statement default: null is right but let me know in case of null do we want to remove default key.

🇮🇳India anand.toshniwal93

I've addressed the spacing between the variables. If there are any other formatting adjustments needed, please let me know.
Attached file for reference

🇮🇳India anand.toshniwal93

Progress update

  1. Parse enums form the comments - Fixed
  2. Also group names are showing up as "default" right now. - Fixed
  3. Blank string bool defaults are still appearing - Fixed

Pending
spacing between the vars would be nice. - 60% of work here is done in case on nested properties formatting is not appearing properly will try to get this done by tomorrow.

🇮🇳India anand.toshniwal93

Issue link where feedback was posted: https://www.drupal.org/project/demo_design_system/issues/3466118#comment... 📌 Convert Starshot Tag component to SDC Needs review
component name: Starshot Tag

@Kristen Pol @jacobadeutsch thanks for the feedback, please find details below

  1. Booleans need to be changed to have their title as the description for the boolean. - Fixed
  2. Should the defaults be displayed in the yml?
    I found example of default in D.O documentation so I have added it https://www.drupal.org/docs/develop/theming-drupal/using-single-director... Annotated example component.yml
  3. The converter didn't create a enums where it should've
    can you please provide detail around this for which prop enums were not generated properly?

    For existing components we have list of enums hardcoded in script. there is no pattern available to retrieve the options/enums for prop from the comment section. if we are creating new components can we have them in some pattern so that script can retrieve and add them as a part of yml?

  4. Not everything with a space in it has quotes around it, not sure if this is necessary or not
    Ran latest script this seems to be resolved, also we using package to generate yaml will check if there are any configs available for this.
  5. it included a blank default for a boolean.. it seems like that it's getting that from line 27 of the twig. I deleted it because I wasn't seeing defaults for other bools, but this could be wrong
    Ran latest script did not see default added for boolean for given component

Attaching generated .component.yml file with new script for reference

🇮🇳India anand.toshniwal93

Updated script as per the feedback provided in comment 14 📌 Create automated script for converting components to SDC Fixed and 15 📌 Create automated script for converting components to SDC Fixed
https://github.com/qed42/twig-sdc-yaml-generator/tree/main

This update also supports automated prop generation for included components.

e.g tag component included in event card and they are available as prop for event card so now script will be able to generate below yml for it

   tags:
      type: array
      title: Tags
      description: Array of tags.
      items:
        type: string

Also for banner component breadcrumb is included and it's available as prop so yml will consist below

breadcrumb:
      type: array
      title: Breadcrumb
      description: Breadcrumb links.
      items:
        type: object
        properties:
          links:
            type: array
            title: Links
            description: 'Array of link objects containing:'
            items:
              type: object
              properties:
                text:
                  type: string
                  title: Text
                  description: Link text.
                url:
                  type: string
                  title: Url
                  description: Link URL.
          active_is_link:
            type: boolean
            title: Active is link
            description: Show active element as a link.

Next steps will check and work on feedback mentioned in comment 13 📌 Create automated script for converting components to SDC Fixed

🇮🇳India anand.toshniwal93

Progress Update

  1. Handling of array type as per schema (not pushed to repo)
  2. ntegrated include statements into the automated property generation process. (not pushed to repo)
{#
/**
 * @file
 * Banner component.
 *
 * Variables:
 * - content_top1: [string] Content slot.
 * - breadcrumb: [array] Breadcrumb links.
 * - content_top2: [string] Content slot.
 * - content_top3: [string] Content slot.
 * - content_middle: [string] Content slot.
 * - content: [string] Content slot.
 * - content_bottom: [string] Content slot.
 * - content_below: [string] Content slot.
 * - site_section: [string] Site section.
 * - title: [string] Title.
  *   ...
 */
#}

Example:

Consider the following Twig file :

{#
/**
* @file
* Banner component.
*
* Variables:
* - content_top1: [string] Content slot.
* - breadcrumb: [array] Breadcrumb links.
* - content_top2: [string] Content slot.
* - content_top3: [string] Content slot.
* - content_middle: [string] Content slot.
* - content: [string] Content slot.
* - content_bottom: [string] Content slot.
* - content_below: [string] Content slot.
* - site_section: [string] Site section.
* - title: [string] Title.
*/
#}
In this example, breadcrumb is a component rendered through an include statement in banner component:

{% if breadcrumb is not empty %}
  <div class="{% if featured_image is not empty %}col-xxs-12 col-m-6{% else %}col-xxs-12{% endif %}">
    {% include '@molecules/breadcrumb/breadcrumb.twig' with {
      theme: theme,
      links: breadcrumb.links,
      active_is_link: breadcrumb.active_is_link,
      modifier_class: 'ct-banner__breadcrumb',
    } only %}
  </div>
{% endif %}

In the comment section, breadcrumb is noted as an array. However, in the .component.yml file, we need to specify links as an array with properties under items.

The script can generate the following YAML, ensuring only the properties of breadcrumb used in the include statement are included (e.g., theme and other breadcrumb properties are excluded):

 breadcrumb:
      type: array
      title: Breadcrumb
      description: Breadcrumb links.
      items:
        links:
          type: array
          title: Links
          description: 'Array of link objects containing:'
          items:
            text:
              type: string
              title: Text
              description: Link text.
            url:
              type: string
              title: Url
              description: Link URL.
        active_is_link:
          type: boolean
          title: Active is link
          description: Show active element as a link.

The script now supports handling nested includes, such as an event card that includes a tag list, which in turn includes tag components.

Next steps

  1. Test this functionality and make any necessary adjustments to match the schema accurately.
  2. Update the repository.
🇮🇳India anand.toshniwal93

Am just started with experience builder so I might be wrong
I started looking into above mentioned issue and below are my findings

1. The above issue is caused due to incorrect fixture.
2. It's failing because layout fixture does not consist `type` property.
due to which keyedLayout is always empty.

Object.values(layout.children).map(item => {
    if (item.type && components[item.type]) {
      keyedLayout[item.uuid] = item
    }
    return true;
  })

3. Component fixture is not matching with endpoint response from `/xb-compnents`
const selectedComponentType = keyedLayout[selectedComponent].type || 'noop';
the above always results in null as keyedLayout is empty.

updating component fixture and layout fixture in below format resolve issue however if you click on nested components "slots" it throws an same error because they are not added to keyedLayout.
Component fixture

{
  "component_1": {
    "name": "Component 1",
    "id": "1"
  },

Layout fixture:

{
        "uuid": "43cd7aa4-0160-4787-a3af-baf44ff17a88",
        "children": [],
        "type": "component_1",
        "nodeType": "component"
      },
🇮🇳India anand.toshniwal93

After attempting to replicate the scenario, I discovered that disabling twig debug resolves the issue, resulting in everything functioning as expected. This aligns with the observation mentioned in the previous comment 🐛 For a view displaying an optional field, 'hide if empty' doesn't work where a node matches the view query but the field is empty Active , where the problem was rectified by turning off twig debugging.

Tried with Drupal: 9.5.11

🇮🇳India anand.toshniwal93

Removed extra added condition to verify if test pass.

🇮🇳India anand.toshniwal93

This patch will get applied if you are using patch from Create a multiple select dropdown widget

Had to create a separate patch for this as both patches making change on same line.

🇮🇳India anand.toshniwal93
  1. Fixed point mentioned by @mkalkbrenner.
  2. Updated condition in `cleanCurrentFilter` so that querystring which are not related to facets should be ignored while processing. I had exposed filter on form and it was being added to URL as ?f%5B0%5D=cloned&f%5B1%5D=services%3Aservice%201&keywords=cloned
🇮🇳India anand.toshniwal93

This is the correct patch, The latest patch here https://www.drupal.org/project/facets/issues/2811331 (comment 60) adds disabled attribute to reset option.
Added a check if disabled attribute is present then remove it. so that reset option can be used.

Sorry for the multiple previous comments 🙏

🇮🇳India anand.toshniwal93

This is the correct patch, The latest patch here https://www.drupal.org/project/facets/issues/2811331 (comment 60) adds disabled attribute to reset option.
Added a check if disabled attribute is present then remove it. so that reset option can be used.

Sorry for the multiple previous comments 🙏

🇮🇳India anand.toshniwal93

The latest patch here https://www.drupal.org/project/facets/issues/2811331 (comment 60) adds disabled attribute to reset option.
Added a check if disabled attribute is present then remove it. so that reset option can be used.

🇮🇳India anand.toshniwal93

Patch against 8.x-2.x-release for upgrade status report issues.

🇮🇳India anand.toshniwal93

After applying above patch am still getting an below error

Error : Call to undefined function _template_preprocess_webform_composite() in template_preprocess_webform_hierarchy() (line 28 of /app/docroot/modules/contrib/webform_hierarchy/webform_hierarchy.module )
#0 [internal function]: template_preprocess_webform_hierarchy(Array, 'webform_hierarc...', Array)
#1 /app/docroot/core/lib/Drupal/Core/Theme/ThemeManager.php(287): call_user_func_array('template_prepro...', Array)
#2 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render('webform_hierarc...', Array)
#3 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, true)
#4 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(148): Drupal\Core\Render\Renderer->render(Array, true)
#5 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#6 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(149): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure) )
#7 /app/docroot/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php(66): Drupal\Core\Render\Renderer->renderRoot(Array)
#8 /app/docroot/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(89): Drupal\Core\Render\MainContent\AjaxRenderer->renderResponse(Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\CurrentRouteMatch))
#9 /app/docroot/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
#10 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\Component\EventDispatcher\ ContainerAwareEventDispatcher))

I was able to get this working by replacing this
\Drupal::moduleHandler()->loadInclude('inc', 'webform', 'includes/webform.theme.template');

with \Drupal::service('module_handler')->loadInclude('webform', 'inc', 'includes/webform.theme.template');

🇮🇳India anand.toshniwal93

+1 (Waiting for the D10 compatible release)

🇮🇳India anand.toshniwal93
  1. Updated static queries to dynamic queries
  2. Fixed issue with batch processing

Patch re-rolled against 3.0.0-rc1 and with above updates.

🇮🇳India anand.toshniwal93

Re-rolling patch from comment 7 against 2.0.6

Production build 0.71.5 2024