[MM-43039] Upgrade and clean up dependencies (#2038)

* Upgrade Electron to v18

* Fix a test

* Upgrade ESLint and TypeScript

* Update Joi

* Clean up and upgrade dependencies

* Upgrade dev dependencies

* Upgrade to Webpack 5

* Update NOTICE.txt

* Update test runtime
This commit is contained in:
Devin Binnie 2022-04-06 19:08:27 -04:00 committed by GitHub
parent 61de4dfb7b
commit 0fea052a9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 18096 additions and 20756 deletions

View file

@ -2,7 +2,8 @@
"root": true,
"extends": [
"plugin:mattermost/react",
"plugin:cypress/recommended"
"plugin:cypress/recommended",
"plugin:react-hooks/recommended"
],
"plugins": [
"babel",
@ -131,7 +132,7 @@
}
},
{
"files": ["tests/**", "**/*.test.*", "tests/*.js"],
"files": ["tests/**", "**/*.test.*", "tests/*.js", "packages/mattermost-redux/test/*"],
"env": {
"jest": true
},
@ -140,6 +141,7 @@
"global-require": 0,
"max-lines": 0,
"new-cap": 0,
"no-empty-function": 0,
"no-import-assign": 0,
"no-process-env": 0,
"prefer-arrow-callback": 0

View file

@ -79,41 +79,6 @@ THE SOFTWARE.
---
## brace-expansion
This product contains 'brace-expansion' by Julian Gruber.
Brace expansion, as known from sh/bash, in JavaScript.
* HOMEPAGE:
* https://github.com/juliangruber/brace-expansion
* LICENSE: MIT
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
## classnames
This product contains 'classnames' by Jed Watson.
@ -287,52 +252,6 @@ SOFTWARE.
---
## font-awesome
This product contains 'font-awesome' by Fort Awesome.
The iconic SVG, font, and CSS framework
* HOMEPAGE:
* https://github.com/FortAwesome/Font-Awesome
* LICENSE: Font Awesome Free License
-------------------------
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
In the Font Awesome Free download, the CC BY 4.0 license applies to all icons
packaged as SVG and JS file types.
# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL)
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.
# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.
We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.
# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**
---
## hapi/joi
This product contains 'hapi/joi' by Sideway Inc.
@ -357,41 +276,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
---
## prop-types
This product contains 'prop-types' by Facebook.
Runtime type checking for React props and similar objects.
* HOMEPAGE:
* https://facebook.github.io/react/
* LICENSE: MIT
MIT License
Copyright (c) 2013-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
## react
This product contains 'react' by facebook.
@ -547,50 +431,6 @@ SOFTWARE.
---
## react-transition-group
This product contains 'react-transition-group' by React Community.
A react component toolset for managing animations
* HOMEPAGE:
* https://github.com/reactjs/react-transition-group#readme
* LICENSE: BSD-3-Clause
BSD 3-Clause License
Copyright (c) 2018, React Community
Forked from React (https://github.com/facebook/react) Copyright 2013-present, Facebook, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
## sass
This product contains 'sass' by sass.
@ -654,43 +494,6 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---
## underscore
This product contains 'underscore' by Jeremy Ashkenas.
JavaScript's functional programming helper library.
* HOMEPAGE:
* http://underscorejs.org
* LICENSE: MIT
Copyright (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative
Reporters & Editors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
---
## valid-url
This product contains 'valid-url' by Odysseas Tsatalos.

38306
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,7 @@
"url": "git://github.com/mattermost/desktop.git"
},
"config": {
"target": "14.1.0",
"target": "18.0.1",
"arch": "x64",
"target_arch": "x64",
"disturl": "https://electronjs.org/headers",
@ -25,9 +25,9 @@
},
"scripts": {
"build": "npm-run-all build:*",
"build:main": "webpack-cli --bail --config webpack.config.main.js",
"build:renderer": "webpack-cli --bail --config webpack.config.renderer.js",
"build-robotjs": "npm rebuild --runtime=electron --target=14.1.0 --disturl=https://atom.io/download/atom-shell --abi=83",
"build:main": "webpack-cli --config webpack.config.main.js",
"build:renderer": "webpack-cli --config webpack.config.renderer.js",
"build-robotjs": "npm rebuild --runtime=electron --target=18.0.1 --disturl=https://atom.io/download/atom-shell --abi=83",
"start": "electron dist/ --disable-dev-mode",
"restart": "npm run build && npm run start",
"storybook": "start-storybook -p 9001 -c src/.storybook",
@ -41,7 +41,7 @@
"test:docker": "node scripts/setup_e2e_docker.js",
"test:e2e": "cross-env NODE_ENV=test npm-run-all build build-robotjs test:e2e:build test:e2e:run",
"test:e2e:nobuild": "cross-env NODE_ENV=test npm-run-all test:e2e:build test:e2e:run",
"test:e2e:build": "webpack-cli --bail --config webpack.config.test.js",
"test:e2e:build": "webpack-cli --config webpack.config.test.js",
"test:e2e:run": "electron-mocha -r @babel/register --reporter mocha-circleci-reporter dist/tests/e2e_bundle.js",
"test:unit": "jest",
"test:unit-ci": "jest --runInBand",
@ -108,103 +108,88 @@
]
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/preset-react": "^7.10.4",
"@babel/register": "^7.0.0",
"@electron/fuses": "^1.4.0",
"@storybook/addon-actions": "^6.2.9",
"@storybook/react": "^6.2.9",
"@types/auto-launch": "^5.0.1",
"@types/electron-devtools-installer": "^2.2.0",
"@types/hapi__joi": "^17.1.6",
"@types/react": "^17.0.11",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^17.0.8",
"@types/react-select": "^4.0.17",
"@types/underscore": "^1.11.2",
"@types/valid-url": "^1.0.3",
"@types/winreg": "^1.2.30",
"@typescript-eslint/eslint-plugin": "4.28.0",
"@typescript-eslint/parser": "4.28.0",
"7zip-bin": "^4.1.0",
"awesome-node-loader": "^1.1.1",
"axios": "^0.24.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.4",
"chai": "^4.2.0",
"copy-webpack-plugin": "^6.2.1",
"cross-env": "^5.2.0",
"css-loader": "^1.0.1",
"devtron": "^1.4.0",
"electron": "17.1.0",
"@babel/cli": "7.17.6",
"@babel/core": "7.17.8",
"@babel/plugin-proposal-class-properties": "7.16.7",
"@babel/plugin-proposal-object-rest-spread": "7.17.3",
"@babel/preset-env": "7.16.11",
"@babel/preset-react": "7.16.7",
"@babel/register": "7.17.7",
"@electron/fuses": "1.5.0",
"@storybook/addon-actions": "6.4.20",
"@storybook/react": "6.4.20",
"@types/auto-launch": "5.0.2",
"@types/electron-devtools-installer": "2.2.1",
"@types/react": "17.0.43",
"@types/react-beautiful-dnd": "13.0.0",
"@types/react-dom": "17.0.14",
"@types/valid-url": "1.0.3",
"@types/winreg": "1.2.31",
"@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "5.18.0",
"7zip-bin": "5.1.1",
"awesome-node-loader": "1.1.1",
"axios": "0.26.1",
"babel-eslint": "10.1.0",
"babel-loader": "8.2.4",
"chai": "4.3.6",
"copy-webpack-plugin": "10.2.4",
"cross-env": "7.0.3",
"css-loader": "6.7.1",
"electron": "18.0.1",
"electron-builder": "22.14.13",
"electron-connect": "0.6.3",
"electron-mocha": "11.0.2",
"electron-notarize": "1.1.1",
"eslint": "7.19.0",
"eslint-import-resolver-webpack": "0.13.0",
"electron-notarize": "1.2.1",
"eslint": "7.29.0",
"eslint-import-resolver-webpack": "0.13.2",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-cypress": "2.11.2",
"eslint-plugin-header": "3.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jquery": "1.5.1",
"eslint-plugin-cypress": "2.11.3",
"eslint-plugin-header": "3.1.1",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-mattermost": "github:mattermost/eslint-plugin-mattermost#46ad99355644a719bf32082f472048f526605181",
"eslint-plugin-no-only-tests": "2.4.0",
"eslint-plugin-react": "7.22.0",
"file-loader": "^2.0.0",
"image-webpack-loader": "5.0.0",
"jest": "^27.3.1",
"jest-junit": "^13.0.0",
"mdi-react": "^6.2.0",
"mini-css-extract-plugin": "1.6.0",
"mocha": "^5.2.0",
"mocha-circleci-reporter": "0.0.3",
"node-gyp": "^8.4.0",
"npm-run-all": "^4.1.5",
"playwright": "^1.15.2",
"robotjs": "^0.6.0",
"sass-loader": "^10.2.0",
"shebang-loader": "^0.0.1",
"style-loader": "^2.0.0",
"ts-prune": "^0.10.2",
"typescript": "^4.3.4",
"url-loader": "^1.1.2",
"webpack": "^4.44.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.11.0",
"webpack-merge": "^4.1.4"
"eslint-plugin-no-only-tests": "2.6.0",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-react-hooks": "4.4.0",
"jest": "27.5.1",
"jest-junit": "13.1.0",
"mini-css-extract-plugin": "2.6.0",
"node-gyp": "9.0.0",
"npm-run-all": "4.1.5",
"playwright": "1.20.2",
"robotjs": "0.6.0",
"sass-loader": "12.6.0",
"shebang-loader": "0.0.1",
"style-loader": "3.3.1",
"ts-prune": "0.10.3",
"typescript": "4.6.3",
"webpack": "5.71.0",
"webpack-cli": "4.9.2",
"webpack-dev-server": "4.8.0",
"webpack-merge": "5.8.0"
},
"dependencies": {
"@hapi/joi": "^16.1.8",
"@mattermost/compass-icons": "0.1.21",
"auto-launch": "^5.0.5",
"bootstrap": "^4.6.0",
"bootstrap-dark": "^1.0.3",
"brace-expansion": "^2.0.0",
"classnames": "^2.3.1",
"auto-launch": "5.0.5",
"bootstrap": "4.6.1",
"bootstrap-dark": "1.0.3",
"classnames": "2.3.1",
"electron-context-menu": "3.1.2",
"electron-devtools-installer": "3.2.0",
"electron-is-dev": "2.0.0",
"electron-log": "4.4.6",
"electron-updater": "5.0.0",
"font-awesome": "^4.7.0",
"pretty-bytes": "^6.0.0",
"prop-types": "^15.6.2",
"react": "^16.14.0",
"react-beautiful-dnd": "^13.1.0",
"react-bootstrap": "^1.6.1",
"react-dom": "^16.14.0",
"react-select": "4.3.1",
"react-transition-group": "^2.5.0",
"sass": "^1.35.1",
"semver": "^5.5.0",
"underscore": "^1.9.1",
"valid-url": "^1.0.9",
"winreg-utf8": "^0.1.1",
"yargs": "^15.3.1"
"joi": "17.6.0",
"pretty-bytes": "6.0.0",
"react": "16.14.0",
"react-beautiful-dnd": "13.1.0",
"react-bootstrap": "1.6.4",
"react-dom": "16.14.0",
"react-select": "5.2.2",
"sass": "1.49.11",
"semver": "7.3.5",
"valid-url": "1.0.9",
"winreg-utf8": "0.1.1",
"yargs": "17.4.0"
}
}

View file

@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
import log from 'electron-log';
import Joi from '@hapi/joi';
import Joi from 'joi';
import {Args} from 'types/args';
import {ConfigV0, ConfigV1, ConfigV2, ConfigV3, TeamWithTabs} from 'types/config';

View file

@ -261,28 +261,31 @@ describe('main/app/utils', () => {
expect(updatePaths).not.toHaveBeenCalled();
});
it('should copy all of the configs when they exist to the new directory', () => {
const migrationPrefs = {
getValue: () => false,
setValue: jest.fn(),
};
JsonFileManager.mockImplementation(() => migrationPrefs);
fs.readFileSync.mockReturnValue('config-data');
fs.existsSync.mockImplementation((path) => {
if (path === '/Library/Application Support/Mattermost') {
return true;
}
return ['config', 'app-state', 'bounds-info', 'migration-info'].some((filename) => path.endsWith(`${filename}.json`));
// this doesn't run on windows because of path resolution
if (process.platform !== 'win32') {
it('should copy all of the configs when they exist to the new directory', () => {
const migrationPrefs = {
getValue: () => false,
setValue: jest.fn(),
};
JsonFileManager.mockImplementation(() => migrationPrefs);
fs.readFileSync.mockReturnValue('config-data');
fs.existsSync.mockImplementation((path) => {
if (path === '/Library/Application Support/Mattermost') {
return true;
}
return ['config', 'app-state', 'bounds-info', 'migration-info'].some((filename) => path.endsWith(`${filename}.json`));
});
dialog.showMessageBoxSync.mockReturnValue(0);
dialog.showOpenDialogSync.mockReturnValue(['/old/data/path']);
migrateMacAppStore();
expect(fs.readFileSync).toHaveBeenCalledWith('/old/data/path/config.json');
expect(fs.writeFileSync).toHaveBeenCalledWith('/path/to/data/config.json', 'config-data');
expect(fs.readFileSync).not.toHaveBeenCalledWith('/old/data/path/allowedProtocols.json');
expect(fs.writeFileSync).not.toHaveBeenCalledWith('/path/to/data/allowedProtocols.json', 'config-data');
expect(updatePaths).toHaveBeenCalled();
expect(migrationPrefs.setValue).toHaveBeenCalledWith('masConfigs', true);
});
dialog.showMessageBoxSync.mockReturnValue(0);
dialog.showOpenDialogSync.mockReturnValue(['/old/data/path']);
migrateMacAppStore();
expect(fs.readFileSync).toHaveBeenCalledWith('/old/data/path/config.json');
expect(fs.writeFileSync).toHaveBeenCalledWith('/path/to/data/config.json', 'config-data');
expect(fs.readFileSync).not.toHaveBeenCalledWith('/old/data/path/allowedProtocols.json');
expect(fs.writeFileSync).not.toHaveBeenCalledWith('/path/to/data/allowedProtocols.json', 'config-data');
expect(updatePaths).toHaveBeenCalled();
expect(migrationPrefs.setValue).toHaveBeenCalledWith('masConfigs', true);
});
}
});
});

View file

@ -3,6 +3,7 @@
import os from 'os';
import path from 'path';
import {app, Notification} from 'electron';
import Utils from 'common/utils/util';

View file

@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import path from 'path';
import {app, Notification} from 'electron';
const assetsDir = path.resolve(app.getAppPath(), 'assets');

View file

@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import path from 'path';
import {app, nativeImage, Tray, systemPreferences, nativeTheme} from 'electron';
import {UPDATE_TRAY} from 'common/communication';

View file

@ -2,9 +2,10 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {app, BrowserWindow} from 'electron';
import path from 'path';
import {app, BrowserWindow} from 'electron';
import {Args} from 'types/args';
import {BACK_BAR_HEIGHT, PRODUCTION, TAB_BAR_HEIGHT} from 'common/utils/constants';

View file

@ -3,6 +3,7 @@
/* eslint-disable max-lines */
import path from 'path';
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent, IpcMainInvokeEvent, desktopCapturer} from 'electron';
import log from 'electron-log';

View file

@ -37,7 +37,7 @@ export default class ExtraBar extends React.PureComponent<Props> {
variant={'link'}
size={'sm'}
>
<span className={'backIcon fa fa-1x fa-angle-left'}/>
<span className={'backIcon icon-arrow-left'}/>
<span className={'backLabel'}>
{'Back'}
</span>

View file

@ -6,7 +6,6 @@ import classNames from 'classnames';
import React, {Fragment} from 'react';
import {Container, Row} from 'react-bootstrap';
import {DropResult} from 'react-beautiful-dnd';
import DotsVerticalIcon from 'mdi-react/DotsVerticalIcon';
import {IpcRendererEvent} from 'electron/renderer';
import prettyBytes from 'pretty-bytes';
@ -504,7 +503,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
ref={this.threeDotMenu}
aria-label='Context menu'
>
<DotsVerticalIcon/>
<i className='icon-dots-vertical'/>
</button>
<TeamDropdownButton
isDisabled={this.state.modalOpen}

View file

@ -8,9 +8,7 @@ import 'renderer/css/settings.css';
import React from 'react';
import {FormCheck, Col, FormGroup, FormText, Container, Row, Button, FormControl} from 'react-bootstrap';
import ReactSelect, {ActionMeta, OptionsType} from 'react-select';
import {debounce} from 'underscore';
import ReactSelect, {ActionMeta, MultiValue} from 'react-select';
import {CombinedConfig, LocalConfiguration} from 'types/config';
import {DeepPartial} from 'types/utils';
@ -76,6 +74,9 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
selectedSpellCheckerLocales: Array<{label: string; value: string}>;
savingIsDebounced: boolean;
resetSaveStateIsDebounced: boolean;
constructor(props: Record<string, never>) {
super(props);
this.state = {
@ -108,6 +109,9 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
this.saveQueue = [];
this.selectedSpellCheckerLocales = [];
this.savingIsDebounced = false;
this.resetSaveStateIsDebounced = false;
}
componentDidMount() {
@ -149,9 +153,17 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
this.processSaveQueue();
}
processSaveQueue = debounce(() => {
processSaveQueue = () => {
if (this.savingIsDebounced) {
return;
}
this.savingIsDebounced = true;
setTimeout(() => {
this.savingIsDebounced = false;
}, 500);
window.ipcRenderer.send(UPDATE_CONFIGURATION, this.saveQueue.splice(0, this.saveQueue.length));
}, 500);
}
updateSaveState = () => {
let queuedUpdateCounts = {
@ -178,13 +190,21 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
this.setState({savingState});
}
resetSaveState = debounce((configType: keyof SavingStateItems) => {
resetSaveState = (configType: keyof SavingStateItems) => {
if (this.resetSaveStateIsDebounced) {
return;
}
this.resetSaveStateIsDebounced = true;
setTimeout(() => {
this.resetSaveStateIsDebounced = false;
}, 2000);
if (this.state.savingState[configType] !== SavingState.SAVING_STATE_SAVING) {
const savingState = Object.assign({}, this.state.savingState);
savingState[configType] = SavingState.SAVING_STATE_DONE;
this.setState({savingState});
}
}, 2000);
}
handleChangeShowTrayIcon = () => {
const shouldShowTrayIcon = this.showTrayIconRef.current?.checked;
@ -314,7 +334,7 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
window.ipcRenderer.send(CHECK_FOR_UPDATES);
}
handleChangeSpellCheckerLocales = (value: OptionsType<{label: string; value: string}>, actionMeta: ActionMeta<{label: string; value: string}>) => {
handleChangeSpellCheckerLocales = (value: MultiValue<{label: string; value: string}>, actionMeta: ActionMeta<{label: string; value: string}>) => {
switch (actionMeta.action) {
case 'select-option':
this.selectedSpellCheckerLocales = [...value];

View file

@ -1,6 +1,5 @@
@import url("components/index.css");
@import url("fonts.css");
@import '~font-awesome/css/font-awesome.css';
@import '~@mattermost/compass-icons/css/compass-icons.css';
html {
@ -63,6 +62,7 @@ body {
line-height: 20px;
height: 36px;
float: left;
margin-left: 4px;
padding-top: 5px;
border: none;
flex: 0 0 40px;
@ -72,9 +72,9 @@ body {
background-color: transparent;
}
.topBar .three-dot-menu svg {
.topBar .three-dot-menu i.icon-dots-vertical {
border-radius: 100px;
padding: 4px;
padding: 2px;
height: 28px;
width: 28px;
}
@ -83,16 +83,16 @@ body {
outline: none;
}
.topBar .three-dot-menu:hover svg, .topBar .three-dot-menu:focus svg, .topBar .three-dot-menu:active svg {
.topBar .three-dot-menu:hover i.icon-dots-vertical, .topBar .three-dot-menu:focus i.icon-dots-vertical, .topBar .three-dot-menu:active i.icon-dots-vertical {
outline: none;
background-color: #c8c8c8;
}
.topBar.darkMode .three-dot-menu:hover svg, .topBar.darkMode .three-dot-menu:focus svg, .topBar.darkMode .three-dot-menu:active svg {
.topBar.darkMode .three-dot-menu:hover i.icon-dots-vertical, .topBar.darkMode .three-dot-menu:focus i.icon-dots-vertical, .topBar.darkMode .three-dot-menu:active i.icon-dots-vertical {
background-color: #383A3F;
}
.topBar.macOS .three-dot-menu:hover svg, .topBar.macOS .three-dot-menu:focus svg, .topBar.macOS .three-dot-menu:active svg {
.topBar.macOS .three-dot-menu:hover i.icon-dots-vertical, .topBar.macOS .three-dot-menu:focus i.icon-dots-vertical, .topBar.macOS .three-dot-menu:active i.icon-dots-vertical {
background: none !important;
}
@ -105,7 +105,7 @@ body {
flex-basis: 0px;
}
.topBar.macOS .three-dot-menu>svg {
.topBar.macOS .three-dot-menu>i.icon-dots-vertical {
display: none;
}

View file

@ -1,8 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {throttle} from 'underscore';
import ding from 'static/sounds/ding.mp3';
import bing from 'static/sounds/bing.mp3';
import crackle from 'static/sounds/crackle.mp3';
@ -22,9 +20,15 @@ const notificationSounds = new Map([
['Upstairs', upstairs],
]);
export const playSound = throttle((soundName: string) => {
if (soundName) {
let canPlaySound = true;
export const playSound = (soundName: string) => {
if (soundName && canPlaySound) {
canPlaySound = false;
setTimeout(() => {
canPlaySound = true;
}, 3000);
const audio = new Audio(notificationSounds.get(soundName));
audio.play();
}
}, 3000, {trailing: false});
};

View file

@ -7,11 +7,10 @@
'use strict';
const childProcess = require('child_process');
const path = require('path');
const webpack = require('webpack');
const path = require('path');
const VERSION = childProcess.execSync('git rev-parse --short HEAD').toString();
const isProduction = process.env.NODE_ENV === 'production';
const isRelease = process.env.CIRCLE_BRANCH && process.env.CIRCLE_BRANCH.startsWith('release-');
@ -29,10 +28,11 @@ module.exports = {
// Some plugins cause errors on the app, so use few plugins.
// https://webpack.js.org/concepts/mode/#mode-production
mode: isProduction ? 'none' : 'development',
bail: true,
plugins: [
new webpack.DefinePlugin(codeDefinitions),
],
devtool: isProduction ? false : '#inline-source-map',
devtool: isProduction ? undefined : 'inline-source-map',
resolve: {
alias: {
renderer: path.resolve(__dirname, 'src/renderer'),

View file

@ -8,7 +8,7 @@
const path = require('path');
const merge = require('webpack-merge');
const {merge} = require('webpack-merge');
const CopyPlugin = require('copy-webpack-plugin');
@ -24,10 +24,6 @@ module.exports = merge(base, {
loadingScreenPreload: './src/main/preload/loadingScreenPreload.js',
urlView: './src/main/preload/urlView.js',
},
output: {
path: path.join(__dirname, 'dist/'),
filename: '[name].js',
},
module: {
rules: [{
test: /\.(js|ts)?$/,
@ -39,9 +35,7 @@ module.exports = merge(base, {
},
}, {
test: /\.mp3$/,
use: {
loader: 'url-loader',
},
type: 'asset/inline',
},
{
test: /\.node$/,

View file

@ -7,9 +7,10 @@
'use strict';
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const merge = require('webpack-merge');
const {merge} = require('webpack-merge');
const base = require('./webpack.config.base');
@ -32,6 +33,7 @@ module.exports = merge(base, {
output: {
path: path.resolve(__dirname, 'dist/renderer'),
filename: '[name]_bundle.js',
assetModuleFilename: '[name].[ext]',
},
plugins: [
new HtmlWebpackPlugin({
@ -139,30 +141,13 @@ module.exports = merge(base, {
],
}, {
test: /\.mp3$/,
use: {
loader: 'url-loader',
},
type: 'asset/inline',
}, {
test: /\.(svg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
publicPath: './assets',
outputPath: '/../assets',
},
},
{loader: 'image-webpack-loader'},
],
type: 'asset/resource',
}, {
test: /\.(eot|ttf|woff|woff2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: '/../assets/fonts',
publicPath: './assets/fonts',
},
type: 'asset/resource',
}],
},
node: {
@ -171,10 +156,6 @@ module.exports = merge(base, {
},
target: 'electron-renderer',
devServer: {
contentBase: 'src/assets',
contentBasePublicPath: '/assets',
inline: true,
publicPath: '/renderer/',
port: WEBSERVER_PORT,
},
});

View file

@ -8,7 +8,7 @@
const path = require('path');
const glob = require('glob');
const merge = require('webpack-merge');
const {merge} = require('webpack-merge');
const base = require('./webpack.config.base');
@ -45,10 +45,6 @@ module.exports = merge(base, {
__dirname: false,
},
devServer: {
contentBase: 'src/assets',
contentBasePublicPath: '/assets',
inline: true,
publicPath: '/renderer/',
port: WEBSERVER_PORT,
},
target: 'electron-main',