Skip to content

Commit

Permalink
update @ProtonMail web clients
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Aug 26, 2024
1 parent a3484a7 commit 9865c0c
Show file tree
Hide file tree
Showing 21 changed files with 481 additions and 436 deletions.
76 changes: 67 additions & 9 deletions patches/protonmail/app-account.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
diff --git a/applications/account/package.json b/applications/account/package.json
index 4ec5d0b741..93c94c449f 100644
index e6b14ce6c5..efc2dbebdf 100644
--- a/applications/account/package.json
+++ b/applications/account/package.json
@@ -6,7 +6,6 @@
"author": "",
"main": "index.js",
"scripts": {
- "build": "cross-env NODE_ENV=production WEBPACK_PARALLELISM=2 TS_NODE_PROJECT=\"../../tsconfig.webpack.json\" proton-pack build --appMode=sso",
- "build:web": "cross-env NODE_ENV=production TS_NODE_PROJECT=\"../../tsconfig.webpack.json\" proton-pack build --webpackOnCaffeine --appMode=sso",
"check-types": "tsc",
"i18n:extract:web": "proton-i18n extract",
"i18n:upgrade": "proton-i18n extract --verbose && proton-i18n crowdin --verbose",
"i18n:validate": "proton-i18n validate lint-functions",

diff --git a/applications/account/webpack.config.ts b/applications/account/webpack.config.ts
index 54f99267f9..68f5892f11 100644
Expand Down Expand Up @@ -44,15 +44,73 @@ index 54f99267f9..68f5892f11 100644
}

diff --git a/applications/account/src/app/content/MainContainer.tsx b/applications/account/src/app/content/MainContainer.tsx
index 5a578b4b7d..80150502c4 100644
index d43566ed37..73c82a0043 100644
--- a/applications/account/src/app/content/MainContainer.tsx
+++ b/applications/account/src/app/content/MainContainer.tsx
@@ -133,7 +133,7 @@ const MainContainer = () => {
@@ -39,7 +39,7 @@ import useAssistantFeatureEnabled from '@proton/components/hooks/assistant/useAs
import { getPublicUserProtonAddressApps, getSSOVPNOnlyAccountApps } from '@proton/shared/lib/apps/apps';
import { getAppFromPathnameSafe, getSlugFromApp } from '@proton/shared/lib/apps/slugHelper';
import { getToApp } from '@proton/shared/lib/authentication/apps';
-import { stripLocalBasenameFromPathname } from '@proton/shared/lib/authentication/pathnameHelper';
+import { stripLocalBasenameFromPathname, getBasename } from '@proton/shared/lib/authentication/pathnameHelper';
import { APPS, SETUP_ADDRESS_PATH, VPN_TV_PATHS } from '@proton/shared/lib/constants';
import { stripLeadingAndTrailingSlash } from '@proton/shared/lib/helpers/string';
import { getHasPassB2BPlan, hasAIAssistant, hasAllProductsB2CPlan } from '@proton/shared/lib/helpers/subscription';
@@ -144,21 +144,6 @@ const MainContainer = () => {
const [isSessionRecoveryAvailable, loadingIsSessionRecoveryAvailable] = useIsSessionRecoveryAvailable();
const recoveryNotification = useRecoveryNotification(false);
const recoveryNotification = useRecoveryNotification(false, false, canDisplayNewSentinelSettings);

- const appFromPathname = getAppFromPathnameSafe(location.pathname);
+ const appFromPathname = getAppFromPathnameSafe(window.location.pathname);
const app = appFromPathname || getToApp(undefined, user);
const appSlug = getSlugFromApp(app);
- const app = appFromPathname || getToApp(undefined, user);
- const appSlug = getSlugFromApp(app);
-
- // We hide the assistant upsell for users on Mail and Calendar app without the assistant when the kill switch is enabled
- const hasAssistant = hasAIAssistant(subscription);
- const { killSwitch: assistantUpsellKillSwitch } = useAssistantFeatureEnabled();
- const hasAllProducts = hasAllProductsB2CPlan(subscription);
- const isInAllowedApps =
- hasAllProducts || appFromPathname === APPS.PROTONMAIL || appFromPathname === APPS.PROTONCALENDAR;
- const assistantKillSwitch = isInAllowedApps ? !hasAssistant && assistantUpsellKillSwitch : true;
-
- const organizationTheme = useOrganizationTheme();
- const [memberships] = useGroupMemberships();
-
const routes = getRoutes({
app,
user,
@@ -178,6 +163,26 @@ const MainContainer = () => {
memberships,
});

+ const _EM_defaultAccountRedirect = getDefaultRedirect(routes.account);
+ const appFromPathname = getAppFromPathnameSafe(location.pathname) ?? (
+ location.pathname.endsWith(_EM_defaultAccountRedirect)
+ ? getAppFromPathnameSafe(`${getBasename()}${location.pathname.substring(0, location.pathname.length - _EM_defaultAccountRedirect.length)}`)
+ : undefined
+ )
+ const app = appFromPathname || getToApp(undefined, user);
+ const appSlug = getSlugFromApp(app);
+
+ // We hide the assistant upsell for users on Mail and Calendar app without the assistant when the kill switch is enabled
+ const hasAssistant = hasAIAssistant(subscription);
+ const { killSwitch: assistantUpsellKillSwitch } = useAssistantFeatureEnabled();
+ const hasAllProducts = hasAllProductsB2CPlan(subscription);
+ const isInAllowedApps =
+ hasAllProducts || appFromPathname === APPS.PROTONMAIL || appFromPathname === APPS.PROTONCALENDAR;
+ const assistantKillSwitch = isInAllowedApps ? !hasAssistant && assistantUpsellKillSwitch : true;
+
+ const organizationTheme = useOrganizationTheme();
+ const [memberships] = useGroupMemberships();
+
useEffect(() => {
setExpand(false);
}, [location.pathname, location.hash]);
@@ -279,7 +284,7 @@ const MainContainer = () => {
if (app === APPS.PROTONPASS) {
return getDefaultPassRedirect(user, routes.account, routes.pass);
}
- return getDefaultRedirect(routes.account);
+ return _EM_defaultAccountRedirect;
})();

return <Redirect to={`/${appSlug}${path}`} />;
6 changes: 3 additions & 3 deletions patches/protonmail/app-calendar.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
diff --git a/applications/calendar/package.json b/applications/calendar/package.json
index 6d44ef4129..8ff11b06cf 100644
index a20adb2e61..3809a620f3 100644
--- a/applications/calendar/package.json
+++ b/applications/calendar/package.json
@@ -6,7 +6,6 @@
"author": "",
"main": "index.js",
"scripts": {
- "build": "cross-env NODE_ENV=production TS_NODE_PROJECT=\"../../tsconfig.webpack.json\" proton-pack build --appMode=sso",
- "build:web": "cross-env NODE_ENV=production TS_NODE_PROJECT=\"../../tsconfig.webpack.json\" proton-pack build --appMode=sso",
"check-types": "tsc",
"i18n:extract:web": "proton-i18n extract",
"i18n:upgrade": "proton-i18n extract --verbose && proton-i18n crowdin --verbose",
"i18n:validate": "proton-i18n validate lint-functions",

diff --git a/applications/calendar/webpack.config.ts b/applications/calendar/webpack.config.ts
index 729c7fc564..8c21b9143e 100644
Expand Down
32 changes: 18 additions & 14 deletions patches/protonmail/app-drive.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
diff --git a/applications/drive/package.json b/applications/drive/package.json
index 1ff78a9928..d232854a68 100644
index f082f72e36..63c181b0d9 100644
--- a/applications/drive/package.json
+++ b/applications/drive/package.json
@@ -5,7 +5,6 @@
"author": "",
@@ -7,7 +7,6 @@
"main": "index.ts",
"scripts": {
- "build": "cross-env NODE_ENV=production TS_NODE_PROJECT=\"../../tsconfig.webpack.json\" proton-pack build --appMode=sso",
"analyze": "yarn build:web --analyze",
- "build:web": "cross-env NODE_ENV=production TS_NODE_PROJECT=\"../../tsconfig.webpack.json\" proton-pack build --appMode=sso",
"check-types": "tsc",
"i18n:getlatest": "proton-i18n upgrade",
"i18n:upgrade": "proton-i18n extract --verbose && proton-i18n crowdin -u --verbose",
"i18n:extract:local": "yarn workspace @proton/i18n build && yarn build:web && proton-i18n extract",
"i18n:extract:web": "proton-i18n extract",

diff --git a/applications/drive/webpack.config.ts b/applications/drive/webpack.config.ts
index afccc2a4b1..8682856d3a 100644
Expand Down Expand Up @@ -106,14 +106,18 @@ index 7483da5f4f..62d7bb7733 100644
* Opens download stream into service worker. Use abort signal when pipeTo can't close the download stream.

diff --git a/applications/drive/src/app/store/_shares/shareUrl.ts b/applications/drive/src/app/store/_shares/shareUrl.ts
index 76b907e2a1..a267a2d50c 100644
index 1b76b8ea81..748ede869b 100644
--- a/applications/drive/src/app/store/_shares/shareUrl.ts
+++ b/applications/drive/src/app/store/_shares/shareUrl.ts
@@ -36,6 +36,6 @@ export const getSharedLink = (sharedURL?: {

const [generatedPassword] = splitGeneratedAndCustomPassword(sharedURL.password, sharedURL);

- const url = sharedURL.publicUrl ? sharedURL.publicUrl : `${window.location.origin}/urls/${sharedURL.token}`;
+ const url = sharedURL.publicUrl ? sharedURL.publicUrl : `https://drive.protonmail.com/urls/${sharedURL.token}`;
return `${url}${generatedPassword !== '' ? `#${generatedPassword}` : ''}`;
@@ -43,5 +43,9 @@ export const getSharedLink = (sharedURL?: {
const url = sharedURL.publicUrl
? replaceLocalURL(sharedURL.publicUrl)
: getAppHref(`/urls/${sharedURL.token}`, APPS.PROTONDRIVE);
- return `${url}${generatedPassword !== '' ? `#${generatedPassword}` : ''}`;
+ const resultUrl = `${url}${generatedPassword !== '' ? `#${generatedPassword}` : ''}`;
+ return new URL(
+ new URL(resultUrl).href.substring(new URL(resultUrl).origin.length),
+ "https://drive.proton.me",
+ ).toString();
};
--
Loading

0 comments on commit 9865c0c

Please sign in to comment.