diff --git a/ts/components/ConfirmationDialog.md b/ts/components/ConfirmationDialog.md
deleted file mode 100644
index 328ce1027831..000000000000
--- a/ts/components/ConfirmationDialog.md
+++ /dev/null
@@ -1,16 +0,0 @@
-#### All Options
-
-```jsx
-
- console.log('onClose')}
- onAffirmative={() => console.log('onAffirmative')}
- affirmativeText="Affirm"
- onNegative={() => console.log('onNegative')}
- negativeText="Negate"
- >
- asdf child
-
-
-```
diff --git a/ts/components/ConfirmationDialog.stories.tsx b/ts/components/ConfirmationDialog.stories.tsx
new file mode 100644
index 000000000000..e5f64537b087
--- /dev/null
+++ b/ts/components/ConfirmationDialog.stories.tsx
@@ -0,0 +1,40 @@
+import * as React from 'react';
+import { ConfirmationDialog } from './ConfirmationDialog';
+
+// @ts-ignore
+import { setup as setupI18n } from '../../js/modules/i18n';
+// @ts-ignore
+import enMessages from '../../_locales/en/messages.json';
+
+import { storiesOf } from '@storybook/react';
+import { action } from '@storybook/addon-actions';
+import { text } from '@storybook/addon-knobs';
+
+const i18n = setupI18n('en', enMessages);
+
+storiesOf('Components/ConfirmationDialog', module).add(
+ 'ConfirmationDialog',
+ () => {
+ return (
+
+ {text('Child text', 'asdf blip')}
+
+ );
+ }
+);
diff --git a/ts/components/ConfirmationDialog.tsx b/ts/components/ConfirmationDialog.tsx
index 98ab848da75e..bb836b4b450c 100644
--- a/ts/components/ConfirmationDialog.tsx
+++ b/ts/components/ConfirmationDialog.tsx
@@ -2,14 +2,18 @@ import * as React from 'react';
import classNames from 'classnames';
import { LocalizerType } from '../types/Util';
+export type ActionSpec = {
+ text: string;
+ action: () => unknown;
+ style?: 'affirmative' | 'negative';
+};
+
export type OwnProps = {
readonly i18n: LocalizerType;
readonly children: React.ReactNode;
- readonly affirmativeText?: string;
- readonly onAffirmative?: () => unknown;
+ readonly title?: string | React.ReactNode;
+ readonly actions: Array
;
readonly onClose: () => unknown;
- readonly negativeText?: string;
- readonly onNegative?: () => unknown;
};
export type Props = OwnProps;
@@ -21,15 +25,7 @@ function focusRef(el: HTMLElement | null) {
}
export const ConfirmationDialog = React.memo(
- ({
- i18n,
- onClose,
- children,
- onAffirmative,
- onNegative,
- affirmativeText,
- negativeText,
- }: Props) => {
+ ({ i18n, onClose, children, title, actions }: Props) => {
React.useEffect(() => {
const handler = ({ key }: KeyboardEvent) => {
if (key === 'Escape') {
@@ -52,22 +48,25 @@ export const ConfirmationDialog = React.memo(
[onClose]
);
- const handleNegative = React.useCallback(() => {
- onClose();
- if (onNegative) {
- onNegative();
- }
- }, [onClose, onNegative]);
-
- const handleAffirmative = React.useCallback(() => {
- onClose();
- if (onAffirmative) {
- onAffirmative();
- }
- }, [onClose, onAffirmative]);
+ const handleAction = React.useCallback(
+ (e: React.MouseEvent) => {
+ onClose();
+ if (e.currentTarget.dataset.action) {
+ const actionIndex = parseInt(e.currentTarget.dataset.action, 10);
+ const { action } = actions[actionIndex];
+ action();
+ }
+ },
+ [onClose, actions]
+ );
return (
+ {title ? (
+
+ {title}
+
+ ) : null}
{children}
@@ -79,28 +78,24 @@ export const ConfirmationDialog = React.memo(
>
{i18n('confirmation-dialog--Cancel')}
- {onNegative && negativeText ? (
+ {actions.map((action, i) => (
- ) : null}
- {onAffirmative && affirmativeText ? (
-
- ) : null}
+ ))}
);
diff --git a/ts/components/ConfirmationModal.tsx b/ts/components/ConfirmationModal.tsx
index b4d64714845b..748dd6b8f266 100644
--- a/ts/components/ConfirmationModal.tsx
+++ b/ts/components/ConfirmationModal.tsx
@@ -1,31 +1,21 @@
import * as React from 'react';
import { createPortal } from 'react-dom';
-import { ConfirmationDialog } from './ConfirmationDialog';
+import {
+ ConfirmationDialog,
+ Props as ConfirmationDialogProps,
+} from './ConfirmationDialog';
import { LocalizerType } from '../types/Util';
export type OwnProps = {
readonly i18n: LocalizerType;
- readonly children: React.ReactNode;
- readonly affirmativeText?: string;
- readonly onAffirmative?: () => unknown;
readonly onClose: () => unknown;
- readonly negativeText?: string;
- readonly onNegative?: () => unknown;
};
-export type Props = OwnProps;
+export type Props = OwnProps & ConfirmationDialogProps;
export const ConfirmationModal = React.memo(
// tslint:disable-next-line max-func-body-length
- ({
- i18n,
- onClose,
- children,
- onAffirmative,
- onNegative,
- affirmativeText,
- negativeText,
- }: Props) => {
+ ({ i18n, onClose, children, ...rest }: Props) => {
const [root, setRoot] = React.useState
(null);
React.useEffect(() => {
@@ -72,14 +62,7 @@ export const ConfirmationModal = React.memo(
className="module-confirmation-dialog__overlay"
onClick={handleCancel}
>
-
+
{children}
,
diff --git a/ts/components/MainHeader.tsx b/ts/components/MainHeader.tsx
index c0b9f28a41f7..a258a243993f 100644
--- a/ts/components/MainHeader.tsx
+++ b/ts/components/MainHeader.tsx
@@ -25,7 +25,7 @@ export interface PropsType {
phoneNumber: string;
isMe: boolean;
name?: string;
- color: ColorType;
+ color?: ColorType;
verified: boolean;
profileName?: string;
avatarPath?: string;
diff --git a/ts/components/conversation/ContactName.tsx b/ts/components/conversation/ContactName.tsx
index 2e82a7bb835e..e9c3bcbda133 100644
--- a/ts/components/conversation/ContactName.tsx
+++ b/ts/components/conversation/ContactName.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { Emojify } from './Emojify';
-interface Props {
+export interface Props {
phoneNumber?: string;
name?: string;
profileName?: string;
diff --git a/ts/components/conversation/ConversationHeader.stories.tsx b/ts/components/conversation/ConversationHeader.stories.tsx
index c43bb6fedb86..88141507a8b5 100644
--- a/ts/components/conversation/ConversationHeader.stories.tsx
+++ b/ts/components/conversation/ConversationHeader.stories.tsx
@@ -64,6 +64,7 @@ const stories: Array