From fae74d257047a58d631521f78fe568861017bc2e Mon Sep 17 00:00:00 2001 From: Sam Hariri <137707942+samh-nl@users.noreply.github.com> Date: Mon, 31 Jul 2023 12:07:25 +0200 Subject: [PATCH 1/4] fix: disable confirm button if offline --- src/components/ConfirmContent.js | 16 +++++++++++++++- src/components/ConfirmModal.js | 5 +++++ src/pages/settings/Security/CloseAccountPage.js | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/components/ConfirmContent.js b/src/components/ConfirmContent.js index 7af2eb6d1d3e..d7d222da1e67 100644 --- a/src/components/ConfirmContent.js +++ b/src/components/ConfirmContent.js @@ -6,6 +6,9 @@ import Header from './Header'; import styles from '../styles/styles'; import Button from './Button'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; +import {withNetwork} from './OnyxProvider'; +import networkPropTypes from './networkPropTypes'; +import compose from '../libs/compose'; import Text from './Text'; const propTypes = { @@ -33,6 +36,9 @@ const propTypes = { /** Whether we should use the danger button color. Use if the action is destructive */ danger: PropTypes.bool, + /** Whether we should disable the confirm button when offline */ + shouldDisableConfirmButtonWhenOffline: PropTypes.bool, + /** Whether we should show the cancel button */ shouldShowCancelButton: PropTypes.bool, @@ -40,6 +46,9 @@ const propTypes = { // eslint-disable-next-line react/forbid-prop-types contentStyles: PropTypes.arrayOf(PropTypes.object), + /** Information about the network */ + network: networkPropTypes.isRequired, + ...withLocalizePropTypes, }; @@ -50,6 +59,7 @@ const defaultProps = { success: true, danger: false, onCancel: () => {}, + shouldDisableConfirmButtonWhenOffline: false, shouldShowCancelButton: true, contentStyles: [], }; @@ -70,6 +80,7 @@ function ConfirmContent(props) { onPress={props.onConfirm} pressOnEnter text={props.confirmText || props.translate('common.yes')} + isDisabled={props.network.isOffline && props.shouldDisableConfirmButtonWhenOffline} /> {props.shouldShowCancelButton && (