sanity-io / orderable-document-list

Drag-and-drop Document Ordering without leaving the Editing surface
MIT License
73 stars 22 forks source link

Enhancements to OrderableDocumentList: Custom createIntent Handling & menuItems injection #75

Closed williamli closed 8 months ago

williamli commented 10 months ago

This PR introduces enhancements to the Orderable Document List menu of the Sanity plugin, allowing for greater customization. Currently, the menu is not customizable and defaults to three options: create, reset, and toggle increment. This update addresses the need for more flexible menu options, particularly in cases like using Sanity alongside of Shopify where the creation of ProductVariants should strictly be controlled by Shopify. When the listing is created as S.listItem()with a canHandleIntent function, ProductVariants creation in Sanity can be disabled; the same cannot be done when ProductVariants is listed using OrderableDocumentList (for custom sorting of variants).

Changes:

createIntent:

boolean, defaults to true.

Purpose

Allows control over the 'create' option in the menu.

Use Case:

In scenarios where records are managed externally (like Shopify) and synced to Sanity, the ability to disable the 'create' option prevents unintended creation of records.

menuItems:

array, defaults to [].

Purpose:

Allows the injection of additional menu items (S.menuItem()) into the Orderable Document List menu.

Benefit:

This feature provides flexibility to add more options to the menu, tailored to specific project requirements.