
* wip * background download * various fixes * wip * wokring autoupgrade * fix menu * fix windows * cleanup * add publishername * fix messages and titles * Test updates * Moved module and added functionality to click icon to install (instead of just download) * Add auto update setting, update on close app if downloaded * Tests, changes for security fixes, update version number * Update E2E tests * Lint fix * Update to latest electron-updater * Revert to stable electron-builder (only needed to update electron-updater) * Fix package-lock * skip flaky test * Update package * Fix E2E test * Fixes for enabling/disabled autoupdater * Fixed GPO definitions * [MM-38300] Set localhost as the test server * blank * Switch to s3 bucket for testing * Update icons to match spec * Add menu items for download/update actions * Type and test fixes * Fix notification circle * Fix macOS app not restarting on Restart/Update * Update dialog box titles * Turn off file system check for Linux * Changes to support deployments * Testing autoupdater deployments to s3 * disable tests for now * asfrehwf * fine no windows WHATEVER * remove windows again * Try universal all in one * pffftttngggguhhhh * make sure it's working * Missed artifacts script * Modify destination as well * one more time! * Update yml files * Oops * add yq manually * oof * Fix the script to work properly * Fix release script * Fix script again so it runs in time * Build version 2 * Revert build specific changes * Lint override * Fix build apps for PR builds * One more change * Add file generation for .deb repo * Deb repo test * skip tests for now * Fix artifact push * Persist after repo creation * Put tests back * Fix unit tests * Enable mac generated builds temp * Temporarily disable tests * Fix issue where notification doesn't pop dialog box * Try version 2 again * Put the version back * Attempting to debug mac app path issue * Fix issue where Mac app will quarantine itself after first update * Lock versions of yq * Fix yq for mac * As usual, Mac is difficult :P * Add quotes to anti-quarantine command * Change to spawn to avoid command injection * Oops * Nightly deployment changes (#2005) * Test nightly deploy * I fixed a some things * aaaaaaaaa * Restore old bucket * Added progress indicator via tooltip * Ship nightly builds to main S3 bucket * PR feedback * Fix a couple security exploits * Fix opacity on light mode button * Use large app icon * Resize icon for Windows * Resize icon for Mac * Update to electron-updater final * Remove Mac support and deb repo * Typo * Remove deb script * Remove checksum function * Removed autoUpdateSettingsPath * Update URL Co-authored-by: = <=> Co-authored-by: Devin Binnie <devin.binnie@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
146 lines
4.3 KiB
TypeScript
146 lines
4.3 KiB
TypeScript
// Copyright (c) 2015-2016 Yuya Ochiai
|
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
import 'renderer/css/index.css';
|
|
|
|
import React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import {CombinedConfig, Team} from 'types/config';
|
|
|
|
import {GET_CONFIGURATION, UPDATE_TEAMS, QUIT, RELOAD_CONFIGURATION} from 'common/communication';
|
|
|
|
import MainPage from './components/MainPage';
|
|
|
|
type State = {
|
|
config?: CombinedConfig;
|
|
}
|
|
|
|
class Root extends React.PureComponent<Record<string, never>, State> {
|
|
constructor(props: Record<string, never>) {
|
|
super(props);
|
|
this.state = {};
|
|
}
|
|
|
|
async componentDidMount() {
|
|
await this.setInitialConfig();
|
|
|
|
window.ipcRenderer.on('synchronize-config', () => {
|
|
this.reloadConfig();
|
|
});
|
|
|
|
window.ipcRenderer.on(RELOAD_CONFIGURATION, () => {
|
|
this.reloadConfig();
|
|
});
|
|
|
|
// Deny drag&drop navigation in mainWindow.
|
|
// Drag&drop is allowed in webview of index.html.
|
|
document.addEventListener('dragover', (event) => event.preventDefault());
|
|
document.addEventListener('drop', (event) => event.preventDefault());
|
|
}
|
|
|
|
setInitialConfig = async () => {
|
|
const config = await this.requestConfig(true);
|
|
this.setState({config});
|
|
}
|
|
|
|
moveTabs = (teamName: string, originalOrder: number, newOrder: number): number | undefined => {
|
|
if (!this.state.config) {
|
|
throw new Error('No config');
|
|
}
|
|
const teams = this.state.config.teams.concat();
|
|
const currentTeamIndex = teams.findIndex((team) => team.name === teamName);
|
|
const tabs = teams[currentTeamIndex].tabs.concat();
|
|
|
|
const tabOrder = tabs.map((team, index) => {
|
|
return {
|
|
index,
|
|
order: team.order,
|
|
};
|
|
}).sort((a, b) => (a.order - b.order));
|
|
|
|
const team = tabOrder.splice(originalOrder, 1);
|
|
tabOrder.splice(newOrder, 0, team[0]);
|
|
|
|
let teamIndex: number | undefined;
|
|
tabOrder.forEach((t, order) => {
|
|
if (order === newOrder) {
|
|
teamIndex = t.index;
|
|
}
|
|
tabs[t.index].order = order;
|
|
});
|
|
teams[currentTeamIndex].tabs = tabs;
|
|
this.setState({
|
|
config: {
|
|
...this.state.config,
|
|
teams,
|
|
},
|
|
});
|
|
this.teamConfigChange(teams);
|
|
return teamIndex;
|
|
};
|
|
|
|
teamConfigChange = async (updatedTeams: Team[]) => {
|
|
window.ipcRenderer.invoke(UPDATE_TEAMS, updatedTeams).then(() => {
|
|
this.reloadConfig();
|
|
});
|
|
};
|
|
|
|
reloadConfig = async () => {
|
|
const config = await this.requestConfig();
|
|
this.setState({config});
|
|
};
|
|
|
|
requestConfig = async (exitOnError?: boolean) => {
|
|
// todo: should we block?
|
|
try {
|
|
const configRequest = await window.ipcRenderer.invoke(GET_CONFIGURATION);
|
|
return configRequest;
|
|
} catch (err: any) {
|
|
console.log(`there was an error with the config: ${err}`);
|
|
if (exitOnError) {
|
|
window.ipcRenderer.send(QUIT, `unable to load configuration: ${err}`, err.stack);
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
openMenu = () => {
|
|
if (window.process.platform !== 'darwin') {
|
|
window.ipcRenderer.send('open-app-menu');
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const {config} = this.state;
|
|
if (!config) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<MainPage
|
|
teams={config.teams}
|
|
lastActiveTeam={config.lastActiveTeam}
|
|
moveTabs={this.moveTabs}
|
|
openMenu={this.openMenu}
|
|
darkMode={config.darkMode}
|
|
appName={config.appName}
|
|
useNativeWindow={config.useNativeWindow}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
window.ipcRenderer.invoke('get-app-version').then(({name, version}) => {
|
|
// eslint-disable-next-line no-undef
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore
|
|
console.log(`Starting ${name} v${version}${__HASH_VERSION__ ? ` commit: ${__HASH_VERSION__}` : ''}`);
|
|
});
|
|
|
|
ReactDOM.render(
|
|
<Root/>,
|
|
document.getElementById('app'),
|
|
);
|