Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/blue-pears-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/app-sdk": minor
---

Added "options" field to AppExtension types within manifest
7 changes: 7 additions & 0 deletions .changeset/eight-eagles-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@saleor/app-sdk": minor
---

Added NEW_TAB target and WIDGET target for AppExtension.

[todo see docs](todo)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we wanted to add docs first or change it afterwards?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think we can merge docs yet so I'd wait to do that before the release

9 changes: 8 additions & 1 deletion .changeset/some-snakes-begin.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@ Add additional `AppExtensionMount` available in Saleor 3.22:
- "PAGE_TYPE_DETAILS_MORE_ACTIONS"
- "MENU_OVERVIEW_CREATE"
- "MENU_OVERVIEW_MORE_ACTIONS"
- "MENU_DETAILS_MORE_ACTIONS";
- "MENU_DETAILS_MORE_ACTIONS"
- "ORDER_DETAILS_WIDGETS"
- "DRAFT_ORDER_DETAILS_WIDGETS"
- "VOUCHER_DETAILS_WIDGETS"
- "PRODUCT_DETAILS_WIDGETS"
- "CUSTOMER_DETAILS_WIDGETS"
- "GIFT_CARD_DETAILS_WIDGETS"
- "COLLECTION_DETAILS_WIDGETS"
111 changes: 87 additions & 24 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type AppExtensionTarget = "POPUP" | "APP_PAGE";
export type AppExtensionTarget = "POPUP" | "APP_PAGE" | "NEW_TAB" | "WIDGET";

// Available mounts in Saleor 3.22 and newer
type AppExtensionMount3_22 =
Expand Down Expand Up @@ -28,7 +28,14 @@ type AppExtensionMount3_22 =
| "PAGE_TYPE_DETAILS_MORE_ACTIONS"
| "MENU_OVERVIEW_CREATE"
| "MENU_OVERVIEW_MORE_ACTIONS"
| "MENU_DETAILS_MORE_ACTIONS";
| "MENU_DETAILS_MORE_ACTIONS"
| "COLLECTION_DETAILS_WIDGETS"
| "CUSTOMER_DETAILS_WIDGETS"
| "PRODUCT_DETAILS_WIDGETS"
| "ORDER_DETAILS_WIDGETS"
| "DRAFT_ORDER_DETAILS_WIDGETS"
| "VOUCHER_DETAILS_WIDGETS"
| "GIFT_CARD_DETAILS_WIDGETS";

export type AppExtensionMount =
| AppExtensionMount3_22
Expand Down Expand Up @@ -229,26 +236,82 @@ export type SyncWebhookEventType =
| "PAYMENT_METHOD_INITIALIZE_TOKENIZATION_SESSION"
| "PAYMENT_METHOD_PROCESS_TOKENIZATION_SESSION";

export interface AppExtension {
interface BaseAppExtension {
/** Name which will be displayed in the dashboard */
label: string;
/** the place where the extension will be mounted */
mount: AppExtensionMount;
/** Method of presenting the interface
`POPUP` will present the interface in a modal overlay
`APP_PAGE` will navigate to the application page
@default `POPUP`
*/
target: AppExtensionTarget;
`POPUP` will present the interface in a modal overlay
`APP_PAGE` will navigate to the application page
@default `POPUP`
*/
permissions: AppPermission[];
/** URL of the view to display;
you can skip the domain and protocol when target is set to `APP_PAGE`, or when your manifest defines an `appUrl`.
you can skip the domain and protocol when target is set to `APP_PAGE`, or when your manifest defines an `appUrl`.

When target is set to `POPUP`, the url will be used to render an `<iframe>`.
When target is set to `POPUP`, the url will be used to render an `<iframe>`.
*/
url: string;
}

type PopupExtensionWidget = BaseAppExtension & {
target: "POPUP";
};

type AppPageExtensionWidget = BaseAppExtension & {
target: "APP_PAGE";
};

/**
* Added in 3.22
*/
type AppExtensionWidget = BaseAppExtension & {
target: "WIDGET";
/**
* Added in 3.22
*/
options?: {
widgetTarget?: {
/**
* Controls how dashboard will open the new tab
* - GET -> open URL in the new window
* - POST -> submit internal <form> using POST method. Passes token and additional parameters into body*
*/
method?: "GET" | "POST";
};
};
};

/**
* Added in 3.22
*/
type AppExtensionNewTab = BaseAppExtension & {
target: "NEW_TAB";
/**
* Added in 3.22
*/
options?: {
/**
* Only when target is NEW_TAB.
*/
newTabTarget?: {
/**
* Controls how dashboard will open the new tab
* - GET -> open URL in the new window
* - POST -> submit internal <form> using POST method. Passes token and additional parameters into body*
*/
method?: "GET" | "POST";
};
};
};

export type AppExtension =
| AppPageExtensionWidget
| AppExtensionNewTab
| AppExtensionWidget
| PopupExtensionWidget;

export interface WebhookManifest {
name: string;
asyncEvents?: AsyncWebhookEventType[];
Expand Down Expand Up @@ -282,18 +345,18 @@ export interface AppManifest {
/** App website rendered in the dashboard */
appUrl: string;
/** Address to the app configuration page, which is rendered in the dashboard
@deprecated in Saleor 3.5, use appUrl instead
*/
@deprecated in Saleor 3.5, use appUrl instead
*/
configurationUrl?: string;
/** Endpoint used during process of app installation

@see [Installing an app](https://docs.saleor.io/docs/3.x/developer/extending/apps/installing-apps#installing-an-app)
*/
@see [Installing an app](https://docs.saleor.io/docs/3.x/developer/extending/apps/installing-apps#installing-an-app)
*/
tokenTargetUrl: string;
/** Short description of privacy policy displayed in the dashboard

@deprecated in Saleor 3.5, use dataPrivacyUrl instead
*/
@deprecated in Saleor 3.5, use dataPrivacyUrl instead
*/
dataPrivacy?: string;
/** URL to the full privacy policy */
dataPrivacyUrl?: string;
Expand All @@ -303,17 +366,17 @@ export interface AppManifest {
supportUrl?: string;
/** List of extensions that will be mounted in Saleor's dashboard

@see For details, please see the [extension section](https://docs.saleor.io/docs/3.x/developer/extending/apps/extending-dashboard-with-apps#key-concepts)
*/
@see For details, please see the [extension section](https://docs.saleor.io/docs/3.x/developer/extending/apps/extending-dashboard-with-apps#key-concepts)
*/
extensions?: AppExtension[];
/** List of webhooks that will be set.

@see For details, please look at [asynchronous webhooks](https://docs.saleor.io/docs/3.x/developer/extending/apps/asynchronous-webhooks),
[synchronous-webhooks](https://docs.saleor.io/docs/3.x/developer/extending/apps/synchronous-webhooks/key-concepts)
and [webhooks' subscription](https://docs.saleor.io/docs/3.x/developer/extending/apps/subscription-webhook-payloads)

Be aware that subscription queries are required in manifest sections
*/
@see For details, please look at [asynchronous webhooks](https://docs.saleor.io/docs/3.x/developer/extending/apps/asynchronous-webhooks),
[synchronous-webhooks](https://docs.saleor.io/docs/3.x/developer/extending/apps/synchronous-webhooks/key-concepts)
and [webhooks' subscription](https://docs.saleor.io/docs/3.x/developer/extending/apps/subscription-webhook-payloads)

Be aware that subscription queries are required in manifest sections
*/
webhooks?: WebhookManifest[];
/**
* Allows app installation for specific Saleor versions, using semver.
Expand Down
Loading