diff --git a/.github/workflows/deploy-cloud.yaml b/.github/workflows/deploy-cloud.yaml index 4737f6653..dc5f9fddf 100644 --- a/.github/workflows/deploy-cloud.yaml +++ b/.github/workflows/deploy-cloud.yaml @@ -17,8 +17,12 @@ jobs: REGION: ${{ github.event.client_payload.region }} SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - MARKETPLACE_URL: "https://apps.saleor.io/" - SALEOR_APPS_ENDPOINT: "https://apps.saleor.io/api/saleor-apps" + # Disable preview when new Marketplace features are in progress. + # If marketplace is done till next release this can be easily enabled + # MARKETPLACE_URL: "https://apps.saleor.io/" + # SALEOR_APPS_PAGE_PATH=saleor-apps + # SALEOR_APPS_JSON_PATH=api/saleor-apps + # APP_TEMPLATE_GALLERY_PATH=template-gallery IS_CLOUD_INSTANCE: true steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/deploy-demo-staging.yaml b/.github/workflows/deploy-demo-staging.yaml index 082e3ceb2..1f7d87051 100644 --- a/.github/workflows/deploy-demo-staging.yaml +++ b/.github/workflows/deploy-demo-staging.yaml @@ -20,8 +20,12 @@ jobs: SENTRY_URL_PREFIX: "~/dashboard/static" SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - MARKETPLACE_URL: "https://apps.saleor.io/" - SALEOR_APPS_ENDPOINT: "https://apps.saleor.io/api/saleor-apps" + # Disable preview when new Marketplace features are in progress. + # If marketplace is done till next release this can be easily enabled + # MARKETPLACE_URL: "https://apps.saleor.io/" + # SALEOR_APPS_PAGE_PATH=saleor-apps + # SALEOR_APPS_JSON_PATH=api/saleor-apps + # APP_TEMPLATE_GALLERY_PATH=template-gallery ENVIRONMENT: demo-staging DEMO_MODE: true steps: diff --git a/.github/workflows/deploy-demo.yaml b/.github/workflows/deploy-demo.yaml index c8df89481..c15d2e35b 100644 --- a/.github/workflows/deploy-demo.yaml +++ b/.github/workflows/deploy-demo.yaml @@ -15,8 +15,12 @@ jobs: SENTRY_URL_PREFIX: "~/dashboard/static" SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - MARKETPLACE_URL: "https://apps.saleor.io/" - SALEOR_APPS_ENDPOINT: "https://apps.saleor.io/api/saleor-apps" + # Disable preview when new Marketplace features are in progress. + # If marketplace is done till next release this can be easily enabled + # MARKETPLACE_URL: "https://apps.saleor.io/" + # SALEOR_APPS_PAGE_PATH=saleor-apps + # SALEOR_APPS_JSON_PATH=api/saleor-apps + # APP_TEMPLATE_GALLERY_PATH=template-gallery ENVIRONMENT: demo DEMO_MODE: true steps: diff --git a/.github/workflows/deploy-master-staging.yaml b/.github/workflows/deploy-master-staging.yaml index fe8a510c8..4b34be641 100644 --- a/.github/workflows/deploy-master-staging.yaml +++ b/.github/workflows/deploy-master-staging.yaml @@ -18,7 +18,9 @@ jobs: SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} MARKETPLACE_URL: "https://marketplace-gray.vercel.app/" - SALEOR_APPS_ENDPOINT: "https://marketplace-gray.vercel.app/api/saleor-apps" + SALEOR_APPS_PAGE_PATH: saleor-apps + SALEOR_APPS_JSON_PATH: api/saleor-apps + APP_TEMPLATE_GALLERY_PATH: template-gallery ENVIRONMENT: saleor-master-staging IS_CLOUD_INSTANCE: true steps: diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index aebf03ee7..9e10d56ab 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -22,8 +22,12 @@ jobs: SENTRY_URL_PREFIX: "~/dashboard/static" SENTRY_DSN: ${{ secrets.SENTRY_DSN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - MARKETPLACE_URL: "https://apps.saleor.io/" - SALEOR_APPS_ENDPOINT: "https://apps.saleor.io/api/saleor-apps" + # Disable preview when new Marketplace features are in progress. + # If marketplace is done till next release this can be easily enabled + # MARKETPLACE_URL: "https://apps.saleor.io/" + # SALEOR_APPS_PAGE_PATH=saleor-apps + # SALEOR_APPS_JSON_PATH=api/saleor-apps + # APP_TEMPLATE_GALLERY_PATH=template-gallery VERSION: ${{ github.event.inputs.git_ref || github.ref_name }} IS_CLOUD_INSTANCE: true steps: diff --git a/README.md b/README.md index c9eb6271b..57cd9df08 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,14 @@ Create `.env` file in a root directory or set environment variables with followi - `STATIC_URL` - URL where the static files are located. E.g. if you use S3 bucket, you should set it to the bucket's URL. By default Saleor assumes you serve static files from the root of your site at `http://localhost:9000/`. +- `MARKETPLACE_URL` - URL where Marketplace App can is located, if not found, will not render navigation link to Marketplace + +- `SALEOR_APPS_PAGE_PATH` - Path joined to `MARKETPLACE_URL` to render Saleor Apps page + +- `SALEOR_APPS_JSON_PATH` - Path joined to `MARKETPLACE_URL` to fetch list of Saleor Apps as JSON + +- `APP_TEMPLATE_GALLERY_PATH` - Path joined to `MARKETPLACE_URL` to render App Template Gallery page + ### Development To start the development server run: diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index e6f0f5c94..58645c770 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -1968,10 +1968,6 @@ "context": "date time attribute type", "string": "Date Time" }, - "E+M17x": { - "context": "marketplace section name", - "string": "Marketplace" - }, "E22x4H": { "context": "no card defuned alert message", "string": "You haven’t defined a gift card product!" @@ -3059,6 +3055,10 @@ "context": "collection", "string": "Not Published" }, + "M2dPzK": { + "context": "app template gallery section name", + "string": "App Templates Gallery" + }, "M6s/9e": { "context": "unassign country, dialog header", "string": "Remove from Shipping Zone" @@ -7238,6 +7238,10 @@ "context": "order total amount", "string": "Total" }, + "ti4Hqw": { + "context": "saleor marketplace section name", + "string": "Saleor Apps Marketplace" + }, "tlGXkh": { "context": "input description", "string": "Unlimited" @@ -7287,6 +7291,9 @@ "u0V06N": { "string": "Max. Order Weight" }, + "u0VQMN": { + "string": "Browse Marketplace" + }, "u24Ppd": { "string": "This attribute cannot be assigned to this product type" }, diff --git a/package-lock.json b/package-lock.json index f989f036a..e72a42374 100644 --- a/package-lock.json +++ b/package-lock.json @@ -106,7 +106,7 @@ "@pollyjs/core": "^5.0.0", "@pollyjs/persister-fs": "^5.0.0", "@release-it/bumper": "^2.0.0", - "@saleor/app-sdk": "~0.20.0", + "@saleor/app-sdk": "~0.23.0", "@sentry/webpack-plugin": "^1.14.0", "@storybook/addon-storyshots": "^5.2.8", "@storybook/react": "^5.1.9", @@ -6332,9 +6332,9 @@ } }, "node_modules/@saleor/app-sdk": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@saleor/app-sdk/-/app-sdk-0.20.0.tgz", - "integrity": "sha512-3vdtnOxt5QGcb4B2o2WR2zQa9fFV3VlxvJWNu22v2Bct1RG6dfv8OrguSFpEARSN2K2E0Bq9Gr80J2vQFiIocg==", + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@saleor/app-sdk/-/app-sdk-0.23.0.tgz", + "integrity": "sha512-tlSwuMhK0CsPI+HoEPZny4hnpUWLd2uPtKH1I0B3z6/Smv8VPUV4bSEKVsPseZ97KQG472yDDaqmSzsZyo43nQ==", "dev": true, "dependencies": { "debug": "^4.3.4", @@ -6347,7 +6347,7 @@ "uuid": "^8.3.2" }, "peerDependencies": { - "next": "^12", + "next": ">=12", "react": ">=17", "react-dom": ">=17" } @@ -45315,9 +45315,9 @@ } }, "@saleor/app-sdk": { - "version": "0.20.0", - "resolved": "https://registry.npmjs.org/@saleor/app-sdk/-/app-sdk-0.20.0.tgz", - "integrity": "sha512-3vdtnOxt5QGcb4B2o2WR2zQa9fFV3VlxvJWNu22v2Bct1RG6dfv8OrguSFpEARSN2K2E0Bq9Gr80J2vQFiIocg==", + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@saleor/app-sdk/-/app-sdk-0.23.0.tgz", + "integrity": "sha512-tlSwuMhK0CsPI+HoEPZny4hnpUWLd2uPtKH1I0B3z6/Smv8VPUV4bSEKVsPseZ97KQG472yDDaqmSzsZyo43nQ==", "dev": true, "requires": { "debug": "^4.3.4", diff --git a/package.json b/package.json index 787708439..b5c0ac5fb 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "@pollyjs/core": "^5.0.0", "@pollyjs/persister-fs": "^5.0.0", "@release-it/bumper": "^2.0.0", - "@saleor/app-sdk": "~0.20.0", + "@saleor/app-sdk": "~0.23.0", "@sentry/webpack-plugin": "^1.14.0", "@storybook/addon-storyshots": "^5.2.8", "@storybook/react": "^5.1.9", diff --git a/src/apps/components/AppPageTabs/AppPageTabs.tsx b/src/apps/components/AppPageTabs/AppPageTabs.tsx index 54301c8f4..06e3dabe6 100644 --- a/src/apps/components/AppPageTabs/AppPageTabs.tsx +++ b/src/apps/components/AppPageTabs/AppPageTabs.tsx @@ -1,17 +1,22 @@ +import { AppPagePathSegment } from "@saleor/apps/hooks/useAppsPageNavigation"; import { PageTab, PageTabs } from "@saleor/macaw-ui"; import React, { ComponentProps } from "react"; import { useIntl } from "react-intl"; -export type AppPageTabValue = - | "THIRD_PARTY" - | "WEBHOOKS_AND_EVENTS" - | "SALEOR_APPS"; +/** + * Bind tab value to path segment to avoid unnecessary mapping + */ +const TabValue: Record = { + SALEOR_APPS: "saleor-apps", + THIRD_PARTY: "third-party", + WEBHOOKS_AND_EVENTS: "webhooks-and-events", +}; type AllProps = ComponentProps; type AvailableProps = Omit & { - value: AppPageTabValue; + value: AppPagePathSegment; showSaleorApps: boolean; - onChange(newValue: AppPageTabValue): void; + onChange(newValue: AppPagePathSegment): void; }; export const AppPageTabs = ({ showSaleorApps, ...props }: AvailableProps) => { @@ -19,23 +24,23 @@ export const AppPageTabs = ({ showSaleorApps, ...props }: AvailableProps) => { return ( - + {showSaleorApps && ( = ({ saleorAppsEnabled, } = useSaleorApps(); + const { updatePath, activeTab } = useAppsPageNavigation(); + useEffect(() => { if (saleorAppsEnabled) { fetchApps(); @@ -64,7 +70,7 @@ const AppsListPage: React.FC = ({ const styles = useStyles(); const intl = useIntl(); - const [activeTab, setActiveTab] = useState("THIRD_PARTY"); + const navigate = useNavigator(); const appsInProgress = appsInProgressList?.appsInstallations; @@ -93,7 +99,7 @@ const AppsListPage: React.FC = ({ const renderContent = () => { switch (activeTab) { - case "THIRD_PARTY": { + case "third-party": { return ( <>

@@ -129,7 +135,7 @@ const AppsListPage: React.FC = ({ ); } - case "WEBHOOKS_AND_EVENTS": { + case "webhooks-and-events": { return ( <>

@@ -147,7 +153,7 @@ const AppsListPage: React.FC = ({ ); } - case "SALEOR_APPS": { + case "saleor-apps": { return ( <>

@@ -167,6 +173,19 @@ const AppsListPage: React.FC = ({ onRemove={onInstalledAppRemove} {...listProps} /> +

+ +
); } @@ -179,7 +198,7 @@ const AppsListPage: React.FC = ({ {renderContent()} diff --git a/src/apps/hooks/useAppsPageNavigation.ts b/src/apps/hooks/useAppsPageNavigation.ts new file mode 100644 index 000000000..f4ca887f5 --- /dev/null +++ b/src/apps/hooks/useAppsPageNavigation.ts @@ -0,0 +1,43 @@ +import { appsSection } from "@saleor/apps/urls"; +import useNavigator from "@saleor/hooks/useNavigator"; +import { useCallback, useMemo } from "react"; +import useRouter from "use-react-router"; + +export type AppPagePathSegment = + | "webhooks-and-events" + | "third-party" + | "saleor-apps"; + +const defaultTab: AppPagePathSegment = "webhooks-and-events"; +const appTypeQueryParam = "type"; + +export const useAppsPageNavigation = () => { + const navigate = useNavigator(); + const { + location: { search }, + } = useRouter(); + + const updatePath = useCallback( + (value: AppPagePathSegment) => { + const qs = new URLSearchParams({ + [appTypeQueryParam]: value, + }).toString(); + + navigate(`${appsSection}?${qs}`, { replace: true, resetScroll: true }); + }, + [navigate], + ); + + const activeTab: AppPagePathSegment = useMemo( + () => + (new URLSearchParams(search).get( + appTypeQueryParam, + ) as AppPagePathSegment) ?? defaultTab, + [search], + ); + + return { + updatePath, + activeTab, + }; +}; diff --git a/src/apps/hooks/useSaleorApps.ts b/src/apps/hooks/useSaleorApps.ts index 94d6951ae..e28e8bf0a 100644 --- a/src/apps/hooks/useSaleorApps.ts +++ b/src/apps/hooks/useSaleorApps.ts @@ -1,4 +1,4 @@ -import { SALEOR_APPS_ENDPOINT } from "@saleor/config"; +import { marketplaceUrlResolver } from "@saleor/marketplace/marketplace-url-resolver"; import { useCallback, useState } from "react"; export interface SaleorApp { @@ -6,7 +6,7 @@ export interface SaleorApp { hostname: string; } -const saleorAppsEnabled = Boolean(SALEOR_APPS_ENDPOINT); +const saleorAppsEnabled = marketplaceUrlResolver.checkMarketplaceConfigExists(); export const useSaleorApps = () => { const [apps, setApps] = useState(undefined); @@ -16,7 +16,7 @@ export const useSaleorApps = () => { return; } - return fetch(SALEOR_APPS_ENDPOINT) + return fetch(marketplaceUrlResolver.getSaleorAppsJsonEndpoint()) .then(response => response.json()) .then((data: SaleorApp[]) => { if ( diff --git a/src/components/AppLayout/menuStructure.ts b/src/components/AppLayout/menuStructure.ts index c4e199876..c8440949a 100644 --- a/src/components/AppLayout/menuStructure.ts +++ b/src/components/AppLayout/menuStructure.ts @@ -18,7 +18,7 @@ import { giftCardListUrl } from "@saleor/giftCards/urls"; import { PermissionEnum, UserFragment } from "@saleor/graphql"; import { commonMessages, sectionNames } from "@saleor/intl"; import { SidebarMenuItem } from "@saleor/macaw-ui"; -import { marketplaceUrl } from "@saleor/marketplace/urls"; +import { marketplaceUrlResolver } from "@saleor/marketplace/marketplace-url-resolver"; import { pageListPath } from "@saleor/pages/urls"; import { IntlShape } from "react-intl"; @@ -76,8 +76,14 @@ function useMenuStructure( { ariaLabel: "marketplace", label: intl.formatMessage(sectionNames.marketplace), - id: "marketplace", - url: marketplaceUrl, + id: "marketplace-saleor-apps", + url: marketplaceUrlResolver.getSaleorAppsDashboardPath(), + }, + { + ariaLabel: "marketplace", + label: intl.formatMessage(sectionNames.appTemplateGallery), + id: "marketplace-template-gallery", + url: marketplaceUrlResolver.getTemplateGalleryDashboardPath(), }, ], }; diff --git a/src/config.ts b/src/config.ts index 752b1653b..7f4381fe5 100644 --- a/src/config.ts +++ b/src/config.ts @@ -8,8 +8,13 @@ export const getAppMountUri = () => export const getApiUrl = () => window.__SALEOR_CONFIG__.API_URL; export const SW_INTERVAL = parseInt(process.env.SW_INTERVAL, 10); export const IS_CLOUD_INSTANCE = process.env.IS_CLOUD_INSTANCE === "true"; -export const MARKETPLACE_URL = process.env.MARKETPLACE_URL; -export const SALEOR_APPS_ENDPOINT = process.env.SALEOR_APPS_ENDPOINT; +export const MARKETPLACE_URL = window.__SALEOR_CONFIG__.MARKETPLACE_URL; +export const MARKETPLACE_SALEOR_APPS_PAGE_PATH = + window.__SALEOR_CONFIG__.SALEOR_APPS_PAGE_PATH; +export const MARKETPLACE_SALEOR_APPS_JSON_PATH = + window.__SALEOR_CONFIG__.SALEOR_APPS_JSON_PATH; +export const MARKETPLACE_APP_TEMPLATE_GALLERY_PATH = + window.__SALEOR_CONFIG__.APP_TEMPLATE_GALLERY_PATH; export const DEFAULT_INITIAL_SEARCH_DATA: SearchVariables = { after: null, diff --git a/src/index.html b/src/index.html index 790324dcc..9d84ba38a 100644 --- a/src/index.html +++ b/src/index.html @@ -10,8 +10,12 @@ Saleor e-commerce diff --git a/src/intl.ts b/src/intl.ts index c8738d545..5288786a9 100644 --- a/src/intl.ts +++ b/src/intl.ts @@ -397,9 +397,14 @@ export const sectionNames = defineMessages({ description: "home section name", }, marketplace: { - id: "E+M17x", - defaultMessage: "Marketplace", - description: "marketplace section name", + id: "ti4Hqw", + defaultMessage: "Saleor Apps Marketplace", + description: "saleor marketplace section name", + }, + appTemplateGallery: { + id: "M2dPzK", + defaultMessage: "App Templates Gallery", + description: "app template gallery section name", }, navigation: { id: "9C7PZE", diff --git a/src/marketplace/index.tsx b/src/marketplace/index.tsx index ef6694446..8cc2494e8 100644 --- a/src/marketplace/index.tsx +++ b/src/marketplace/index.tsx @@ -6,17 +6,28 @@ import { WindowTitle } from "@saleor/components/WindowTitle"; import { MARKETPLACE_URL } from "@saleor/config"; import useNavigator from "@saleor/hooks/useNavigator"; import { sectionNames } from "@saleor/intl"; -import React from "react"; +import { marketplaceUrlResolver } from "@saleor/marketplace/marketplace-url-resolver"; +import { marketplaceUrl } from "@saleor/marketplace/urls"; +import React, { useMemo } from "react"; import { useIntl } from "react-intl"; +import useRouter from "use-react-router"; import { useStyles } from "./styles"; +const getDeepPath = (path: string) => path.replace(marketplaceUrl, ""); + const Component = () => { const classes = useStyles(); const intl = useIntl(); const navigate = useNavigator(); + const router = useRouter(); - if (!MARKETPLACE_URL) { + const marketplaceUrl = useMemo( + () => new URL(getDeepPath(router.location.pathname), MARKETPLACE_URL).href, + [router.location.pathname], + ); + + if (!marketplaceUrlResolver.checkMarketplaceConfigExists()) { return navigate("/")} />; } @@ -26,7 +37,7 @@ const Component = () => { { + const resolver = new MarketplaceUrlResolver(); + + expect( + resolver.getMarketplaceDeepUrlFromPath("/marketplace/saleor-apps"), + ).toEqual("/saleor-apps"); + }); + + it("Generates full dashboard url that points to Marketplace - Saleor Apps", () => { + const resolver = new MarketplaceUrlResolver(); + + expect(resolver.getSaleorAppsDashboardPath()).toEqual( + "/marketplace/saleor-apps", + ); + }); + + it("Generates full dashboard url that points to Marketplace - App Template Gallery", () => { + const resolver = new MarketplaceUrlResolver(); + + expect(resolver.getTemplateGalleryDashboardPath()).toEqual( + "/marketplace/template-gallery", + ); + }); +}); diff --git a/src/marketplace/marketplace-url-resolver.ts b/src/marketplace/marketplace-url-resolver.ts new file mode 100644 index 000000000..2fe71653c --- /dev/null +++ b/src/marketplace/marketplace-url-resolver.ts @@ -0,0 +1,43 @@ +import { + MARKETPLACE_APP_TEMPLATE_GALLERY_PATH, + MARKETPLACE_SALEOR_APPS_JSON_PATH, + MARKETPLACE_SALEOR_APPS_PAGE_PATH, + MARKETPLACE_URL, +} from "@saleor/config"; +import urlJoin from "url-join"; + +export class MarketplaceUrlResolver { + private rootSection = "/marketplace"; + + private marketplaceAppBaseUrl = MARKETPLACE_URL; + private saleorAppsPath = MARKETPLACE_SALEOR_APPS_PAGE_PATH; + private saleorAppsJsonPath = MARKETPLACE_SALEOR_APPS_JSON_PATH; + private templateGalleryJsonPath = MARKETPLACE_APP_TEMPLATE_GALLERY_PATH; + + checkMarketplaceConfigExists() { + return Boolean( + this.marketplaceAppBaseUrl && + this.saleorAppsPath && + this.saleorAppsJsonPath && + this.templateGalleryJsonPath, + ); + } + + getMarketplaceDeepUrlFromPath(path: string) { + return path.replace(this.rootSection, ""); + } + + getTemplateGalleryDashboardPath() { + return urlJoin(this.rootSection, MARKETPLACE_APP_TEMPLATE_GALLERY_PATH); + } + + getSaleorAppsDashboardPath() { + return urlJoin(this.rootSection, MARKETPLACE_SALEOR_APPS_PAGE_PATH); + } + + getSaleorAppsJsonEndpoint() { + return urlJoin(this.marketplaceAppBaseUrl, this.saleorAppsJsonPath); + } +} + +export const marketplaceUrlResolver = new MarketplaceUrlResolver(); diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index c66c4ab5c..66c1d7a00 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -25434,6 +25434,7 @@ exports[`Storyshots Views / Apps / Apps list default 1`] = ` +

- Third party apps are installed with App Manifests. They contain UI accessible from dashboard and can extend it. + Local apps are custom webhooks & token pairs that can be used to connect apps and access Saleor API.

- Ongoing Installations - -
-
-
- - - - - - - - - - - - - - -
- - app - - -
- Problem occured during installation - -
- - -
- - app pending - - -
- Installing app... -
-
-
- - - -
-
-
- - app success - -
-
- -
-
-
-
- - Third Party Apps + Internal Apps
- +
-
`; diff --git a/testUtils/setup.ts b/testUtils/setup.ts index c3a3ac668..5d6e3aaf0 100644 --- a/testUtils/setup.ts +++ b/testUtils/setup.ts @@ -3,4 +3,8 @@ document.getElementById = () => document.createElement("div"); window.__SALEOR_CONFIG__ = { API_URL: "http://localhost:8000/graphql/", APP_MOUNT_URI: "/", + MARKETPLACE_URL: "http//localhost:3000", + SALEOR_APPS_PAGE_PATH: "/saleor-apps", + SALEOR_APPS_JSON_PATH: "/api/saleor-apps", + APP_TEMPLATE_GALLERY_PATH: "/template-gallery", }; diff --git a/types.d.ts b/types.d.ts index 297b69044..3b0a980f8 100644 --- a/types.d.ts +++ b/types.d.ts @@ -10,5 +10,9 @@ declare interface Window { __SALEOR_CONFIG__: { API_URL: string; APP_MOUNT_URI: string; + MARKETPLACE_URL: string; + SALEOR_APPS_PAGE_PATH: string; + SALEOR_APPS_JSON_PATH: string; + APP_TEMPLATE_GALLERY_PATH: string; }; } diff --git a/vite.config.js b/vite.config.js index bf87e7b6c..e74cc310f 100644 --- a/vite.config.js +++ b/vite.config.js @@ -24,6 +24,9 @@ export default defineConfig(({ command, mode }) => { SENTRY_DSN, ENVIRONMENT, STATIC_URL, + SALEOR_APPS_PAGE_PATH, + SALEOR_APPS_JSON_PATH, + APP_TEMPLATE_GALLERY_PATH, } = env; const enableSentry = @@ -38,6 +41,10 @@ export default defineConfig(({ command, mode }) => { data: { API_URL: API_URI, APP_MOUNT_URI, + SALEOR_APPS_PAGE_PATH, + SALEOR_APPS_JSON_PATH, + APP_TEMPLATE_GALLERY_PATH, + MARKETPLACE_URL, }, }, }),