Settings view modals and categories

pull/717/head
Vincent 5 years ago
parent 589f77a85f
commit e7d3bc6d35

@ -1162,6 +1162,14 @@
"message": "Delete Account",
"description": "Text for button in settings view to delete account"
},
"deleteAccountWarning": {
"message": "Are you sure you want to delete your account?",
"description": "Warning for account deletion in settings view"
},
"deleteAccountWarningSub": {
"message": "This is completely irreversible and will leave no trace.",
"description": "Warning for account deletion in settings view"
},
"deleteContact": {
"message": "Delete Contact",
"description":
@ -1341,7 +1349,7 @@
"description": "Text describing what the clear data button will do."
},
"clearDataButton": {
"message": "Clear data",
"message": "Clear Data",
"description":
"Button in the settings dialog starting process to delete all data"
},
@ -2471,5 +2479,29 @@
},
"decline": {
"message": "Decline"
},
"accountSettingsTitle": {
"message": "Account"
},
"accountSettingsDescription": {
"message": "Manage your account"
},
"privacySettingsTitle": {
"message": "Privacy"
},
"privacySettingsDescription": {
"message": "Privacy description"
},
"notificationSettingsTitle": {
"message": "Notifications"
},
"notificationSettingsDescription": {
"message": "Choose what you're notified about."
},
"devicesSettingsTitle": {
"message": "Devices"
},
"devicesSettingsDescription": {
"message": "Managed linked devices."
}
}

@ -807,15 +807,21 @@
el: $('#session-confirm-container'),
title: params.title,
message: params.message,
messageSub: params.messageSub || undefined,
resolve: params.resolve || undefined,
reject: params.reject || undefined,
okText: params.okText || undefined,
okTheme: params.okTheme || undefined,
closeTheme: params.closeTheme || undefined,
cancelText: params.cancelText || undefined,
hideCancel: params.hideCancel || false,
});
confirmDialog.render();
};
window.showSeedDialog = window.owsDesktopApp.appView.showSeedDialog;
window.generateID = () =>
Math.random()
.toString(36)
@ -866,6 +872,13 @@
return toastID;
};
window.deleteAccount = () => {
// Delete local data
// TOOD. MAKE THIS PROCESS SECURED WITH rm-secure
// https://www.npmjs.com/package/secure-rm
alert('YOUR ACCOUNT HAS BEEN DELETED');
}
window.sendGroupInvitations = (serverInfo, pubkeys) => {
pubkeys.forEach(async pubkey => {
const convo = await ConversationController.getOrCreateAndWait(
@ -1132,10 +1145,8 @@
});
Whisper.events.on('showSeedDialog', async () => {
const manager = await getAccountManager();
if (appView && manager) {
const seed = manager.getCurrentMnemonic();
appView.showSeedDialog(seed);
if (appView) {
appView.showSeedDialog();
}
});

@ -15,6 +15,8 @@
this.applyTheme();
this.applyHideMenu();
this.showSeedDialog = this.showSeedDialog.bind(this);
},
events: {
'click .openInstaller': 'openInstaller', // NetworkStatusView has this button
@ -200,8 +202,8 @@
const dialog = Whisper.PasswordDialogView();
this.el.append(dialog.el);
},
showSeedDialog(seed) {
const dialog = new Whisper.SeedDialogView({ seed });
showSeedDialog() {
const dialog = new Whisper.SeedDialogView();
this.el.append(dialog.el);
},
showQRDialog(string) {

@ -11,12 +11,15 @@
this.props = {
title: options.title,
message: options.message,
messageSub: options.messageSub,
onClickOk: this.ok.bind(this),
onClickClose: this.cancel.bind(this),
resolve: options.resolve,
reject: options.reject,
okText: options.okText,
cancelText: options.cancelText,
okTheme: options.okTheme,
closeTheme: options.closeTheme,
hideCancel: options.hideCancel,
};
},

@ -579,6 +579,7 @@ label {
font-size: 15px;
line-height: 13px;
margin-bottom: $session-margin-sm;
padding-top: 0px;
color: $session-color-white;
}
@ -698,6 +699,21 @@ label {
}
}
.session-confirm {
&-wrapper {
.session-modal__body .session-modal__centered{
margin: $session-margin-lg
}
}
&-main-message{
font-size: 15px;
}
&-sub-message {
margin-top: 5px;
}
}
.session-toggle {
width: 51px;
height: 31px;
@ -899,4 +915,3 @@ label {
.messages li {
transition: $session-transition-duration !important;
}

@ -265,8 +265,7 @@ $session-compose-margin: 20px;
.session-button.square-outline.square.green,
.session-button.square-outline.square.white,
.session-button.square-outline.square.danger
{
.session-button.square-outline.square.danger {
flex-grow: 1;
border: 1px solid $session-shade-7;
height: 50px;
@ -342,13 +341,13 @@ $session-compose-margin: 20px;
}
}
.left-pane-setting {
&-bottom-buttons {
@include bottom-buttons();
}
&-content, &-section {
&-content,
&-section {
display: flex;
flex-direction: column;
}
@ -364,22 +363,20 @@ $session-compose-margin: 20px;
padding: 0px 12px;
cursor: pointer;
transition: $session-transition-duration !important;
transition: $session-transition-duration !important;
&>div {
& > div {
display: block;
}
&.active{
&.active {
background-color: $session-shade-9;
}
&:hover{
&:hover {
background-color: $session-shade-7;
}
&__buttons {
display: flex;
@ -392,8 +389,11 @@ $session-compose-margin: 20px;
}
}
}
}
&-input-group {
display: inline-flex;
}
}
.panel-text-divider {
width: 100%;

@ -240,12 +240,8 @@ export class LeftPane extends React.Component<Props, State> {
}
private renderSettingSection() {
const {
} = this.props;
const {} = this.props;
return (
<LeftPaneSettingSection
/>
);
return <LeftPaneSettingSection />;
}
}

@ -148,7 +148,7 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
return;
}
// reset our pubKeyPasted, we can either have a pasted sessionID or a sessionID got from a search
this.setState({ pubKeyPasted: '' }, () => {
window.Session.emptyContentEditableDivs();
});
@ -171,7 +171,6 @@ export class LeftPaneContactSection extends React.Component<Props, any> {
public clearSearch() {
this.props.clearSearch();
//this.setFocus();
}
public search() {

@ -9,47 +9,48 @@ import {
SessionButtonType,
} from './SessionButton';
import {
SessionIcon,
SessionIconSize,
SessionIconType,
} from './icon';
import { SessionIcon, SessionIconSize, SessionIconType } from './icon';
import { SessionSearchInput } from './SessionSearchInput';
import { Session } from 'inspector';
export enum SessionSettingCategory {
Account = 'account',
Privacy = 'privacy',
Notifications = 'notifications',
Devices = 'devices',
}
export interface Props {
}
export interface Props {}
export interface State {
settingCategory: SessionSettingCategory;
searchQuery: string;
}
export class LeftPaneSettingSection extends React.Component<Props, State> {
//private readonly updateSearchBound: (searchedString: string) => void;
public constructor(props: Props) {
super(props);
this.state = {
settingCategory: SessionSettingCategory.Privacy,
searchQuery: '',
};
this.setCategory = this.setCategory.bind(this);
this.renderRows = this.renderRows.bind(this);
//this.updateSearchBound = this.updateSearch.bind(this);
}
public render(): JSX.Element {
return (
<div className="left-pane-setting-section">
{this.renderHeader()}
{this.renderSettings()}
{this.renderHeader()}
{this.renderSettings()}
</div>
);
}
@ -62,67 +63,78 @@ export class LeftPaneSettingSection extends React.Component<Props, State> {
null,
undefined,
undefined,
undefined,
undefined
);
}
public renderRows () {
public renderRows(): JSX.Element {
const categories = this.getCategories();
return (
<>
{categories.map((item) => (
<div
key={item.id}
className={classNames('left-pane-setting-category-list-item', item.id === this.state.settingCategory ? 'active' : '')}
onClick={() => this.setCategory(item.id)}
>
<div>
<strong>{ item.title }</strong>
<br/>
<span className="text-subtle">
{item.description }
</span>
</div>
<div>
{ item.id === this.state.settingCategory &&
<SessionIcon
iconSize={SessionIconSize.Medium}
iconType={SessionIconType.Chevron}
iconRotation={270}
/>
}
</div>
{categories.map(item => (
<div
key={item.id}
className={classNames(
'left-pane-setting-category-list-item',
item.id === this.state.settingCategory ? 'active' : ''
)}
onClick={() => this.setCategory(item.id)}
>
<div>
<strong>{item.title}</strong>
<br />
<span className="text-subtle">{item.description}</span>
</div>
))}
<div>
{item.id === this.state.settingCategory && (
<SessionIcon
iconSize={SessionIconSize.Medium}
iconType={SessionIconType.Chevron}
iconRotation={270}
/>
)}
</div>
</div>
))}
</>
);
}
public renderCategories() {
public renderCategories(): JSX.Element {
return (
<div className="module-left-pane__list" key={0}>
<div className="left-pane-setting-category-list">
{this.renderRows()}
</div>
<div className="left-pane-setting-category-list">
{this.renderRows()}
</div>
</div>
)
);
}
public renderSettings(): JSX.Element {
return (
<div className="left-pane-setting-content">
<div className="left-pane-setting-input-group">
<SessionSearchInput
searchString={this.state.searchQuery}
onChange={() => null}
placeholder=''
/>
<div className="left-pane-setting-input-button">
<SessionButton
buttonType={SessionButtonType.Square}
buttonColor={SessionButtonColor.Green}
text={'>'}
/>
</div>
</div>
{this.renderCategories()}
{this.renderBottomButtons()}
</div>
);
}
public renderBottomButtons(): JSX.Element {
const deleteAccount = window.i18n('deleteAccount');
const showSeed = window.i18n('showSeed');
@ -133,33 +145,54 @@ export class LeftPaneSettingSection extends React.Component<Props, State> {
text={deleteAccount}
buttonType={SessionButtonType.SquareOutline}
buttonColor={SessionButtonColor.Danger}
onClick={this.onDeleteAccount}
/>
<SessionButton
text={showSeed}
buttonType={SessionButtonType.SquareOutline}
buttonColor={SessionButtonColor.White}
onClick={window.showSeedDialog}
/>
</div>
);
}
public getCategories(){
public onDeleteAccount() {
const params = {
title: window.i18n('deleteAccount'),
message: window.i18n('deleteAccountWarning'),
messageSub: window.i18n('deleteAccountWarningSub'),
resolve: window.deleteAccount,
okTheme: 'danger',
};
window.confirmationDialog(params);
}
public getCategories() {
return [
{
id: SessionSettingCategory.Account,
title: window.i18n('accountSettingsTitle'),
description: window.i18n('accountSettingsDescription'),
},
{
id: SessionSettingCategory.Privacy,
title: 'Privacy',
description: 'Privacy description',
title: window.i18n('privacySettingsTitle'),
description: window.i18n('privacySettingsDescription'),
},
{
id: SessionSettingCategory.Notifications,
title: 'Notifications',
description: "Choose what you're notified about."
title: window.i18n('notificationSettingsTitle'),
description: window.i18n('notificationSettingsDescription'),
},
{
id: SessionSettingCategory.Devices,
title: 'Linked Devices',
description: "Managed linked devices."
}
title: window.i18n('devicesSettingsTitle'),
description: window.i18n('devicesSettingsDescription'),
},
];
}
@ -168,4 +201,34 @@ export class LeftPaneSettingSection extends React.Component<Props, State> {
settingCategory: category,
});
}
// public updateSearch(searchTerm: string) {
// const { updateSearchTerm, clearSearch } = this.props;
// if (!searchTerm) {
// clearSearch();
// return;
// }
// // reset our pubKeyPasted, we can either have a pasted sessionID or a sessionID got from a search
// this.setState({ pubKeyPasted: '' }, () => {
// window.Session.emptyContentEditableDivs();
// });
// if (updateSearchTerm) {
// updateSearchTerm(searchTerm);
// }
// if (searchTerm.length < 2) {
// return;
// }
// const cleanedTerm = cleanSearchTerm(searchTerm);
// if (!cleanedTerm) {
// return;
// }
// this.debouncedSearch(cleanedTerm);
// }
}

@ -1,9 +1,10 @@
import React from 'react';
import { SessionModal } from './SessionModal';
import { SessionButton } from './SessionButton';
import { SessionButton, SessionButtonColor } from './SessionButton';
interface Props {
message: string;
messageSub: string;
title: string;
onOk?: any;
onClose?: any;
@ -12,11 +13,16 @@ interface Props {
okText?: string;
cancelText?: string;
hideCancel: boolean;
okTheme: SessionButtonColor;
closeTheme: SessionButtonColor;
}
export class SessionConfirm extends React.Component<Props> {
public static defaultProps = {
title: '',
messageSub: '',
okTheme: SessionButtonColor.Primary,
closeTheme: SessionButtonColor.Primary,
hideCancel: false,
};
@ -25,7 +31,7 @@ export class SessionConfirm extends React.Component<Props> {
}
public render() {
const { title, message, onClickOk, onClickClose, hideCancel } = this.props;
const { title, message, messageSub, okTheme, closeTheme, onClickOk, onClickClose, hideCancel } = this.props;
const okText = this.props.okText || window.i18n('ok');
const cancelText = this.props.cancelText || window.i18n('cancel');
@ -42,19 +48,31 @@ export class SessionConfirm extends React.Component<Props> {
{!showHeader && <div className="spacer-lg" />}
<div className="session-modal__centered">
<span className="text-subtle">{message}</span>
<span className={ messageSub ? "session-confirm-main-message" : "text-subtle" }>{message}</span>
{ messageSub && (
<span className="session-confirm-sub-message text-subtle">{messageSub}</span>
)}
</div>
<div className="spacer-lg" />
<div className="session-modal__button-group">
<SessionButton text={okText} onClick={onClickOk} />
<SessionButton
text={okText}
buttonColor={okTheme}
onClick={onClickOk}
/>
{!hideCancel && (
<SessionButton text={cancelText} onClick={onClickClose} />
<SessionButton
text={cancelText}
buttonColor={closeTheme}
onClick={onClickClose}
/>
)}
</div>
</SessionModal>
);
}
}

@ -32,7 +32,7 @@ export class SessionQRModal extends React.Component<Props> {
<div className="spacer-sm" />
<div className="qr-dialog__description text-subtle">
<SessionHtmlRenderer html={window.i18n('QRCodeDescription')} />
<SessionHtmlRenderer html={window.i18n('QRCodeDescription')} />
</div>
<div className="spacer-lg" />

@ -213,6 +213,7 @@ export class SessionSeedModal extends React.Component<Props, State> {
title: window.i18n('copiedMnemonic'),
type: 'success',
id: 'copySeedToast',
shouldFade: false,
});
}

@ -20,7 +20,6 @@ interface Props {
id?: string;
type?: SessionToastType;
description?: string;
fadeToast: any;
closeToast: any;
}

4
ts/global.d.ts vendored

@ -1,5 +1,7 @@
interface Window {
Events: any;
deleteAllData: any;
deleteAccount: any;
getAccountManager: any;
mnemonic: any;
clipboard: any;
@ -19,6 +21,8 @@ interface Window {
generateID: any;
storage: any;
pushToast: any;
confirmationDialog: any;
showSeedDialog: any;
}
interface Promise<T> {

Loading…
Cancel
Save