Merge remote-tracking branch 'mattermost/master' into auto-updater

This commit is contained in:
Yuya Ochiai 2018-10-16 00:28:47 +09:00
commit ccdfbae3b2
31 changed files with 888 additions and 447 deletions

View file

@ -17,10 +17,11 @@
"no-console": 0,
"no-process-env": 0,
"no-underscore-dangle": 1,
"no-var": 2,
"react/jsx-indent": [2, 2],
"react/jsx-indent-props": [2, 2],
"react/no-find-dom-node": 2,
"react/no-set-state": 1,
"react/prefer-es6-class": 1,
"react/require-optimization": 0
}
}

View file

@ -17,10 +17,18 @@ Release date: TBD
[#843](https://github.com/mattermost/desktop/pull/843)
- Added `Ctrl/Cmd+F` shortcut to work as browser-like search.
[#399](https://github.com/mattermost/desktop/issues/399)
- Preserved case of first letter in spellcheck.
[#869](https://github.com/mattermost/desktop/pull/869)
#### Windows
- Set "app start on login" preference to default on and synchronize its state with config.json.
[#846](https://github.com/mattermost/desktop/pull/846)
#### Mac
- Add **.dmg** package to support installation.
[#588](https://github.com/mattermost/desktop/pull/588)
- Support "Hide" option of Login Items in Preferences.
[#853](https://github.com/mattermost/desktop/pull/853)
#### Linux
- [tar.gz] Use SVG icon for Linux application menus in place of PNG icon
@ -28,10 +36,13 @@ Release date: TBD
- Updated categories in order to be listed under the appropriate submenu of the application starter.
[#816](https://github.com/mattermost/desktop/pull/816)
[#818](https://github.com/mattermost/desktop/pull/818)
- Set "app start on login" preference to default on and synchronize its state with config.json.
[#846](https://github.com/mattermost/desktop/pull/846)
### Architectural Changes
- Major version upgrade of Electron to v2.0.2. Electron is the underlying technology used to build the Desktop apps.
- Major version upgrade of Electron to v2.0.8. Electron is the underlying technology used to build the Desktop apps.
[#820](https://github.com/mattermost/desktop/pull/820)
[#847](https://github.com/mattermost/desktop/pull/847)
- Artifact names are configured via `electron-builder.json`.
[#825](https://github.com/mattermost/desktop/pull/825)

View file

@ -10,12 +10,14 @@ This document includes a list of open source components used in Mattermost Deskt
## auto-launch
This product contains a modified portion of 'auto-launch', which allows one to launch any application or executable at startup, by Teamwork.com.
This product contains 'auto-launch' by Donal Linehan.
Launch node applications or executables at login (Mac, Windows, and Linux)
* HOMEPAGE:
* https://github.com/Teamwork/node-auto-launch
* https://github.com/4ver/node-auto-launch
* LICENSE:
* LICENSE: MIT
MIT License
@ -43,18 +45,18 @@ SOFTWARE.
## bootstrap
This product contains a modified portion of 'bootstrap', which is an HTML, CSS, and JavaScript framework for developing responsive, mobile first
projects on the web, by Twitter, Inc. and Bootstrap Authors.
This product contains 'bootstrap' by The Bootstrap Authors.
The most popular front-end framework for developing responsive, mobile first projects on the web.
* HOMEPAGE:
* https://github.com/twbs/bootstrap
* https://getbootstrap.com/
* LICENSE:
* LICENSE: MIT
The MIT License (MIT)
Copyright (c) 2011-2017 Twitter, Inc.
Copyright (c) 2011-2017 The Bootstrap Authors
Copyright (c) 2011-2016 Twitter, 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
@ -78,150 +80,297 @@ THE SOFTWARE.
## electron-context-menu
This product contains a modified portion of 'electron-context-menu', which provides a context menu for Electron apps, by Sindre Sorhus.
This product contains 'electron-context-menu' by Sindre Sorhus.
Context menu for your Electron app
* HOMEPAGE:
* https://github.com/sindresorhus/electron-context-menu
* https://github.com/sindresorhus/electron-context-menu#readme
* LICENSE:
* LICENSE: MIT
The MIT License (MIT)
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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:
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 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.
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.
---
## electron-devtools-installer
This product contains a modified portion of 'electron-devtools-installer', which allows an easy way to ensure Chrome DevTools extensions into Electron,
by Samuel Attard.
This product contains 'electron-devtools-installer' by Samuel Attard.
An easy way to install Dev Tools extensions into Electron applications
* HOMEPAGE:
* https://github.com/MarshallOfSound/electron-devtools-installer
* https://github.com/GPMDP/electron-devtools-installer#readme
* LICENSE:
* LICENSE: MIT
The MIT License (MIT)
Copyright (c) 2016 Samuel Attard
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:
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.
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.
---
## electron-is-dev
This product contains a modified portion of 'electron-is-dev', which checks if Electron is running in development, by Sindre Sorhus.
This product contains 'electron-is-dev' by Sindre Sorhus.
Check if Electron is running in development
* HOMEPAGE:
* https://github.com/sindresorhus/electron-is-dev
* https://github.com/sindresorhus/electron-is-dev#readme
* LICENSE:
* LICENSE: MIT
The MIT License (MIT)
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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:
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 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.
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.
---
## electron-squirrel-startup
This product contains 'electron-squirrel-startup' by Lucas Hrabovsky.
Default Squirrel.Windows event handler for your Electron apps.
* HOMEPAGE:
* http://github.com/mongodb-js/electron-squirrel-startup
* LICENSE: Apache-2.0
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
---
## prop-types
This product contains a modified portion of 'prop-types', runtime type checking for React props and similar objects, by Facebook, Inc.
This product contains 'prop-types' by Facebook.
Runtime type checking for React props and similar objects.
* HOMEPAGE:
* https://github.com/facebook/prop-types
* https://facebook.github.io/react/
* LICENSE:
BSD License
For React software
Copyright (c) 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 Facebook 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.
---
## react
This product contains a modified portion of 'react', a declarative, efficient, and flexible JavaScript library for building user interfaces,
'create-react-class', a drop-in replacement for React.createClass, and 'react-dom', the entry point of the DOM-related
rendering paths, by Facebook, Inc.
* HOMEPAGE:
* https://github.com/facebook/react
* LICENSE:
* LICENSE: MIT
MIT License
@ -247,15 +396,51 @@ SOFTWARE.
---
## react-bootstrap
## react
This product contains a modified portion of 'react-bootstrap', Bootstrap 3 components for front-end framework built with React, by Stephen J. Collings,
Matthew Honnibal, Pieter Vanderwerff and react-bootstrap.
This product contains 'react' by Facebook.
React is a JavaScript library for building user interfaces.
* HOMEPAGE:
* https://github.com/react-bootstrap/react-bootstrap
* https://reactjs.org/
* LICENSE:
* LICENSE: MIT
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
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-bootstrap
This product contains 'react-bootstrap' by Stephen J. Collings.
Bootstrap 3 components built with React
* HOMEPAGE:
* https://react-bootstrap.github.io/
* LICENSE: MIT
The MIT License (MIT)
@ -281,14 +466,51 @@ THE SOFTWARE.
---
## react-transition-group
## react-dom
This product contains a modified portion of 'react-transition-group', a fork, and "drop in" replacement for the original React TransitionGroup addons, by React Community.
This product contains 'react-dom' by Facebook.
React package for working with the DOM.
* HOMEPAGE:
* https://github.com/reactjs/react-transition-group
* https://reactjs.org/
* LICENSE:
* LICENSE: MIT
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
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-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
@ -325,16 +547,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## simple-spellchecker
This product contains a modified portion of 'simple-spellchecker', a simple and fast spellchecker with spelling suggestions and Electron's integration, by jfmdev.
This product contains 'simple-spellchecker' by JFMDev.
Access to the source code of Simple Spellchecker ©jfmdev can be found at https://github.com/jfmdev/simple-spellchecker.
A simple spellchecker compatible with Electron
* HOMEPAGE:
* https://github.com/jfmdev/simple-spellchecker
* https://github.com/jfmdev/simple-spellchecker#readme
* LICENSE:
* LICENSE: MPL-2.0
Mozilla Public License Version 2.0
Mozilla Public License Version 2.0
==================================
1. Definitions
@ -712,16 +934,16 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
## underscore
This product contains a modified portion of 'underscore', a utility-belt library for JavaScript that provides support for usual functional suspects
without extending any core JavaScript objects, by Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors.
This product contains 'underscore' by Jeremy Ashkenas.
JavaScript's functional programming helper library.
* HOMEPAGE:
* https://github.com/jashkenas/underscore
* http://underscorejs.org
* LICENSE:
* LICENSE: MIT
The MIT License (MIT)
Copyright (c) 2009-2017 Jeremy Ashkenas, DocumentCloud and Investigative
Copyright (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative
Reporters & Editors
Permission is hereby granted, free of charge, to any person
@ -749,12 +971,14 @@ OTHER DEALINGS IN THE SOFTWARE.
## yargs
This product contains a modified portion of 'yargs', a modern successor to optimist, by James Halliday and Yargs.
This product contains 'yargs' by GitHub user "yargs".
yargs the modern, pirate-themed, successor to optimist.
* HOMEPAGE:
* https://github.com/yargs/yargs
* http://yargs.js.org/
* LICENSE:
* LICENSE: MIT
Copyright 2010 James Halliday (mail@substack.net)
Modified work Copyright 2014 Contributors (ben@npmjs.com)

View file

@ -49,7 +49,7 @@
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",
"devtron": "^1.4.0",
"electron": "2.0.2",
"electron": "2.0.8",
"electron-builder": "20.14.7",
"electron-builder-squirrel-windows": "~20.14.0",
"electron-connect": "^0.6.3",

View file

@ -3,26 +3,27 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import {findDOMNode} from 'react-dom';
import {Button, Col, ControlLabel, Form, FormGroup, FormControl, Modal} from 'react-bootstrap';
export default class LoginModal extends React.Component {
constructor(props) {
super(props);
this.handleSubmit = this.handleSubmit.bind(this);
this.usernameRef = React.createRef();
this.passwordRef = React.createRef();
}
handleSubmit(event) {
event.preventDefault();
const usernameNode = findDOMNode(this.refs.username);
const passwordNode = findDOMNode(this.refs.password);
const usernameNode = this.usernameRef.current;
const passwordNode = this.passwordRef.current;
this.props.onLogin(this.props.request, usernameNode.value, passwordNode.value);
usernameNode.value = '';
passwordNode.value = '';
}
render() {
var theServer = '';
let theServer = '';
if (!this.props.show) {
theServer = '';
} else if (this.props.authInfo.isProxy) {
@ -53,7 +54,7 @@ export default class LoginModal extends React.Component {
<FormControl
type='text'
placeholder='User Name'
ref='username'
ref={this.usernameRef}
onClick={(e) => {
e.stopPropagation();
}}
@ -69,7 +70,7 @@ export default class LoginModal extends React.Component {
<FormControl
type='password'
placeholder='Password'
ref='password'
ref={this.passwordRef}
onClick={(e) => {
e.stopPropagation();
}}

View file

@ -1,11 +1,13 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/* eslint-disable react/no-set-state */
import url from 'url';
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import {CSSTransition, TransitionGroup} from 'react-transition-group';
import {Grid, Row} from 'react-bootstrap';
@ -21,24 +23,13 @@ import PermissionRequestDialog from './PermissionRequestDialog.jsx';
import Finder from './Finder.jsx';
import NewTeamModal from './NewTeamModal.jsx';
const MainPage = createReactClass({
propTypes: {
onUnreadCountChange: PropTypes.func.isRequired,
teams: PropTypes.array.isRequired,
onTeamConfigChange: PropTypes.func.isRequired,
initialIndex: PropTypes.number.isRequired,
useSpellChecker: PropTypes.bool.isRequired,
onSelectSpellCheckerLocale: PropTypes.func.isRequired,
deeplinkingUrl: PropTypes.string,
showAddServerButton: PropTypes.bool.isRequired,
requestingPermission: TabBar.propTypes.requestingPermission,
onClickPermissionDialog: PropTypes.func,
},
export default class MainPage extends React.Component {
constructor(props) {
super(props);
getInitialState() {
let key = this.props.initialIndex;
if (this.props.deeplinkingUrl !== null) {
for (var i = 0; i < this.props.teams.length; i++) {
for (let i = 0; i < this.props.teams.length; i++) {
if (this.props.deeplinkingUrl.includes(this.props.teams[i].url)) {
key = i;
break;
@ -46,8 +37,9 @@ const MainPage = createReactClass({
}
}
return {
this.state = {
key,
sessionsExpired: new Array(this.props.teams.length),
unreadCounts: new Array(this.props.teams.length),
mentionCounts: new Array(this.props.teams.length),
unreadAtActive: new Array(this.props.teams.length),
@ -55,9 +47,22 @@ const MainPage = createReactClass({
loginQueue: [],
targetURL: '',
};
},
this.activateFinder = this.activateFinder.bind(this);
this.addServer = this.addServer.bind(this);
this.closeFinder = this.closeFinder.bind(this);
this.focusOnWebView = this.focusOnWebView.bind(this);
this.handleLogin = this.handleLogin.bind(this);
this.handleLoginCancel = this.handleLoginCancel.bind(this);
this.handleOnTeamFocused = this.handleOnTeamFocused.bind(this);
this.handleSelect = this.handleSelect.bind(this);
this.handleTargetURLChange = this.handleTargetURLChange.bind(this);
this.inputBlur = this.inputBlur.bind(this);
this.markReadAtActive = this.markReadAtActive.bind(this);
}
componentDidMount() {
var self = this;
const self = this;
ipcRenderer.on('login-request', (event, request, authInfo) => {
self.setState({
loginRequired: true,
@ -96,7 +101,7 @@ const MainPage = createReactClass({
self.refs[`mattermostView${self.state.key}`].focusOnWebView();
}
var currentWindow = remote.getCurrentWindow();
const currentWindow = remote.getCurrentWindow();
currentWindow.on('focus', focusListener);
window.addEventListener('beforeunload', () => {
currentWindow.removeListener('focus', focusListener);
@ -132,7 +137,7 @@ const MainPage = createReactClass({
ipcRenderer.on('protocol-deeplink', (event, deepLinkUrl) => {
const lastUrlDomain = Utils.getDomain(deepLinkUrl);
for (var i = 0; i < this.props.teams.length; i++) {
for (let i = 0; i < this.props.teams.length; i++) {
if (lastUrlDomain === Utils.getDomain(self.refs[`mattermostView${i}`].getSrc())) {
if (this.state.key !== i) {
this.handleSelect(i);
@ -146,30 +151,34 @@ const MainPage = createReactClass({
ipcRenderer.on('toggle-find', () => {
this.activateFinder(true);
});
},
}
componentDidUpdate(prevProps, prevState) {
if (prevState.key !== this.state.key) { // i.e. When tab has been changed
this.refs[`mattermostView${this.state.key}`].focusOnWebView();
}
},
}
handleSelect(key) {
const newKey = (this.props.teams.length + key) % this.props.teams.length;
this.setState({
key: newKey,
finderVisible: false,
});
var webview = document.getElementById('mattermostView' + newKey);
const webview = document.getElementById('mattermostView' + newKey);
ipcRenderer.send('update-title', {
title: webview.getTitle(),
});
this.handleOnTeamFocused(newKey);
},
}
handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned) {
var unreadCounts = this.state.unreadCounts;
var mentionCounts = this.state.mentionCounts;
var unreadAtActive = this.state.unreadAtActive;
var mentionAtActiveCounts = this.state.mentionAtActiveCounts;
handleBadgeChange = (index, sessionExpired, unreadCount, mentionCount, isUnread, isMentioned) => {
const sessionsExpired = this.state.sessionsExpired;
const unreadCounts = this.state.unreadCounts;
const mentionCounts = this.state.mentionCounts;
const unreadAtActive = this.state.unreadAtActive;
const mentionAtActiveCounts = this.state.mentionAtActiveCounts;
sessionsExpired[index] = sessionExpired;
unreadCounts[index] = unreadCount;
mentionCounts[index] = mentionCount;
@ -181,27 +190,32 @@ const MainPage = createReactClass({
}
}
this.setState({
sessionsExpired,
unreadCounts,
mentionCounts,
unreadAtActive,
mentionAtActiveCounts,
});
this.handleUnreadCountTotalChange();
},
this.handleBadgesChange();
}
markReadAtActive(index) {
var unreadAtActive = this.state.unreadAtActive;
var mentionAtActiveCounts = this.state.mentionAtActiveCounts;
const unreadAtActive = this.state.unreadAtActive;
const mentionAtActiveCounts = this.state.mentionAtActiveCounts;
unreadAtActive[index] = false;
mentionAtActiveCounts[index] = 0;
this.setState({
unreadAtActive,
mentionAtActiveCounts,
});
this.handleUnreadCountTotalChange();
},
handleUnreadCountTotalChange() {
if (this.props.onUnreadCountChange) {
var allUnreadCount = this.state.unreadCounts.reduce((prev, curr) => {
this.handleBadgesChange();
}
handleBadgesChange = () => {
if (this.props.onBadgeChange) {
const someSessionsExpired = this.state.sessionsExpired.some((sessionExpired) => sessionExpired);
let allUnreadCount = this.state.unreadCounts.reduce((prev, curr) => {
return prev + curr;
}, 0);
this.state.unreadAtActive.forEach((state) => {
@ -209,31 +223,36 @@ const MainPage = createReactClass({
allUnreadCount += 1;
}
});
var allMentionCount = this.state.mentionCounts.reduce((prev, curr) => {
let allMentionCount = this.state.mentionCounts.reduce((prev, curr) => {
return prev + curr;
}, 0);
this.state.mentionAtActiveCounts.forEach((count) => {
allMentionCount += count;
});
this.props.onUnreadCountChange(allUnreadCount, allMentionCount);
this.props.onBadgeChange(someSessionsExpired, allUnreadCount, allMentionCount);
}
},
}
handleOnTeamFocused(index) {
// Turn off the flag to indicate whether unread message of active channel contains at current tab.
this.markReadAtActive(index);
},
}
handleLogin(request, username, password) {
ipcRenderer.send('login-credentials', request, username, password);
const loginQueue = this.state.loginQueue;
loginQueue.shift();
this.setState({loginQueue});
},
}
handleLoginCancel() {
const loginQueue = this.state.loginQueue;
loginQueue.shift();
this.setState({loginQueue});
},
}
handleTargetURLChange(targetURL) {
clearTimeout(this.targetURLDisappearTimeout);
if (targetURL === '') {
@ -244,47 +263,49 @@ const MainPage = createReactClass({
} else {
this.setState({targetURL});
}
},
}
addServer() {
this.setState({
showNewTeamModal: true,
});
},
}
focusOnWebView(e) {
if (e.target.className !== 'finder-input') {
this.refs[`mattermostView${this.state.key}`].focusOnWebView();
}
},
}
activateFinder() {
this.setState({
finderVisible: true,
focusFinder: true,
});
},
}
closeFinder() {
this.setState({
finderVisible: false,
});
},
}
inputBlur() {
this.setState({
focusFinder: false,
});
},
}
render() {
var self = this;
var tabsRow;
const self = this;
let tabsRow;
if (this.props.teams.length > 1) {
tabsRow = (
<Row>
<TabBar
id='tabBar'
teams={this.props.teams}
sessionsExpired={this.state.sessionsExpired}
unreadCounts={this.state.unreadCounts}
mentionCounts={this.state.mentionCounts}
unreadAtActive={this.state.unreadAtActive}
@ -300,15 +321,15 @@ const MainPage = createReactClass({
);
}
var views = this.props.teams.map((team, index) => {
function handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned) {
self.handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned);
const views = this.props.teams.map((team, index) => {
function handleBadgeChange(sessionExpired, unreadCount, mentionCount, isUnread, isMentioned) {
self.handleBadgeChange(index, sessionExpired, unreadCount, mentionCount, isUnread, isMentioned);
}
function handleNotificationClick() {
self.handleSelect(index);
}
var id = 'mattermostView' + index;
var isActive = self.state.key === index;
const id = 'mattermostView' + index;
const isActive = self.state.key === index;
let teamUrl = team.url;
const deeplinkingUrl = this.props.deeplinkingUrl;
@ -326,27 +347,27 @@ const MainPage = createReactClass({
src={teamUrl}
name={team.name}
onTargetURLChange={self.handleTargetURLChange}
onUnreadCountChange={handleUnreadCountChange}
onBadgeChange={handleBadgeChange}
onNotificationClick={handleNotificationClick}
ref={id}
active={isActive}
/>);
});
var viewsRow = (
const viewsRow = (
<Row>
{views}
</Row>);
var request = null;
var authServerURL = null;
var authInfo = null;
let request = null;
let authServerURL = null;
let authInfo = null;
if (this.state.loginQueue.length !== 0) {
request = this.state.loginQueue[0].request;
const tmpURL = url.parse(this.state.loginQueue[0].request.url);
authServerURL = `${tmpURL.protocol}//${tmpURL.host}`;
authInfo = this.state.loginQueue[0].authInfo;
}
var modal = (
const modal = (
<NewTeamModal
show={this.state.showNewTeamModal}
onClose={() => {
@ -419,7 +440,18 @@ const MainPage = createReactClass({
</div>
</div>
);
},
});
}
}
export default MainPage;
MainPage.propTypes = {
onBadgeChange: PropTypes.func.isRequired,
teams: PropTypes.array.isRequired,
onTeamConfigChange: PropTypes.func.isRequired,
initialIndex: PropTypes.number.isRequired,
useSpellChecker: PropTypes.bool.isRequired,
onSelectSpellCheckerLocale: PropTypes.func.isRequired,
deeplinkingUrl: PropTypes.string,
showAddServerButton: PropTypes.bool.isRequired,
requestingPermission: TabBar.propTypes.requestingPermission,
onClickPermissionDialog: PropTypes.func,
};

View file

@ -9,8 +9,6 @@ import url from 'url';
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import {findDOMNode} from 'react-dom';
import {ipcRenderer, remote, shell} from 'electron';
import contextMenu from '../js/contextMenu';
@ -43,37 +41,40 @@ function isNetworkDrive(fileURL) {
return false;
}
const MattermostView = createReactClass({
propTypes: {
name: PropTypes.string,
id: PropTypes.string,
onTargetURLChange: PropTypes.func,
onUnreadCountChange: PropTypes.func,
src: PropTypes.string,
active: PropTypes.bool,
withTab: PropTypes.bool,
useSpellChecker: PropTypes.bool,
onSelectSpellCheckerLocale: PropTypes.func,
},
export default class MattermostView extends React.Component {
constructor(props) {
super(props);
getInitialState() {
return {
this.state = {
errorInfo: null,
isContextMenuAdded: false,
reloadTimeoutID: null,
isLoaded: false,
};
},
handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned) {
if (this.props.onUnreadCountChange) {
this.props.onUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned);
this.handleUnreadCountChange = this.handleUnreadCountChange.bind(this);
this.reload = this.reload.bind(this);
this.clearCacheAndReload = this.clearCacheAndReload.bind(this);
this.focusOnWebView = this.focusOnWebView.bind(this);
this.canGoBack = this.canGoBack.bind(this);
this.canGoForward = this.canGoForward.bind(this);
this.goBack = this.goBack.bind(this);
this.goForward = this.goForward.bind(this);
this.getSrc = this.getSrc.bind(this);
this.handleDeepLink = this.handleDeepLink.bind(this);
this.webviewRef = React.createRef();
}
handleUnreadCountChange(sessionExpired, unreadCount, mentionCount, isUnread, isMentioned) {
if (this.props.onBadgeChange) {
this.props.onBadgeChange(sessionExpired, unreadCount, mentionCount, isUnread, isMentioned);
}
},
}
componentDidMount() {
var self = this;
var webview = findDOMNode(this.refs.webview);
const self = this;
const webview = this.webviewRef.current;
webview.addEventListener('did-fail-load', (e) => {
console.log(self.props.name, 'webview did-fail-load', e);
@ -105,8 +106,8 @@ const MattermostView = createReactClass({
// Open link in browserWindow. for exmaple, attached files.
webview.addEventListener('new-window', (e) => {
var currentURL = url.parse(webview.getURL());
var destURL = url.parse(e.url);
const currentURL = url.parse(webview.getURL());
const destURL = url.parse(e.url);
if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:' && destURL.protocol !== `${scheme}:`) {
ipcRenderer.send('confirm-protocol', destURL.protocol, e.url);
return;
@ -157,15 +158,16 @@ const MattermostView = createReactClass({
isLoaded: true,
});
break;
case 'onUnreadCountChange':
var unreadCount = event.args[0];
var mentionCount = event.args[1];
case 'onBadgeChange': {
const sessionExpired = event.args[0];
const unreadCount = event.args[1];
const mentionCount = event.args[2];
const isUnread = event.args[3];
const isMentioned = event.args[4];
self.handleUnreadCountChange(sessionExpired, unreadCount, mentionCount, isUnread, isMentioned);
// isUnread and isMentioned is pulse flag.
var isUnread = event.args[2];
var isMentioned = event.args[3];
self.handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned);
break;
}
case 'onNotificationClick':
self.props.onNotificationClick();
break;
@ -207,7 +209,7 @@ const MattermostView = createReactClass({
break;
}
});
},
}
reload() {
clearTimeout(this.state.reloadTimeoutID);
@ -216,63 +218,63 @@ const MattermostView = createReactClass({
reloadTimeoutID: null,
isLoaded: false,
});
var webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
webview.reload();
},
}
clearCacheAndReload() {
this.setState({
errorInfo: null,
});
var webContents = findDOMNode(this.refs.webview).getWebContents();
const webContents = this.webviewRef.current.getWebContents();
webContents.session.clearCache(() => {
webContents.reload();
});
},
}
focusOnWebView() {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
const webContents = webview.getWebContents(); // webContents might not be created yet.
if (webContents && !webContents.isFocused()) {
webview.focus();
webContents.focus();
}
},
}
canGoBack() {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
return webview.getWebContents().canGoBack();
},
}
canGoForward() {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
return webview.getWebContents().canGoForward();
},
}
goBack() {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
webview.getWebContents().goBack();
},
}
goForward() {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
webview.getWebContents().goForward();
},
}
getSrc() {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
return webview.src;
},
}
handleDeepLink(relativeUrl) {
const webview = findDOMNode(this.refs.webview);
const webview = this.webviewRef.current;
webview.executeJavaScript(
'history.pushState(null, null, "' + relativeUrl + '");'
);
webview.executeJavaScript(
'dispatchEvent(new PopStateEvent("popstate", null));'
);
},
}
render() {
const errorView = this.state.errorInfo ? (
@ -312,11 +314,21 @@ const MattermostView = createReactClass({
id={this.props.id}
preload={preloadJS}
src={this.props.src}
ref='webview'
ref={this.webviewRef}
/>
{ loadingImage }
</div>);
},
});
}
}
export default MattermostView;
MattermostView.propTypes = {
name: PropTypes.string,
id: PropTypes.string,
onTargetURLChange: PropTypes.func,
onBadgeChange: PropTypes.func,
src: PropTypes.string,
active: PropTypes.bool,
withTab: PropTypes.bool,
useSpellChecker: PropTypes.bool,
onSelectSpellCheckerLocale: PropTypes.func,
};

View file

@ -1,14 +1,14 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/* eslint-disable react/no-set-state */
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import ReactDOM from 'react-dom';
import {Button, Checkbox, Col, FormGroup, Grid, HelpBlock, Navbar, Radio, Row} from 'react-bootstrap';
import {ipcRenderer, remote} from 'electron';
import AutoLaunch from 'auto-launch';
import {debounce} from 'underscore';
import buildConfig from '../../common/config/buildConfig';
@ -17,11 +17,6 @@ import settings from '../../common/settings';
import TeamList from './TeamList.jsx';
import AutoSaveIndicator from './AutoSaveIndicator.jsx';
const appLauncher = new AutoLaunch({
name: remote.app.getName(),
isHidden: true,
});
function backToIndex(index) {
const target = typeof index === 'undefined' ? 0 : index;
const indexURL = remote.getGlobal('isDev') ? 'http://localhost:8080/browser/index.html' : `file://${remote.app.getAppPath()}/browser/index.html`;
@ -31,20 +26,16 @@ function backToIndex(index) {
const CONFIG_TYPE_SERVERS = 'servers';
const CONFIG_TYPE_APP_OPTIONS = 'appOptions';
const SettingsPage = createReactClass({
propTypes: {
configFile: PropTypes.string,
enableServerManagement: PropTypes.bool,
},
export default class SettingsPage extends React.Component {
constructor(props) {
super(props);
getInitialState() {
var initialState;
let initialState;
try {
initialState = settings.readFileSync(this.props.configFile);
} catch (e) {
initialState = settings.loadDefault();
}
initialState.showAddTeamForm = false;
initialState.trayWasVisible = remote.getCurrentWindow().trayWasVisible;
if (initialState.teams.length === 0) {
@ -54,18 +45,32 @@ const SettingsPage = createReactClass({
appOptions: AutoSaveIndicator.SAVING_STATE_DONE,
servers: AutoSaveIndicator.SAVING_STATE_DONE,
};
this.state = initialState;
this.startSaveConfig = this.startSaveConfig.bind(this);
this.didSaveConfig = this.didSaveConfig.bind(this);
this.handleTeamsChange = this.handleTeamsChange.bind(this);
this.saveConfig = this.saveConfig.bind(this);
this.handleCancel = this.handleCancel.bind(this);
this.handleChangeShowTrayIcon = this.handleChangeShowTrayIcon.bind(this);
this.handleChangeTrayIconTheme = this.handleChangeTrayIconTheme.bind(this);
this.handleChangeAutoStart = this.handleChangeAutoStart.bind(this);
this.handleChangeMinimizeToTray = this.handleChangeMinimizeToTray.bind(this);
this.toggleShowTeamForm = this.toggleShowTeamForm.bind(this);
this.setShowTeamFormVisibility = this.setShowTeamFormVisibility.bind(this);
this.handleFlashWindow = this.handleFlashWindow.bind(this);
this.handleBounceIcon = this.handleBounceIcon.bind(this);
this.handleBounceIconType = this.handleBounceIconType.bind(this);
this.handleShowUnreadBadge = this.handleShowUnreadBadge.bind(this);
this.handleChangeUseSpellChecker = this.handleChangeUseSpellChecker.bind(this);
this.handleChangeEnableHardwareAcceleration = this.handleChangeEnableHardwareAcceleration.bind(this);
this.updateTeam = this.updateTeam.bind(this);
this.addServer = this.addServer.bind(this);
this.trayIconThemeRef = React.createRef();
}
return initialState;
},
componentDidMount() {
if (process.platform === 'win32' || process.platform === 'linux') {
var self = this;
appLauncher.isEnabled().then((enabled) => {
self.setState({
autostart: enabled,
});
});
}
ipcRenderer.on('add-server', () => {
this.setState({
showAddTeamForm: true,
@ -74,7 +79,7 @@ const SettingsPage = createReactClass({
ipcRenderer.on('switch-tab', (event, key) => {
backToIndex(key);
});
},
}
startSaveConfig(configType) {
if (!this.startSaveConfigImpl) {
@ -97,7 +102,7 @@ const SettingsPage = createReactClass({
savingState[configType] = AutoSaveIndicator.SAVING_STATE_SAVING;
this.setState({savingState});
this.startSaveConfigImpl[configType]();
},
}
didSaveConfig(configType) {
if (!this.didSaveConfigImpl) {
@ -111,7 +116,7 @@ const SettingsPage = createReactClass({
}, 2000);
}
this.didSaveConfigImpl[configType]();
},
}
handleTeamsChange(teams) {
this.setState({
@ -122,10 +127,10 @@ const SettingsPage = createReactClass({
this.setState({showAddTeamForm: true});
}
setImmediate(this.startSaveConfig, CONFIG_TYPE_SERVERS);
},
}
saveConfig(callback) {
var config = {
const config = {
teams: this.state.teams,
showTrayIcon: this.state.showTrayIcon,
trayIconTheme: this.state.trayIconTheme,
@ -140,6 +145,7 @@ const SettingsPage = createReactClass({
useSpellChecker: this.state.useSpellChecker,
spellCheckerLocale: this.state.spellCheckerLocale,
enableHardwareAcceleration: this.state.enableHardwareAcceleration,
autostart: this.state.autostart,
};
settings.writeFile(this.props.configFile, config, (err) => {
@ -149,36 +155,16 @@ const SettingsPage = createReactClass({
}
ipcRenderer.send('update-menu', config);
ipcRenderer.send('update-config');
if (process.platform === 'win32' || process.platform === 'linux') {
const autostart = this.state.autostart;
this.saveAutoStart(autostart, callback);
} else {
callback();
}
callback();
});
},
saveAutoStart(autostart, callback) {
appLauncher.isEnabled().then((enabled) => {
if (enabled && !autostart) {
appLauncher.disable().then(() => {
callback();
}).catch(callback);
} else if (!enabled && autostart) {
appLauncher.enable().then(() => {
callback();
}).catch(callback);
} else {
callback();
}
}).catch(callback);
},
}
handleCancel() {
backToIndex();
},
}
handleChangeShowTrayIcon() {
var shouldShowTrayIcon = !this.refs.showTrayIcon.props.checked;
const shouldShowTrayIcon = !this.refs.showTrayIcon.props.checked;
this.setState({
showTrayIcon: shouldShowTrayIcon,
});
@ -190,19 +176,22 @@ const SettingsPage = createReactClass({
}
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleChangeTrayIconTheme() {
this.setState({
trayIconTheme: ReactDOM.findDOMNode(this.refs.trayIconTheme).value,
trayIconTheme: this.trayIconThemeRef.current.value,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleChangeAutoStart() {
this.setState({
autostart: !this.refs.autostart.props.checked,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleChangeMinimizeToTray() {
const shouldMinimizeToTray = this.state.showTrayIcon && !this.refs.minimizeToTray.props.checked;
@ -210,18 +199,21 @@ const SettingsPage = createReactClass({
minimizeToTray: shouldMinimizeToTray,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
toggleShowTeamForm() {
this.setState({
showAddTeamForm: !this.state.showAddTeamForm,
});
document.activeElement.blur();
},
}
setShowTeamFormVisibility(val) {
this.setState({
showAddTeamForm: val,
});
},
}
handleFlashWindow() {
this.setState({
notifications: {
@ -230,7 +222,8 @@ const SettingsPage = createReactClass({
},
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleBounceIcon() {
this.setState({
notifications: {
@ -239,7 +232,8 @@ const SettingsPage = createReactClass({
},
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleBounceIconType(event) {
this.setState({
notifications: {
@ -248,45 +242,46 @@ const SettingsPage = createReactClass({
},
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleShowUnreadBadge() {
this.setState({
showUnreadBadge: !this.refs.showUnreadBadge.props.checked,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleChangeUseSpellChecker() {
this.setState({
useSpellChecker: !this.refs.useSpellChecker.props.checked,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
handleChangeEnableHardwareAcceleration() {
this.setState({
enableHardwareAcceleration: !this.refs.enableHardwareAcceleration.props.checked,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_APP_OPTIONS);
},
}
updateTeam(index, newData) {
var teams = this.state.teams;
const teams = this.state.teams;
teams[index] = newData;
this.setState({
teams,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_SERVERS);
},
}
addServer(team) {
var teams = this.state.teams;
const teams = this.state.teams;
teams.push(team);
this.setState({
teams,
});
setImmediate(this.startSaveConfig, CONFIG_TYPE_SERVERS);
},
}
render() {
const settingsPage = {
@ -324,7 +319,7 @@ const SettingsPage = createReactClass({
},
};
var teamsRow = (
const teamsRow = (
<Row>
<Col md={12}>
<TeamList
@ -344,7 +339,7 @@ const SettingsPage = createReactClass({
</Row>
);
var serversRow = (
const serversRow = (
<Row>
<Col
md={10}
@ -375,7 +370,7 @@ const SettingsPage = createReactClass({
</Row>
);
var srvMgmt;
let srvMgmt;
if (this.props.enableServerManagement === true) {
srvMgmt = (
<div>
@ -386,7 +381,7 @@ const SettingsPage = createReactClass({
);
}
var options = [];
const options = [];
// MacOS has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX
if (process.platform === 'win32' || process.platform === 'linux') {
@ -417,7 +412,7 @@ const SettingsPage = createReactClass({
{'Check spelling'}
<HelpBlock>
{'Highlight misspelled words in your messages.'}
{' Available for English, French, German, Spanish, and Dutch.'}
{' Available for English, French, German, Portuguese, Spanish, and Dutch.'}
</HelpBlock>
</Checkbox>);
@ -514,6 +509,7 @@ const SettingsPage = createReactClass({
options.push(
<FormGroup
key='trayIconTheme'
ref={this.trayIconThemeRef}
style={{marginLeft: '20px'}}
>
{'Icon theme: '}
@ -576,7 +572,7 @@ const SettingsPage = createReactClass({
</Checkbox>
);
var optionsRow = (options.length > 0) ? (
const optionsRow = (options.length > 0) ? (
<Row>
<Col md={12}>
<h2 style={settingsPage.sectionHeading}>{'App Options'}</h2>
@ -625,7 +621,10 @@ const SettingsPage = createReactClass({
</Grid>
</div>
);
},
});
}
}
export default SettingsPage;
SettingsPage.propTypes = {
configFile: PropTypes.string,
enableServerManagement: PropTypes.bool,
};

View file

@ -10,6 +10,8 @@ import PermissionRequestDialog from './PermissionRequestDialog.jsx';
export default class TabBar extends React.Component { // need "this"
render() {
const tabs = this.props.teams.map((team, index) => {
const sessionExpired = this.props.sessionsExpired[index];
let unreadCount = 0;
if (this.props.unreadCounts[index] > 0) {
unreadCount = this.props.unreadCounts[index];
@ -27,11 +29,16 @@ export default class TabBar extends React.Component { // need "this"
}
let badgeDiv;
if (mentionCount !== 0) {
if (sessionExpired) {
badgeDiv = (
<div className='TabBar-badge TabBar-badge-nomention'>{'•'}</div>
);
} else if (mentionCount !== 0) {
badgeDiv = (
<div className='TabBar-badge'>
{mentionCount}
</div>);
</div>
);
}
const id = 'teamTabItem' + index;
const requestingPermission = this.props.requestingPermission[index];
@ -114,6 +121,7 @@ TabBar.propTypes = {
id: PropTypes.string,
onSelect: PropTypes.func,
teams: PropTypes.array,
sessionsExpired: PropTypes.array,
unreadCounts: PropTypes.array,
unreadAtActive: PropTypes.array,
mentionCounts: PropTypes.array,

View file

@ -3,27 +3,17 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import {ListGroup} from 'react-bootstrap';
import TeamListItem from './TeamListItem.jsx';
import NewTeamModal from './NewTeamModal.jsx';
import RemoveServerModal from './RemoveServerModal.jsx';
const TeamList = createReactClass({
propTypes: {
onTeamsChange: PropTypes.func,
showAddTeamForm: PropTypes.bool,
teams: PropTypes.array,
addServer: PropTypes.func,
updateTeam: PropTypes.func,
toggleAddTeamForm: PropTypes.func,
setAddTeamFormVisibility: PropTypes.func,
onTeamClick: PropTypes.func,
},
export default class TeamList extends React.Component {
constructor(props) {
super(props);
getInitialState() {
return {
this.state = {
showEditTeamForm: false,
indexToRemoveServer: -1,
team: {
@ -32,15 +22,23 @@ const TeamList = createReactClass({
index: false,
},
};
},
this.handleTeamRemove = this.handleTeamRemove.bind(this);
this.handleTeamAdd = this.handleTeamAdd.bind(this);
this.handleTeamEditing = this.handleTeamEditing.bind(this);
this.openServerRemoveModal = this.openServerRemoveModal.bind(this);
this.closeServerRemoveModal = this.closeServerRemoveModal.bind(this);
}
handleTeamRemove(index) {
console.log(index);
var teams = this.props.teams;
const teams = this.props.teams;
teams.splice(index, 1);
this.props.onTeamsChange(teams);
},
}
handleTeamAdd(team) {
var teams = this.props.teams;
const teams = this.props.teams;
// check if team already exists and then change existing team or add new one
if ((typeof team.index !== 'undefined') && teams[team.index]) {
@ -60,7 +58,8 @@ const TeamList = createReactClass({
});
this.props.onTeamsChange(teams);
},
}
handleTeamEditing(teamName, teamUrl, teamIndex) {
this.setState({
showEditTeamForm: true,
@ -70,19 +69,19 @@ const TeamList = createReactClass({
index: teamIndex,
},
});
},
}
openServerRemoveModal(indexForServer) {
this.setState({indexToRemoveServer: indexForServer});
},
}
closeServerRemoveModal() {
this.setState({indexToRemoveServer: -1});
},
}
render() {
var self = this;
var teamNodes = this.props.teams.map((team, i) => {
const self = this;
const teamNodes = this.props.teams.map((team, i) => {
function handleTeamRemove() {
document.activeElement.blur();
self.openServerRemoveModal(i);
@ -110,7 +109,7 @@ const TeamList = createReactClass({
);
});
var addServerForm = (
const addServerForm = (
<NewTeamModal
show={this.props.showAddTeamForm || this.state.showEditTeamForm}
editMode={this.state.showEditTeamForm}
@ -126,7 +125,7 @@ const TeamList = createReactClass({
this.props.setAddTeamFormVisibility(false);
}}
onSave={(newTeam) => {
var teamData = {
const teamData = {
name: newTeam.name,
url: newTeam.url,
};
@ -171,7 +170,16 @@ const TeamList = createReactClass({
{ removeServerModal}
</ListGroup>
);
},
});
}
}
export default TeamList;
TeamList.propTypes = {
onTeamsChange: PropTypes.func,
showAddTeamForm: PropTypes.bool,
teams: PropTypes.array,
addServer: PropTypes.func,
updateTeam: PropTypes.func,
toggleAddTeamForm: PropTypes.func,
setAddTeamFormVisibility: PropTypes.func,
onTeamClick: PropTypes.func,
};

View file

@ -53,6 +53,11 @@
border-radius: 50%;
}
.TabBar .TabBar-badge.TabBar-badge-nomention {
font-size: 22pt;
line-height: 18px;
}
.TabBar .teamTabItem-unread {
font-weight: bold;
}

View file

@ -31,19 +31,23 @@ if (teams.length === 0) {
window.location = 'settings.html';
}
function showUnreadBadgeWindows(unreadCount, mentionCount) {
function showBadgeWindows(sessionExpired, unreadCount, mentionCount) {
function sendBadge(dataURL, description) {
// window.setOverlayIcon() does't work with NativeImage across remote boundaries.
// https://github.com/atom/electron/issues/4011
ipcRenderer.send('update-unread', {
overlayDataURL: dataURL,
description,
sessionExpired,
unreadCount,
mentionCount,
});
}
if (mentionCount > 0) {
if (sessionExpired) {
const dataURL = createBadgeDataURL('•');
sendBadge(dataURL, 'Session Expired: Please sign in to continue receiving notifications.');
} else if (mentionCount > 0) {
const dataURL = createBadgeDataURL(mentionCount.toString());
sendBadge(dataURL, 'You have unread mentions (' + mentionCount + ')');
} else if (unreadCount > 0 && AppConfig.data.showUnreadBadge) {
@ -54,8 +58,10 @@ function showUnreadBadgeWindows(unreadCount, mentionCount) {
}
}
function showUnreadBadgeOSX(unreadCount, mentionCount) {
if (mentionCount > 0) {
function showBadgeOSX(sessionExpired, unreadCount, mentionCount) {
if (sessionExpired) {
remote.app.dock.setBadge('•');
} else if (mentionCount > 0) {
remote.app.dock.setBadge(mentionCount.toString());
} else if (unreadCount > 0 && AppConfig.data.showUnreadBadge) {
remote.app.dock.setBadge('•');
@ -64,34 +70,39 @@ function showUnreadBadgeOSX(unreadCount, mentionCount) {
}
ipcRenderer.send('update-unread', {
sessionExpired,
unreadCount,
mentionCount,
});
}
function showUnreadBadgeLinux(unreadCount, mentionCount) {
function showBadgeLinux(sessionExpired, unreadCount, mentionCount) {
if (remote.app.isUnityRunning()) {
remote.app.setBadgeCount(mentionCount);
if (sessionExpired) {
remote.app.setBadgeCount(mentionCount + 1);
} else {
remote.app.setBadgeCount(mentionCount);
}
}
ipcRenderer.send('update-unread', {
sessionExpired,
unreadCount,
mentionCount,
});
}
function showUnreadBadge(unreadCount, mentionCount) {
function showBadge(sessionExpired, unreadCount, mentionCount) {
switch (process.platform) {
case 'win32':
showUnreadBadgeWindows(unreadCount, mentionCount);
showBadgeWindows(sessionExpired, unreadCount, mentionCount);
break;
case 'darwin':
showUnreadBadgeOSX(unreadCount, mentionCount);
showBadgeOSX(sessionExpired, unreadCount, mentionCount);
break;
case 'linux':
showUnreadBadgeLinux(unreadCount, mentionCount);
showBadgeLinux(sessionExpired, unreadCount, mentionCount);
break;
default:
}
}
@ -168,7 +179,7 @@ ReactDOM.render(
<MainPage
teams={teams}
initialIndex={initialIndex}
onUnreadCountChange={showUnreadBadge}
onBadgeChange={showBadge}
onTeamConfigChange={teamConfigChange}
useSpellChecker={AppConfig.data.useSpellChecker}
onSelectSpellCheckerLocale={handleSelectSpellCheckerLocale}

View file

@ -22,7 +22,7 @@ function getSuggestionsMenus(win, suggestions) {
function getSpellCheckerLocaleMenus(onSelectSpellCheckerLocale) {
const currentLocale = ipcRenderer.sendSync('get-spellchecker-locale');
const locales = [
{language: 'English', locale: 'en-US'},
{language: 'English (US)', locale: 'en-US'},
{language: 'French', locale: 'fr-FR'},
{language: 'German', locale: 'de-DE'},
{language: 'Spanish', locale: 'es-ES'},

View file

@ -51,7 +51,7 @@ window.addEventListener('load', () => {
});
function hasClass(element, className) {
var rclass = /[\t\r\n\f]/g;
const rclass = /[\t\r\n\f]/g;
if ((' ' + element.className + ' ').replace(rclass, ' ').indexOf(className) > -1) {
return true;
}
@ -66,9 +66,13 @@ function getUnreadCount() {
this.mentionCount = 0;
}
// LHS not found => Log out => Count should be 0.
// LHS not found => Log out => Count should be 0, but session may be expired.
if (document.getElementById('sidebar-left') === null) {
ipcRenderer.sendToHost('onUnreadCountChange', 0, 0, false, false);
const extraParam = (new URLSearchParams(window.location.search)).get('extra');
const sessionExpired = extraParam === 'expired';
ipcRenderer.sendToHost('onBadgeChange', sessionExpired, 0, 0, false, false);
this.sessionExpired = sessionExpired;
this.unreadCount = 0;
this.mentionCount = 0;
setTimeout(getUnreadCount, UNREAD_COUNT_INTERVAL);
@ -77,7 +81,7 @@ function getUnreadCount() {
// unreadCount in sidebar
// Note: the active channel doesn't have '.unread-title'.
var unreadCount = document.getElementsByClassName('unread-title').length;
let unreadCount = document.getElementsByClassName('unread-title').length;
// unreadCount in team sidebar
const teamSideBar = document.getElementsByClassName('team-sidebar'); // team-sidebar doesn't have id
@ -86,30 +90,30 @@ function getUnreadCount() {
}
// mentionCount in sidebar
var elem = document.getElementsByClassName('badge');
var mentionCount = 0;
for (var i = 0; i < elem.length; i++) {
const elem = document.getElementsByClassName('badge');
let mentionCount = 0;
for (let i = 0; i < elem.length; i++) {
if (isElementVisible(elem[i]) && !hasClass(elem[i], 'badge-notify')) {
mentionCount += Number(elem[i].innerHTML);
}
}
var postAttrName = 'data-reactid';
var lastPostElem = document.querySelector('div[' + postAttrName + '="' + this.lastCheckedPostId + '"]');
var isUnread = false;
var isMentioned = false;
const postAttrName = 'data-reactid';
const lastPostElem = document.querySelector('div[' + postAttrName + '="' + this.lastCheckedPostId + '"]');
let isUnread = false;
let isMentioned = false;
if (lastPostElem === null || !isElementVisible(lastPostElem)) {
// When load channel or change channel, this.lastCheckedPostId is invalid.
// So we get latest post and save lastCheckedPostId.
// find active post-list.
var postLists = document.querySelectorAll('div.post-list__content');
const postLists = document.querySelectorAll('div.post-list__content');
if (postLists.length === 0) {
setTimeout(getUnreadCount, UNREAD_COUNT_INTERVAL);
return;
}
var post = null;
for (var j = 0; j < postLists.length; j++) {
let post = null;
for (let j = 0; j < postLists.length; j++) {
if (isElementVisible(postLists[j])) {
post = postLists[j].children[0];
}
@ -130,19 +134,19 @@ function getUnreadCount() {
post = post.nextSibling;
}
} else if (lastPostElem !== null) {
var newPostElem = lastPostElem.nextSibling;
let newPostElem = lastPostElem.nextSibling;
while (newPostElem) {
this.lastCheckedPostId = newPostElem.getAttribute(postAttrName);
isUnread = true;
var activeChannel = document.querySelector('.active .sidebar-channel');
var closeButton = activeChannel.getElementsByClassName('btn-close');
const activeChannel = document.querySelector('.active .sidebar-channel');
const closeButton = activeChannel.getElementsByClassName('btn-close');
if (closeButton.length === 1 && closeButton[0].getAttribute('aria-describedby') === 'remove-dm-tooltip') {
// If active channel is DM, all posts is treated as menion.
isMentioned = true;
break;
} else {
// If active channel is public/private channel, only mentioned post is treated as mention.
var highlight = newPostElem.getElementsByClassName('mention-highlight');
const highlight = newPostElem.getElementsByClassName('mention-highlight');
if (highlight.length !== 0 && isElementVisible(highlight[0])) {
isMentioned = true;
break;
@ -152,11 +156,12 @@ function getUnreadCount() {
}
}
if (this.unreadCount !== unreadCount || this.mentionCount !== mentionCount || isUnread || isMentioned) {
ipcRenderer.sendToHost('onUnreadCountChange', unreadCount, mentionCount, isUnread, isMentioned);
if (this.sessionExpired || this.unreadCount !== unreadCount || this.mentionCount !== mentionCount || isUnread || isMentioned) {
ipcRenderer.sendToHost('onBadgeChange', false, unreadCount, mentionCount, isUnread, isMentioned);
}
this.unreadCount = unreadCount;
this.mentionCount = mentionCount;
this.sessionExpired = false;
setTimeout(getUnreadCount, UNREAD_COUNT_INTERVAL);
}
setTimeout(getUnreadCount, UNREAD_COUNT_INTERVAL);

View file

@ -20,6 +20,7 @@ const defaultPreferences = {
showUnreadBadge: true,
useSpellChecker: true,
enableHardwareAcceleration: true,
autostart: true,
};
export default defaultPreferences;

View file

@ -20,7 +20,7 @@ function upgradeV0toV1(configV0) {
}
export default function upgradeToLatest(config) {
var configVersion = config.version ? config.version : 0;
const configVersion = config.version ? config.version : 0;
switch (configVersion) {
case 0:
return upgradeToLatest(upgradeV0toV1(config));

View file

@ -4,7 +4,7 @@
'use strict';
import os from 'os';
var releaseSplit = os.release().split('.');
const releaseSplit = os.release().split('.');
export default {
major: parseInt(releaseSplit[0], 10),

View file

@ -45,7 +45,7 @@ export default {
if (config.version !== defaultPreferences.version) {
throw new Error('version ' + config.version + ' is not equal to ' + defaultPreferences.version);
}
var data = JSON.stringify(config, null, ' ');
const data = JSON.stringify(config, null, ' ');
fs.writeFile(configFile, data, 'utf8', callback);
},
@ -59,7 +59,7 @@ export default {
fs.mkdirSync(dir);
}
var data = JSON.stringify(config, null, ' ');
const data = JSON.stringify(config, null, ' ');
fs.writeFileSync(configFile, data, 'utf8');
},

View file

@ -23,6 +23,7 @@ import {parse as parseArgv} from 'yargs';
import {protocols} from '../electron-builder.json';
import AutoLauncher from './main/AutoLauncher';
import CriticalErrorHandler from './main/CriticalErrorHandler';
import upgradeAutoLaunch from './main/autoLaunch';
import autoUpdater from './main/autoUpdater';
@ -48,6 +49,7 @@ import PermissionManager from './main/PermissionManager';
import permissionRequestHandler from './main/permissionRequestHandler';
import AppStateManager from './main/AppStateManager';
import initCookieManager from './main/cookieManager';
import {shouldBeHiddenOnStartup} from './main/utils';
import SpellChecker from './main/SpellChecker';
@ -55,7 +57,7 @@ const assetsDir = path.resolve(app.getAppPath(), 'assets');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
let mainWindow = null;
let spellChecker = null;
let deeplinkingUrl = null;
let scheme = null;
@ -63,11 +65,7 @@ let appState = null;
let permissionManager = null;
const argv = parseArgv(process.argv.slice(1));
var hideOnStartup;
if (argv.hidden) {
hideOnStartup = true;
}
const hideOnStartup = shouldBeHiddenOnStartup(argv);
if (argv['data-dir']) {
app.setPath('userData', path.resolve(argv['data-dir']));
@ -75,7 +73,7 @@ if (argv['data-dir']) {
global.isDev = isDev && !argv.disableDevMode;
var config = {};
let config = {};
try {
const configFile = app.getPath('userData') + '/config.json';
config = settings.readFileSync(configFile);
@ -100,6 +98,15 @@ if (config.enableHardwareAcceleration === false) {
ipcMain.on('update-config', () => {
const configFile = app.getPath('userData') + '/config.json';
config = settings.readFileSync(configFile);
if (process.platform === 'win32' || process.platform === 'linux') {
const appLauncher = new AutoLauncher();
const autoStartTask = config.autostart ? appLauncher.enable() : appLauncher.disable();
autoStartTask.then(() => {
console.log('config.autostart has been configured:', config.autostart);
}).catch((err) => {
console.log('error:', err);
});
}
const trustedURLs = settings.mergeDefaultTeams(config.teams).map((team) => team.url);
permissionManager.setTrustedURLs(trustedURLs);
ipcMain.emit('update-dict', true, config.spellCheckerLocale);
@ -118,7 +125,7 @@ function switchMenuIconImages(icons, isDarkMode) {
}
}
var trayIcon = null;
let trayIcon = null;
const trayImages = (() => {
switch (process.platform) {
case 'win32':
@ -294,7 +301,7 @@ app.on('certificate-error', (event, webContents, url, error, certificate, callba
event.preventDefault();
callback(true);
} else {
var detail = `URL: ${url}\nError: ${error}`;
let detail = `URL: ${url}\nError: ${error}`;
if (certificateStore.isExisting(url)) {
detail = 'Certificate is different from previous one.\n\n' + detail;
}
@ -526,7 +533,14 @@ app.on('ready', () => {
}
if (trayIcon && !trayIcon.isDestroyed()) {
if (arg.mentionCount > 0) {
if (arg.sessionExpired) {
// reuse the mention icon when the session is expired
trayIcon.setImage(trayImages.mention);
if (process.platform === 'darwin') {
trayIcon.setPressedImage(trayImages.clicked.mention);
}
trayIcon.setToolTip('Session Expired: Please sign in to continue receiving notifications.');
} else if (arg.mentionCount > 0) {
trayIcon.setImage(trayImages.mention);
if (process.platform === 'darwin') {
trayIcon.setPressedImage(trayImages.clicked.mention);
@ -551,8 +565,8 @@ app.on('ready', () => {
if (process.platform === 'darwin') {
session.defaultSession.on('will-download', (event, item) => {
var filename = item.getFilename();
var savePath = dialog.showSaveDialog({
const filename = item.getFilename();
const savePath = dialog.showSaveDialog({
title: filename,
defaultPath: os.homedir() + '/Downloads/' + filename,
});
@ -567,7 +581,7 @@ app.on('ready', () => {
// Set application menu
ipcMain.on('update-menu', (event, configData) => {
var aMenu = appMenu.createMenu(mainWindow, configData, global.isDev);
const aMenu = appMenu.createMenu(mainWindow, configData, global.isDev);
Menu.setApplicationMenu(aMenu);
// set up context menu for tray icon

48
src/main/AutoLauncher.js Normal file
View file

@ -0,0 +1,48 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import AutoLaunch from 'auto-launch';
import {app} from 'electron';
import isDev from 'electron-is-dev';
export default class AutoLauncher {
constructor() {
this.appLauncher = new AutoLaunch({
name: app.getName(),
isHidden: true,
});
}
isEnabled() {
return this.appLauncher.isEnabled();
}
async blankPromise() {
return null;
}
async enable() {
if (isDev) {
console.log('In development mode, autostart config never effects');
return this.blankPromise();
}
const enabled = await this.isEnabled();
if (!enabled) {
return this.appLauncher.enable();
}
return this.blankPromise();
}
async disable() {
if (isDev) {
console.log('In development mode, autostart config never effects');
return this.blankPromise();
}
const enabled = await this.isEnabled();
if (enabled) {
return this.appLauncher.disable();
}
return this.blankPromise();
}
}

View file

@ -70,7 +70,24 @@ export default class SpellChecker extends EventEmitter {
}
getSuggestions(word, maxSuggestions) {
return this.dict.getSuggestions(word, maxSuggestions);
const suggestions = this.dict.getSuggestions(word, maxSuggestions);
const firstCharWord = word.charAt(0);
let i;
for (i = 0; i < suggestions.length; i++) {
if (suggestions[i].charAt(0).toUpperCase() === firstCharWord.toUpperCase()) {
suggestions[i] = firstCharWord + suggestions[i].slice(1);
}
}
const uniqueSuggestions = suggestions.reduce((a, b) => {
if (a.indexOf(b) < 0) {
a.push(b);
}
return a;
}, []);
return uniqueSuggestions;
}
}

View file

@ -9,7 +9,7 @@ import fs from 'fs';
import {app, dialog, ipcMain, shell} from 'electron';
const allowedProtocolFile = path.resolve(app.getPath('userData'), 'allowedProtocols.json');
var allowedProtocols = [];
let allowedProtocols = [];
function init(mainWindow) {
fs.readFile(allowedProtocolFile, 'utf-8', (err, data) => {

View file

@ -56,7 +56,7 @@ CertificateStore.prototype.isExisting = function isExisting(targetURL) {
};
CertificateStore.prototype.isTrusted = function isTrusted(targetURL, certificate) {
var host = getHost(targetURL);
const host = getHost(targetURL);
if (!this.isExisting(targetURL)) {
return false;
}

View file

@ -7,7 +7,7 @@ import path from 'path';
import {app, BrowserWindow} from 'electron';
function saveWindowState(file, window) {
var windowState = window.getBounds();
const windowState = window.getBounds();
windowState.maximized = window.isMaximized();
windowState.fullscreen = window.isFullScreen();
try {
@ -26,7 +26,7 @@ function createMainWindow(config, options) {
// Create the browser window.
const boundsInfoPath = path.join(app.getPath('userData'), 'bounds-info.json');
var windowOptions;
let windowOptions;
try {
windowOptions = JSON.parse(fs.readFileSync(boundsInfoPath, 'utf-8'));
} catch (e) {

View file

@ -15,11 +15,11 @@ function createTemplate(mainWindow, config, isDev) {
type: 'separator',
};
var appName = app.getName();
var firstMenuName = (process.platform === 'darwin') ? appName : 'File';
var template = [];
const appName = app.getName();
const firstMenuName = (process.platform === 'darwin') ? appName : 'File';
const template = [];
var platformAppMenu = process.platform === 'darwin' ? [{
let platformAppMenu = process.platform === 'darwin' ? [{
label: 'About ' + appName,
role: 'about',
click() {
@ -217,7 +217,7 @@ function createTemplate(mainWindow, config, isDev) {
}],
};
template.push(windowMenu);
var submenu = [];
const submenu = [];
if (buildConfig.helpLink) {
submenu.push({
label: 'Learn More...',

View file

@ -10,7 +10,7 @@ import settings from '../../common/settings';
function createTemplate(mainWindow, config, isDev) {
const settingsURL = isDev ? 'http://localhost:8080/browser/settings.html' : `file://${app.getAppPath()}/browser/settings.html`;
const teams = settings.mergeDefaultTeams(config.teams);
var template = [
const template = [
...teams.slice(0, 9).map((team, i) => {
return {
label: team.name,

17
src/main/utils.js Normal file
View file

@ -0,0 +1,17 @@
// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {app} from 'electron';
export function shouldBeHiddenOnStartup(parsedArgv) {
if (parsedArgv.hidden) {
return true;
}
if (process.platform === 'darwin') {
if (app.getLoginItemSettings().wasOpenedAsHidden) {
return true;
}
}
return false;
}

View file

@ -11,7 +11,6 @@
"dependencies": {
"auto-launch": "^5.0.5",
"bootstrap": "^3.3.7",
"create-react-class": "^15.6.3",
"electron-context-menu": "0.9.0",
"electron-devtools-installer": "^2.2.4",
"electron-is-dev": "^0.3.0",

View file

@ -136,14 +136,6 @@ core-js@^2.4.0:
version "2.5.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b"
create-react-class@^15.6.3:
version "15.6.3"
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.3.tgz#2d73237fb3f970ae6ebe011a9e66f46dbca80036"
dependencies:
fbjs "^0.8.9"
loose-envify "^1.3.1"
object-assign "^4.1.1"
cross-unzip@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/cross-unzip/-/cross-unzip-0.0.2.tgz#5183bc47a09559befcf98cc4657964999359372f"

View file

@ -67,6 +67,27 @@ describe('main/Spellchecker.js', function() {
spellchecker.spellCheck('Mattermost').should.equal(true);
spellchecker.spellCheck('mattermost').should.equal(true);
});
it('should give at most the requested number of suggestions', function() {
// helllo known to give at least 4 suggestions
spellchecker.getSuggestions('helllo', 4).length.should.be.equal(4);
spellchecker.getSuggestions('helllo', 1).length.should.be.equal(1);
});
it('should give suggestions which preserve case of first letter', function() {
let suggestions = spellchecker.getSuggestions('carr', 4);
suggestions.length.should.not.be.equal(0);
let i;
for (i = 0; i < suggestions.length; i++) {
suggestions[i].charAt(0).should.be.equal('c');
}
suggestions = spellchecker.getSuggestions('Carr', 4);
suggestions.length.should.not.be.equal(0);
for (i = 0; i < suggestions.length; i++) {
suggestions[i].charAt(0).should.be.equal('C');
}
});
});
describe('en-GB', function() {
@ -107,5 +128,20 @@ describe('main/Spellchecker.js', function() {
spellchecker.spellCheck('-100').should.equal(true);
spellchecker.spellCheck('3.14').should.equal(true);
});
it('should give suggestions which preserve case of first letter', function() {
let suggestions = spellchecker.getSuggestions('gutenn', 4);
suggestions.length.should.not.be.equal(0);
let i;
for (i = 0; i < suggestions.length; i++) {
suggestions[i].charAt(0).should.be.equal('g');
}
suggestions = spellchecker.getSuggestions('Gutenn', 4);
suggestions.length.should.not.be.equal(0);
for (i = 0; i < suggestions.length; i++) {
suggestions[i].charAt(0).should.be.equal('G');
}
});
});
});

View file

@ -3726,9 +3726,9 @@ electron-to-chromium@^1.3.47:
version "1.3.48"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.48.tgz#d3b0d8593814044e092ece2108fc3ac9aea4b900"
electron@2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/electron/-/electron-2.0.2.tgz#b77e05f83419cc5ec921a2d21f35b55e4bfc3d68"
electron@2.0.8:
version "2.0.8"
resolved "https://registry.yarnpkg.com/electron/-/electron-2.0.8.tgz#6ec7113b356e09cc9899797e0d41ebff8163e962"
dependencies:
"@types/node" "^8.0.24"
electron-download "^3.0.1"