diff --git a/stylesheets/components/SafetyNumberViewer.scss b/stylesheets/components/SafetyNumberViewer.scss index c7226497f5e7..77a04339de39 100644 --- a/stylesheets/components/SafetyNumberViewer.scss +++ b/stylesheets/components/SafetyNumberViewer.scss @@ -74,35 +74,8 @@ text-align: center; } - &__close-button { - display: flex; - justify-content: flex-end; - - button { - background: inherit; - border: none; - cursor: pointer; - padding: 0; - - @include keyboard-mode { - &:focus { - border: 1px solid $color-ultramarine; - } - } - - span { - display: inline-block; - height: 24px; - width: 24px; - - @include light-theme { - @include color-svg('../images/icons/v2/x-24.svg', $color-gray-60); - } - @include dark-theme { - @include color-svg('../images/icons/v2/x-24.svg', $color-gray-05); - } - } - } + &__buttons { + text-align: right; } &__button { diff --git a/ts/components/CallManager.stories.tsx b/ts/components/CallManager.stories.tsx index 8d97fcd5c25e..b177c06e8b24 100644 --- a/ts/components/CallManager.stories.tsx +++ b/ts/components/CallManager.stories.tsx @@ -21,7 +21,7 @@ import { AvatarColors } from '../types/Colors'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource'; import { setupI18n } from '../util/setupI18n'; -import type { Props as SafetyNumberViewerProps } from '../state/smart/SafetyNumberViewer'; +import type { SafetyNumberProps } from './SafetyNumberChangeDialog'; import enMessages from '../../_locales/en/messages.json'; import { ThemeType } from '../types/Util'; @@ -90,7 +90,7 @@ const createProps = (storyProps: Partial = {}): PropsType => ({ openSystemPreferencesAction: action('open-system-preferences-action'), playRingtone: action('play-ringtone'), renderDeviceSelection: () =>
, - renderSafetyNumberViewer: (_: SafetyNumberViewerProps) =>
, + renderSafetyNumberViewer: (_: SafetyNumberProps) =>
, setGroupCallVideoRequest: action('set-group-call-video-request'), setIsCallActive: action('set-is-call-active'), setLocalAudio: action('set-local-audio'), diff --git a/ts/components/SafetyNumberChangeDialog.tsx b/ts/components/SafetyNumberChangeDialog.tsx index 22ee8d07347a..fa49bfc3c8c7 100644 --- a/ts/components/SafetyNumberChangeDialog.tsx +++ b/ts/components/SafetyNumberChangeDialog.tsx @@ -16,7 +16,7 @@ import { isInSystemContacts } from '../util/isInSystemContacts'; export type SafetyNumberProps = { contactID: string; - onClose?: () => void; + onClose: () => void; }; export type Props = { @@ -59,7 +59,7 @@ export const SafetyNumberChangeDialog = ({ if (selectedContact) { return ( - + {renderSafetyNumber({ contactID: selectedContact.id, onClose })} ); diff --git a/ts/components/SafetyNumberModal.tsx b/ts/components/SafetyNumberModal.tsx index 7d7e42607878..d1eae750939b 100644 --- a/ts/components/SafetyNumberModal.tsx +++ b/ts/components/SafetyNumberModal.tsx @@ -8,7 +8,7 @@ import { SafetyNumberViewer } from './SafetyNumberViewer'; type PropsType = { toggleSafetyNumberModal: () => unknown; -} & SafetyNumberViewerPropsType; +} & Omit; export const SafetyNumberModal = ({ i18n, @@ -20,10 +20,14 @@ export const SafetyNumberModal = ({ hasXButton i18n={i18n} moduleClassName="module-SafetyNumberViewer__modal" - onClose={() => toggleSafetyNumberModal()} + onClose={toggleSafetyNumberModal} title={i18n('SafetyNumberModal__title')} > - + ); }; diff --git a/ts/components/SafetyNumberViewer.stories.tsx b/ts/components/SafetyNumberViewer.stories.tsx index 4c904eb4a549..10526053e600 100644 --- a/ts/components/SafetyNumberViewer.stories.tsx +++ b/ts/components/SafetyNumberViewer.stories.tsx @@ -58,7 +58,7 @@ const createProps = (overrideProps: Partial = {}): PropsType => ({ ? overrideProps.verificationDisabled : false ), - onClose: overrideProps.onClose, + onClose: action('onClose'), }); const story = storiesOf('Components/SafetyNumberViewer', module); diff --git a/ts/components/SafetyNumberViewer.tsx b/ts/components/SafetyNumberViewer.tsx index 1200eca148e4..e2519d54239d 100644 --- a/ts/components/SafetyNumberViewer.tsx +++ b/ts/components/SafetyNumberViewer.tsx @@ -8,10 +8,10 @@ import { Intl } from './Intl'; import type { LocalizerType } from '../types/Util'; export type PropsType = { - contact?: ConversationType; + contact: ConversationType; generateSafetyNumber: (contact: ConversationType) => void; i18n: LocalizerType; - onClose?: () => void; + onClose: () => void; safetyNumber: string; toggleVerified: (contact: ConversationType) => void; verificationDisabled: boolean; @@ -41,7 +41,16 @@ export const SafetyNumberViewer = ({ if (!contact.phoneNumber) { return (
- {i18n('cannotGenerateSafetyNumber')} +
{i18n('cannotGenerateSafetyNumber')}
+
+ +
); } @@ -60,13 +69,6 @@ export const SafetyNumberViewer = ({ return (
- {onClose && ( -
- -
- )}
{safetyNumber || getPlaceholder()}
diff --git a/ts/state/roots/createSafetyNumberViewer.tsx b/ts/state/roots/createSafetyNumberViewer.tsx index 20f610ad3bb9..8c0fd0c3e357 100644 --- a/ts/state/roots/createSafetyNumberViewer.tsx +++ b/ts/state/roots/createSafetyNumberViewer.tsx @@ -6,16 +6,12 @@ import { Provider } from 'react-redux'; import type { Store } from 'redux'; +import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog'; import { SmartSafetyNumberViewer } from '../smart/SafetyNumberViewer'; -type Props = { - contactID: string; - onClose?: () => void; -}; - export const createSafetyNumberViewer = ( store: Store, - props: Props + props: SafetyNumberProps ): React.ReactElement => ( diff --git a/ts/state/smart/CallManager.tsx b/ts/state/smart/CallManager.tsx index 0fdd6b06f8fd..d6e0eac8e9ed 100644 --- a/ts/state/smart/CallManager.tsx +++ b/ts/state/smart/CallManager.tsx @@ -22,7 +22,7 @@ import { CallMode, CallState } from '../../types/Calling'; import type { StateType } from '../reducer'; import { missingCaseError } from '../../util/missingCaseError'; import { SmartCallingDeviceSelection } from './CallingDeviceSelection'; -import type { Props as SafetyNumberViewerProps } from './SafetyNumberViewer'; +import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog'; import { SmartSafetyNumberViewer } from './SafetyNumberViewer'; import { callingTones } from '../../util/callingTones'; import { @@ -41,7 +41,7 @@ function renderDeviceSelection(): JSX.Element { return ; } -function renderSafetyNumberViewer(props: SafetyNumberViewerProps): JSX.Element { +function renderSafetyNumberViewer(props: SafetyNumberProps): JSX.Element { return ; } diff --git a/ts/state/smart/SafetyNumberViewer.tsx b/ts/state/smart/SafetyNumberViewer.tsx index c170dd94b7fd..b40226ef3d22 100644 --- a/ts/state/smart/SafetyNumberViewer.tsx +++ b/ts/state/smart/SafetyNumberViewer.tsx @@ -5,16 +5,12 @@ import { connect } from 'react-redux'; import { mapDispatchToProps } from '../actions'; import { SafetyNumberViewer } from '../../components/SafetyNumberViewer'; import type { StateType } from '../reducer'; +import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog'; import { getContactSafetyNumber } from '../selectors/safetyNumber'; import { getConversationSelector } from '../selectors/conversations'; import { getIntl } from '../selectors/user'; -export type Props = { - contactID: string; - onClose?: () => void; -}; - -const mapStateToProps = (state: StateType, props: Props) => { +const mapStateToProps = (state: StateType, props: SafetyNumberProps) => { return { ...props, ...getContactSafetyNumber(state, props),