Remove legacy Marketplace code and env variables that it was using (#3342)

* Remove legacy Marketplace code and env variables that it was using

* Update locales
This commit is contained in:
Lukasz Ostrowski 2023-03-14 12:17:19 +01:00 committed by GitHub
parent 183a523e50
commit 5b945162a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 11 additions and 266 deletions

View file

@ -26,7 +26,6 @@ Modify API_URI if you want test instance to use custom backend. CYPRESS_API_URI
API_URI=https://automation-dashboard.staging.saleor.cloud/graphql/
APPS_MARKETPLACE_API_URI=https://apps.staging.saleor.io/api/v2/saleor-apps
SALEOR_APPS_ENDPOINT=https://apps.saleor.io/api/saleor-apps
### Do you want to run more stable tests?

View file

@ -20,9 +20,8 @@ COPY src/ src/
ARG API_URI
ARG APP_MOUNT_URI
ARG APPS_MARKETPLACE_API_URI,
ARG APPS_TUNNEL_URL_KEYWORDS,
ARG SALEOR_APPS_ENDPOINT
ARG APPS_MARKETPLACE_API_URI
ARG APPS_TUNNEL_URL_KEYWORDS
ARG STATIC_URL
ARG SKIP_SOURCEMAPS
@ -30,7 +29,6 @@ ENV API_URI ${API_URI:-http://localhost:8000/graphql/}
ENV APP_MOUNT_URI ${APP_MOUNT_URI:-/dashboard/}
ENV APPS_MARKETPLACE_API_URI ${APPS_MARKETPLACE_API_URI:-https://apps.saleor.io/api/v2/saleor-apps}
ENV APPS_TUNNEL_URL_KEYWORDS ${APPS_TUNNEL_URL_KEYWORDS}
ENV SALEOR_APPS_ENDPOINT=${SALEOR_APPS_ENDPOINT}
ENV STATIC_URL ${STATIC_URL:-/dashboard/}
ENV SKIP_SOURCEMAPS ${SKIP_SOURCEMAPS:-true}
RUN npm run build

View file

@ -3279,10 +3279,6 @@
"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"
@ -7780,10 +7776,6 @@
"context": "order total amount",
"string": "Total"
},
"ti4Hqw": {
"context": "saleor marketplace section name",
"string": "Saleor Apps Marketplace"
},
"tlGXkh": {
"context": "input description",
"string": "Unlimited"

View file

@ -60,7 +60,7 @@ describe("RowActions", () => {
expect(screen.getByTestId("show-more-button")).toBeInTheDocument();
});
it("should render card meu with multiple items", async () => {
it("should render card menu with multiple items", async () => {
// Arrange
render(
<ThemeProvider>

View file

@ -6,7 +6,6 @@ import { AppPaths } from "@dashboard/apps/urls";
import { useUser } from "@dashboard/auth";
import { categoryListUrl } from "@dashboard/categories/urls";
import { collectionListUrl } from "@dashboard/collections/urls";
import { MARKETPLACE_URL } from "@dashboard/config";
import { configurationMenuUrl } from "@dashboard/configuration";
import { getConfigMenuItemsPermissions } from "@dashboard/configuration/utils";
import { customerListUrl } from "@dashboard/customers/urls";
@ -14,7 +13,6 @@ import { saleListUrl, voucherListUrl } from "@dashboard/discounts/urls";
import { giftCardListUrl } from "@dashboard/giftCards/urls";
import { PermissionEnum } from "@dashboard/graphql";
import { commonMessages, sectionNames } from "@dashboard/intl";
import { marketplaceUrlResolver } from "@dashboard/marketplace/marketplace-url-resolver";
import { orderDraftListUrl, orderListUrl } from "@dashboard/orders/urls";
import { pageListPath } from "@dashboard/pages/urls";
import { productListUrl } from "@dashboard/products/urls";
@ -54,48 +52,14 @@ export function useMenuStructure() {
paddingY: 4,
};
// This will be deleted when Marketplace is released
// Consider this solution as temporary
const getAppSection = (): SidebarMenuItem => {
if (MARKETPLACE_URL) {
return {
icon: <MarketplaceIcon {...iconSettings} />,
label: intl.formatMessage(sectionNames.apps),
permissions: [PermissionEnum.MANAGE_APPS],
id: "apps_section",
type: "itemGroup",
children: [
{
label: intl.formatMessage(sectionNames.apps),
id: "apps",
url: AppPaths.appListPath,
type: "item",
},
{
label: intl.formatMessage(sectionNames.marketplace),
id: "marketplace-saleor-apps",
url: marketplaceUrlResolver.getSaleorAppsDashboardPath(),
type: "item",
},
{
label: intl.formatMessage(sectionNames.appTemplateGallery),
id: "marketplace-template-gallery",
url: marketplaceUrlResolver.getTemplateGalleryDashboardPath(),
type: "item",
},
],
};
}
return {
const getAppSection = (): SidebarMenuItem => ({
icon: <MarketplaceIcon {...iconSettings} />,
label: intl.formatMessage(sectionNames.apps),
permissions: [PermissionEnum.MANAGE_APPS],
id: "apps",
url: AppPaths.appListPath,
type: "item",
};
};
});
const menuItems: SidebarMenuItem[] = [
{

View file

@ -9,25 +9,6 @@ export const getApiUrl = () => window.__SALEOR_CONFIG__.API_URL;
export const SW_INTERVAL = parseInt(process.env.SW_INTERVAL, 10) || 300;
export const IS_CLOUD_INSTANCE =
window.__SALEOR_CONFIG__.IS_CLOUD_INSTANCE === "true";
/**
* @deprecated
*/
export const MARKETPLACE_URL = window.__SALEOR_CONFIG__.MARKETPLACE_URL;
/**
* @deprecated
*/
export const MARKETPLACE_SALEOR_APPS_PAGE_PATH =
window.__SALEOR_CONFIG__.SALEOR_APPS_PAGE_PATH;
/**
* @deprecated
*/
export const MARKETPLACE_SALEOR_APPS_JSON_PATH =
window.__SALEOR_CONFIG__.SALEOR_APPS_JSON_PATH;
/**
* @deprecated
*/
export const MARKETPLACE_APP_TEMPLATE_GALLERY_PATH =
window.__SALEOR_CONFIG__.APP_TEMPLATE_GALLERY_PATH;
export const getAppsConfig = () => ({
marketplaceApiUri: window.__SALEOR_CONFIG__.APPS_MARKETPLACE_API_URI,

View file

@ -17,10 +17,6 @@
window.__SALEOR_CONFIG__ = {
API_URL: "<%= API_URL %>",
APP_MOUNT_URI: "<%= APP_MOUNT_URI %>",
MARKETPLACE_URL: "<%= MARKETPLACE_URL %>",
SALEOR_APPS_PAGE_PATH: "<%= SALEOR_APPS_PAGE_PATH %>",
SALEOR_APPS_JSON_PATH: "<%= SALEOR_APPS_JSON_PATH %>",
APP_TEMPLATE_GALLERY_PATH: "<%= APP_TEMPLATE_GALLERY_PATH %>",
APPS_MARKETPLACE_API_URI: "<%= APPS_MARKETPLACE_API_URI %>",
APPS_TUNNEL_URL_KEYWORDS: "<%= APPS_TUNNEL_URL_KEYWORDS %>",
IS_CLOUD_INSTANCE: "<%= IS_CLOUD_INSTANCE %>",

View file

@ -56,8 +56,6 @@ import HomePage from "./home";
import { FlagsServiceProvider } from "./hooks/useFlags/flagsService";
import { useLocationState } from "./hooks/useLocationState";
import { commonMessages } from "./intl";
import MarketplaceSection from "./marketplace";
import { marketplaceUrl } from "./marketplace/urls";
import NavigationSection from "./navigation";
import { navigationSection } from "./navigation/urls";
import { NotFound } from "./NotFound";
@ -285,11 +283,6 @@ const Routes: React.FC = () => {
path={AppSections.appsSection}
component={AppsSection}
/>
<SectionRoute
permissions={[PermissionEnum.MANAGE_APPS]}
path={marketplaceUrl}
component={MarketplaceSection}
/>
<SectionRoute
permissions={[PermissionEnum.MANAGE_PRODUCTS]}
path={warehouseSection}

View file

@ -438,16 +438,6 @@ export const sectionNames = defineMessages({
defaultMessage: "Home",
description: "home section name",
},
marketplace: {
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",
defaultMessage: "Navigation",

View file

@ -1,51 +0,0 @@
import { AppFrame } from "@dashboard/apps/components/AppFrame";
import NotFoundPage from "@dashboard/components/NotFoundPage";
import PreviewPill from "@dashboard/components/PreviewPill";
import { WindowTitle } from "@dashboard/components/WindowTitle";
import { MARKETPLACE_URL } from "@dashboard/config";
import useNavigator from "@dashboard/hooks/useNavigator";
import { sectionNames } from "@dashboard/intl";
import { marketplaceUrlResolver } from "@dashboard/marketplace/marketplace-url-resolver";
import { marketplaceUrl } from "@dashboard/marketplace/urls";
import { Container } from "@material-ui/core";
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();
const marketplaceUrl = useMemo(
() => new URL(getDeepPath(router.location.pathname), MARKETPLACE_URL).href,
[router.location.pathname],
);
if (!marketplaceUrlResolver.checkMarketplaceConfigExists()) {
return <NotFoundPage onBack={() => navigate("/")} />;
}
return (
<>
<WindowTitle title={intl.formatMessage(sectionNames.marketplace)} />
<Container>
<PreviewPill className={classes.previewPill} />
<AppFrame
src={marketplaceUrl}
// Marketplace doesn't require app token nor id
appToken=""
appId=""
className={classes.iframe}
/>
</Container>
</>
);
};
export default Component;

View file

@ -1,27 +0,0 @@
import { MarketplaceUrlResolver } from "@dashboard/marketplace/marketplace-url-resolver";
describe("MarketplaceUrlResolver", function() {
it("Resolves deep marketplace url from full path", () => {
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",
);
});
});

View file

@ -1,43 +0,0 @@
import {
MARKETPLACE_APP_TEMPLATE_GALLERY_PATH,
MARKETPLACE_SALEOR_APPS_JSON_PATH,
MARKETPLACE_SALEOR_APPS_PAGE_PATH,
MARKETPLACE_URL,
} from "@dashboard/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();

View file

@ -1,18 +0,0 @@
import { makeStyles } from "@saleor/macaw-ui";
const useStyles = makeStyles(
theme => ({
iframe: {
height: "100vh",
position: "sticky",
},
previewPill: {
marginBottom: theme.spacing(2),
},
}),
{
name: "marketplaceStyles",
},
);
export { useStyles };

View file

@ -1,3 +0,0 @@
const marketplaceSection = "/marketplace/";
export const marketplaceUrl = marketplaceSection;

View file

@ -2,10 +2,6 @@
window.__SALEOR_CONFIG__ = {
API_URL: "",
APP_MOUNT_URI: "/",
MARKETPLACE_URL: "",
SALEOR_APPS_PAGE_PATH: "",
SALEOR_APPS_JSON_PATH: "",
IS_CLOUD_INSTANCE: "",
APP_TEMPLATE_GALLERY_PATH: "",
};
</script>

View file

@ -23,10 +23,6 @@ document.createRange = () => {
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",
APPS_MARKETPLACE_API_URI: "http://localhost:3000",
APPS_TUNNEL_URL_KEYWORDS: ".ngrok.io;.saleor.live",
IS_CLOUD_INSTANCE: "true",

4
types.d.ts vendored
View file

@ -14,10 +14,6 @@ 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;
APPS_MARKETPLACE_API_URI?: string;
APPS_TUNNEL_URL_KEYWORDS?: string;
IS_CLOUD_INSTANCE?: string;

View file

@ -28,11 +28,6 @@ export default defineConfig(({ command, mode }) => {
API_URI,
SW_INTERVAL,
IS_CLOUD_INSTANCE,
/**
* @deprecated
*/
MARKETPLACE_URL, // To be removed
SALEOR_APPS_ENDPOINT,
APP_MOUNT_URI,
SENTRY_ORG,
SENTRY_PROJECT,
@ -40,9 +35,6 @@ export default defineConfig(({ command, mode }) => {
SENTRY_DSN,
ENVIRONMENT,
STATIC_URL,
SALEOR_APPS_PAGE_PATH,
SALEOR_APPS_JSON_PATH,
APP_TEMPLATE_GALLERY_PATH,
APPS_MARKETPLACE_API_URI,
APPS_TUNNEL_URL_KEYWORDS,
SKIP_SOURCEMAPS,
@ -70,10 +62,6 @@ 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,
APPS_MARKETPLACE_API_URI,
APPS_TUNNEL_URL_KEYWORDS,
IS_CLOUD_INSTANCE,
@ -162,8 +150,6 @@ export default defineConfig(({ command, mode }) => {
API_URI,
SW_INTERVAL,
IS_CLOUD_INSTANCE,
MARKETPLACE_URL,
SALEOR_APPS_ENDPOINT,
APP_MOUNT_URI,
SENTRY_DSN,
ENVIRONMENT,