diff --git a/.changeset/tall-fireants-sleep.md b/.changeset/tall-fireants-sleep.md new file mode 100644 index 000000000..fecf4f508 --- /dev/null +++ b/.changeset/tall-fireants-sleep.md @@ -0,0 +1,6 @@ +--- +'@shopify/ui-extensions': minor +'@shopify/ui-extensions-react': minor +--- + +Add admin print action targets diff --git a/packages/ui-extensions/docs/surfaces/admin/staticPages/targets-overview.doc.ts b/packages/ui-extensions/docs/surfaces/admin/staticPages/targets-overview.doc.ts index 6804347ad..a02063e46 100644 --- a/packages/ui-extensions/docs/surfaces/admin/staticPages/targets-overview.doc.ts +++ b/packages/ui-extensions/docs/surfaces/admin/staticPages/targets-overview.doc.ts @@ -191,6 +191,35 @@ You register targets in your \`shopify.extension.toml\` and inside the Javascrip }, ], }, + { + type: 'GenericAccordion', + title: 'Admin print action locations', + anchorLink: 'print-locations', + sectionContent: + 'Admin print action extensions appear on order and product pages in the admin.', + accordionContent: [ + { + title: 'Order details', + description: + 'This page shows information about a single order. The `admin.order-details.print-action.render` target is available on this page.', + }, + { + title: 'Product details', + description: + 'This page shows information about a single product. The `admin.product-details.print-action.render` target is available on this page.', + }, + { + title: 'Order index selection', + description: + 'This page shows a table of multiple orders. The `admin.order-index.selection-print-action.render` target is available on this page when multiple orders are selected.', + }, + { + title: 'Product index selection', + description: + 'This page shows a table of multiple products. The `admin.product-index.selection-print-action.render` target is available on this page when multiple products are selected.', + }, + ], + }, { type: 'Markdown', title: 'Customer segmentation locations', diff --git a/packages/ui-extensions/src/surfaces/admin/api.ts b/packages/ui-extensions/src/surfaces/admin/api.ts index 838c4a8b8..995aeb523 100644 --- a/packages/ui-extensions/src/surfaces/admin/api.ts +++ b/packages/ui-extensions/src/surfaces/admin/api.ts @@ -4,6 +4,7 @@ export type {Navigation} from './api/block/block'; export type {CustomerSegmentTemplateApi} from './api/customer-segment-template/customer-segment-template'; export type {ActionExtensionApi} from './api/action/action'; export type {BlockExtensionApi} from './api/block/block'; +export type {PrintActionExtensionApi} from './api/print-action/print-action'; export type {ProductDetailsConfigurationApi} from './api/product-configuration/product-details-configuration'; export type {ProductVariantDetailsConfigurationApi} from './api/product-configuration/product-variant-details-configuration'; export type {OrderRoutingRuleApi} from './api/order-routing-rule/order-routing-rule'; diff --git a/packages/ui-extensions/src/surfaces/admin/api/print-action/print-action.doc.ts b/packages/ui-extensions/src/surfaces/admin/api/print-action/print-action.doc.ts new file mode 100644 index 000000000..8aff867ff --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/api/print-action/print-action.doc.ts @@ -0,0 +1,20 @@ +import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs'; + +const data: ReferenceEntityTemplateSchema = { + name: 'Print Action Extension API', + description: + 'This API is available to all print action extension types. Note that the [`AdminPrintAction`](/docs/api/admin-extensions/components/other/adminprintaction) component is required to build admin print action extensions.', + isVisualComponent: false, + type: 'API', + definitions: [ + { + title: 'PrintActionExtensionApi', + description: '', + type: 'PrintActionExtensionApi', + }, + ], + category: 'API', + related: [], +}; + +export default data; diff --git a/packages/ui-extensions/src/surfaces/admin/api/print-action/print-action.ts b/packages/ui-extensions/src/surfaces/admin/api/print-action/print-action.ts new file mode 100644 index 000000000..34eba6b51 --- /dev/null +++ b/packages/ui-extensions/src/surfaces/admin/api/print-action/print-action.ts @@ -0,0 +1,12 @@ +import type {StandardApi} from '../standard/standard'; +import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-targets'; +import type {Data} from '../shared'; + +export interface PrintActionExtensionApi< + ExtensionTarget extends AnyExtensionTarget, +> extends StandardApi { + /** + * Information about the currently viewed or selected items. + */ + data: Data; +} diff --git a/packages/ui-extensions/src/surfaces/admin/extension-targets.ts b/packages/ui-extensions/src/surfaces/admin/extension-targets.ts index 8e8961431..0ec438f45 100644 --- a/packages/ui-extensions/src/surfaces/admin/extension-targets.ts +++ b/packages/ui-extensions/src/surfaces/admin/extension-targets.ts @@ -6,6 +6,7 @@ import type { CustomerSegmentTemplateApi, ActionExtensionApi, BlockExtensionApi, + PrintActionExtensionApi, ProductDetailsConfigurationApi, ProductVariantDetailsConfigurationApi, OrderRoutingRuleApi, @@ -252,7 +253,7 @@ export interface ExtensionTargets { >; /** - * Renders an admin action extension in the abandonded checkout page. Open this extension from the "More Actions" menu. + * Renders an admin action extension in the abandoned checkout page. Open this extension from the "More Actions" menu. * * See the [list of available components](/docs/api/admin-extensions/components). */ @@ -335,7 +336,7 @@ export interface ExtensionTargets { >; /** - * Renders an admin action extension in the customer index page when multiple resources are selected. Open this extension from the "More Actions" menu of the resource list. The resource ids are available to this extension at runtime. + * Renders an admin action extension in the customer index page when multiple resources are selected. Open this extension from the "More Actions" menu of the resource list. The resource ids are available to this extension at runtime. * * See the [list of available components](/docs/api/admin-extensions/components). */ @@ -354,6 +355,50 @@ export interface ExtensionTargets { AllComponents >; + // Print actions and bulk print actions + + /** + * Renders an admin print action extension in the order index page when multiple resources are selected. Open this extension from the "Print" menu of the resource list. The resource ids are available to this extension at runtime. + * + * See the [list of available components](/docs/api/admin-extensions/components). + */ + 'admin.order-details.print-action.render': RenderExtension< + PrintActionExtensionApi<'admin.order-details.print-action.render'>, + AllComponents + >; + + /** + * Renders an admin print action extension in the product index page when multiple resources are selected. Open this extension from the "Print" menu of the resource list. The resource ids are available to this extension at runtime. + * + * See the [list of available components](/docs/api/admin-extensions/components). + */ + 'admin.product-details.print-action.render': RenderExtension< + PrintActionExtensionApi<'admin.product-details.print-action.render'>, + AllComponents + >; + + /** + * Renders an admin print action extension in the order index page when multiple resources are selected. Open this extension from the "Print" menu of the resource list. The resource ids are available to this extension at runtime. + * + * See the [list of available components](/docs/api/admin-extensions/components). + */ + 'admin.order-index.selection-print-action.render': RenderExtension< + PrintActionExtensionApi<'admin.order-index.selection-print-action.render'>, + AllComponents + >; + + /** + * Renders an admin print action extension in the product index page when multiple resources are selected. Open this extension from the "Print" menu of the resource list. The resource ids are available to this extension at runtime. + * + * See the [list of available components](/docs/api/admin-extensions/components). + */ + 'admin.product-index.selection-print-action.render': RenderExtension< + PrintActionExtensionApi<'admin.product-index.selection-print-action.render'>, + AllComponents + >; + + // Other + /** * Renders Product Configuration on product details and product variant details *