Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lib): add modalSize object to the toggleModal message #447

Conversation

Dawntraoz
Copy link
Contributor

@Dawntraoz Dawntraoz commented Dec 24, 2024

What?

  • Retrieve isAIEnabled as plugin state
  • Add the requestUserContext action and postMessage functionality to grab the user info isSpaceAdmin and permissions
  • Add the modalSize as an optional parameter in the toggleModal postMessage to allow setting the max-width and/or max-height of the new modal with portal. (Only applicable when enablePortalModal is equal to true.

Why?

JIRA: SHAPE-7911 & SHAPE-7912

The user info, isSpaceAdmin is needed by us and the permissions property was requested on this issue and also needed in some of our integrations as, for example, the Akeneo PIM.

The need to define custom modal sizes and the isAIEnabled state property is an internal demand of an integration we are currently working on.

How to test? (optional)

To test it out, you will need to:

  1. Run the Storyfront locally using the feat/SHAPE-7911-get-the-new-provided-values-and-define-the-new-action branch (still being reviewed https://github.com/storyblok/storyfront/pull/6904).

  2. Open the packages/demo/src/components/FieldPluginDemo.tsx file and specify the targetOrigin to http://localhost:3300 (Storyfront running address):
    image

  3. Create a new fieldtype and deploy the field plugin demo:

yarn
yarn build
yarn workspace demo build

Now, copy the generated bundle file (located at packages/demo/dist/index.js) and paste it into the newly created field.

  1. Add the new field type to any of your stories.
    If everything was configured properly, you should see, in your Visual Editor, something similar to:
Screenshot 2025-01-02 at 18 39 25

Test new Actions:

New modal sizing

Check the modal sizing by clicking on the Toggle Modal button and check if the modal max-width was set to '50%' accordingly. Try changing this value and also adding a height.

Screenshot 2025-01-03 at 12 07 07

Request user context

You can change the logged-in user's permissions (under the space's Settings page) and see them reflected in the displayed text when requesting the user context by clicking the "Request user context" button.
Screenshot 2025-01-02 at 18 42 14

Then, access the story with a non-admin user to see if the isSpaceAdmin property is set to "No" when the user context is requested.

Test new State

Disable/Enable the AI feature under the space's settings page and check if the isAIEnabled property is correct.
image

@Dawntraoz Dawntraoz self-assigned this Dec 24, 2024
Copy link

vercel bot commented Dec 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plugin-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2025 1:15pm

@Dawntraoz Dawntraoz changed the title feat(SHAPE-7911): add modalSize object to the toggleModal message feat(lib): add modalSize object to the toggleModal message Dec 24, 2024
…y permissions types, add ModalSize type and ModalSize test
@Dawntraoz Dawntraoz force-pushed the feat/SHAPE-7911-get-the-new-provided-values-and-define-the-new-action branch from 4d82b09 to 3d0779d Compare January 2, 2025 11:16
Copy link
Contributor

@demetriusfeijoo demetriusfeijoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Dawntraoz

It took me some time to review (even already had checked it before) it but I guess I finished 🫠 🤣

The only thing I think should be looked at is the Sandbox not returning the callbackId to the field plugin to allow it to remove the callback from the queue properly and also to return a value correctly to the field plugin application.

Screen.Recording.2025-01-03.at.00.18.36.mov

@Dawntraoz
Copy link
Contributor Author

Thanks, @demetriusfeijoo, for the review! I have already introduced the changes you suggested. Can you double-check now? 🫂

Copy link
Contributor

@demetriusfeijoo demetriusfeijoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazingggg job @Dawntraoz 🚀 🚀

2025, here we go 🎉 🎉

@Dawntraoz Dawntraoz merged commit d16f691 into main Jan 9, 2025
4 checks passed
@Dawntraoz Dawntraoz deleted the feat/SHAPE-7911-get-the-new-provided-values-and-define-the-new-action branch January 9, 2025 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants