Skip to content

Commit

Permalink
Revert "[CP-2193] I want to be informed about problem with connecting…
Browse files Browse the repository at this point in the history
… a device (#1395)"

This reverts commit 8ca1e54.
  • Loading branch information
OskarMichalkiewicz committed Oct 2, 2023
1 parent 04401ce commit 3f16534
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ interface Props {
osVersion: string | undefined
checkingForOsForceUpdate: boolean
shouldCheckForForceUpdateNeed: boolean
initializationFailed: boolean
}

const BaseApp: FunctionComponent<Props> = ({
Expand All @@ -69,7 +68,6 @@ const BaseApp: FunctionComponent<Props> = ({
osVersion,
checkingForOsForceUpdate,
shouldCheckForForceUpdateNeed,
initializationFailed,
}) => {
useRouterListener(history, {
[URL_MAIN.contacts]: [],
Expand All @@ -95,12 +93,7 @@ const BaseApp: FunctionComponent<Props> = ({
return
}

if (
deviceConnecting ||
deviceLocked ||
checkingForOsForceUpdate ||
initializationFailed
) {
if (deviceConnecting || deviceLocked || checkingForOsForceUpdate) {
history.push(URL_ONBOARDING.connecting)
} else if (!deviceFeaturesVisible) {
history.push(URL_ONBOARDING.welcome)
Expand Down Expand Up @@ -161,7 +154,6 @@ const isDeviceRestarting = (state: RootState & ReduxRootState): boolean => {

const mapStateToProps = (state: RootState & ReduxRootState) => {
return {
initializationFailed: !state.dataSync.initialized,
deviceFeaturesVisible:
(state.device.status.connected &&
Boolean(state.device.status.unlocked)) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { modalsManagerReducer } from "App/modals-manager/reducers"
import { settingsReducer } from "App/settings/reducers"
import { checkUpdateAvailable } from "App/settings/actions/check-update-available.action"
import { updateOsReducer } from "App/update/reducers"
import { dataSyncReducer } from "App/data-sync/reducers"

jest.mock("App/settings/actions/check-update-available.action")

Expand Down Expand Up @@ -110,7 +109,6 @@ const store = init({
modalsManager: modalsManagerReducer,
settings: settingsReducer,
update: updateOsReducer,
dataSync: dataSyncReducer,
},
},
}) as Store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import Loader from "App/__deprecated__/renderer/components/core/loader/loader.co
import { LoaderType } from "App/__deprecated__/renderer/components/core/loader/loader.interface"
import styled from "styled-components"
import { backgroundColor } from "App/__deprecated__/renderer/styles/theming/theme-getters"
import { useSelector } from "react-redux"
import { ReduxRootState } from "App/__deprecated__/renderer/store"

export const Container = styled.section`
display: grid;
Expand Down Expand Up @@ -49,7 +47,6 @@ interface Props {
}

const ConnectingContent: FunctionComponent<Props> = ({ longerConnection }) => {
const { initialized } = useSelector((state: ReduxRootState) => state.dataSync)
return (
<Container>
<main>
Expand All @@ -59,10 +56,9 @@ const ConnectingContent: FunctionComponent<Props> = ({ longerConnection }) => {
<Text
displayStyle={TextDisplayStyle.Headline3}
message={{
id:
longerConnection && initialized
? "module.onboarding.connectingLongMessage"
: "module.onboarding.connectingMessage",
id: longerConnection
? "module.onboarding.connectingLongMessage"
: "module.onboarding.connectingMessage",
}}
/>
</main>
Expand Down
8 changes: 1 addition & 7 deletions packages/app/src/connecting/components/connecting.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { SynchronizationState } from "App/data-sync/reducers"
import { DeviceType } from "App/device/constants"
import { RequestResponseStatus } from "App/core/types/request-response.interface"
import { CriticalBatteryLevelModalTestIds } from "App/connecting/components/critical-battery-level-modal/critical-battery-level-modal-test-ids.enum"
import { Provider } from "react-redux"
import store from "App/__deprecated__/renderer/store"

jest.mock("App/connecting/requests/register-first-phone-connection")

Expand Down Expand Up @@ -48,11 +46,7 @@ const render = (extraProps?: Partial<Props>) => {
...defaultProps,
...extraProps,
}
const outcome = renderWithThemeAndIntl(
<Provider store={store}>
<Connecting {...props} />
</Provider>
)
const outcome = renderWithThemeAndIntl(<Connecting {...props} />)
return {
...outcome,
}
Expand Down
69 changes: 20 additions & 49 deletions packages/app/src/connecting/components/error-connecting-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,20 @@
*/

import { FunctionComponent } from "App/__deprecated__/renderer/types/function-component.interface"
import { intl, textFormatters } from "App/__deprecated__/renderer/utils/intl"
import { intl } from "App/__deprecated__/renderer/utils/intl"
import { RoundIconWrapper } from "App/__deprecated__/renderer/components/core/modal-shared/modal-shared"
import Icon from "App/__deprecated__/renderer/components/core/icon/icon.component"
import Text, {
TextDisplayStyle,
} from "App/__deprecated__/renderer/components/core/text/text.component"
import { ModalText } from "App/contacts/components/sync-contacts-modal/sync-contacts.styled"
import { TextDisplayStyle } from "App/__deprecated__/renderer/components/core/text/text.component"
import React, { ComponentProps } from "react"
import { defineMessages } from "react-intl"
import styled from "styled-components"
import {
ModalContent,
ModalDialog,
RoundIconWrapper,
} from "App/ui/components/modal-dialog"
import { ModalDialog } from "App/ui/components/modal-dialog"
import { ModalSize } from "App/__deprecated__/renderer/components/core/modal/modal.interface"
import { Size } from "App/__deprecated__/renderer/components/core/button/button.config"
import { ErrorConnectingModalTestIds } from "App/connecting/components/error-connecting-modal-test-ids.enum"
import { IconType } from "App/__deprecated__/renderer/components/core/icon/icon-type"
import { ModalLayers } from "App/modals-manager/constants/modal-layers.enum"
import {
fontWeight,
textColor,
} from "App/__deprecated__/renderer/styles/theming/theme-getters"
import { ipcRenderer } from "electron-better-ipc"
import { HelpActions } from "App/__deprecated__/common/enums/help-actions.enum"

const messages = defineMessages({
errorConnectingModalHeaderTitle: {
Expand All @@ -43,23 +33,20 @@ const messages = defineMessages({
id: "module.connecting.errorConnectingDescription",
},
})
const StyledLink = styled.a`
text-decoration: underline;
cursor: pointer;
font-size: 1.4rem;
font-weight: ${fontWeight("default")};
color: ${textColor("action")};
`
const StyledModalContent = styled(ModalContent)`
p {
text-align: left;

const ModalContent = styled.div`
display: flex;
flex-direction: column;
align-items: center;
p:first-of-type {
margin-top: 0;
}
`

const ErrorConnectingModal: FunctionComponent<
ComponentProps<typeof ModalDialog>
> = ({ onClose, ...props }) => {
const openHelpWindow = () => ipcRenderer.callMain(HelpActions.OpenWindow)
return (
<ModalDialog
testId={ErrorConnectingModalTestIds.Container}
Expand All @@ -74,35 +61,19 @@ const ErrorConnectingModal: FunctionComponent<
layer={ModalLayers.ErrorConnecting}
{...props}
>
<StyledModalContent>
<ModalContent>
<RoundIconWrapper>
<Icon type={IconType.ThinFail} width={3.2} />
</RoundIconWrapper>
<Text
displayStyle={TextDisplayStyle.Paragraph4}
color="secondary"
message={{
...messages.errorConnectingModalTitle,
values: {
...textFormatters,
},
}}
<ModalText
displayStyle={TextDisplayStyle.Headline4}
message={messages.errorConnectingModalTitle}
/>
<Text
<ModalText
displayStyle={TextDisplayStyle.Paragraph4}
color="secondary"
message={{
...messages.errorConnectingDescription,
values: {
link: (
<StyledLink onClick={openHelpWindow}>
connection help page.
</StyledLink>
),
},
}}
message={messages.errorConnectingDescription}
/>
</StyledModalContent>
</ModalContent>
</ModalDialog>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const defaultProps: Props = {
appForcedUpdateFlowShow: false,
appUpdateFlowShow: false,
contactSupportFlowShow: false,
deviceInitializationFailedModalShowEnabled: false,
hideModals: jest.fn(),
}

Expand Down Expand Up @@ -152,4 +153,25 @@ describe("`ModalsManager` component", () => {
).not.toBeInTheDocument()
})
})

describe("when component is render with proper where `deviceInitializationFailedModalShowEnabled` is set to `true`", () => {
test("`ErrorConnectingModal` is visible", () => {
const { queryByTestId } = render({
deviceInitializationFailedModalShowEnabled: true,
})

expect(
queryByTestId(ErrorConnectingModalTestIds.Container)
).toBeInTheDocument()
expect(
queryByTestId(ContactSupportFlowTestIds.ContactSupportModal)
).not.toBeInTheDocument()
expect(
queryByTestId(AppUpdateFlowTestIds.Container)
).not.toBeInTheDocument()
expect(
queryByTestId(AppForcedUpdateFlowTestIds.Container)
).not.toBeInTheDocument()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "App/settings/components"
import ContactSupportFlow from "App/contact-support/containers/contact-support-flow.container"
import { UpdateOsInterruptedFlowContainer } from "App/update/components/update-os-interrupted-flow"
import ErrorConnectingModal from "App/connecting/components/error-connecting-modal"
import { useSelector } from "react-redux"
import { ReduxRootState } from "App/__deprecated__/renderer/store"
import PrivacyPolicyModal from "App/settings/components/privacy-policy-modal/privacy-policy-modal.component"
Expand All @@ -19,13 +20,16 @@ type Props = {
appForcedUpdateFlowShow: boolean
appUpdateFlowShow: boolean
contactSupportFlowShow: boolean
deviceInitializationFailedModalShowEnabled: boolean
hideModals: () => void
}

const ModalsManager: FunctionComponent<Props> = ({
appForcedUpdateFlowShow,
appUpdateFlowShow,
contactSupportFlowShow,
deviceInitializationFailedModalShowEnabled,
hideModals,
}) => {
const { privacyPolicyAccepted } = useSelector(
(state: ReduxRootState) => state.settings
Expand All @@ -37,6 +41,9 @@ const ModalsManager: FunctionComponent<Props> = ({

return (
<>
{deviceInitializationFailedModalShowEnabled && (
<ErrorConnectingModal open closeModal={hideModals} />
)}
{appForcedUpdateFlowShow && <AppForcedUpdateFlowContainer />}
{appUpdateFlowShow && <AppUpdateFlowContainer />}
{contactSupportFlowShow && <ContactSupportFlow />}
Expand Down

0 comments on commit 3f16534

Please sign in to comment.