diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 39e629741..924f8a0bd 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1827,5 +1827,11 @@ }, "orJoinOneOfThese": { "message": "Or join one of these..." + }, + "onionPathIndicatorTitle": { + "message": "Path" + }, + "onionPathIndicatorDescription": { + "message": "Session hides your IP by bouncing your messages through several Service Nodes in Session's decentralized network. These are the countries your connection is currently being bounced through:" } } diff --git a/ts/components/OnionStatusDialog.tsx b/ts/components/OnionStatusDialog.tsx new file mode 100644 index 000000000..47b666575 --- /dev/null +++ b/ts/components/OnionStatusDialog.tsx @@ -0,0 +1,336 @@ +import React, { useState } from 'react'; +import classNames from 'classnames'; +import { QRCode } from 'react-qr-svg'; + +import { Avatar, AvatarSize } from './Avatar'; + +import { SessionButton, SessionButtonColor, SessionButtonType } from './session/SessionButton'; + +import { SessionIconButton, SessionIconSize, SessionIconType } from './session/icon'; +import { SessionModal } from './session/SessionModal'; +import { PillDivider } from './session/PillDivider'; +import { ToastUtils, UserUtils } from '../session/utils'; +import { DefaultTheme } from 'styled-components'; +import { MAX_USERNAME_LENGTH } from './session/registration/RegistrationTabs'; +import { SessionSpinner } from './session/SessionSpinner'; + +// interface Props { +// i18n: any; +// profileName: string; +// avatarPath: string; +// pubkey: string; +// onClose: any; +// onOk: any; +// theme: DefaultTheme; +// } + +interface State { + profileName: string; + setProfileName: string; + avatar: string; + mode: 'default' | 'edit' | 'qr'; + loading: boolean; +} + +interface Props { + i18n: any; + theme: DefaultTheme; + nodes: Array; + onClose: any; +} + + + +export const OnionStatusDialog = (props: Props) => { + const {i18n, theme, onClose} = props.i18n; + + return ( + +
+ + {i18n('onionPathIndicatorDescription')} +
+
+ ); +} + +// export class OnionStatusDialog extends React.Component { +// private readonly inputEl: any; + +// constructor(props: any) { +// super(props); + +// this.onNameEdited = this.onNameEdited.bind(this); +// this.closeDialog = this.closeDialog.bind(this); +// this.onClickOK = this.onClickOK.bind(this); +// this.onKeyUp = this.onKeyUp.bind(this); +// this.onFileSelected = this.onFileSelected.bind(this); +// this.fireInputEvent = this.fireInputEvent.bind(this); + +// this.state = { +// profileName: this.props.profileName, +// setProfileName: this.props.profileName, +// avatar: this.props.avatarPath, +// mode: 'default', +// loading: false, +// }; + +// this.inputEl = React.createRef(); + +// window.addEventListener('keyup', this.onKeyUp); +// } + +// public render() { +// const i18n = this.props.i18n; + +// const viewDefault = this.state.mode === 'default'; +// const viewEdit = this.state.mode === 'edit'; +// const viewQR = this.state.mode === 'qr'; + +// const sessionID = UserUtils.getOurPubKeyStrFromCache(); + +// const backButton = +// viewEdit || viewQR +// ? [ +// { +// iconType: SessionIconType.Chevron, +// iconRotation: 90, +// onClick: () => { +// this.setState({ mode: 'default' }); +// }, +// }, +// ] +// : undefined; + +// return ( +// +//
+ +// {viewQR && this.renderQRView(sessionID)} +// {viewDefault && this.renderDefaultView()} +// {viewEdit && this.renderEditView()} + +//
+// +//

{sessionID}

+ +//
+// + +// {viewDefault || viewQR ? ( +// { +// this.copySessionID(sessionID); +// }} +// /> +// ) : ( +// !this.state.loading && ( +// +// ) +// )} + +//
+//
+// +// ); +// } + +// private renderProfileHeader() { +// return ( +// <> +//
+//
+// {this.renderAvatar()} +//
+// +//
+// { +// this.setState({ mode: 'qr' }); +// }} +// theme={this.props.theme} +// /> +//
+//
+//
+// +// ); +// } + +// private fireInputEvent() { +// this.setState({ mode: 'edit' }, () => { +// const el = this.inputEl.current; +// if (el) { +// el.click(); +// } +// }); +// } + +// private renderDefaultView() { +// return ( +// <> +// {this.renderProfileHeader()} + +//
+//

{this.state.setProfileName}

+// { +// this.setState({ mode: 'edit' }); +// }} +// theme={this.props.theme} +// /> +//
+// +// ); +// } + +// private renderEditView() { +// const placeholderText = window.i18n('displayName'); + +// return ( +// <> +// {this.renderProfileHeader()} +//
+// +//
+// +// ); +// } + +// private renderQRView(sessionID: string) { +// const bgColor = '#FFFFFF'; +// const fgColor = '#1B1B1B'; + +// return ( +//
+// +//
+// ); +// } + +// private onFileSelected() { +// const file = this.inputEl.current.files[0]; +// const url = window.URL.createObjectURL(file); + +// this.setState({ +// avatar: url, +// }); +// } + +// private renderAvatar() { +// const { avatar, profileName } = this.state; +// const { pubkey } = this.props; +// const userName = profileName || pubkey; + +// return ; +// } + +// private onNameEdited(event: any) { +// const newName = event.target.value.replace(window.displayNameRegex, ''); + +// this.setState(state => { +// return { +// ...state, +// profileName: newName, +// }; +// }); +// } + +// private onKeyUp(event: any) { +// switch (event.key) { +// case 'Enter': +// if (this.state.mode === 'edit') { +// this.onClickOK(); +// } +// break; +// case 'Esc': +// case 'Escape': +// this.closeDialog(); +// break; +// default: +// } +// } + +// private copySessionID(sessionID: string) { +// window.clipboard.writeText(sessionID); +// ToastUtils.pushCopiedToClipBoard(); +// } + +// private onClickOK() { +// const newName = this.state.profileName.trim(); + +// if (newName.length === 0 || newName.length > MAX_USERNAME_LENGTH) { +// return; +// } + +// const avatar = +// this.inputEl && +// this.inputEl.current && +// this.inputEl.current.files && +// this.inputEl.current.files.length > 0 +// ? this.inputEl.current.files[0] +// : null; + +// this.setState( +// { +// loading: true, +// }, +// async () => { +// await this.props.onOk(newName, avatar); +// this.setState({ +// loading: false, + +// mode: 'default', +// setProfileName: this.state.profileName, +// }); +// } +// ); +// } + +// private closeDialog() { +// window.removeEventListener('keyup', this.onKeyUp); + +// this.props.onClose(); +// } +// } diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 592955b45..67876fb4b 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -70,7 +70,7 @@ const Section = (props: { type: SectionType; avatarPath?: string }) => { } else if (type === SectionType.PathIndicator) { // Show Path Indicator Modal console.log("status clicked") - // window.showPathIndicatorDialog(); + // window.showOnionStatusDialog(); } else { dispatch(clearSearch());