Skip to content

Commit

Permalink
chore: merging staging
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebon committed Feb 8, 2024
2 parents 0432077 + 9bea469 commit 2102975
Show file tree
Hide file tree
Showing 9 changed files with 435 additions and 229 deletions.
2 changes: 2 additions & 0 deletions bin/build-tools/lib/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

export interface CommonConfig {
aboutReleasesUrl: string;
aboutUpdatesUrl: string;
adminUrl: string;
appBase: string;
buildDir: string;
Expand Down
2 changes: 2 additions & 0 deletions bin/build-tools/lib/commonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export async function getCommonConfig(envFile: string, wireJson: string): Promis

const commonConfig: CommonConfig = {
...defaultConfig,
aboutReleasesUrl: process.env.URL_ABOUT_RELEASES || defaultConfig.aboutReleasesUrl,
aboutUpdatesUrl: process.env.URL_ABOUT_UPDATES || defaultConfig.aboutUpdatesUrl,
adminUrl: process.env.URL_ADMIN || defaultConfig.adminUrl,
appBase: process.env.APP_BASE || defaultConfig.appBase,
buildDir: defaultConfig.buildDir || 'wrap/build',
Expand Down
1 change: 1 addition & 0 deletions electron/src/lib/eventType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const EVENT_TYPE = {
},
ACTION: {
CHANGE_ENVIRONMENT: 'EVENT_TYPE.ACTION.CHANGE_ENVIRONMENT',
CHANGE_DOWNLOAD_LOCATION: 'EVENT_TYPE.ACTION.CHANGE_DOWNLOAD_LOCATION',
CREATE_SSO_ACCOUNT: 'EVENT_TYPE.ACTION.CREATE_SSO_ACCOUNT',
CREATE_SSO_ACCOUNT_RESPONSE: 'EVENT_TYPE.ACTION.CREATE_SSO_ACCOUNT_RESPONSE',
DECRYPT: 'EVENT_TYPE.ACTION.DECRYPT',
Expand Down
33 changes: 33 additions & 0 deletions electron/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import * as remoteMain from '@electron/remote/main';
import {
app,
dialog,
BrowserWindow,
BrowserWindowConstructorOptions,
Event as ElectronEvent,
Expand All @@ -30,6 +31,7 @@ import {
safeStorage,
HandlerDetails,
} from 'electron';
import electronDl from 'electron-dl';
import windowStateKeeper from 'electron-window-state';
import fs from 'fs-extra';
import {getProxySettings} from 'get-proxy-settings';
Expand Down Expand Up @@ -80,6 +82,8 @@ const LOG_FILE = path.join(LOG_DIR, 'electron.log');
const PRELOAD_JS = path.join(APP_PATH, 'dist/preload/preload-app.js');
const PRELOAD_RENDERER_JS = path.join(APP_PATH, 'dist/preload/preload-webview.js');
const WRAPPER_CSS = path.join(APP_PATH, 'css/wrapper.css');
const ICON = path.join(APP_PATH, 'img/download-dialog/logo@2x.png');

const WINDOW_SIZE = {
DEFAULT_HEIGHT: 768,
DEFAULT_WIDTH: 1024,
Expand All @@ -98,6 +102,26 @@ const fileBasedProxyConfig = settings.restore<string | undefined>(SettingsType.P
const logger = getLogger(path.basename(__filename));
const currentLocale = locale.getCurrent();
const startHidden = Boolean(argv[config.ARGUMENT.STARTUP] || argv[config.ARGUMENT.HIDDEN]);
const customDownloadPath = settings.restore<string | undefined>(SettingsType.DOWNLOAD_PATH);
const appHomePath = (path: string) => `${app.getPath('home')}\\${path}`;

if (customDownloadPath) {
electronDl({
directory: appHomePath(customDownloadPath),
saveAs: false,
onCompleted: () => {
dialog.showMessageBox({
type: 'none',
icon: ICON,
title: locale.getText('enforcedDownloadComplete'),
message: locale.getText('enforcedDownloadMessage', {
path: appHomePath(customDownloadPath) ?? app.getPath('downloads'),
}),
buttons: [locale.getText('enforcedDownloadButton')],
});
},
});
}

if (argv[config.ARGUMENT.VERSION]) {
console.info(config.version);
Expand Down Expand Up @@ -186,6 +210,15 @@ const bindIpcEvents = (): void => {
ipcMain.on(EVENT_TYPE.ABOUT.SHOW, () => AboutWindow.showWindow());

ipcMain.handle(EVENT_TYPE.ACTION.GET_OG_DATA, (_event, url) => getOpenGraphDataAsync(url));

ipcMain.on(EVENT_TYPE.ACTION.CHANGE_DOWNLOAD_LOCATION, (_event, downloadPath?: string) => {
if (downloadPath && EnvironmentUtil.platform.IS_WINDOWS) {
fs.ensureDirSync(appHomePath(downloadPath));
//save the downloadPath locally
settings.save(SettingsType.DOWNLOAD_PATH, downloadPath);
settings.persistToFile();
}
});
};

const checkConfigV0FullScreen = (mainWindowState: windowStateKeeper.State): void => {
Expand Down
6 changes: 6 additions & 0 deletions electron/src/preload/preload-webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ const subscribeToWebappEvents = (): void => {
ipcRenderer.sendToHost(EVENT_TYPE.ACCOUNT.UPDATE_INFO, info);
});

window.amplify.subscribe(WebAppEvents.TEAM.DOWNLOAD_PATH_UPDATE, (downloadPath?: string) => {
logger.info(`Received amplify event ${WebAppEvents.TEAM.DOWNLOAD_PATH_UPDATE}:`, `"${downloadPath}",`);
logger.info('forwarding last event ...');
ipcRenderer.send(EVENT_TYPE.ACTION.CHANGE_DOWNLOAD_LOCATION, downloadPath);
});

window.addEventListener(WebAppEvents.LIFECYCLE.CHANGE_ENVIRONMENT, event => {
const data = (event as CustomEvent).detail;
if (data) {
Expand Down
2 changes: 2 additions & 0 deletions electron/src/settings/SettingsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export enum SettingsType {
AUTO_LAUNCH = 'shouldAutoLaunch',
/** Custom web app URL to use in on-premise deployments. The "env" setting must be set to "CUSTOM" to use this. */
CUSTOM_WEBAPP_URL = 'customWebAppURL',
/** Custom download path for the app. */
DOWNLOAD_PATH = 'downloadPath',
/** Enable spell checker in desktop app? */
ENABLE_SPELL_CHECKING = 'enableSpellChecking',
/** Which cloud environment ("PRODUCTION", "INTERNAL", "AVS", ...) to use when loading the webapp? */
Expand Down
1 change: 1 addition & 0 deletions electron/src/settings/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum ARGUMENT {
STARTUP = 'startup',
USER_DATA_DIR = 'user_data_dir',
VERSION = 'version',
DLPATH = 'dlpath',
}

export const config = {
Expand Down
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"author": "Wire Swiss <wireapp@wire.com>",
"dependencies": {
"@electron/remote": "2.1.1",
"@electron/remote": "2.1.2",
"@hapi/joi": "17.1.1",
"@wireapp/certificate-check": "0.7.8",
"@wireapp/commons": "5.2.4",
"@wireapp/protocol-messaging": "1.44.0",
"@wireapp/react-ui-kit": "9.12.7",
"@wireapp/react-ui-kit": "9.12.8",
"@wireapp/webapp-events": "0.20.1",
"auto-launch": "5.0.6",
"axios": "0.21.2",
"content-type": "1.0.5",
"electron-dl": "^3.5.1",
"electron-window-state": "5.0.3",
"fs-extra": "10.1.0",
"fs-extra": "11.2.0",
"get-proxy-settings": "0.1.13",
"globby": "11.1",
"iconv-lite": "0.6.3",
Expand All @@ -32,11 +33,11 @@
},
"description": "The most secure collaboration platform.",
"devDependencies": {
"@babel/core": "7.23.7",
"@babel/core": "7.23.9",
"@babel/helper-string-parser": "7.23.4",
"@babel/plugin-proposal-class-properties": "7.18.6",
"@babel/plugin-proposal-optional-chaining": "7.21.0",
"@babel/preset-env": "7.23.8",
"@babel/preset-env": "7.23.9",
"@babel/preset-react": "7.23.3",
"@babel/preset-typescript": "7.23.3",
"@babel/register": "7.23.7",
Expand All @@ -47,14 +48,14 @@
"@types/auto-launch": "5.0.5",
"@types/content-type": "1.1.8",
"@types/eslint": "^8.56.2",
"@types/fs-extra": "9.0.11",
"@types/fs-extra": "11.0.4",
"@types/hapi__joi": "^17.1.14",
"@types/is-ci": "3.0.4",
"@types/jest": "^29.5.11",
"@types/lodash": "4.14.202",
"@types/minimist": "1.2.5",
"@types/mocha": "10.0.6",
"@types/node": "18.19.8",
"@types/node": "18.19.10",
"@types/open-graph": "0.2.5",
"@types/platform": "1.3.6",
"@types/prettier": "^2.7.3",
Expand All @@ -63,13 +64,13 @@
"@types/redux-logger": "^3.0.12",
"@types/sinon": "17.0.3",
"@types/sort-json": "2.0.3",
"@typescript-eslint/eslint-plugin": "6.19.0",
"@typescript-eslint/parser": "6.19.0",
"@typescript-eslint/eslint-plugin": "6.19.1",
"@typescript-eslint/parser": "6.19.1",
"@wireapp/copy-config": "1.3.6",
"@wireapp/eslint-config": "3.0.5",
"@wireapp/prettier-config": "0.6.3",
"adm-zip": "0.5.10",
"aws-sdk": "2.1540.0",
"aws-sdk": "2.1545.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"babel-jest": "29.7.0",
Expand All @@ -79,8 +80,8 @@
"core-js": "3.35.1",
"cross-env": "7.0.3",
"css-loader": "6.9.1",
"dotenv": "16.3.2",
"electron": "27.2.4",
"dotenv": "16.4.1",
"electron": "27.3.0",
"electron-builder": "24.9.1",
"electron-mocha": "12.2.0",
"electron-packager": "17.1.2",
Expand All @@ -95,7 +96,7 @@
"eslint-plugin-jasmine": "4.1.3",
"eslint-plugin-jest": "27.6.3",
"eslint-plugin-jest-dom": "5.1.0",
"eslint-plugin-jsdoc": "46.9.1",
"eslint-plugin-jsdoc": "48.0.4",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-no-unsanitized": "4.0.2",
"eslint-plugin-prettier": "4.2.1",
Expand All @@ -111,7 +112,7 @@
"jest-environment-jsdom": "29.7.0",
"lint-staged": "15.2.0",
"mocha": "10.2.0",
"nock": "13.5.0",
"nock": "13.5.1",
"nyc": "15.1.0",
"prettier": "2.8.8",
"rimraf": "5.0.5",
Expand All @@ -120,7 +121,7 @@
"style-loader": "3.3.4",
"ts-node": "10.9.2",
"typescript": "5.3.3",
"webpack": "5.89.0",
"webpack": "5.90.0",
"webpack-cli": "5.1.4"
},
"homepage": "https://wire.com",
Expand Down
Loading

0 comments on commit 2102975

Please sign in to comment.