Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/cold-cooks-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Removed demo mode code.
3 changes: 1 addition & 2 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ APP_MOUNT_URI=/
APPS_MARKETPLACE_API_URL=https://apps.saleor.io/api/v2/saleor-apps
EXTENSIONS_API_URL=https://apps.saleor.io/api/v1/extensions
LOCALE_CODE="EN"
DEMO_MODE=false

MAILPITURL=xxxx #For playwright

Expand All @@ -12,4 +11,4 @@ E2E_USER_PASSWORD=xxxx
E2E_PERMISSIONS_USERS_PASSWORD=xxxx
BASE_URL=http://localhost:9000/

ONBOARDING_USER_JOINED_DATE_THRESHOLD=2024-07-01
ONBOARDING_USER_JOINED_DATE_THRESHOLD=2024-07-01
1 change: 0 additions & 1 deletion .storybook/vite.storybook.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default defineConfig({
define: {
"process.env": {
NODE_ENV: JSON.stringify("development"),
DEMO_MODE: JSON.stringify(false),
},
FLAGS_SERVICE_ENABLED: false,
FLAGS: JSON.stringify({}),
Expand Down
8 changes: 0 additions & 8 deletions src/auth/components/LoginPage/form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DEMO_MODE } from "@dashboard/config";
import useForm, { FormChange, SubmitPromise } from "@dashboard/hooks/useForm";
import useHandleFormSubmit from "@dashboard/hooks/useHandleFormSubmit";
import * as React from "react";
Expand All @@ -21,13 +20,6 @@ export interface LoginFormProps {
}

const getLoginFormData = () => {
if (DEMO_MODE) {
return {
email: "admin@example.com",
password: "admin",
};
}

return { email: "", password: "" };
};

Expand Down
12 changes: 1 addition & 11 deletions src/auth/hooks/useAuthProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApolloClient, ApolloError } from "@apollo/client";
import { IMessageContext } from "@dashboard/components/messages";
import { DEMO_MODE } from "@dashboard/config";
import { AccountErrorCode, useUserDetailsQuery } from "@dashboard/graphql";
import useLocalStorage from "@dashboard/hooks/useLocalStorage";
import useNavigator from "@dashboard/hooks/useNavigator";
Expand All @@ -26,7 +25,6 @@ import {
UserContext,
UserContextError,
} from "../types";
import { displayDemoMessage } from "../utils";

export interface UseAuthProviderOpts {
intl: IntlShape;
Expand Down Expand Up @@ -145,10 +143,6 @@ export function useAuthProvider({ intl, notify, apolloClient }: UseAuthProviderO
const hasUser = !!result.data?.tokenCreate?.user;

if (hasUser && !errorList?.length) {
if (DEMO_MODE) {
displayDemoMessage(intl, notify);
}

saveCredentials(result.data!.tokenCreate!.user!, password);
} else {
const userContextErrorList: UserContextError[] = [];
Expand Down Expand Up @@ -217,11 +211,7 @@ export function useAuthProvider({ intl, notify, apolloClient }: UseAuthProviderO
await handleLogout();
}

if (result && !result.data?.externalObtainAccessTokens?.errors.length) {
if (DEMO_MODE) {
displayDemoMessage(intl, notify);
}
} else {
if (!result || result.data?.externalObtainAccessTokens?.errors.length) {
setErrors(["externalLoginError"]);
await handleLogout();
}
Expand Down
7 changes: 0 additions & 7 deletions src/auth/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { ApolloError, ServerError } from "@apollo/client/core";
import { IMessage, IMessageContext } from "@dashboard/components/messages";
import { UseNotifierResult } from "@dashboard/hooks/useNotifier";
import { commonMessages } from "@dashboard/intl";
import { getMutationErrors, parseLogMessage } from "@dashboard/misc";
import { IntlShape } from "react-intl";

import { isJwtError, isTokenExpired } from "./errors";

export const displayDemoMessage = (intl: IntlShape, notify: UseNotifierResult) => {
notify({
text: intl.formatMessage(commonMessages.demo),
});
};

const getNetworkErrors = (error: ApolloError): string[] => {
const networkErrors = error.networkError as ServerError;

Expand Down
55 changes: 0 additions & 55 deletions src/components/DemoBanner/DemoBanner.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/DemoBanner/constants.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/DemoBanner/index.ts

This file was deleted.

57 changes: 0 additions & 57 deletions src/components/DemoBanner/styles.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ export const defaultListSettings: AppListViewSettings = {

export const APP_VERSION = process.env.CUSTOM_VERSION || `v${packageInfo.version}`;

export const DEMO_MODE = process.env.DEMO_MODE === "true";
export const GTM_ID = process.env.GTM_ID;

export const DEFAULT_NOTIFICATION_SHOW_TIME = 3000;
Expand Down
2 changes: 0 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
content="Sign in to the Saleor Dashboard to manage your orders, payments, products and more."
/>

<%- injectOgTags %>

<script>
window.__SALEOR_CONFIG__ = {
API_URL: "<%= API_URL %>",
Expand Down
4 changes: 1 addition & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "@saleor/macaw-ui-next/style";
import "./index.css";

import { ApolloProvider } from "@apollo/client";
import DemoBanner from "@dashboard/components/DemoBanner";
import { history, Route, Router } from "@dashboard/components/Router";
import { extensionsSection } from "@dashboard/extensions/urls";
import { PermissionEnum } from "@dashboard/graphql";
Expand Down Expand Up @@ -49,7 +48,7 @@ import { ProductAnalytics } from "./components/ProductAnalytics";
import { SavebarRefProvider } from "./components/Savebar/SavebarRefContext";
import { ShopProvider } from "./components/Shop";
import { WindowTitle } from "./components/WindowTitle";
import { DEMO_MODE, GTM_ID } from "./config";
import { GTM_ID } from "./config";
import ConfigurationSection from "./configuration";
import { getConfigMenuItemsPermissions } from "./configuration/utils";
import AppStateProvider from "./containers/AppState";
Expand Down Expand Up @@ -169,7 +168,6 @@ const Routes = () => {
return (
<>
<WindowTitle title={intl.formatMessage(commonMessages.dashboard)} />
{DEMO_MODE && <DemoBanner />}
{homePageLoaded ? (
<ExternalAppProvider>
<AppLayout fullSize={isAppPath}>
Expand Down
6 changes: 0 additions & 6 deletions src/intl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ export const commonMessages = defineMessages({
id: "hzSNj4",
defaultMessage: "Dashboard",
},
demo: {
id: "i0AcKY",
defaultMessage:
"Just to let you know... You're in demo mode. You can play around with the dashboard but can't save changes.",
description: "notification message after log in",
},
description: {
id: "Q8Qw5B",
defaultMessage: "Description",
Expand Down
17 changes: 0 additions & 17 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default defineConfig(({ command, mode }) => {
EXTENSIONS_API_URL,
APPS_TUNNEL_URL_KEYWORDS,
SKIP_SOURCEMAPS,
DEMO_MODE,
CUSTOM_VERSION,
FLAGS_SERVICE_ENABLED,
LOCALE_CODE,
Expand Down Expand Up @@ -92,21 +91,6 @@ export default defineConfig(({ command, mode }) => {
POSTHOG_HOST,
ONBOARDING_USER_JOINED_DATE_THRESHOLD,
ENABLED_SERVICE_NAME_HEADER,
injectOgTags:
DEMO_MODE &&
`
<meta property="og:type" content="website">
<meta property="og:title" content="Sign in to the Saleor Dashboard">
<meta property="og:description" content="Sign in to the Saleor Dashboard to manage your orders, payments, products and more.">
<meta property="og:image" content="${base}og.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Sign in to the Saleor Dashboard">
<meta name="twitter:description" content="Sign in to the Saleor Dashboard to manage your orders, payments, products and more.">
<meta name="twitter:image" content="${base}og.png">
<meta property="og:url" content="https://demo.saleor.io/dashboard/">
<meta property="twitter:domain" content="demo.saleor.io">
<meta property="twitter:url" content="https://demo.saleor.io/dashboard/">
`,
},
},
}),
Expand Down Expand Up @@ -161,7 +145,6 @@ export default defineConfig(({ command, mode }) => {
APP_MOUNT_URI,
SENTRY_DSN,
ENVIRONMENT,
DEMO_MODE,
CUSTOM_VERSION,
LOCALE_CODE,
SENTRY_RELEASE,
Expand Down
Loading