From 9baef3e9e9fbcbc201219e3387917339e3eaa261 Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Wed, 15 Jan 2025 09:19:44 -0800 Subject: [PATCH] Revert to window --- packages/desktop-client/playwright.config.js | 8 ++++---- packages/desktop-client/src/components/FatalError.tsx | 2 +- packages/desktop-client/src/components/HelpMenu.tsx | 2 +- .../desktop-client/src/components/UpdateNotification.tsx | 2 +- .../desktop-client/src/components/accounts/Account.tsx | 4 ++-- .../src/components/manager/ConfigServer.tsx | 4 ++-- .../src/components/manager/ManagementApp.tsx | 2 +- .../ImportTransactionsModal/ImportTransactionsModal.jsx | 2 +- .../modals/manager/ConfirmChangeDocumentDir.tsx | 4 ++-- .../src/components/modals/manager/FilesSettingsModal.tsx | 2 +- .../src/components/modals/manager/ImportActualModal.tsx | 2 +- .../src/components/modals/manager/ImportYNAB4Modal.tsx | 2 +- .../src/components/modals/manager/ImportYNAB5Modal.tsx | 2 +- .../desktop-client/src/components/reports/Overview.tsx | 4 ++-- .../desktop-client/src/components/settings/Export.tsx | 2 +- packages/desktop-client/src/global-events.ts | 2 +- packages/desktop-client/src/gocardless.ts | 2 +- packages/desktop-client/src/util/versions.ts | 4 ++-- 18 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/desktop-client/playwright.config.js b/packages/desktop-client/playwright.config.js index cd075de8005..170172dc70b 100644 --- a/packages/desktop-client/playwright.config.js +++ b/packages/desktop-client/playwright.config.js @@ -26,7 +26,7 @@ expect.extend({ : locator.locator('[data-theme]'); // Check lightmode - await locator.evaluate(() => global.Actual.setTheme('auto')); + await locator.evaluate(() => window.Actual.setTheme('auto')); await expect(dataThemeLocator).toHaveAttribute('data-theme', 'auto'); const lightmode = await expect(locator).toHaveScreenshot(config); @@ -35,7 +35,7 @@ expect.extend({ } // Switch to darkmode and check - await locator.evaluate(() => global.Actual.setTheme('dark')); + await locator.evaluate(() => window.Actual.setTheme('dark')); await expect(dataThemeLocator).toHaveAttribute('data-theme', 'dark'); const darkmode = await expect(locator).toHaveScreenshot(config); @@ -45,7 +45,7 @@ expect.extend({ } // Switch to midnight theme and check - await locator.evaluate(() => global.Actual.setTheme('midnight')); + await locator.evaluate(() => window.Actual.setTheme('midnight')); await expect(dataThemeLocator).toHaveAttribute('data-theme', 'midnight'); const midnightMode = await expect(locator).toHaveScreenshot(config); @@ -55,7 +55,7 @@ expect.extend({ } // Switch back to lightmode - await locator.evaluate(() => global.Actual.setTheme('auto')); + await locator.evaluate(() => window.Actual.setTheme('auto')); return { message: () => 'pass', pass: true, diff --git a/packages/desktop-client/src/components/FatalError.tsx b/packages/desktop-client/src/components/FatalError.tsx index d2d902bdd11..6ce18aecd46 100644 --- a/packages/desktop-client/src/components/FatalError.tsx +++ b/packages/desktop-client/src/components/FatalError.tsx @@ -217,7 +217,7 @@ export function FatalError({ error }: FatalErrorProps) { )} - diff --git a/packages/desktop-client/src/components/HelpMenu.tsx b/packages/desktop-client/src/components/HelpMenu.tsx index f3086402c11..40a4208ed41 100644 --- a/packages/desktop-client/src/components/HelpMenu.tsx +++ b/packages/desktop-client/src/components/HelpMenu.tsx @@ -37,7 +37,7 @@ const getPageDocs = (page: string) => { }; function openDocsForCurrentPage() { - global.Actual.openURLInBrowser(getPageDocs(window.location.pathname)); + window.Actual.openURLInBrowser(getPageDocs(window.location.pathname)); } type HelpMenuItem = 'docs' | 'keyboard-shortcuts' | 'goal-templates'; diff --git a/packages/desktop-client/src/components/UpdateNotification.tsx b/packages/desktop-client/src/components/UpdateNotification.tsx index 0c5bb5e21af..6d5fbba55d9 100644 --- a/packages/desktop-client/src/components/UpdateNotification.tsx +++ b/packages/desktop-client/src/components/UpdateNotification.tsx @@ -69,7 +69,7 @@ export function UpdateNotification() { textDecoration: 'underline', }} onClick={() => - global.Actual.openURLInBrowser( + window.Actual.openURLInBrowser( 'https://actualbudget.org/docs/releases', ) } diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsx index 473b6791cec..07492a2322f 100644 --- a/packages/desktop-client/src/components/accounts/Account.tsx +++ b/packages/desktop-client/src/components/accounts/Account.tsx @@ -634,7 +634,7 @@ class AccountInternal extends PureComponent< const account = this.props.accounts.find(acct => acct.id === accountId); if (account) { - const res = await global.Actual.openFileDialog({ + const res = await window.Actual.openFileDialog({ filters: [ { name: t('Financial Files'), @@ -669,7 +669,7 @@ class AccountInternal extends PureComponent< accountName && accountName.replace(/[()]/g, '').replace(/\s+/g, '-'); const filename = `${normalizedName || 'transactions'}.csv`; - global.Actual.saveFile( + window.Actual.saveFile( exportedTransactions, filename, t('Export Transactions'), diff --git a/packages/desktop-client/src/components/manager/ConfigServer.tsx b/packages/desktop-client/src/components/manager/ConfigServer.tsx index c3bbb5a4b6e..107676551bb 100644 --- a/packages/desktop-client/src/components/manager/ConfigServer.tsx +++ b/packages/desktop-client/src/components/manager/ConfigServer.tsx @@ -35,7 +35,7 @@ export function ConfigServer() { const [error, setError] = useState(null); const restartElectronServer = useCallback(() => { - global.Actual.restartElectronServer(); + globalThis.window.Actual.restartElectronServer(); setError(null); }, []); @@ -88,7 +88,7 @@ export function ConfigServer() { } async function onSelectSelfSignedCertificate() { - const selfSignedCertificateLocation = await global.Actual.openFileDialog({ + const selfSignedCertificateLocation = await window.Actual.openFileDialog({ properties: ['openFile'], filters: [ { diff --git a/packages/desktop-client/src/components/manager/ManagementApp.tsx b/packages/desktop-client/src/components/manager/ManagementApp.tsx index 3ff6f8ce49e..12d2c79ffe0 100644 --- a/packages/desktop-client/src/components/manager/ManagementApp.tsx +++ b/packages/desktop-client/src/components/manager/ManagementApp.tsx @@ -52,7 +52,7 @@ function Version() { }, }} > - {`App: v${global.Actual.ACTUAL_VERSION} | Server: ${version}`} + {`App: v${window.Actual.ACTUAL_VERSION} | Server: ${version}`} ); } diff --git a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx index 6f8daa1c04b..1abef1d39d8 100644 --- a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx +++ b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx @@ -471,7 +471,7 @@ export function ImportTransactionsModal({ options }) { } async function onNewFile() { - const res = await global.Actual.openFileDialog({ + const res = await window.Actual.openFileDialog({ filters: [ { name: 'Financial Files', diff --git a/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx b/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx index b1702dfdcf4..87f930acca4 100644 --- a/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx +++ b/packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx @@ -51,7 +51,7 @@ export function ConfirmChangeDocumentDirModal({ const dispatch = useDispatch(); const restartElectronServer = useCallback(() => { - global.Actual.restartElectronServer(); + window.Actual.restartElectronServer(); }, []); const [_documentDir, setDocumentDirPref] = useGlobalPref( @@ -64,7 +64,7 @@ export function ConfirmChangeDocumentDirModal({ setLoading(true); try { if (moveFiles) { - await global.Actual.moveBudgetDirectory( + await window.Actual.moveBudgetDirectory( currentBudgetDirectory, newDirectory, ); diff --git a/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx b/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx index 476c329602b..d6275e817fd 100644 --- a/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx +++ b/packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx @@ -19,7 +19,7 @@ function FileLocationSettings() { const dispatch = useDispatch(); async function onChooseDocumentDir() { - const chosenDirectory = await global.Actual.openFileDialog({ + const chosenDirectory = await window.Actual.openFileDialog({ properties: ['openDirectory'], }); diff --git a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx index 733f970620b..87421f22886 100644 --- a/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx +++ b/packages/desktop-client/src/components/modals/manager/ImportActualModal.tsx @@ -38,7 +38,7 @@ export function ImportActualModal() { const [importing, setImporting] = useState(false); async function onImport() { - const res = await global.Actual.openFileDialog({ + const res = await window.Actual.openFileDialog({ properties: ['openFile'], filters: [{ name: 'actual', extensions: ['zip', 'blob'] }], }); diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx index e6f11670660..65020cb063e 100644 --- a/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx +++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB4Modal.tsx @@ -30,7 +30,7 @@ export function ImportYNAB4Modal() { const [importing, setImporting] = useState(false); async function onImport() { - const res = await global.Actual.openFileDialog({ + const res = await window.Actual.openFileDialog({ properties: ['openFile'], filters: [{ name: 'ynab', extensions: ['zip'] }], }); diff --git a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx index 773d0181a27..3b8e4752e31 100644 --- a/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx +++ b/packages/desktop-client/src/components/modals/manager/ImportYNAB5Modal.tsx @@ -33,7 +33,7 @@ export function ImportYNAB5Modal() { const [importing, setImporting] = useState(false); async function onImport() { - const res = await global.Actual.openFileDialog({ + const res = await window.Actual.openFileDialog({ properties: ['openFile'], filters: [{ name: 'ynab', extensions: ['json'] }], }); diff --git a/packages/desktop-client/src/components/reports/Overview.tsx b/packages/desktop-client/src/components/reports/Overview.tsx index 558f20aed66..f3e467c7473 100644 --- a/packages/desktop-client/src/components/reports/Overview.tsx +++ b/packages/desktop-client/src/components/reports/Overview.tsx @@ -211,14 +211,14 @@ export function Overview() { }), } satisfies ExportImportDashboard; - global.Actual.saveFile( + window.Actual.saveFile( JSON.stringify(data, null, 2), 'dashboard.json', 'Export Dashboard', ); }; const onImport = async () => { - const openFileDialog = global.Actual.openFileDialog; + const openFileDialog = window.Actual.openFileDialog; if (!openFileDialog) { dispatch( diff --git a/packages/desktop-client/src/components/settings/Export.tsx b/packages/desktop-client/src/components/settings/Export.tsx index 2b43a22f386..2f2a33dbb11 100644 --- a/packages/desktop-client/src/components/settings/Export.tsx +++ b/packages/desktop-client/src/components/settings/Export.tsx @@ -33,7 +33,7 @@ export function ExportBudget() { return; } - global.Actual.saveFile( + window.Actual.saveFile( response.data, `${format(new Date(), 'yyyy-MM-dd')}-${budgetName}.zip`, t('Export budget'), diff --git a/packages/desktop-client/src/global-events.ts b/packages/desktop-client/src/global-events.ts index b0fb7b3d66f..ed8d7b3311d 100644 --- a/packages/desktop-client/src/global-events.ts +++ b/packages/desktop-client/src/global-events.ts @@ -162,6 +162,6 @@ export function handleGlobalEvents(store: AppStore) { }); listen('api-fetch-redirected', () => { - global.Actual.reload(); + window.Actual.reload(); }); } diff --git a/packages/desktop-client/src/gocardless.ts b/packages/desktop-client/src/gocardless.ts index b76c3dea751..fc92c403f36 100644 --- a/packages/desktop-client/src/gocardless.ts +++ b/packages/desktop-client/src/gocardless.ts @@ -25,7 +25,7 @@ function _authorize( if ('error' in resp) return resp; const { link, requisitionId } = resp; - global.Actual.openURLInBrowser(link); + window.Actual.openURLInBrowser(link); return send('gocardless-poll-web-token', { upgradingAccountId, diff --git a/packages/desktop-client/src/util/versions.ts b/packages/desktop-client/src/util/versions.ts index 0c9d8e5d30e..291d236403f 100644 --- a/packages/desktop-client/src/util/versions.ts +++ b/packages/desktop-client/src/util/versions.ts @@ -30,7 +30,7 @@ export async function getLatestVersion(): Promise { const json = await response.json(); const tags = json .map(t => t.name) - .concat([`v${global.Actual.ACTUAL_VERSION}`]); + .concat([`v${window.Actual.ACTUAL_VERSION}`]); tags.sort(cmpSemanticVersion); return tags[tags.length - 1]; @@ -41,7 +41,7 @@ export async function getLatestVersion(): Promise { } export async function getIsOutdated(latestVersion: string): Promise { - const clientVersion = global.Actual.ACTUAL_VERSION; + const clientVersion = window.Actual.ACTUAL_VERSION; if (latestVersion === 'unknown') { return Promise.resolve(false); }