summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/WireguardKeysPage.tsx
blob: b0c25e06a9d437b948ceaddc6d9932c0ef3743c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { connect } from 'react-redux';
import { links } from '../../config.json';
import WireguardKeys from '../components/WireguardKeys';
import withAppContext, { IAppContext } from '../context';
import { IHistoryProps, withHistory } from '../lib/history';
import { IWgKey } from '../redux/settings/reducers';
import { IReduxState, ReduxDispatch } from '../redux/store';

const mapStateToProps = (state: IReduxState) => ({
  keyState: state.settings.wireguardKeyState,
  isOffline: state.connection.isBlocked,
  tunnelState: state.connection.status,
  windowFocused: state.userInterface.windowFocused,
});
const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAppContext) => {
  return {
    onClose: () => props.history.pop(),
    onGenerateKey: () => props.app.generateWireguardKey(),
    onReplaceKey: (oldKey: IWgKey) => props.app.replaceWireguardKey(oldKey),
    onVerifyKey: (publicKey: IWgKey) => props.app.verifyWireguardKey(publicKey),
    onVisitWebsiteKey: () => props.app.openLinkWithAuth(links.manageKeys),
  };
};

export default withAppContext(
  withHistory(connect(mapStateToProps, mapDispatchToProps)(WireguardKeys)),
);