CL server unable to render the stories when storybook not installed at root of Drupal Installation

Created on 23 June 2023, over 1 year ago
Updated 29 April 2024, 9 months ago

Problem/Motivation

I had success working with Storybook along with SDC and CL Server when I followed all the steps in https://git.drupalcode.org/project/cl_server/-/blob/2.x/docs/storybook.md . However, there is one step where we need to install Storybook at the root of the Drupal installation. Doing so and making corresponding changes in main.js for discovering the stories, storybook stops working and gives as shown.

Steps to reproduce

Follow all the steps here: https://git.drupalcode.org/project/cl_server/-/blob/2.x/docs/storybook.md except the part where it says: "Add Storybook to your Drupal repo":

  1. Instead of installing it to the root of your repo, install storybook inside a custom theme.
  2. Create main.js in .storybook folder and change the paths in main.js for discovering stories inside the custom theme:
    // .storybook/main.js
    module.exports = {
      // Change the place where storybook searched for stories.
      stories: [
        "../**/*.stories.mdx",
        "../**/*.stories.@(json|yml)",
      ],
      // ...
    };
    
  3. Follow other steps as per the instructions.
  4. Start the storybook with npm or yarn command.
  5. Getting an error something like this:

Proposed resolution

Seems CL server is assuming the storybook will be calling the stories from the root, there needs to be sort some of logic to make this more flexible.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇮🇳India sagarchauhan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sagarchauhan
  • First commit to issue fork.
  • @lussoluca opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇮🇹Italy lussoluca Italy

    I've tried to reuse the discovery code from SDC to find the component

  • Status changed to Needs work over 1 year ago
  • e0ipso Can Picafort

    I think we need to figure out the question above.

  • 🇮🇹Italy lussoluca Italy

    What if two components have the same machine name, but different provider (module or theme that contains the component)?

    How the actual implementation solves this issue?

  • e0ipso Can Picafort

    That happens in the code you deleted in the MR.

  • 🇮🇹Italy lussoluca Italy

    Ok, I see what you mean; the story file must be in the component folder, and this solves the issue of multiple components with the same machine name but different providers.

    I'm still considering introducing Storybook in a new project, but in my setup, Storybook will probably not have access to the Drupal filesystem.

    Do you think we can introduce a new option to @lullabot/storybook-drupal-addon like variant to pass an optional provider? Then in this module, we can use the provider option to resolve cases where more than one component has the same machine name.

    I can update this MR and create a new one for @lullabot/storybook-drupal-addon, if you think this is a good idea.

  • 🇺🇸United States Danny Englander San Diego

    I tested the code from the MR and it is working fine with all the storybook things right within my theme folder. It sounds like there still needs work on this but I did want to chime in.

  • e0ipso Can Picafort

    #8 I think that the actual fix is to have a (like the domain for the Drupal site) that specifies the path of the Storybook install. Then we can pass that setting (if not empty) in the HTTP request, like you are mentioning for the abandoned "variant". This info can be leveraged in the findStoryFile.

  • First commit to issue fork.
  • 🇫🇷France prudloff Lille

    All our components are in the theme, so I wrote a patch that always uses the theme as provider.
    But I understand why this solution would not work for everyone.

  • 🇳🇱Netherlands yustinTR

    this works for me

  • 🇳🇱Netherlands eelkeblok Netherlands 🇳🇱

    It is helpful to say what the source of your patch is. I think it is just the contents of merge request 13, right?

  • 🇳🇱Netherlands eelkeblok Netherlands 🇳🇱

    I merged 2.x into the "only use theme" branch. I suspect this was actually not necessary (but doesn't hurt either), I was getting my patches mixed up.

  • 🇪🇨Ecuador afsch Otavalo

    I had the same error, for my project, I had to update the module and create a patch to revert this file "src/Controller/ServerEndpointController.php" because looks like the change from cl_components to sdc is not fully compatible yet.

Production build 0.71.5 2024