Skip to content

Commit

Permalink
use flags instead of removing excalidraw+ references
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenjohanson committed Sep 4, 2024
1 parent 4d88dc4 commit 2f1ca71
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 198 deletions.
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ VITE_APP_HTTP_STORAGE_BACKEND_URL=http://localhost:8080
# collaboration WebSocket server (https://github.com/excalidraw/excalidraw-room)
VITE_APP_WS_SERVER_URL=http://localhost:5001

VITE_APP_PLUS_LP=https://plus.excalidraw.com
VITE_APP_PLUS_APP=https://app.excalidraw.com
VITE_APP_PLUS_LP=
VITE_APP_PLUS_APP=

VITE_APP_AI_BACKEND=

Expand Down
147 changes: 11 additions & 136 deletions excalidraw-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import {
} from "../packages/excalidraw/utils";
import {
FIREBASE_STORAGE_PREFIXES,
isExcalidrawPlusSignedUser,
STORAGE_KEYS,
SYNC_BROWSER_TABS_TIMEOUT,
} from "./app_constants";
Expand Down Expand Up @@ -107,13 +106,8 @@ import {
} from "../packages/excalidraw/components/CommandPalette/CommandPalette";
import {
GithubIcon,
XBrandIcon,
DiscordIcon,
ExcalLogo,
usersIcon,
exportToPlus,
share,
youtubeIcon,
} from "../packages/excalidraw/components/icons";
import { appThemeAtom, useHandleAppTheme } from "./useHandleAppTheme";
import { getPreferredLanguage } from "./app-language/language-detector";
Expand Down Expand Up @@ -304,11 +298,11 @@ const initializeScene = async (opts: {
} else if (scene) {
return isExternalScene && jsonBackendMatch
? {
scene,
isExternalScene,
id: jsonBackendMatch[1],
key: jsonBackendMatch[2],
}
scene,

Check warning on line 301 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
isExternalScene,

Check warning on line 302 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
id: jsonBackendMatch[1],

Check warning on line 303 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `········` with `··········`
key: jsonBackendMatch[2],

Check warning on line 304 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
}

Check warning on line 305 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
: { scene, isExternalScene: false };
}
return { scene: null, isExternalScene: false };
Expand Down Expand Up @@ -708,45 +702,6 @@ const ExcalidrawWrapper = () => {
);
}

const ExcalidrawPlusCommand = {
label: "Excalidraw+",
category: DEFAULT_CATEGORIES.links,
predicate: true,
icon: <div style={{ width: 14 }}>{ExcalLogo}</div>,
keywords: ["plus", "cloud", "server"],
perform: () => {
window.open(
`${
import.meta.env.VITE_APP_PLUS_LP
}/plus?utm_source=excalidraw&utm_medium=app&utm_content=command_palette`,
"_blank",
);
},
};
const ExcalidrawPlusAppCommand = {
label: "Sign up",
category: DEFAULT_CATEGORIES.links,
predicate: true,
icon: <div style={{ width: 14 }}>{ExcalLogo}</div>,
keywords: [
"excalidraw",
"plus",
"cloud",
"server",
"signin",
"login",
"signup",
],
perform: () => {
window.open(
`${
import.meta.env.VITE_APP_PLUS_APP
}?utm_source=excalidraw&utm_medium=app&utm_content=command_palette`,
"_blank",
);
},
};

return (
<div
style={{ height: "100%" }}
Expand Down Expand Up @@ -807,7 +762,7 @@ const ExcalidrawWrapper = () => {
<OverwriteConfirmDialog>
<OverwriteConfirmDialog.Actions.ExportToImage />
<OverwriteConfirmDialog.Actions.SaveToDisk />
{excalidrawAPI && (
{excalidrawAPI && import.meta.env.VITE_APP_PLUS_LP && (
<OverwriteConfirmDialog.Action
title={t("overwriteConfirm.action.excalidrawPlus.title")}
actionLabel={t("overwriteConfirm.action.excalidrawPlus.button")}
Expand All @@ -829,8 +784,7 @@ const ExcalidrawWrapper = () => {
onTextSubmit={async (input) => {
try {
const response = await fetch(
`${
import.meta.env.VITE_APP_AI_BACKEND
`${import.meta.env.VITE_APP_AI_BACKEND

Check warning on line 787 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `⏎··················`
}/v1/ai/text-to-diagram/generate`,
{
method: "POST",
Expand All @@ -850,9 +804,9 @@ const ExcalidrawWrapper = () => {
"X-Ratelimit-Remaining",
)
? parseInt(
response.headers.get("X-Ratelimit-Remaining") || "0",
10,
)
response.headers.get("X-Ratelimit-Remaining") || "0",

Check warning on line 807 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
10,

Check warning on line 808 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
)

Check warning on line 809 in excalidraw-app/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `··`
: undefined;

const json = await response.json();
Expand Down Expand Up @@ -1001,91 +955,12 @@ const ExcalidrawWrapper = () => {
],
perform: () => {
window.open(
"https://github.com/excalidraw/excalidraw",
"https://github.com/kitsteam/excalidraw",
"_blank",
"noopener noreferrer",
);
},
},
{
label: t("labels.followUs"),
icon: XBrandIcon,
category: DEFAULT_CATEGORIES.links,
predicate: true,
keywords: ["twitter", "contact", "social", "community"],
perform: () => {
window.open(
"https://x.com/excalidraw",
"_blank",
"noopener noreferrer",
);
},
},
{
label: t("labels.discordChat"),
category: DEFAULT_CATEGORIES.links,
predicate: true,
icon: DiscordIcon,
keywords: [
"chat",
"talk",
"contact",
"bugs",
"requests",
"report",
"feedback",
"suggestions",
"social",
"community",
],
perform: () => {
window.open(
"https://discord.gg/UexuTaE",
"_blank",
"noopener noreferrer",
);
},
},
{
label: "YouTube",
icon: youtubeIcon,
category: DEFAULT_CATEGORIES.links,
predicate: true,
keywords: ["features", "tutorials", "howto", "help", "community"],
perform: () => {
window.open(
"https://youtube.com/@excalidraw",
"_blank",
"noopener noreferrer",
);
},
},
...(isExcalidrawPlusSignedUser
? [
{
...ExcalidrawPlusAppCommand,
label: "Sign in / Go to Excalidraw+",
},
]
: [ExcalidrawPlusCommand, ExcalidrawPlusAppCommand]),

{
label: t("overwriteConfirm.action.excalidrawPlus.button"),
category: DEFAULT_CATEGORIES.export,
icon: exportToPlus,
predicate: true,
keywords: ["plus", "export", "save", "backup"],
perform: () => {
if (excalidrawAPI) {
exportToExcalidrawPlus(
excalidrawAPI.getSceneElements(),
excalidrawAPI.getAppState(),
excalidrawAPI.getFiles(),
excalidrawAPI.getName(),
);
}
},
},
{
...CommandPalette.defaultItems.toggleTheme,
perform: () => {
Expand Down
1 change: 0 additions & 1 deletion excalidraw-app/app_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const STORAGE_KEYS = {
export const COOKIES = {
AUTH_STATE_COOKIE: "excplus-auth",
} as const;

export const isExcalidrawPlusSignedUser = document.cookie.includes(
COOKIES.AUTH_STATE_COOKIE,
);
9 changes: 2 additions & 7 deletions excalidraw-app/components/AppFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from "react";
import { Footer } from "../../packages/excalidraw/index";
import { EncryptedIcon } from "./EncryptedIcon";
import { ExcalidrawPlusAppLink } from "./ExcalidrawPlusAppLink";
import { isExcalidrawPlusSignedUser } from "../app_constants";

export const AppFooter = React.memo(() => {
return (
Expand All @@ -14,11 +12,8 @@ export const AppFooter = React.memo(() => {
alignItems: "center",
}}
>
{isExcalidrawPlusSignedUser ? (
<ExcalidrawPlusAppLink />
) : (
<EncryptedIcon />
)}
(
<EncryptedIcon />)
</div>
</Footer>
);
Expand Down
20 changes: 11 additions & 9 deletions excalidraw-app/components/AppMainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ export const AppMainMenu: React.FC<{
<MainMenu.DefaultItems.ClearCanvas />
<MainMenu.Separator />
<MainMenu.DefaultItems.Socials />
<MainMenu.ItemLink
icon={loginIcon}
href={`${import.meta.env.VITE_APP_PLUS_APP}${
isExcalidrawPlusSignedUser ? "" : "/sign-up"
}?utm_source=signin&utm_medium=app&utm_content=hamburger`}
className="highlighted"
>
{isExcalidrawPlusSignedUser ? "Sign in" : "Sign up"}
</MainMenu.ItemLink>
{import.meta.env.VITE_APP_PLUS_LP && (
<MainMenu.ItemLink
icon={loginIcon}
href={`${import.meta.env.VITE_APP_PLUS_APP}${
isExcalidrawPlusSignedUser ? "" : "/sign-up"
}?utm_source=signin&utm_medium=app&utm_content=hamburger`}
className="highlighted"
>
{isExcalidrawPlusSignedUser ? "Sign in" : "Sign up"}
</MainMenu.ItemLink>
)}
<MainMenu.Separator />
<MainMenu.DefaultItems.ToggleTheme
allowSystemTheme
Expand Down
25 changes: 1 addition & 24 deletions excalidraw-app/components/AppWelcomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,14 @@ import { loginIcon } from "../../packages/excalidraw/components/icons";
import { useI18n } from "../../packages/excalidraw/i18n";
import { WelcomeScreen } from "../../packages/excalidraw/index";
import { isExcalidrawPlusSignedUser } from "../app_constants";
import { POINTER_EVENTS } from "../../packages/excalidraw/constants";

export const AppWelcomeScreen: React.FC<{
onCollabDialogOpen: () => any;
isCollabEnabled: boolean;
}> = React.memo((props) => {
const { t } = useI18n();
let headingContent;

if (isExcalidrawPlusSignedUser) {
headingContent = t("welcomeScreen.app.center_heading_plus")
.split(/(Excalidraw\+)/)
.map((bit, idx) => {
if (bit === "Excalidraw+") {
return (
<a
style={{ pointerEvents: POINTER_EVENTS.inheritFromUI }}
href={`${
import.meta.env.VITE_APP_PLUS_APP
}?utm_source=excalidraw&utm_medium=app&utm_content=welcomeScreenSignedInUser`}
key={idx}
>
Excalidraw+
</a>
);
}
return bit;
});
} else {
headingContent = t("welcomeScreen.app.center_heading");
}
const headingContent = t("welcomeScreen.app.center_heading");

return (
<WelcomeScreen>
Expand Down
19 changes: 0 additions & 19 deletions excalidraw-app/components/ExcalidrawPlusAppLink.tsx

This file was deleted.

Loading

0 comments on commit 2f1ca71

Please sign in to comment.