Finishing up some modals
parent
66911d6f06
commit
6ee5d041fb
@ -0,0 +1,55 @@
|
|||||||
|
/* global Whisper */
|
||||||
|
|
||||||
|
// eslint-disable-next-line func-names
|
||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
|
Whisper.SessionConfirmView = Whisper.View.extend({
|
||||||
|
initialize(options) {
|
||||||
|
this.props = {
|
||||||
|
title: options.title,
|
||||||
|
message: options.message,
|
||||||
|
onClickOk: this.ok.bind(this),
|
||||||
|
onClickClose: this.cancel.bind(this),
|
||||||
|
resolve: options.resolve,
|
||||||
|
reject: options.reject,
|
||||||
|
okText: options.okText,
|
||||||
|
cancelText: options.cancelText,
|
||||||
|
hideCancel: options.hideCancel,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
this.$('.session-confirm-wrapper').remove();
|
||||||
|
|
||||||
|
this.confirmView = new Whisper.ReactWrapperView({
|
||||||
|
className: 'session-confirm-wrapper',
|
||||||
|
Component: window.Signal.Components.SessionConfirm,
|
||||||
|
props: this.props,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$el.append(this.confirmView.el);
|
||||||
|
},
|
||||||
|
|
||||||
|
ok() {
|
||||||
|
this.$('.session-confirm-wrapper').remove();
|
||||||
|
if (this.props.resolve){
|
||||||
|
this.props.resolve()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
this.$('.session-confirm-wrapper').remove();
|
||||||
|
if (this.props.reject) {
|
||||||
|
this.props.reject()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onKeyup(event) {
|
||||||
|
if (event.key === 'Escape' || event.key === 'Esc') {
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
})();
|
@ -0,0 +1,76 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { SessionModal } from './SessionModal';
|
||||||
|
import { SessionButton } from './SessionButton';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
message: string;
|
||||||
|
title: string;
|
||||||
|
onOk?: any;
|
||||||
|
onClose?: any;
|
||||||
|
onClickOk: any,
|
||||||
|
onClickClose: any,
|
||||||
|
okText?: string;
|
||||||
|
cancelText?: string;
|
||||||
|
hideCancel: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SessionConfirm extends React.Component<Props> {
|
||||||
|
public static defaultProps = {
|
||||||
|
title: '',
|
||||||
|
hideCancel: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(props: any) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
public render() {
|
||||||
|
const { title,
|
||||||
|
message,
|
||||||
|
onClickOk,
|
||||||
|
onClickClose,
|
||||||
|
hideCancel,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
const okText = this.props.okText || window.i18n('ok');
|
||||||
|
const cancelText = this.props.cancelText || window.i18n('cancel');
|
||||||
|
const showHeader = !! this.props.title;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SessionModal
|
||||||
|
title={title}
|
||||||
|
onClose={() => null}
|
||||||
|
onOk={() => null}
|
||||||
|
showExitIcon={false}
|
||||||
|
showHeader={showHeader}
|
||||||
|
>
|
||||||
|
{ showHeader ? null : (
|
||||||
|
<div className="spacer-lg"></div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="session-modal__centered">
|
||||||
|
<span className="text-subtle">
|
||||||
|
{message}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="spacer-lg"></div>
|
||||||
|
|
||||||
|
<div className="session-modal__button-group">
|
||||||
|
<SessionButton
|
||||||
|
text={okText}
|
||||||
|
onClick={onClickOk}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{ hideCancel ? null : (
|
||||||
|
<SessionButton
|
||||||
|
text={cancelText}
|
||||||
|
onClick={onClickClose}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</SessionModal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue