From 152d27c4d9773c6b5bc35dbbeaefa278bc380a1c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 14 Oct 2024 13:27:48 +0300 Subject: [PATCH 01/78] Add flexibility to show modal dialog --- src/error-manager/show-modal-dialog.js | 37 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/error-manager/show-modal-dialog.js b/src/error-manager/show-modal-dialog.js index d73db5d9..597e09a2 100644 --- a/src/error-manager/show-modal-dialog.js +++ b/src/error-manager/show-modal-dialog.js @@ -1,6 +1,6 @@ 'use strict' -const { app, dialog, screen, remote } = require('electron') +const { app, dialog, screen } = require('electron') const fs = require('fs') const path = require('path') const { Converter } = require('showdown') @@ -53,19 +53,23 @@ const converter = new Converter({ const _fireAlert = (params) => { const { title = 'Should a bug report be submitted?', - html - } = params - const win = wins.mainWindow + html = '', + parentWin, + hasNoParentWin + } = params ?? {} + const win = parentWin ?? wins.mainWindow - if (!isMainWinAvailable()) { + if ( + !hasNoParentWin && + !isMainWinAvailable(win) + ) { return { value: false } } - const _screen = screen || remote.screen const { getCursorScreenPoint, getDisplayNearestPoint - } = _screen + } = screen const { workArea } = getDisplayNearestPoint(getCursorScreenPoint()) @@ -76,7 +80,8 @@ const _fireAlert = (params) => { const eventHandlerCtx = addOnceProcEventHandler( WINDOW_EVENT_NAMES.CLOSED, - () => closeAlert(alert) + () => closeAlert(alert), + win ) const bwOptions = { @@ -103,8 +108,6 @@ const _fireAlert = (params) => { }), icon: 'question', - title, - html, focusConfirm: true, showConfirmButton: true, confirmButtonText: 'Report', @@ -112,6 +115,10 @@ const _fireAlert = (params) => { cancelButtonText: 'Cancel', timerProgressBar: false, + ...params, + title, + html, + willOpen: () => { if ( !alert || @@ -164,18 +171,22 @@ module.exports = async (params) => { const { errBoxTitle = 'Bug report', errBoxDescription = 'A new Github issue will be opened', - mdIssue + mdIssue, + alertOpts = {} } = params if ( app.isReady() && - isMainWinAvailable() + ( + alertOpts?.hasNoParentWin || + isMainWinAvailable(alertOpts?.parentWin ?? wins.mainWindow) + ) ) { const html = converter.makeHtml(mdIssue) const { value - } = await _fireAlert({ html }) + } = await _fireAlert({ html, ...alertOpts }) return { isExit: false, From 039ad52072f830078915415f2e3464ee357fb178 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 14 Oct 2024 13:28:50 +0300 Subject: [PATCH 02/78] Show useful error modal if os docs dir is misconfigured --- src/error-manager/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/error-manager/index.js b/src/error-manager/index.js index 910e2fec..789c325a 100644 --- a/src/error-manager/index.js +++ b/src/error-manager/index.js @@ -214,6 +214,29 @@ const initLogger = () => { if (message.level === 'error') { const error = message.data.join(os.EOL) + if (/Failed to get 'documents' path/gi.test(error)) { + const title = 'The OS Documents directory has been misconfigured' + const msg = `\ +This indicates that your OS \`Documents\` directory has been misconfigured. +Please, set it to a valid location or reset it to the default` + + showModalDialog({ + errBoxTitle: title, + errBoxDescription: msg, + mdIssue: msg, + alertOpts: { + icon: 'error', + title, + showConfirmButton: false, + hasNoParentWin: true + } + }) + .then(() => { app.quit() }) + .catch((err) => { console.error(err) }) + + return + } + /* * Don't open a new issue when: * - It can't download differentially it would fallback to full download From 34184340a4bc2a9291ff9d22367132380b49bc2a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 15 Oct 2024 13:15:07 +0300 Subject: [PATCH 03/78] Fix emergency app exit --- src/error-manager/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error-manager/index.js b/src/error-manager/index.js index 789c325a..3027f9f4 100644 --- a/src/error-manager/index.js +++ b/src/error-manager/index.js @@ -231,7 +231,7 @@ Please, set it to a valid location or reset it to the default` hasNoParentWin: true } }) - .then(() => { app.quit() }) + .then(() => { app.exit() }) .catch((err) => { console.error(err) }) return From 2f63e10ef6fd983ce3465575dbddb98a4b6d89e3 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 16 Oct 2024 13:20:49 +0300 Subject: [PATCH 04/78] Add ability to get correct user data path if not initiated --- src/helpers/get-user-data-path.js | 10 ++++++++++ src/helpers/index.js | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 src/helpers/get-user-data-path.js diff --git a/src/helpers/get-user-data-path.js b/src/helpers/get-user-data-path.js new file mode 100644 index 00000000..1baafb4f --- /dev/null +++ b/src/helpers/get-user-data-path.js @@ -0,0 +1,10 @@ +'use strict' + +const { app } = require('electron') + +const productName = require('./product-name') + +module.exports = () => { + return app.getPath('userData') + .replace('bfx-report-electron', productName) +} diff --git a/src/helpers/index.js b/src/helpers/index.js index 964742ad..21253d14 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -13,6 +13,7 @@ const isMainWinAvailable = require( './is-main-win-available' ) const productName = require('./product-name') +const getUserDataPath = require('./get-user-data-path') const getAlertCustomClassObj = require('./get-alert-custom-class-obj') const parseEnvValToBool = require('./parse-env-val-to-bool') const isBfxApiStaging = require('./is-bfx-api-staging') @@ -26,6 +27,7 @@ module.exports = { getServerPromise, isMainWinAvailable, productName, + getUserDataPath, getAlertCustomClassObj, parseEnvValToBool, isBfxApiStaging, From f4698ab4bce1b24d17e238e8c5f7bc95c687f64a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 16 Oct 2024 13:21:58 +0300 Subject: [PATCH 05/78] Fix logs collection for bug report --- src/error-manager/collect-logs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/error-manager/collect-logs.js b/src/error-manager/collect-logs.js index 6d259629..95b3ccd8 100644 --- a/src/error-manager/collect-logs.js +++ b/src/error-manager/collect-logs.js @@ -1,11 +1,12 @@ 'use strict' -const { app } = require('electron') const { promisify } = require('util') const path = require('path') const fs = require('fs') const log = require('electron-log') +const getUserDataPath = require('../helpers/get-user-data-path') + const readFile = promisify(fs.readFile) const truncateLog = require('./truncate-log') @@ -35,7 +36,7 @@ const _readLogFile = async (logPath, byteLimit = 8000) => { module.exports = async () => { const { path: mainLogPath } = log.transports.file.getFile() - const pathToUserData = app.getPath('userData') + const pathToUserData = getUserDataPath() const logsFolder = path.join(pathToUserData, 'logs') const workerErrorsPath = path.join( logsFolder, From 60702bef44b5f6851a8bcad5d026e6ff39299969 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 16 Oct 2024 13:24:03 +0300 Subject: [PATCH 06/78] Improve app init to use translations in error layout --- src/initialize-app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/initialize-app.js b/src/initialize-app.js index 942567c8..353523fa 100644 --- a/src/initialize-app.js +++ b/src/initialize-app.js @@ -31,7 +31,8 @@ const { } = require('./errors') const { deserializeError, - getFreePort + getFreePort, + getUserDataPath } = require('./helpers') const { checkForUpdatesAndNotify @@ -157,6 +158,8 @@ const _manageConfigs = (params = {}) => { module.exports = async () => { try { + TranslationIpcChannelHandlers.create() + app.on('window-all-closed', () => { app.quit() }) @@ -169,7 +172,7 @@ module.exports = async () => { app.setAppUserModelId(app.name) } - const pathToUserData = app.getPath('userData') + const pathToUserData = getUserDataPath() const pathToUserDocuments = app.getPath('documents') const configsKeeper = _manageConfigs({ @@ -182,8 +185,6 @@ module.exports = async () => { await i18next.changeLanguage(savedLanguage) } - TranslationIpcChannelHandlers.create() - const secretKey = await makeOrReadSecretKey( { pathToUserData } ) @@ -216,6 +217,7 @@ module.exports = async () => { printToPDF() } catch (err) { + await app.whenReady() await createErrorWindow(pathToLayoutAppInitErr) throw err From 8e03934e17cab69d5c9272426206861d7401c265 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 16 Oct 2024 13:27:34 +0300 Subject: [PATCH 07/78] Add ability to use translations in browser windows --- .../main-renderer-ipc-bridge/preload.js | 15 +++++++++++---- .../translation-ipc-channel-handlers.js | 11 +++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/window-creators/main-renderer-ipc-bridge/preload.js b/src/window-creators/main-renderer-ipc-bridge/preload.js index 6975813e..b1a1c04e 100644 --- a/src/window-creators/main-renderer-ipc-bridge/preload.js +++ b/src/window-creators/main-renderer-ipc-bridge/preload.js @@ -10,9 +10,14 @@ const CHANNEL_NAMES = { const INVOKE_METHOD_NAMES = { SET_LANGUAGE: 'setLanguage', GET_LANGUAGE: 'getLanguage', - GET_AVAILABLE_LANGUAGES: 'getAvailableLanguages' + GET_AVAILABLE_LANGUAGES: 'getAvailableLanguages', + TRANSLATE: 'translate' } +const CHANNEL_MAP = new Map([ + [CHANNEL_NAMES.TRANSLATIONS, INVOKE_METHOD_NAMES] +]) + const getEventName = (channel, method) => { return `${channel}:${method}` } @@ -25,9 +30,11 @@ const invoke = (channel, method, args) => { const bfxReportElectronApi = {} -for (const methodName of Object.values(INVOKE_METHOD_NAMES)) { - bfxReportElectronApi[methodName] = (args) => { - return invoke(CHANNEL_NAMES.TRANSLATIONS, methodName, args) +for (const [channelName, invokeMethodNames] of CHANNEL_MAP) { + for (const methodName of Object.values(invokeMethodNames)) { + bfxReportElectronApi[methodName] = (args) => { + return invoke(channelName, methodName, args) + } } } diff --git a/src/window-creators/main-renderer-ipc-bridge/translation-ipc-channel-handlers.js b/src/window-creators/main-renderer-ipc-bridge/translation-ipc-channel-handlers.js index 6a329627..0e3d1865 100644 --- a/src/window-creators/main-renderer-ipc-bridge/translation-ipc-channel-handlers.js +++ b/src/window-creators/main-renderer-ipc-bridge/translation-ipc-channel-handlers.js @@ -10,8 +10,6 @@ const createMenu = require('../../create-menu') class TranslationIpcChannelHandlers extends IpcChannelHandlers { constructor () { super('translations') - - this.configsKeeper = getConfigsKeeperByName('main') } async setLanguageHandler (event, args) { @@ -32,8 +30,9 @@ class TranslationIpcChannelHandlers extends IpcChannelHandlers { createMenu() } - const isSaved = await this.configsKeeper - .saveConfigs({ language }) + const configsKeeper = getConfigsKeeperByName('main') + const isSaved = await configsKeeper + ?.saveConfigs?.({ language }) if (isSaved) { return language @@ -49,6 +48,10 @@ class TranslationIpcChannelHandlers extends IpcChannelHandlers { async getAvailableLanguagesHandler (event, args) { return getAvailableLanguages() } + + async translateHandler (event, args) { + return i18next.t(args?.key, args?.opts) + } } module.exports = TranslationIpcChannelHandlers From 3f0fcdc412297565fd88bb947eeeae9cb79b3660 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 16 Oct 2024 13:41:59 +0300 Subject: [PATCH 08/78] Use translations in app init error layout --- .../layouts/app-init-error.html | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/window-creators/layouts/app-init-error.html b/src/window-creators/layouts/app-init-error.html index a6415129..81ffae7b 100644 --- a/src/window-creators/layouts/app-init-error.html +++ b/src/window-creators/layouts/app-init-error.html @@ -58,7 +58,38 @@ -
Application initialization error
- +
Application initialization error
+ + + From 334711a80cc9ac296816793ec4e4c2c885daad7e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 16 Oct 2024 13:42:42 +0300 Subject: [PATCH 09/78] Add translations for app init error layout --- build/locales/en/translations.json | 6 +++++- build/locales/ru/translations.json | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 081a4a4c..75550186 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -1,6 +1,10 @@ { "common": { - "title": "Report" + "title": "Report", + "appInitError": { + "description": "Application initialization error", + "closeBtnText": "Close" + } }, "menu": { "macMainSubmenu": { diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index df5ac1aa..8e280749 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -1,6 +1,10 @@ { "common": { - "title": "Отчет" + "title": "Отчет", + "appInitError": { + "description": "Ошибка инициализации приложения", + "closeBtnText": "Закрыть" + } }, "menu": { "macMainSubmenu": { From 620c135c846264358144139a1c868293dd400254 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 17 Oct 2024 13:41:32 +0300 Subject: [PATCH 10/78] Fix zenity closing behavior for error modal win on ubuntu --- src/error-manager/show-modal-dialog.js | 27 ++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/error-manager/show-modal-dialog.js b/src/error-manager/show-modal-dialog.js index 597e09a2..e1aa1947 100644 --- a/src/error-manager/show-modal-dialog.js +++ b/src/error-manager/show-modal-dialog.js @@ -212,14 +212,25 @@ module.exports = async (params) => { } // On Linux needs to spawn zenity gui tool to show error - await spawn('zenity', [ - '--error', - `--title=${errBoxTitle}`, - `--text=${errBoxDescription}`, - '--width=800', - '--ok-label=Exit', - '--no-markup' - ]) + // If push close btn in menu bar zenity will exit with 1 + // which will cause an error + try { + await spawn('zenity', [ + '--error', + `--title=${errBoxTitle}`, + `--text=${errBoxDescription}`, + '--width=800', + '--ok-label=Report and Exit', + '--no-markup' + ]) + } catch (err) { + console.debug(err) + + return { + isExit: true, + isReported: false + } + } return res } From 5b1d1c0fbd37595353e70b4a9e063173fcd4988e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 17 Oct 2024 13:45:22 +0300 Subject: [PATCH 11/78] Add general-ipc-channel-handlers for app exit in browser win --- .../general-ipc-channel-handlers.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/window-creators/main-renderer-ipc-bridge/general-ipc-channel-handlers.js diff --git a/src/window-creators/main-renderer-ipc-bridge/general-ipc-channel-handlers.js b/src/window-creators/main-renderer-ipc-bridge/general-ipc-channel-handlers.js new file mode 100644 index 00000000..e93cb14a --- /dev/null +++ b/src/window-creators/main-renderer-ipc-bridge/general-ipc-channel-handlers.js @@ -0,0 +1,13 @@ +'use strict' + +const { app } = require('electron') + +const IpcChannelHandlers = require('./ipc.channel.handlers') + +class GeneralIpcChannelHandlers extends IpcChannelHandlers { + async exitHandler (event, args) { + return app.exit(args?.code ?? 0) + } +} + +module.exports = GeneralIpcChannelHandlers From 221f5325adf5f029305820ceb9dd5bff37a53ca4 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 17 Oct 2024 13:46:17 +0300 Subject: [PATCH 12/78] Init general-ipc-channel-handlers --- src/initialize-app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/initialize-app.js b/src/initialize-app.js index 353523fa..a6b76e34 100644 --- a/src/initialize-app.js +++ b/src/initialize-app.js @@ -9,6 +9,9 @@ const { REPORT_FILES_PATH_VERSION } = require('./const') const TranslationIpcChannelHandlers = require( './window-creators/main-renderer-ipc-bridge/translation-ipc-channel-handlers' ) +const GeneralIpcChannelHandlers = require( + './window-creators/main-renderer-ipc-bridge/general-ipc-channel-handlers' +) const triggerSyncAfterUpdates = require('./trigger-sync-after-updates') const triggerElectronLoad = require('./trigger-electron-load') const wins = require('./window-creators/windows') @@ -158,6 +161,7 @@ const _manageConfigs = (params = {}) => { module.exports = async () => { try { + GeneralIpcChannelHandlers.create() TranslationIpcChannelHandlers.create() app.on('window-all-closed', () => { From a1539bbfe57a55ec9690ad61c216098558880ea4 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 17 Oct 2024 13:48:36 +0300 Subject: [PATCH 13/78] Register general-ipc-channel-handlers in preload script --- src/window-creators/main-renderer-ipc-bridge/preload.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/window-creators/main-renderer-ipc-bridge/preload.js b/src/window-creators/main-renderer-ipc-bridge/preload.js index b1a1c04e..650a1589 100644 --- a/src/window-creators/main-renderer-ipc-bridge/preload.js +++ b/src/window-creators/main-renderer-ipc-bridge/preload.js @@ -4,10 +4,14 @@ const { contextBridge, ipcRenderer } = require('electron') const isTestEnv = process.env.NODE_ENV === 'test' const CHANNEL_NAMES = { + GENERAL: 'general', TRANSLATIONS: 'translations' } -const INVOKE_METHOD_NAMES = { +const GENERAL_INVOKE_METHOD_NAMES = { + EXIT: 'exit' +} +const TRANSLATIONS_INVOKE_METHOD_NAMES = { SET_LANGUAGE: 'setLanguage', GET_LANGUAGE: 'getLanguage', GET_AVAILABLE_LANGUAGES: 'getAvailableLanguages', @@ -15,7 +19,8 @@ const INVOKE_METHOD_NAMES = { } const CHANNEL_MAP = new Map([ - [CHANNEL_NAMES.TRANSLATIONS, INVOKE_METHOD_NAMES] + [CHANNEL_NAMES.GENERAL, GENERAL_INVOKE_METHOD_NAMES], + [CHANNEL_NAMES.TRANSLATIONS, TRANSLATIONS_INVOKE_METHOD_NAMES] ]) const getEventName = (channel, method) => { From 7237c2ea685759a44dd0717d036aae15c2538c32 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 17 Oct 2024 13:50:19 +0300 Subject: [PATCH 14/78] Improve app init error layout --- .../layouts/app-init-error.html | 73 +++++++++++++++++-- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/src/window-creators/layouts/app-init-error.html b/src/window-creators/layouts/app-init-error.html index 81ffae7b..f64bff5c 100644 --- a/src/window-creators/layouts/app-init-error.html +++ b/src/window-creators/layouts/app-init-error.html @@ -7,9 +7,17 @@ Bitfinex Reports
Application initialization error
- +
+ + + + + + + + + + + + + +
+ - From d4a99b58534013ad360fcd3aa5a883c87b5a54e1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 22 Oct 2024 14:36:42 +0300 Subject: [PATCH 20/78] Improve loading window workflow --- src/initialize-app.js | 9 -- .../change-loading-win-visibility-state.js | 100 ++++++++++-------- src/window-creators/index.js | 17 +-- 3 files changed, 60 insertions(+), 66 deletions(-) diff --git a/src/initialize-app.js b/src/initialize-app.js index 632a503e..ebceb062 100644 --- a/src/initialize-app.js +++ b/src/initialize-app.js @@ -14,9 +14,7 @@ const GeneralIpcChannelHandlers = require( ) const triggerSyncAfterUpdates = require('./trigger-sync-after-updates') const triggerElectronLoad = require('./trigger-electron-load') -const wins = require('./window-creators/windows') const runServer = require('./run-server') -const appStates = require('./app-states') const { createMainWindow, createErrorWindow @@ -207,13 +205,6 @@ module.exports = async () => { manageWorkerMessages(ipc) await isServerReadyPromise await triggerSyncAfterUpdates() - - // Legacy fix related to reprodducing the same behavior on all OS, - // waiting for checks that it was resolved in the last electron ver - if (appStates.isMainWinMaximized) { - wins.mainWindow.maximize() - } - await hideLoadingWindow({ isRequiredToShowMainWin: true }) await triggerElectronLoad(portsMap) await checkForUpdatesAndNotify() diff --git a/src/window-creators/change-loading-win-visibility-state.js b/src/window-creators/change-loading-win-visibility-state.js index cbc6677a..8225a1aa 100644 --- a/src/window-creators/change-loading-win-visibility-state.js +++ b/src/window-creators/change-loading-win-visibility-state.js @@ -1,13 +1,17 @@ 'use strict' -const { BrowserWindow, ipcMain } = require('electron') +const { BrowserWindow } = require('electron') const wins = require('./windows') +const appStates = require('../app-states') const { hideWindow, showWindow, centerWindow } = require('../helpers/manage-window') +const GeneralIpcChannelHandlers = require( + './main-renderer-ipc-bridge/general-ipc-channel-handlers' +) let intervalMarker @@ -34,11 +38,20 @@ const _setParentWindow = (noParent) => { const win = BrowserWindow.getFocusedWindow() + if (noParent) { + wins.loadingWindow.setParentWindow(null) + + return + } if ( - noParent || - Object.values(wins).every((w) => w !== win) + Object.values(wins).every((w) => w !== win) || + win === wins.loadingWindow ) { - wins.loadingWindow.setParentWindow(null) + const mainWindow = !wins.mainWindow?.isDestroyed() + ? wins.mainWindow + : null + + wins.loadingWindow.setParentWindow(mainWindow) return } @@ -110,38 +123,31 @@ const _stopProgressLoader = ( win.setProgressBar(-0.1) } -const _setLoadingDescription = (win, description) => { - return new Promise((resolve) => { - try { - if ( - !win || - typeof win !== 'object' || - win.isDestroyed() || - typeof description !== 'string' - ) { - resolve() - - return - } - - ipcMain.once('loading:description-ready', (event, err) => { - if (err) { - console.error(err) - } - - resolve() - }) - - win.webContents.send( - 'loading:description', - description - ) - } catch (err) { - console.error(err) - - resolve() +const _setLoadingDescription = async (win, description) => { + try { + if ( + !win || + typeof win !== 'object' || + win.isDestroyed() || + typeof description !== 'string' + ) { + return + } + + const loadingDescReadyPromise = GeneralIpcChannelHandlers + .onLoadingDescriptionReady() + + GeneralIpcChannelHandlers + .sendLoadingDescription(win, { description }) + + const loadingRes = await loadingDescReadyPromise + + if (loadingRes?.err) { + console.error(loadingRes?.err) } - }) + } catch (err) { + console.error(err) + } } const showLoadingWindow = async (opts = {}) => { @@ -151,7 +157,7 @@ const showLoadingWindow = async (opts = {}) => { isNotRunProgressLoaderRequired = false, isIndeterminateMode = false, noParent = false - } = { ...opts } + } = opts ?? {} if ( !wins.loadingWindow || @@ -188,14 +194,7 @@ const showLoadingWindow = async (opts = {}) => { const hideLoadingWindow = async (opts = {}) => { const { isRequiredToShowMainWin = false - } = { ...opts } - - if (isRequiredToShowMainWin) { - await showWindow( - wins.mainWindow, - { shouldWinBeFocused: true } - ) - } + } = opts ?? {} // need to empty description await _setLoadingDescription( @@ -204,6 +203,19 @@ const hideLoadingWindow = async (opts = {}) => { ) _stopProgressLoader() + if (isRequiredToShowMainWin) { + await showWindow( + wins.mainWindow, + { shouldWinBeFocused: true } + ) + + // Legacy fix related to reprodducing the same behavior on all OS, + // waiting for checks that it was resolved in the last electron ver + if (appStates.isMainWinMaximized) { + wins.mainWindow.maximize() + } + } + return hideWindow( wins.loadingWindow, { shouldWinBeBlurred: true } diff --git a/src/window-creators/index.js b/src/window-creators/index.js index 86070cf8..b17c5cf7 100644 --- a/src/window-creators/index.js +++ b/src/window-creators/index.js @@ -96,7 +96,6 @@ const _createWindow = async ( height: defaultHeight } = workAreaSize const isMainWindow = winName === 'mainWindow' - const isLoadingWindow = winName === 'loadingWindow' const { width = defaultWidth, height = defaultHeight, @@ -173,10 +172,7 @@ const _createWindow = async ( centerWindow(wins[winName]) } - await showWindow( - wins[winName], - { shouldWinBeShownInactive: isLoadingWindow } - ) + await showWindow(wins[winName]) return res } @@ -278,12 +274,11 @@ const createLoadingWindow = async () => { if ( wins.loadingWindow && typeof wins.loadingWindow === 'object' && - !wins.loadingWindow.isDestroyed() && - !wins.loadingWindow.isVisible() + !wins.loadingWindow.isDestroyed() ) { await showLoadingWindow() - return {} + return { win: wins.loadingWindow } } const winProps = await _createChildWindow( @@ -291,11 +286,7 @@ const createLoadingWindow = async () => { 'loadingWindow', { width: 350, - height: 350, - webPreferences: { - nodeIntegration: true, - contextIsolation: false - } + height: 350 } ) From 3082d67913fc74c59689db443f8f4dc15f0cef68 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 22 Oct 2024 14:38:25 +0300 Subject: [PATCH 21/78] Bump electron version to have latest patch --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 140a0984..2744479e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "concurrently": "9.0.1", "cross-env": "7.0.3", "dotenv": "16.3.1", - "electron": "27.3.5", + "electron": "27.3.11", "electron-builder": "24.10.0", "mocha": "10.2.0", "standard": "17.1.0", From cf9ce453533213be31e840bcc785113ce8fb184a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 23 Oct 2024 11:37:31 +0300 Subject: [PATCH 22/78] Fix issue with Wine to build Windows release under container --- Dockerfile.win-builder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.win-builder b/Dockerfile.win-builder index b4119164..f40d6348 100644 --- a/Dockerfile.win-builder +++ b/Dockerfile.win-builder @@ -10,7 +10,7 @@ COPY ./scripts/helpers/install-nodejs.sh ./scripts/helpers/install-nodejs.sh RUN ./scripts/helpers/install-nodejs.sh ${NODE_VERSION} \ # Remove the `Wine` source entry to resolve # the release key expiration issue for `apt-get update` - && sed -i '/Wine/d' /etc/apt/sources.list \ + && rm -rf /etc/apt/sources.list.d/wine* \ && apt-get update -y \ && apt-get install -y --no-install-recommends \ p7zip-full \ From 81d4acf9b82a1fcad57ce5e20f45b1a22b707da6 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 23 Oct 2024 18:29:47 +0300 Subject: [PATCH 23/78] Remove redundant opts default values --- src/window-creators/change-loading-win-visibility-state.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/window-creators/change-loading-win-visibility-state.js b/src/window-creators/change-loading-win-visibility-state.js index 8225a1aa..158a47ab 100644 --- a/src/window-creators/change-loading-win-visibility-state.js +++ b/src/window-creators/change-loading-win-visibility-state.js @@ -150,7 +150,7 @@ const _setLoadingDescription = async (win, description) => { } } -const showLoadingWindow = async (opts = {}) => { +const showLoadingWindow = async (opts) => { const { description = '', isRequiredToCloseAllWins = false, @@ -191,7 +191,7 @@ const showLoadingWindow = async (opts = {}) => { await _closeAllWindows() } -const hideLoadingWindow = async (opts = {}) => { +const hideLoadingWindow = async (opts) => { const { isRequiredToShowMainWin = false } = opts ?? {} From a1f7ccd17b7f5f34f80b4051dbf3f67684f3aa65 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 24 Oct 2024 12:33:02 +0300 Subject: [PATCH 24/78] Prevent returning translation key if a value is missing --- src/i18next/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/i18next/index.js b/src/i18next/index.js index d7e2d305..d5a82448 100644 --- a/src/i18next/index.js +++ b/src/i18next/index.js @@ -72,9 +72,9 @@ const initI18next = () => { const configs = { initImmediate: false, fallbackLng: { - es: ['es-EM'], - pt: ['pt-BR'], - zh: ['zh-CN'], + es: ['es-EM', 'en'], + pt: ['pt-BR', 'en'], + zh: ['zh-CN', 'en'], default: ['en'] }, lng: _getDefaultLanguage(), From a19d3a4017a1281fe776d18d7159c8fe41dc4f9a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 25 Oct 2024 04:36:07 +0300 Subject: [PATCH 25/78] Add macos compatibility to sed cli usage --- .github/workflows/build-electron-app.yml | 8 ++---- scripts/build-release.sh | 20 ++++++------- scripts/build-ui.sh | 36 ++++++++++++------------ scripts/setup.sh | 20 ++++++------- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/.github/workflows/build-electron-app.yml b/.github/workflows/build-electron-app.yml index 8dceeaf9..b05d9f68 100644 --- a/.github/workflows/build-electron-app.yml +++ b/.github/workflows/build-electron-app.yml @@ -134,16 +134,12 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - - name: Replace macOS’s sed with GNU’s sed - run: | - brew install gnu-sed - echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH - if: github.event.inputs.version != '' name: Set release version run: | - sed -i -e \ + sed -i".bak" -E -e \ "s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/g" \ - "./package.json" + "./package.json"; rm -f "./package.json.bak" - if: contains(fromJson('["true", "1", true, 1]'), github.event.inputs.isAutoUpdateDisabled) name: Turn off auto-update run: | diff --git a/scripts/build-release.sh b/scripts/build-release.sh index 9c0a5b1b..5d8ad5f5 100755 --- a/scripts/build-release.sh +++ b/scripts/build-release.sh @@ -141,24 +141,24 @@ fi if [ $isDevEnv == 1 ]; then echo -e "\n${COLOR_YELLOW}Developer environment is turned on!${COLOR_NORMAL}" - sed -i -e \ + sed -i".bak" -E -e \ "s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"development\"/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" else - sed -i -e \ + sed -i".bak" -E -e \ "s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"production\"/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" fi if [ $isAutoUpdateDisabled == 1 ]; then echo -e "\n${COLOR_YELLOW}Auto-update is turned off!${COLOR_NORMAL}" - sed -i -E -e \ + sed -i".bak" -E -e \ "s/\"IS_AUTO_UPDATE_DISABLED\": (false)|(true)/\"IS_AUTO_UPDATE_DISABLED\": true/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" else - sed -i -E -e \ + sed -i".bak" -E -e \ "s/\"IS_AUTO_UPDATE_DISABLED\": (false)|(true)/\"IS_AUTO_UPDATE_DISABLED\": false/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" fi changeDirOwnershipToCurrUser "$ELECTRON_CACHE" "$(id -u):$(id -g)" @@ -186,9 +186,9 @@ cp "$EXPRESS_FOLDER/config/default.json.example" \ echo -e "\n${COLOR_BLUE}Setting backend configs${COLOR_NORMAL}" escapedBfxApiUrl=$(escapeString $bfxApiUrl) -sed -i -e \ +sed -i".bak" -E -e \ "s/\"restUrl\": \".*\"/\"restUrl\": \"$escapedBfxApiUrl\"/g" \ - "$WORKER_FOLDER/config/service.report.json" + "$WORKER_FOLDER/config/service.report.json"; rm -f "$WORKER_FOLDER/config/service.report.json.bak" installBackendDeps "$targetPlatform" diff --git a/scripts/build-ui.sh b/scripts/build-ui.sh index 8c8c00d4..9e43823c 100755 --- a/scripts/build-ui.sh +++ b/scripts/build-ui.sh @@ -93,34 +93,34 @@ echo -e "\n${COLOR_BLUE}Setting UI configs${COLOR_NORMAL}" escapedBfxHomeUrl=$(escapeString $bfxHomeUrl) escapedBfxKeyUrl=$(escapeString $bfxKeyUrl) -sed -i -e \ +sed -i".bak" -E -e \ "s/HOME_URL: .*,/HOME_URL: \'$escapedBfxHomeUrl\',/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/API_URL: .*,/API_URL: \'http:\/\/${BACKEND_ADDRESS}\/api\',/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/WS_ADDRESS: .*,/WS_ADDRESS: \'ws:\/\/${BACKEND_ADDRESS}\/ws\',/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/KEY_URL: .*,/KEY_URL: \'$escapedBfxKeyUrl\/api\',/g" \ - "$UI_CONFIGS_FILE" + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" -sed -i -e \ +sed -i".bak" -E -e \ "s/localExport: false/localExport: true/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/showAuthPage: false/showAuthPage: true/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/showFrameworkMode: false/showFrameworkMode: true/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/hostedFrameworkMode: true/hostedFrameworkMode: false/g" \ - "$UI_CONFIGS_FILE" -sed -i -e \ + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" +sed -i".bak" -E -e \ "s/isElectronApp: false/isElectronApp: true/g" \ - "$UI_CONFIGS_FILE" + "$UI_CONFIGS_FILE"; rm -f "$UI_CONFIGS_FILE.bak" cd "$UI_FOLDER" echo -e "\n${COLOR_BLUE}Installing the UI deps...${COLOR_NORMAL}" diff --git a/scripts/setup.sh b/scripts/setup.sh index 62f1f3a8..9c7e07e6 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -83,24 +83,24 @@ fi if [ $isDevEnv == 1 ]; then echo -e "\n${COLOR_YELLOW}Developer environment is turned on!${COLOR_NORMAL}" - sed -i -e \ + sed -i".bak" -E -e \ "s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"development\"/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" else - sed -i -e \ + sed -i".bak" -E -e \ "s/\"NODE_ENV\": \".*\"/\"NODE_ENV\": \"production\"/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" fi if [ $isAutoUpdateDisabled == 1 ]; then echo -e "\n${COLOR_YELLOW}Auto-update is turned off!${COLOR_NORMAL}" - sed -i -E -e \ + sed -i".bak" -E -e \ "s/\"IS_AUTO_UPDATE_DISABLED\": (false)|(true)/\"IS_AUTO_UPDATE_DISABLED\": true/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" else - sed -i -E -e \ + sed -i".bak" -E -e \ "s/\"IS_AUTO_UPDATE_DISABLED\": (false)|(true)/\"IS_AUTO_UPDATE_DISABLED\": false/g" \ - "$ROOT/$ELECTRON_ENV_FILE_NAME" + "$ROOT/$ELECTRON_ENV_FILE_NAME"; rm -f "$ROOT/$ELECTRON_ENV_FILE_NAME.bak" fi if [ $syncRepo == 1 ]; then @@ -132,9 +132,9 @@ cp "$EXPRESS_FOLDER/config/default.json.example" \ echo -e "\n${COLOR_BLUE}Setting backend configs${COLOR_NORMAL}" escapedBfxApiUrl=$(escapeString $bfxApiUrl) -sed -i -e \ +sed -i".bak" -E -e \ "s/\"restUrl\": \".*\"/\"restUrl\": \"$escapedBfxApiUrl\"/g" \ - "$WORKER_FOLDER/config/service.report.json" + "$WORKER_FOLDER/config/service.report.json"; rm -f "$WORKER_FOLDER/config/service.report.json.bak" installBackendDeps From 57fc2debdb5daaa48d38217eb19a372b21810fa5 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:32:51 +0200 Subject: [PATCH 26/78] Add translation support to error manager --- src/error-manager/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/error-manager/index.js b/src/error-manager/index.js index 3027f9f4..2d1a665f 100644 --- a/src/error-manager/index.js +++ b/src/error-manager/index.js @@ -3,6 +3,7 @@ const { app, Menu } = require('electron') const os = require('os') const cleanStack = require('clean-stack') +const i18next = require('i18next') const isDevEnv = process.env.NODE_ENV === 'development' @@ -215,10 +216,8 @@ const initLogger = () => { const error = message.data.join(os.EOL) if (/Failed to get 'documents' path/gi.test(error)) { - const title = 'The OS Documents directory has been misconfigured' - const msg = `\ -This indicates that your OS \`Documents\` directory has been misconfigured. -Please, set it to a valid location or reset it to the default` + const title = i18next.t('common.errorManager.failedToGetDocsPath.title') + const msg = i18next.t('common.errorManager.failedToGetDocsPath.message') showModalDialog({ errBoxTitle: title, From a26fac8a30c151b5061fe2af7872a6483e1de7e1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:33:15 +0200 Subject: [PATCH 27/78] Add en translation for error manager --- build/locales/en/translations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 75550186..a5529360 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -4,6 +4,12 @@ "appInitError": { "description": "Application initialization error", "closeBtnText": "Close" + }, + "errorManager": { + "failedToGetDocsPath": { + "title": "The OS Documents directory has been misconfigured", + "message": "This indicates that your OS `Documents` directory has been misconfigured.\nPlease, set it to a valid location or reset it to the default" + } } }, "menu": { From cdeaae9b0ec7a7f2c7e00606691212fafb787e68 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:33:39 +0200 Subject: [PATCH 28/78] Add ru translation for error manager --- build/locales/ru/translations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 8e280749..e462af15 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -4,6 +4,12 @@ "appInitError": { "description": "Ошибка инициализации приложения", "closeBtnText": "Закрыть" + }, + "errorManager": { + "failedToGetDocsPath": { + "title": "Каталог Документы ОС был неправильно настроен", + "message": "Это означает, что каталог `Документы` вашей ОС был неправильно настроен.\nПожалуйста, укажите правильное расположение или сбросьте его до значений по умолчанию" + } } }, "menu": { From 2501d835b6deeff797183fdf13717acb70a227ee Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:47:43 +0200 Subject: [PATCH 29/78] Add translation support to error description getter --- src/error-manager/get-error-description.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/error-manager/get-error-description.js b/src/error-manager/get-error-description.js index 13a03fde..f1c650c8 100644 --- a/src/error-manager/get-error-description.js +++ b/src/error-manager/get-error-description.js @@ -2,14 +2,15 @@ const os = require('os') const cleanStack = require('clean-stack') +const i18next = require('i18next') module.exports = (params) => { const { error } = { ...params } const title = '[BUG REPORT]' const description = 'Bug report' - const errBoxTitle = 'Bug report' - const errBoxDescription = 'A new Github issue will be opened' + const errBoxTitle = i18next.t('common.errorManager.errorModalDialog.errBoxTitle') + const errBoxDescription = i18next.t('common.errorManager.errorModalDialog.errBoxDescription') if ( error && From 64783179aeb668149e5121f4213946ab28ae067e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:48:06 +0200 Subject: [PATCH 30/78] Add en translation for error description getter --- build/locales/en/translations.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index a5529360..9f719a9b 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -9,6 +9,10 @@ "failedToGetDocsPath": { "title": "The OS Documents directory has been misconfigured", "message": "This indicates that your OS `Documents` directory has been misconfigured.\nPlease, set it to a valid location or reset it to the default" + }, + "errorModalDialog": { + "errBoxTitle": "Bug report", + "errBoxDescription": "A new GitHub issue will be opened" } } }, From dab777f81735730f03e9b9f525414ee49043686b Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:48:26 +0200 Subject: [PATCH 31/78] Add ru translation for error description getter --- build/locales/ru/translations.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index e462af15..b48a25a9 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -9,6 +9,10 @@ "failedToGetDocsPath": { "title": "Каталог Документы ОС был неправильно настроен", "message": "Это означает, что каталог `Документы` вашей ОС был неправильно настроен.\nПожалуйста, укажите правильное расположение или сбросьте его до значений по умолчанию" + }, + "errorModalDialog": { + "errBoxTitle": "Отчет об ошибке", + "errBoxDescription": "Будет открыта новая проблема в GitHub" } } }, From c29703038c62ba33f953fffa1d04831d34574ad5 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 14:08:03 +0200 Subject: [PATCH 32/78] Add translation support to error modal dialog --- src/error-manager/show-modal-dialog.js | 28 ++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/error-manager/show-modal-dialog.js b/src/error-manager/show-modal-dialog.js index e1aa1947..b32f82cf 100644 --- a/src/error-manager/show-modal-dialog.js +++ b/src/error-manager/show-modal-dialog.js @@ -6,6 +6,7 @@ const path = require('path') const { Converter } = require('showdown') const Alert = require('electron-alert') const { rootPath } = require('electron-root-path') +const i18next = require('i18next') const wins = require('../window-creators/windows') const spawn = require('../helpers/spawn') @@ -110,9 +111,9 @@ const _fireAlert = (params) => { icon: 'question', focusConfirm: true, showConfirmButton: true, - confirmButtonText: 'Report', + confirmButtonText: i18next.t('common.errorManager.errorModalDialog.confirmButtonText'), showCancelButton: true, - cancelButtonText: 'Cancel', + cancelButtonText: i18next.t('common.errorManager.errorModalDialog.cancelButtonText'), timerProgressBar: false, ...params, @@ -169,11 +170,26 @@ const _fireAlert = (params) => { module.exports = async (params) => { const { - errBoxTitle = 'Bug report', - errBoxDescription = 'A new Github issue will be opened', + /* + * It's important to add default translation here + * to have a description if an error occurs + * before the translation init + */ + errBoxTitle = i18next.t( + 'common.errorManager.errorModalDialog.errBoxTitle', + 'Bug report' + ), + errBoxDescription = i18next.t( + 'common.errorManager.errorModalDialog.errBoxDescription', + 'A new GitHub issue will be opened' + ), mdIssue, alertOpts = {} - } = params + } = params ?? {} + const zenityBtn = i18next.t( + 'common.errorManager.errorModalDialog.zenityBtn', + 'Report and Exit' + ) if ( app.isReady() && @@ -220,7 +236,7 @@ module.exports = async (params) => { `--title=${errBoxTitle}`, `--text=${errBoxDescription}`, '--width=800', - '--ok-label=Report and Exit', + `--ok-label=${zenityBtn}`, '--no-markup' ]) } catch (err) { From 5e83852c517e3754eeb6cec83c01dc1af339f2c1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 14:08:44 +0200 Subject: [PATCH 33/78] Add en translation for error modal dialog --- build/locales/en/translations.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 9f719a9b..61cfdd21 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -12,7 +12,10 @@ }, "errorModalDialog": { "errBoxTitle": "Bug report", - "errBoxDescription": "A new GitHub issue will be opened" + "errBoxDescription": "A new GitHub issue will be opened", + "zenityBtn": "Report and Exit", + "confirmButtonText": "Report", + "cancelButtonText": "Cancel" } } }, From 9f75fd2bd58995ca77ea38fb33f76e0a4b6ad082 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 14:09:05 +0200 Subject: [PATCH 34/78] Add ru translation for error modal dialog --- build/locales/ru/translations.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index b48a25a9..08c6c3bb 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -12,7 +12,10 @@ }, "errorModalDialog": { "errBoxTitle": "Отчет об ошибке", - "errBoxDescription": "Будет открыта новая проблема в GitHub" + "errBoxDescription": "Будет открыта новая проблема в GitHub", + "zenityBtn": "Отправить Отчет и Выйти", + "confirmButtonText": "Отправить Отчет", + "cancelButtonText": "Отменить" } } }, From 57f5984253b4a3c353728da2415245d162b5d196 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 09:15:16 +0200 Subject: [PATCH 35/78] Add translations to error alert window title --- build/locales/en/translations.json | 3 ++- build/locales/ru/translations.json | 3 ++- src/error-manager/show-modal-dialog.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 61cfdd21..7554093b 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -15,7 +15,8 @@ "errBoxDescription": "A new GitHub issue will be opened", "zenityBtn": "Report and Exit", "confirmButtonText": "Report", - "cancelButtonText": "Cancel" + "cancelButtonText": "Cancel", + "title": "Should a bug report be submitted?" } } }, diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 08c6c3bb..e5a83e88 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -15,7 +15,8 @@ "errBoxDescription": "Будет открыта новая проблема в GitHub", "zenityBtn": "Отправить Отчет и Выйти", "confirmButtonText": "Отправить Отчет", - "cancelButtonText": "Отменить" + "cancelButtonText": "Отменить", + "title": "Должен ли быть отправлен отчет об ошибке?" } } }, diff --git a/src/error-manager/show-modal-dialog.js b/src/error-manager/show-modal-dialog.js index b32f82cf..24456a3d 100644 --- a/src/error-manager/show-modal-dialog.js +++ b/src/error-manager/show-modal-dialog.js @@ -53,7 +53,7 @@ const converter = new Converter({ const _fireAlert = (params) => { const { - title = 'Should a bug report be submitted?', + title = i18next.t('common.errorManager.errorModalDialog.title'), html = '', parentWin, hasNoParentWin From f00eb288124b6b544cfdbbd6f828429ca169d0e6 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 09:28:29 +0200 Subject: [PATCH 36/78] Fix carriage return newline in translations --- build/locales/en/translations.json | 2 +- build/locales/ru/translations.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 7554093b..f65f8c51 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -8,7 +8,7 @@ "errorManager": { "failedToGetDocsPath": { "title": "The OS Documents directory has been misconfigured", - "message": "This indicates that your OS `Documents` directory has been misconfigured.\nPlease, set it to a valid location or reset it to the default" + "message": "This indicates that your OS `Documents` directory has been misconfigured.\n\rPlease, set it to a valid location or reset it to the default" }, "errorModalDialog": { "errBoxTitle": "Bug report", diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index e5a83e88..f2935d1c 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -8,7 +8,7 @@ "errorManager": { "failedToGetDocsPath": { "title": "Каталог Документы ОС был неправильно настроен", - "message": "Это означает, что каталог `Документы` вашей ОС был неправильно настроен.\nПожалуйста, укажите правильное расположение или сбросьте его до значений по умолчанию" + "message": "Это означает, что каталог `Документы` вашей ОС был неправильно настроен.\n\rПожалуйста, укажите правильное расположение или сбросьте его до значений по умолчанию" }, "errorModalDialog": { "errBoxTitle": "Отчет об ошибке", From b5157ed0fecf29f619ccdb925cad5073eee0f46f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 11:35:13 +0200 Subject: [PATCH 37/78] Add translation support to sync native notification --- src/show-notification/show-sync-notification.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/show-notification/show-sync-notification.js b/src/show-notification/show-sync-notification.js index 8aeceda9..22158926 100644 --- a/src/show-notification/show-sync-notification.js +++ b/src/show-notification/show-sync-notification.js @@ -1,5 +1,7 @@ 'use strict' +const i18next = require('i18next') + const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) @@ -14,13 +16,13 @@ const getBody = (params) => { } = params ?? {} if (isError) { - return 'Data sync completed with an error!' + return i18next.t('common.nativeNotification.sync.errorBody') } if (isInterrupted) { - return 'Data sync interrupted!' + return i18next.t('common.nativeNotification.sync.interruptedBody') } - return 'Data sync completed successfully!' + return i18next.t('common.nativeNotification.sync.completedBody') } module.exports = (mess) => { From ef147b089eab7a7d230ae1a37fce3512b7fa1560 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 11:35:35 +0200 Subject: [PATCH 38/78] Add translation support to trx tax report native notification --- src/show-notification/show-trx-tax-report-notification.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/show-notification/show-trx-tax-report-notification.js b/src/show-notification/show-trx-tax-report-notification.js index 869ca964..64e202d6 100644 --- a/src/show-notification/show-trx-tax-report-notification.js +++ b/src/show-notification/show-trx-tax-report-notification.js @@ -1,5 +1,7 @@ 'use strict' +const i18next = require('i18next') + const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) @@ -18,8 +20,8 @@ module.exports = (mess) => { const isError = state === PROCESS_MESSAGES.ERROR_TRX_TAX_REPORT const body = isError - ? 'An unexpected error occurred while generating the tax report!' - : 'Your tax report is ready!' + ? i18next.t('common.nativeNotification.trxTaxReport.errorBody') + : i18next.t('common.nativeNotification.trxTaxReport.completedBody') const urgency = isError ? 'critical' : 'normal' showNotification({ body, urgency }) From cbe40dbb7652233441484fe2ad56eca453c9e5f8 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 11:35:59 +0200 Subject: [PATCH 39/78] Add en translation for native notification --- build/locales/en/translations.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index f65f8c51..bcd54370 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -18,6 +18,19 @@ "cancelButtonText": "Cancel", "title": "Should a bug report be submitted?" } + }, + "nativeNotification": { + "defaulTitle": "Bitfinex Report", + "defaultBody": "Notification", + "sync": { + "completedBody": "Data sync completed successfully!", + "interruptedBody": "Data sync interrupted!", + "errorBody": "Data sync completed with an error!" + }, + "trxTaxReport": { + "completedBody": "Your tax report is ready!", + "errorBody": "An unexpected error occurred while generating the tax report!" + } } }, "menu": { From d58ac4590eb278b61b0dbe9f79d76315bd5dcffb Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 11:36:20 +0200 Subject: [PATCH 40/78] Add ru translation for native notification --- build/locales/ru/translations.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index f2935d1c..85f107e9 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -18,6 +18,19 @@ "cancelButtonText": "Отменить", "title": "Должен ли быть отправлен отчет об ошибке?" } + }, + "nativeNotification": { + "defaulTitle": "Bitfinex Report", + "defaultBody": "Уведомление", + "sync": { + "completedBody": "Синхронизация данных успешно завершена!", + "interruptedBody": "Синхронизация данных прервана!", + "errorBody": "Синхронизация данных завершена с ошибкой!" + }, + "trxTaxReport": { + "completedBody": "Ваш налоговый отчет готов!", + "errorBody": "При формировании налогового отчета произошла непредвиденная ошибка!" + } } }, "menu": { From 132c8210bbb1f71933cecbe645ff8da4d2e09f07 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 29 Oct 2024 11:36:38 +0200 Subject: [PATCH 41/78] Add translations to native notification default values --- src/show-notification/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/show-notification/index.js b/src/show-notification/index.js index 7fd24702..659874ac 100644 --- a/src/show-notification/index.js +++ b/src/show-notification/index.js @@ -2,6 +2,7 @@ const { Notification } = require('electron') const path = require('path') +const i18next = require('i18next') const icon = path.join(__dirname, '../../build/icons/64x64.png') @@ -11,8 +12,8 @@ module.exports = (params) => { } const notification = new Notification({ - title: 'Bitfinex Report', - body: 'Notification', + title: i18next.t('common.nativeNotification.defaulTitle'), + body: i18next.t('common.nativeNotification.defaultBody'), silent: false, timeoutType: 'never', urgency: 'normal', From ffca95f449bd8bfa0f860ba4d1b9792594576e75 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 30 Oct 2024 11:58:54 +0200 Subject: [PATCH 42/78] Add translation support to auto-updater --- src/auto-updater/index.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index 1e01e9de..824a5d0a 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -11,6 +11,7 @@ const { } = require('electron-updater') const Alert = require('electron-alert') const yaml = require('js-yaml') +const i18next = require('i18next') const log = require('../error-manager/log') const BfxMacUpdater = require('./bfx.mac.updater') @@ -264,7 +265,7 @@ const _autoUpdaterFactory = () => { autoUpdater.addInstallingUpdateEventHandler(() => { return showLoadingWindow({ - description: 'Updating...', + description: i18next.t('common.autoUpdater.loadingWindow.description'), isRequiredToCloseAllWins: true }) }) @@ -314,7 +315,7 @@ const _autoUpdaterFactory = () => { /ERR_INTERNET_DISCONNECTED/gi.test(err.toString()) ) { await _fireToast({ - title: 'Internet disconnected', + title: i18next.t('common.autoUpdater.errorToast.inetIssueTitle'), icon: 'error', timer: 60000 }) @@ -323,7 +324,7 @@ const _autoUpdaterFactory = () => { } await _fireToast({ - title: 'Application update failed', + title: i18next.t('common.autoUpdater.errorToast.title'), icon: 'error', timer: 60000 }) @@ -339,7 +340,7 @@ const _autoUpdaterFactory = () => { await _fireToast( { - title: 'Checking for update', + title: i18next.t('common.autoUpdater.checkingForUpdateToast.title'), type: 'warning', timer: 10000 }, @@ -359,8 +360,11 @@ const _autoUpdaterFactory = () => { const { value, dismiss } = await _fireToast( { - title: `An update to v${version} is available`, - text: 'Starting download...', + title: i18next.t( + 'common.autoUpdater.updateAvailableToast.title', + { version } + ), + text: i18next.t('common.autoUpdater.updateAvailableToast.description'), icon: 'info', timer: 10000 } @@ -395,7 +399,7 @@ const _autoUpdaterFactory = () => { await _fireToast( { - title: 'No updates available', + title: i18next.t('common.autoUpdater.updateNotAvailableToast.title'), icon: 'success', timer: 10000 } @@ -418,7 +422,7 @@ const _autoUpdaterFactory = () => { await _fireToast( { - title: 'Downloading...', + title: i18next.t('common.autoUpdater.downloadProgressToast.title'), icon: 'info' }, { @@ -450,8 +454,11 @@ const _autoUpdaterFactory = () => { const { value } = await _fireToast( { - title: `Update v${version} downloaded`, - text: 'Should the app be updated right now?', + title: i18next.t( + 'common.autoUpdater.updateDownloadedToast.title', + { version } + ), + text: i18next.t('common.autoUpdater.updateDownloadedToast.description'), icon: 'question', timer: 60000, showCancelButton: true From dcc68f6c2d1f7d5179d6894c9a1e986ece292b5d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 30 Oct 2024 12:01:38 +0200 Subject: [PATCH 43/78] Add en translation for auto-updater --- build/locales/en/translations.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index bcd54370..0d8e2cb9 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -31,6 +31,32 @@ "completedBody": "Your tax report is ready!", "errorBody": "An unexpected error occurred while generating the tax report!" } + }, + "autoUpdater": { + "loadingWindow": { + "description": "Updating..." + }, + "errorToast": { + "title": "Application update failed", + "inetIssueTitle": "Internet disconnected" + }, + "checkingForUpdateToast": { + "title": "Checking for update" + }, + "updateAvailableToast": { + "title": "An update to v{{version}} is available", + "description": "Starting download..." + }, + "updateNotAvailableToast": { + "title": "No updates available" + }, + "downloadProgressToast": { + "title": "Downloading..." + }, + "updateDownloadedToast": { + "title": "Update v{{version}} downloaded", + "description": "Should the app be updated right now?" + } } }, "menu": { From bb6737a93d49c6653af85efa563c725264918613 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 30 Oct 2024 12:01:59 +0200 Subject: [PATCH 44/78] Add ru translation for auto-updater --- build/locales/ru/translations.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 85f107e9..5c622ce4 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -31,6 +31,32 @@ "completedBody": "Ваш налоговый отчет готов!", "errorBody": "При формировании налогового отчета произошла непредвиденная ошибка!" } + }, + "autoUpdater": { + "loadingWindow": { + "description": "Обновление..." + }, + "errorToast": { + "title": "Обновление приложения не удалось", + "inetIssueTitle": "Интернет отключен" + }, + "checkingForUpdateToast": { + "title": "Проверка обновления" + }, + "updateAvailableToast": { + "title": "Доступно обновление до версии v{{version}}", + "description": "Начинаем загрузку..." + }, + "updateNotAvailableToast": { + "title": "Нет доступных обновлений" + }, + "downloadProgressToast": { + "title": "Загрузка..." + }, + "updateDownloadedToast": { + "title": "Обновление v{{version}} загружено", + "description": "Стоит ли обновить приложение прямо сейчас?" + } } }, "menu": { From 4f8285380d2af925e2e91505c65d45552938520c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 30 Oct 2024 12:02:20 +0200 Subject: [PATCH 45/78] Add ability to override IS_AUTO_UPDATE_BEING_TESTED flag in dev mode via .env --- .env.example | 1 + index.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.env.example b/.env.example index b1b45271..61996485 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,7 @@ REPO_BRANCH=master IS_BFX_API_STAGING=0 IS_DEV_ENV=0 IS_AUTO_UPDATE_DISABLED=0 +IS_AUTO_UPDATE_BEING_TESTED=0 SHOULD_LOCALHOST_BE_USED_FOR_LOADING_UI_IN_DEV_MODE=0 diff --git a/index.js b/index.js index ef0a267b..3677828a 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,10 @@ try { process.env[key] = val } } catch (err) {} +try { + // Uses only in dev mode as dotenv is added into dev deps + require('dotenv').config({ override: true }) +} catch (err) {} const { app } = require('electron') require('./src/i18next') From c4369a49673f7ff3ca63bc687e9a415d9982ed03 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 31 Oct 2024 13:22:47 +0200 Subject: [PATCH 46/78] Add translation support to restore db --- src/restore-db/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/restore-db/index.js b/src/restore-db/index.js index 46c8e71a..0561f757 100644 --- a/src/restore-db/index.js +++ b/src/restore-db/index.js @@ -5,6 +5,7 @@ const fs = require('fs') const path = require('path') const Alert = require('electron-alert') const { rootPath } = require('electron-root-path') +const i18next = require('i18next') const ipcs = require('../ipcs') const wins = require('../window-creators/windows') @@ -55,7 +56,7 @@ const sound = { freq: 'F2', type: 'triange', duration: 1.5 } const _fireAlert = (params) => { const { - title = 'Select DB backup file', + title = i18next.t('common.restoreDB.modalDialog.title'), backupFilesMetadata } = params const win = wins.mainWindow @@ -121,7 +122,8 @@ const _fireAlert = (params) => { showConfirmButton: true, focusCancel: true, showCancelButton: true, - cancelButtonText: 'Cancel', + confirmButtonText: i18next.t('common.restoreDB.modalDialog.confirmButtonText'), + cancelButtonText: i18next.t('common.restoreDB.modalDialog.cancelButtonText'), timerProgressBar: false, input: 'radio', @@ -238,9 +240,9 @@ module.exports = () => { ) { await showMessageModalDialog(wins.mainWindow, { type: 'warning', - title: 'DB restoring', - message: 'Suitable DB backup file has not been found', - buttons: ['OK'], + title: i18next.t('common.restoreDB.messageModalDialog.title'), + message: i18next.t('common.restoreDB.messageModalDialog.message'), + buttons: [i18next.t('common.restoreDB.messageModalDialog.confirmButtonText')], defaultId: 0, cancelId: 0 }) From 60914d577e933b56bbed289f72df9f69494bd799 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 31 Oct 2024 13:23:07 +0200 Subject: [PATCH 47/78] Add translation support to restore db message modal dialog --- src/manage-worker-messages.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index 8ee967c9..14f4e316 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -1,6 +1,7 @@ 'use strict' const { app, BrowserWindow } = require('electron') +const i18next = require('i18next') const wins = require('./window-creators/windows') const relaunch = require('./relaunch') @@ -27,10 +28,7 @@ const PROCESS_STATES = require( ) module.exports = (ipc) => { - const win = isMainWinAvailable( - wins.mainWindow, - { shouldCheckVisibility: true } - ) + const win = isMainWinAvailable(wins.mainWindow) ? wins.mainWindow : BrowserWindow.getFocusedWindow() @@ -66,18 +64,17 @@ module.exports = (ipc) => { await showWindow(win) const hasNotDbBeenRestored = state === PROCESS_MESSAGES.DB_HAS_NOT_BEEN_RESTORED - const messChunk = hasNotDbBeenRestored - ? ' not' - : '' const type = hasNotDbBeenRestored ? 'error' : 'info' await showMessageModalDialog(win, { type, - title: 'DB restoring', - message: `DB has${messChunk} been restored`, - buttons: ['OK'], + title: i18next.t('common.restoreDB.messageModalDialog.title'), + message: hasNotDbBeenRestored + ? i18next.t('common.restoreDB.messageModalDialog.dbNotRestoredMessage') + : i18next.t('common.restoreDB.messageModalDialog.dbRestoredMessage'), + buttons: [i18next.t('common.restoreDB.messageModalDialog.confirmButtonText')], defaultId: 0, cancelId: 0 }) From c0f36e76dd78078f3d33472952c0f55439a9467d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 31 Oct 2024 13:24:42 +0200 Subject: [PATCH 48/78] Add en translation for restore-db --- build/locales/en/translations.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 0d8e2cb9..2ca63a01 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -57,6 +57,20 @@ "title": "Update v{{version}} downloaded", "description": "Should the app be updated right now?" } + }, + "restoreDB": { + "modalDialog": { + "title": "Select DB backup file", + "confirmButtonText": "OK", + "cancelButtonText": "Cancel" + }, + "messageModalDialog": { + "title": "DB restoring", + "message": "Suitable DB backup file has not been found", + "dbRestoredMessage": "DB has been restored", + "dbNotRestoredMessage": "DB has not been restored", + "confirmButtonText": "OK" + } } }, "menu": { From a25d4e9339fad6ee9b5191944a7b29440b79e624 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 31 Oct 2024 13:24:59 +0200 Subject: [PATCH 49/78] Add ru translation for restore-db --- build/locales/ru/translations.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 5c622ce4..20312638 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -57,6 +57,20 @@ "title": "Обновление v{{version}} загружено", "description": "Стоит ли обновить приложение прямо сейчас?" } + }, + "restoreDB": { + "modalDialog": { + "title": "Выберите файл резервной копии БД", + "confirmButtonText": "OK", + "cancelButtonText": "Отменить" + }, + "messageModalDialog": { + "title": "Восстановление БД", + "message": "Подходящий файл резервной копии БД не найден", + "dbRestoredMessage": "БД была восстановлена", + "dbNotRestoredMessage": "БД не была восстановлена", + "confirmButtonText": "OK" + } } }, "menu": { From 8f24a86cad64ddf63f7bffd0b8df01b54b93b43c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 1 Nov 2024 12:07:19 +0200 Subject: [PATCH 50/78] Add helper to get ui fonts as css string --- src/helpers/get-ui-fonts-as-css-string.js | 17 +++++++++++++++++ src/helpers/index.js | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/helpers/get-ui-fonts-as-css-string.js diff --git a/src/helpers/get-ui-fonts-as-css-string.js b/src/helpers/get-ui-fonts-as-css-string.js new file mode 100644 index 00000000..7cd10939 --- /dev/null +++ b/src/helpers/get-ui-fonts-as-css-string.js @@ -0,0 +1,17 @@ +'use strict' + +const { rootPath } = require('electron-root-path') +const fs = require('fs') +const path = require('path') + +const fontsPath = path.join(rootPath, 'bfx-report-ui/build/fonts/') +const fontsStyle = fs.readFileSync( + path.join(fontsPath, 'roboto.css'), + 'utf8' +) +const fStyleWithNormalizedPaths = fontsStyle.replace( + /url\(\.\/(.*\..*)\)/g, + `url(${fontsPath}$1)` +) + +module.exports = () => fStyleWithNormalizedPaths diff --git a/src/helpers/index.js b/src/helpers/index.js index 964742ad..ceb4e425 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -17,6 +17,7 @@ const getAlertCustomClassObj = require('./get-alert-custom-class-obj') const parseEnvValToBool = require('./parse-env-val-to-bool') const isBfxApiStaging = require('./is-bfx-api-staging') const waitPort = require('./wait-port') +const getUIFontsAsCSSString = require('./get-ui-fonts-as-css-string') module.exports = { getFreePort, @@ -29,5 +30,6 @@ module.exports = { getAlertCustomClassObj, parseEnvValToBool, isBfxApiStaging, - waitPort + waitPort, + getUIFontsAsCSSString } From fa39f5ef0ead03504990a20dbd1b337dd205e81b Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 1 Nov 2024 12:08:41 +0200 Subject: [PATCH 51/78] Fix loading ui fonts to restore-db modal window --- src/restore-db/index.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/restore-db/index.js b/src/restore-db/index.js index 0561f757..c95eada5 100644 --- a/src/restore-db/index.js +++ b/src/restore-db/index.js @@ -4,7 +4,6 @@ const { app, screen, remote } = require('electron') const fs = require('fs') const path = require('path') const Alert = require('electron-alert') -const { rootPath } = require('electron-root-path') const i18next = require('i18next') const ipcs = require('../ipcs') @@ -18,6 +17,9 @@ const isMainWinAvailable = require( const getAlertCustomClassObj = require( '../helpers/get-alert-custom-class-obj' ) +const getUIFontsAsCSSString = require( + '../helpers/get-ui-fonts-as-css-string' +) const showMessageModalDialog = require( '../show-message-modal-dialog' ) @@ -32,9 +34,7 @@ const { addOnceProcEventHandler } = require('../window-creators/window-event-manager') -const fontsStyle = fs.readFileSync(path.join( - rootPath, 'bfx-report-ui/build/fonts/roboto.css' -)) +const fontsStyle = getUIFontsAsCSSString() const alertStyle = fs.readFileSync(path.join( __dirname, '../modal-dialog-src/modal-dialog.css' )) @@ -101,10 +101,7 @@ const _fireAlert = (params) => { darkTheme: false, parent: win, modal: true, - width: 1000, - webPreferences: { - contextIsolation: false - } + width: 1000 } const swalOptions = { position: 'center', From 47f2d2a1efede75b6212df905f71604be78c2c55 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Fri, 1 Nov 2024 12:10:27 +0200 Subject: [PATCH 52/78] Fix min-width for restore-db modal window --- src/restore-db/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/restore-db/index.js b/src/restore-db/index.js index c95eada5..206f6373 100644 --- a/src/restore-db/index.js +++ b/src/restore-db/index.js @@ -101,7 +101,7 @@ const _fireAlert = (params) => { darkTheme: false, parent: win, modal: true, - width: 1000 + minWidth: 1000 } const swalOptions = { position: 'center', From 8c5ed4e5b3a252ada52b605169fb38d68f83235e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 4 Nov 2024 13:03:17 +0200 Subject: [PATCH 53/78] Fix loading ui fonts to all modal windows --- src/auto-updater/index.js | 7 ++++--- src/change-sync-frequency.js | 8 +++++--- src/error-manager/show-modal-dialog.js | 7 ++++--- src/show-docs/index.js | 7 ++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index 824a5d0a..76b29710 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -28,14 +28,15 @@ const { WINDOW_EVENT_NAMES, addOnceProcEventHandler } = require('../window-creators/window-event-manager') +const getUIFontsAsCSSString = require( + '../helpers/get-ui-fonts-as-css-string' +) const MENU_ITEM_IDS = require('../create-menu/menu.item.ids') const isAutoUpdateDisabled = parseEnvValToBool(process.env.IS_AUTO_UPDATE_DISABLED) -const fontsStyle = fs.readFileSync(path.join( - __dirname, '../../bfx-report-ui/build/fonts/roboto.css' -)) +const fontsStyle = getUIFontsAsCSSString() const toastStyle = fs.readFileSync(path.join( __dirname, 'toast-src/toast.css' )) diff --git a/src/change-sync-frequency.js b/src/change-sync-frequency.js index a2d9a83a..b79df78d 100644 --- a/src/change-sync-frequency.js +++ b/src/change-sync-frequency.js @@ -6,9 +6,11 @@ const cronValidate = require('cron-validate') const path = require('path') const fs = require('fs') -const fontsStyle = fs.readFileSync(path.join( - __dirname, '../bfx-report-ui/build/fonts/roboto.css' -)) +const getUIFontsAsCSSString = require( + './helpers/get-ui-fonts-as-css-string' +) + +const fontsStyle = getUIFontsAsCSSString() const modalDialogStyle = fs.readFileSync(path.join( __dirname, 'modal-dialog-src/modal-dialog.css' )) diff --git a/src/error-manager/show-modal-dialog.js b/src/error-manager/show-modal-dialog.js index 24456a3d..7c7f6f27 100644 --- a/src/error-manager/show-modal-dialog.js +++ b/src/error-manager/show-modal-dialog.js @@ -23,13 +23,14 @@ const { WINDOW_EVENT_NAMES, addOnceProcEventHandler } = require('../window-creators/window-event-manager') +const getUIFontsAsCSSString = require( + '../helpers/get-ui-fonts-as-css-string' +) const mdStyle = fs.readFileSync(path.join( rootPath, 'node_modules', 'github-markdown-css/github-markdown.css' )) -const fontsStyle = fs.readFileSync(path.join( - __dirname, '../../bfx-report-ui/build/fonts/roboto.css' -)) +const fontsStyle = getUIFontsAsCSSString() const alertStyle = fs.readFileSync(path.join( __dirname, '../modal-dialog-src/modal-dialog.css' )) diff --git a/src/show-docs/index.js b/src/show-docs/index.js index 5f7f3a6b..96509680 100644 --- a/src/show-docs/index.js +++ b/src/show-docs/index.js @@ -18,6 +18,9 @@ const { closeAlert } = require('../modal-dialog-src/utils') const { UserManualShowingError } = require('../errors') +const getUIFontsAsCSSString = require( + '../helpers/get-ui-fonts-as-css-string' +) const mdUserManual = fs.readFileSync( path.join(rootPath, 'docs/user-manual.md'), @@ -31,9 +34,7 @@ const { const mdStyle = fs.readFileSync(path.join( rootPath, 'node_modules', 'github-markdown-css/github-markdown.css' )) -const fontsStyle = fs.readFileSync(path.join( - rootPath, 'bfx-report-ui/build/fonts/roboto.css' -)) +const fontsStyle = getUIFontsAsCSSString() const alertStyle = fs.readFileSync(path.join( __dirname, '../modal-dialog-src/modal-dialog.css' )) From 4afcf0d76c94c38de0e8ed5f2468c031e41b7a87 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Nov 2024 12:27:20 +0200 Subject: [PATCH 54/78] Add translation support to show-docs --- src/show-docs/index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/show-docs/index.js b/src/show-docs/index.js index 96509680..70bacd5a 100644 --- a/src/show-docs/index.js +++ b/src/show-docs/index.js @@ -6,6 +6,7 @@ const path = require('path') const { Converter } = require('showdown') const Alert = require('electron-alert') const { rootPath } = require('electron-root-path') +const i18next = require('i18next') const wins = require('../window-creators/windows') const isMainWinAvailable = require( @@ -59,7 +60,7 @@ const converter = new Converter({ const _fireAlert = (params) => { const { type = 'info', - title = 'User manual', + title = i18next.t('common.showDocs.modalDialog.title'), html } = params const win = wins.mainWindow @@ -96,10 +97,7 @@ const _fireAlert = (params) => { darkTheme: false, parent: win, modal: true, - width: 1000, - webPreferences: { - contextIsolation: false - } + width: 1000 } const swalOptions = { position: 'center', @@ -115,7 +113,7 @@ const _fireAlert = (params) => { showConfirmButton: false, focusCancel: true, showCancelButton: true, - cancelButtonText: 'Cancel', + cancelButtonText: i18next.t('common.showDocs.modalDialog.cancelButtonText'), timerProgressBar: false, willOpen: () => { From 8a5db7411fefe7107ec2b0ff6198de607ec1773a Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Nov 2024 12:30:09 +0200 Subject: [PATCH 55/78] Add en translation for show-docs --- build/locales/en/translations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 2ca63a01..9dabda0d 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -71,6 +71,12 @@ "dbNotRestoredMessage": "DB has not been restored", "confirmButtonText": "OK" } + }, + "showDocs": { + "modalDialog": { + "title": "User manual", + "cancelButtonText": "Close" + } } }, "menu": { From 0176c0d22a977dddd88a8bc2a73620b66039192f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Nov 2024 12:31:02 +0200 Subject: [PATCH 56/78] Add ru translation for show-docs --- build/locales/ru/translations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 20312638..5166c8bd 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -71,6 +71,12 @@ "dbNotRestoredMessage": "БД не была восстановлена", "confirmButtonText": "OK" } + }, + "showDocs": { + "modalDialog": { + "title": "Руководство пользователя", + "cancelButtonText": "Закрыть" + } } }, "menu": { From 5dd07dc35e1477eb5768c1eae0af201d68b88a6b Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Nov 2024 14:42:15 +0200 Subject: [PATCH 57/78] Add ability to set md user manual with different langs into i18next --- src/i18next/index.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/i18next/index.js b/src/i18next/index.js index d5a82448..9945ae2d 100644 --- a/src/i18next/index.js +++ b/src/i18next/index.js @@ -20,6 +20,31 @@ const availableLanguages = [...allFileNames.reduce((accum, fileName) => { return accum }, new Set())] +const docPath = path.join(rootPath, 'docs') +const docFileName = 'user-manual.md' +const allDocFileNames = fs.readdirSync(docPath) +const lngDocMap = allDocFileNames.reduce((accum, dirName) => { + const dirPath = path.join(docPath, dirName) + const dirStats = fs.lstatSync(dirPath) + + if (!dirStats.isDirectory()) { + return accum + } + + const filePath = path.join(dirPath, docFileName) + const fileStats = fs.lstatSync(filePath) + + if (!fileStats.isFile()) { + return accum + } + + const mdUserManual = fs.readFileSync(filePath, 'utf8') + + accum.set(dirName, mdUserManual) + + return accum +}, new Map()) + let i18nextInstance = null const _getLanguageFromAvailableOnes = (language) => { @@ -89,6 +114,13 @@ const initI18next = () => { i18next .use(Backend) .init(configs) + + for (const [lng, mdUserManual] of lngDocMap) { + i18next.addResourceBundle(lng, 'mdDocs', { + userManual: mdUserManual + }) + } + i18nextInstance = i18next return i18next From c65a98727d0260f1556f1b46097479f538548a3d Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Nov 2024 14:42:45 +0200 Subject: [PATCH 58/78] Get md user manual from i18next --- src/show-docs/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/show-docs/index.js b/src/show-docs/index.js index 70bacd5a..b49f6150 100644 --- a/src/show-docs/index.js +++ b/src/show-docs/index.js @@ -23,10 +23,6 @@ const getUIFontsAsCSSString = require( '../helpers/get-ui-fonts-as-css-string' ) -const mdUserManual = fs.readFileSync( - path.join(rootPath, 'docs/user-manual.md'), - 'utf8' -) const { WINDOW_EVENT_NAMES, addOnceProcEventHandler @@ -169,7 +165,7 @@ module.exports = async (params = {}) => { const { type, title, - mdDoc = mdUserManual + mdDoc = i18next.t('mdDocs:userManual') } = params if ( From 6787814778874a2e4325b23d38821a14ce33f071 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 5 Nov 2024 14:44:10 +0200 Subject: [PATCH 59/78] Split md user manual by languages --- docs/{ => en}/user-manual.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{ => en}/user-manual.md (100%) diff --git a/docs/user-manual.md b/docs/en/user-manual.md similarity index 100% rename from docs/user-manual.md rename to docs/en/user-manual.md From d30bf5702768b13b7d8109435b90162ea6b50529 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 10:19:19 +0200 Subject: [PATCH 60/78] Add translation support to print-to-pdf --- src/print-to-pdf/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/print-to-pdf/index.js b/src/print-to-pdf/index.js index 0aaf2b2f..272e82e7 100644 --- a/src/print-to-pdf/index.js +++ b/src/print-to-pdf/index.js @@ -3,6 +3,7 @@ const { BrowserWindow } = require('electron') const fs = require('fs/promises') const path = require('path') +const i18next = require('i18next') const ipcs = require('../ipcs') const wins = require('../window-creators/windows') @@ -25,7 +26,7 @@ module.exports = () => { const { templateFilePath, - template = 'No data', + template = i18next.t('common.printToPDF.defaultTemplate'), format = 'portrait', orientation = 'Letter', uid = null @@ -73,7 +74,7 @@ module.exports = () => { font-weight: 400; font-size: 8px; "> - Page from + ${i18next.t('common.printToPDF.pagination.page')} ${i18next.t('common.printToPDF.pagination.from')} ` }) From 626dcea4362a9c42fc3625e6a8c7a282554cb318 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 10:19:43 +0200 Subject: [PATCH 61/78] Add en translation for print-to-pdf --- build/locales/en/translations.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 9dabda0d..4d8adddf 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -77,6 +77,13 @@ "title": "User manual", "cancelButtonText": "Close" } + }, + "printToPDF": { + "defaultTemplate": "No data", + "pagination": { + "page": "Page", + "from": "from" + } } }, "menu": { From 9e0b53badb8f704b2fef21e5812cb59b38c61716 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 10:20:05 +0200 Subject: [PATCH 62/78] Add ru translation for print-to-pdf --- build/locales/ru/translations.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 5166c8bd..99b09746 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -77,6 +77,13 @@ "title": "Руководство пользователя", "cancelButtonText": "Закрыть" } + }, + "printToPDF": { + "defaultTemplate": "Нет данных", + "pagination": { + "page": "Страница", + "from": "из" + } } }, "menu": { From 0e331ce7a4d9fb0eea532f4838b2339a21f5ba05 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 11:02:05 +0200 Subject: [PATCH 63/78] Add translation support to change-reports-folder --- src/change-reports-folder.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/change-reports-folder.js b/src/change-reports-folder.js index 4bdb9efc..e68ee85b 100644 --- a/src/change-reports-folder.js +++ b/src/change-reports-folder.js @@ -1,6 +1,7 @@ 'use strict' const { dialog, BrowserWindow } = require('electron') +const i18next = require('i18next') const { REPORT_FILES_PATH_VERSION } = require('./const') @@ -24,9 +25,9 @@ module.exports = ({ pathToUserDocuments }) => { } = await dialog.showOpenDialog( win, { - title: 'Change reports folder', + title: i18next.t('common.changeReportsFolder.modalDialog.title'), defaultPath: pathToUserDocuments, - buttonLabel: 'Select', + buttonLabel: i18next.t('common.changeReportsFolder.modalDialog.buttonLabel'), properties: [ 'openDirectory', 'createDirectory', @@ -63,7 +64,11 @@ module.exports = ({ pathToUserDocuments }) => { relaunch() } catch (err) { try { - await showErrorModalDialog(win, 'Change reports folder', err) + await showErrorModalDialog( + win, + i18next.t('common.changeReportsFolder.modalDialog.title'), + err + ) } catch (err) { console.error(err) } From a2bdecd6f0d293927a96114b00cf1a2e8283de01 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 11:02:31 +0200 Subject: [PATCH 64/78] Add en translation for change-reports-folder --- build/locales/en/translations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 4d8adddf..ec1c78bb 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -84,6 +84,12 @@ "page": "Page", "from": "from" } + }, + "changeReportsFolder": { + "modalDialog": { + "title": "Change reports folder", + "buttonLabel": "Select" + } } }, "menu": { From 5eb84c3df7227d409548c67a4da53c99da3e925c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 11:03:02 +0200 Subject: [PATCH 65/78] Add ru translation for change-reports-folder --- build/locales/ru/translations.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 99b09746..601d7efd 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -84,6 +84,12 @@ "page": "Страница", "from": "из" } + }, + "changeReportsFolder": { + "modalDialog": { + "title": "Изменить папку отчетов", + "buttonLabel": "Выбрать" + } } }, "menu": { From 29ed78e15ca05cdc739e073e580bd403cf8b709f Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 6 Nov 2024 11:03:25 +0200 Subject: [PATCH 66/78] Improve entering parent win to change-reports-folder dialog --- src/change-reports-folder.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/change-reports-folder.js b/src/change-reports-folder.js index e68ee85b..7cd937e7 100644 --- a/src/change-reports-folder.js +++ b/src/change-reports-folder.js @@ -13,10 +13,14 @@ const showErrorModalDialog = require('./show-error-modal-dialog') const pauseApp = require('./pause-app') const relaunch = require('./relaunch') const { getConfigsKeeperByName } = require('./configs-keeper') +const wins = require('./window-creators/windows') +const isMainWinAvailable = require('./helpers/is-main-win-available') module.exports = ({ pathToUserDocuments }) => { return async () => { - const win = BrowserWindow.getFocusedWindow() + const win = isMainWinAvailable(wins.mainWindow) + ? wins.mainWindow + : BrowserWindow.getFocusedWindow() try { const { From 222a2cabfc48b3c6509deefa224f709a9a8f9326 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 12:03:37 +0200 Subject: [PATCH 67/78] Add translation support to change-sync-frequency --- src/change-sync-frequency.js | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/change-sync-frequency.js b/src/change-sync-frequency.js index b79df78d..6efd196b 100644 --- a/src/change-sync-frequency.js +++ b/src/change-sync-frequency.js @@ -5,6 +5,7 @@ const Alert = require('electron-alert') const cronValidate = require('cron-validate') const path = require('path') const fs = require('fs') +const i18next = require('i18next') const getUIFontsAsCSSString = require( './helpers/get-ui-fonts-as-css-string' @@ -88,10 +89,7 @@ const _fireFrameless = (alert, opts) => { thickFrame: false, closable: false, backgroundColor: '#172d3e', - hasShadow: false, - webPreferences: { - contextIsolation: false - } + hasShadow: false } const swalOptions = { background: '#172d3e', @@ -132,7 +130,7 @@ module.exports = () => { } const timeFormatAlertOptions = { - title: 'Set time format', + title: i18next.t('common.changeSyncFrequency.timeFormatModalDialog.title'), icon: 'question', customClass: getAlertCustomClassObj({ title: 'titleColor', @@ -141,14 +139,21 @@ module.exports = () => { }), focusConfirm: true, showCancelButton: true, + confirmButtonText: i18next + .t('common.changeSyncFrequency.timeFormatModalDialog.confirmButtonText'), + cancelButtonText: i18next + .t('common.changeSyncFrequency.timeFormatModalDialog.cancelButtonText'), progressSteps: [1, 2], currentProgressStep: 0, input: 'radio', inputValue: 'hours', inputOptions: { - mins: 'Mins', - hours: 'Hours', - days: 'Days' + mins: i18next + .t('common.changeSyncFrequency.timeFormatModalDialog.inputOptions.mins'), + hours: i18next + .t('common.changeSyncFrequency.timeFormatModalDialog.inputOptions.hours'), + days: i18next + .t('common.changeSyncFrequency.timeFormatModalDialog.inputOptions.days') }, willOpen: () => { if (!timeFormatAlert.browserWindow) return @@ -157,7 +162,7 @@ module.exports = () => { } } const alertOptions = { - title: 'Set sync frequency', + title: i18next.t('common.changeSyncFrequency.timeModalDialog.title'), icon: 'question', customClass: getAlertCustomClassObj({ title: 'titleColor', @@ -166,6 +171,10 @@ module.exports = () => { }), focusConfirm: true, showCancelButton: true, + confirmButtonText: i18next + .t('common.changeSyncFrequency.timeModalDialog.confirmButtonText'), + cancelButtonText: i18next + .t('common.changeSyncFrequency.timeModalDialog.cancelButtonText'), progressSteps: [1, 2], currentProgressStep: 1, input: 'range', @@ -284,7 +293,11 @@ module.exports = () => { relaunch() } catch (err) { try { - await showErrorModalDialog(win, 'Change sync frequency', err) + await showErrorModalDialog( + win, + i18next.t('common.changeSyncFrequency.title'), + err + ) } catch (err) { console.error(err) } From c87d79e87b755adb92382d93a0bd7b2461015ec8 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 12:04:01 +0200 Subject: [PATCH 68/78] Add en translation for change-sync-frequency --- build/locales/en/translations.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index ec1c78bb..6880ae45 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -90,6 +90,24 @@ "title": "Change reports folder", "buttonLabel": "Select" } + }, + "changeSyncFrequency": { + "title": "Change sync frequency", + "timeFormatModalDialog": { + "title": "Set time format", + "confirmButtonText": "OK", + "cancelButtonText": "Cancel", + "inputOptions": { + "mins": "Mins", + "hours": "Hours", + "days": "Days" + } + }, + "timeModalDialog": { + "title": "Set sync frequency", + "confirmButtonText": "OK", + "cancelButtonText": "Cancel" + } } }, "menu": { From ec24e6e779f7b636e16b5e462230e33d2b56cf84 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 12:04:28 +0200 Subject: [PATCH 69/78] Add ru translation for change-sync-frequency --- build/locales/ru/translations.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 601d7efd..9a6b10b2 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -90,6 +90,24 @@ "title": "Изменить папку отчетов", "buttonLabel": "Выбрать" } + }, + "changeSyncFrequency": { + "title": "Изменить частоту синхронизации", + "timeFormatModalDialog": { + "title": "Установить формат времени", + "confirmButtonText": "OK", + "cancelButtonText": "Отмена", + "inputOptions": { + "mins": "Мин.", + "hours": "Часы", + "days": "Дни" + } + }, + "timeModalDialog": { + "title": "Установить частоту синхронизации", + "confirmButtonText": "OK", + "cancelButtonText": "Отмена" + } } }, "menu": { From e7ba2a7ab32b27586a2c6b649d44fad9e79e112c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 13:25:33 +0200 Subject: [PATCH 70/78] Extend translations for auto-update buttons --- build/locales/en/translations.json | 3 +++ build/locales/ru/translations.json | 3 +++ src/auto-updater/index.js | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index 6880ae45..f812093d 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -33,6 +33,9 @@ } }, "autoUpdater": { + "title": "Update", + "confirmButtonText": "OK", + "cancelButtonText": "Cancel", "loadingWindow": { "description": "Updating..." }, diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index 9a6b10b2..ecde8e7b 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -33,6 +33,9 @@ } }, "autoUpdater": { + "title": "Обновление", + "confirmButtonText": "OK", + "cancelButtonText": "Отменить", "loadingWindow": { "description": "Обновление..." }, diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index 76b29710..d9dd5da9 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -141,9 +141,11 @@ const _fireToast = ( backdrop: 'rgba(0,0,0,0.0)', icon: 'info', - title: 'Update', + title: i18next.t('common.autoUpdater.title'), showConfirmButton: true, showCancelButton: false, + confirmButtonText: i18next.t('common.autoUpdater.confirmButtonText'), + cancelButtonText: i18next.t('common.autoUpdater.cancelButtonText'), timerProgressBar: false, ...opts, From 0a98b1d2c404bdaceae79e8c424c9a8065c6d945 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 13:26:41 +0200 Subject: [PATCH 71/78] Fix width for long text translations --- src/auto-updater/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index d9dd5da9..9d407abc 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -127,7 +127,7 @@ const _fireToast = ( backgroundColor: '#172d3e', darkTheme: false, height, - width: opts?.width ?? 800, + width: opts?.width ?? 1000, parent: win, modal: false, webPreferences: { From f90d608099d60d04a077bacdd32983a930fc8e7e Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 14:16:31 +0200 Subject: [PATCH 72/78] Add translation support to enforce-macos-app-location --- src/enforce-macos-app-location.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/enforce-macos-app-location.js b/src/enforce-macos-app-location.js index 0562c20b..bd9b0996 100644 --- a/src/enforce-macos-app-location.js +++ b/src/enforce-macos-app-location.js @@ -1,6 +1,7 @@ 'use strict' const { app, dialog } = require('electron') +const i18next = require('i18next') const productName = require('./helpers/product-name') const { @@ -22,11 +23,18 @@ module.exports = async () => { const clickedButtonIndex = dialog.showMessageBoxSync({ type: 'error', - message: 'Move to Applications folder?', - detail: `${productName} must live in the Applications folder to be able to run correctly.`, + message: i18next + .t('common.enforceMacOSAppLocation.appLocationModalDialog.message'), + detail: i18next.t( + 'common.enforceMacOSAppLocation.appLocationModalDialog.detail', + { productName } + ), buttons: [ - 'Move to Applications folder', - `Quit ${productName}` + i18next.t('common.enforceMacOSAppLocation.appLocationModalDialog.confirmButtonText'), + i18next.t( + 'common.enforceMacOSAppLocation.appLocationModalDialog.cancelButtonText', + { productName } + ) ], defaultId: 0, cancelId: 1 @@ -39,7 +47,8 @@ module.exports = async () => { } await showLoadingWindow({ - description: 'Moving the app...', + description: i18next + .t('common.enforceMacOSAppLocation.loadingWindow.description'), isRequiredToCloseAllWins: true, isIndeterminateMode: true }) @@ -49,9 +58,12 @@ module.exports = async () => { if (conflict === 'existsAndRunning') { dialog.showMessageBoxSync({ type: 'error', - message: `Another version of ${productName} is currently running. Quit it, then launch this version of the app again.`, + message: i18next.t( + 'common.enforceMacOSAppLocation.appRunningModalDialog.message', + { productName } + ), buttons: [ - 'OK' + i18next.t('common.enforceMacOSAppLocation.appRunningModalDialog.confirmButtonText') ] }) From 26e20ca51c34f100d14c94b4470f634e71277b83 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 14:16:53 +0200 Subject: [PATCH 73/78] Add en translation for enforce-macos-app-location --- build/locales/en/translations.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build/locales/en/translations.json b/build/locales/en/translations.json index f812093d..8cebb1a4 100644 --- a/build/locales/en/translations.json +++ b/build/locales/en/translations.json @@ -111,6 +111,21 @@ "confirmButtonText": "OK", "cancelButtonText": "Cancel" } + }, + "enforceMacOSAppLocation": { + "appLocationModalDialog": { + "message": "Move to Applications folder?", + "detail": "{{productName}} must live in the Applications folder to be able to run correctly", + "confirmButtonText": "Move to Applications folder", + "cancelButtonText": "Quit {{productName}}" + }, + "loadingWindow": { + "description": "Moving the app..." + }, + "appRunningModalDialog": { + "message": "Another version of {{productName}} is currently running. Quit it, then launch this version of the app again", + "confirmButtonText": "OK" + } } }, "menu": { From 3d3716149cc1be8297c3f78ca7daa8c9fc5eda88 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 7 Nov 2024 14:17:13 +0200 Subject: [PATCH 74/78] Add ru translation for enforce-macos-app-location --- build/locales/ru/translations.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build/locales/ru/translations.json b/build/locales/ru/translations.json index ecde8e7b..aaf29b4e 100644 --- a/build/locales/ru/translations.json +++ b/build/locales/ru/translations.json @@ -111,6 +111,21 @@ "confirmButtonText": "OK", "cancelButtonText": "Отмена" } + }, + "enforceMacOSAppLocation": { + "appLocationModalDialog": { + "message": "Переместить в папку Приложения?", + "detail": "{{productName}} должен находиться в папке Приложения для корректной работы", + "confirmButtonText": "Переместить в папку Приложения", + "cancelButtonText": "Выйти из {{productName}}" + }, + "loadingWindow": { + "description": "Перемещение приложения..." + }, + "appRunningModalDialog": { + "message": "В настоящее время запущена другая версия {{productName}}. Закройте ее, затем снова запустите эту версию приложения", + "confirmButtonText": "OK" + } } }, "menu": { From 7faafca222934bab058485e3c853ac7823bc8e9c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:05:41 +0200 Subject: [PATCH 75/78] Bump version up to v4.30.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2744479e..42c82aff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report-electron", - "version": "4.29.0", + "version": "4.30.0", "repository": "https://github.com/bitfinexcom/bfx-report-electron", "description": "Reporting tool", "author": "bitfinex.com", From ac80915a2f9da85c96b319e9e148a238e804cfd5 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 28 Oct 2024 13:06:09 +0200 Subject: [PATCH 76/78] Add changelog for v4.30.0 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6860b51..091185c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.30.0] - 2024-10-30 + +### Added + +- Implemented `Your Assets` section for the web `Account Summary` page. Improved sections titles styling. PR: [bfx-report-ui#880](https://github.com/bitfinexcom/bfx-report-ui/pull/880) +- Implemented `UI` language selection binding with `ElectronJS` wrapper. PR: [bfx-report-ui#882](https://github.com/bitfinexcom/bfx-report-ui/pull/882) +- Extended ElectronJS app wrapper translations. Improved the app-init-error layout. Fixed logs collection for bug report. PR: [bfx-report-electron#422](https://github.com/bitfinexcom/bfx-report-electron/pull/422) + +### Changed + +- Improved the loading window workflow to bring more consistency in the sequence of showing windows. Added ability to send/listen events for the app-init layout via the context bridge between the main and renderer ipc to be secure. Fixed issue with focusing the main window on the launch. PR: [bfx-report-electron#424](https://github.com/bitfinexcom/bfx-report-electron/pull/424) +- Prevented returning the translation key `key.nestedKey.etc` if a value is missing for a certain language and added the ability to try to take one from the default `en` translation file. PR: [bfx-report-electron#426](https://github.com/bitfinexcom/bfx-report-electron/pull/426) +- Reworked `sed` commands to be able to run the build `bash` scripts on both OSs `Ubuntu` and `MacOS` as they have slightly different implementation. PR: [bfx-report-electron#427](https://github.com/bitfinexcom/bfx-report-electron/pull/427) + +### Fixed + +- Fixed `2FA` login flow to prevent the token request duplication possibility noted in some user scenarios. PR: [bfx-report-ui#881](https://github.com/bitfinexcom/bfx-report-ui/pull/881) +- Fixed issue with `Wine` to build `Windows` release under container. PR: [bfx-report-electron#425](https://github.com/bitfinexcom/bfx-report-electron/pull/425) + +### Security + +- Bumped `cookie` from `0.6.0` to `0.7.1`, `express` from `4.21.0` to `4.21.1`. PR: [bfx-report-ui#879](https://github.com/bitfinexcom/bfx-report-ui/pull/879) +- Bumped `electron` from `27.3.11` to `27.3.5`. PR: [bfx-report-electron#424](https://github.com/bitfinexcom/bfx-report-electron/pull/424) + ## [4.29.0] - 2024-10-16 ### Added From 5f115e4a48fbf3918f05a27b7b233853801af729 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 12 Nov 2024 09:45:58 +0200 Subject: [PATCH 77/78] Extend changelog to keep it up to date --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 091185c7..751a2068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [4.30.0] - 2024-10-30 +## [4.30.0] - 2024-11-13 ### Added - Implemented `Your Assets` section for the web `Account Summary` page. Improved sections titles styling. PR: [bfx-report-ui#880](https://github.com/bitfinexcom/bfx-report-ui/pull/880) - Implemented `UI` language selection binding with `ElectronJS` wrapper. PR: [bfx-report-ui#882](https://github.com/bitfinexcom/bfx-report-ui/pull/882) - Extended ElectronJS app wrapper translations. Improved the app-init-error layout. Fixed logs collection for bug report. PR: [bfx-report-electron#422](https://github.com/bitfinexcom/bfx-report-electron/pull/422) +- Added translation support to the `error manager` module. PR: [bfx-report-electron#428](https://github.com/bitfinexcom/bfx-report-electron/pull/428) +- Added translation support to the `native notifications` module. PR: [bfx-report-electron#429](https://github.com/bitfinexcom/bfx-report-electron/pull/429) +- Added translation support to the `auto-updater` module. PRs: [bfx-report-electron#430](https://github.com/bitfinexcom/bfx-report-electron/pull/430), [bfx-report-electron#438](https://github.com/bitfinexcom/bfx-report-electron/pull/438) +- Added translation support to the `restore DB` module. PR: [bfx-report-electron#431](https://github.com/bitfinexcom/bfx-report-electron/pull/431) +- Added translation support to the `show-docs` module, and added the ability to set the `markdown` user manual with different languages into `i18next` (if doc for the corresponding lang does not exist takes `en` by default). PR: [bfx-report-electron#434](https://github.com/bitfinexcom/bfx-report-electron/pull/434) +- Added translation support to the `print-to-pdf` module. PR: [bfx-report-electron#435](https://github.com/bitfinexcom/bfx-report-electron/pull/435) +- Added translation support to the `change-reports-folder` module. PR: [bfx-report-electron#436](https://github.com/bitfinexcom/bfx-report-electron/pull/436) +- Added translation support to the `change-sync-frequency` module. PR: [bfx-report-electron#437](https://github.com/bitfinexcom/bfx-report-electron/pull/437) +- Added translation support to the `enforce-macos-app-location` module. PR: [bfx-report-electron#439](https://github.com/bitfinexcom/bfx-report-electron/pull/439) ### Changed @@ -25,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed `2FA` login flow to prevent the token request duplication possibility noted in some user scenarios. PR: [bfx-report-ui#881](https://github.com/bitfinexcom/bfx-report-ui/pull/881) - Fixed issue with `Wine` to build `Windows` release under container. PR: [bfx-report-electron#425](https://github.com/bitfinexcom/bfx-report-electron/pull/425) +- Fixed loading UI fonts to all modal windows. PR: [bfx-report-electron#432](https://github.com/bitfinexcom/bfx-report-electron/pull/432) ### Security From 53cd911dca204de8edd30a54ae853e3b1c015a74 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 13 Nov 2024 07:06:56 +0200 Subject: [PATCH 78/78] Update sub-modules --- bfx-report-ui | 2 +- bfx-reports-framework | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bfx-report-ui b/bfx-report-ui index 154f887b..3a0e0812 160000 --- a/bfx-report-ui +++ b/bfx-report-ui @@ -1 +1 @@ -Subproject commit 154f887b7e45e6187293396d6b5b2c41bb9beb06 +Subproject commit 3a0e08123ba4b55ad378fa38defe41024d0de4b5 diff --git a/bfx-reports-framework b/bfx-reports-framework index 617e751c..a6a782ee 160000 --- a/bfx-reports-framework +++ b/bfx-reports-framework @@ -1 +1 @@ -Subproject commit 617e751c1b0badc39d6c546eac3f2d41760f797d +Subproject commit a6a782ee0284f8f4bd3205b415f59080e037820e