Skip to content

Commit

Permalink
fix/2025 - remove leave community button from Possible impersonation …
Browse files Browse the repository at this point in the history
…attack modal and screen (#2037)

* feat: hide button

* feat: remove button from screen and modal

* docs: add link to commit

* fix: rtl test cleanup

* fix: cleanup

* fix: cleanup
  • Loading branch information
Kacper-RF authored Nov 7, 2023
1 parent abfb503 commit 9e3ba4e
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 111 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[unreleased]

* Temporarily hiding leave community button from Possible impersonation attack

[2.0.3-alpha.0]

* Filter CSRs - remove old csrs and replace with new for each pubkey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ const StyledGrid = styled(Grid)(({ theme }) => ({

export interface PossibleImpersonationAttackModalComponentProps {
communityName: string
leaveCommunity: () => void
open: boolean
handleClose: () => void
}

const PossibleImpersonationAttackModalComponent: React.FC<PossibleImpersonationAttackModalComponentProps> = ({
communityName,
leaveCommunity,
handleClose,
open,
}) => {
Expand All @@ -69,9 +67,7 @@ const PossibleImpersonationAttackModalComponent: React.FC<PossibleImpersonationA
<br />
<strong>This should never happen and we recommend leaving this community immediately!</strong>
</Typography>
<Button className={classes.button} data-testid='unregistered-button' onClick={leaveCommunity}>
Leave community
</Button>
{/* Temporarily hiding button - https://github.com/TryQuiet/quiet/issues/2025 */}
</StyledGrid>
</Modal>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { capitalizeFirstLetter } from '@quiet/common'
import { communities, users } from '@quiet/state-manager'
import React, { useEffect } from 'react'
import { useSelector } from 'react-redux'
import { clearCommunity } from '../../..'
import { useModal } from '../../../containers/hooks'
import { ModalName } from '../../../sagas/modals/modals.types'
import PossibleImpersonationAttackModalComponent from './PossibleImpersonationAttackModal.component'
Expand All @@ -19,22 +18,14 @@ const PossibleImpersonationAttackModalContainer = () => {
communityName = capitalizeFirstLetter(community.name)
}

const leaveCommunity = async () => {
await clearCommunity()
}

useEffect(() => {
if (duplicateCerts) {
possibleImpersonationAttackModal.handleOpen()
}
}, [duplicateCerts])

return (
<PossibleImpersonationAttackModalComponent
communityName={communityName}
leaveCommunity={leaveCommunity}
{...possibleImpersonationAttackModal}
/>
<PossibleImpersonationAttackModalComponent communityName={communityName} {...possibleImpersonationAttackModal} />
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const args: PossibleImpersonationAttackModalComponentProps = {
handleClose: function (): void {},
open: true,
communityName: 'devteam',
leaveCommunity: function (): void {},
}

Component.args = args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ describe('PossibleImpersonationAttackModal', () => {
it('renderComponent', () => {
const result = renderComponent(
<ThemeProvider theme={theme}>
<PossibleImpersonationAttackModalComponent
handleClose={() => {}}
open={true}
communityName={'devteam'}
leaveCommunity={() => {}}
/>
<PossibleImpersonationAttackModalComponent handleClose={() => {}} open={true} communityName={'devteam'} />
</ThemeProvider>
)
expect(result.baseElement).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -121,17 +116,6 @@ describe('PossibleImpersonationAttackModal', () => {
This should never happen and we recommend leaving this community immediately!
</strong>
</p>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeMedium MuiButton-textSizeMedium PossibleImpersonationAttackModalComponent-button css-1skytee-MuiButtonBase-root-MuiButton-root"
data-testid="unregistered-button"
tabindex="0"
type="button"
>
Leave community
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,5 @@ describe('Possible Impersonation Attack', () => {

const modal = screen.getByTestId('possible-impersonation-attack-modal-component')
expect(modal).toBeVisible()

const button = screen.getByTestId('unregistered-button')
expect(button).toBeVisible()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const classes = StyleSheet.create({
const PossibleImpersonationAttackComponent: React.FC<PossibleImpersonationAttackComponentProps> = ({
handleBackButton,
communityName,
leaveCommunity,
}) => {
return (
<View
Expand All @@ -62,7 +61,7 @@ const PossibleImpersonationAttackComponent: React.FC<PossibleImpersonationAttack
<Typography fontSize={14} fontWeight={'bold'} style={classes.text2}>
This should never happen and we recommend leaving this community immediately!
</Typography>
<Button width={160} title={'Leave community'} onPress={leaveCommunity} />
{/* Temporarily hiding button - https://github.com/TryQuiet/quiet/issues/2025 */}
</View>
</View>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react'
import PossibleImpersonationAttackComponent from './PossibleImpersonationAttack.component'

storiesOf('PossibleImpersonationAttack', module).add('Default', () => (
<PossibleImpersonationAttackComponent communityName='devteam' leaveCommunity={() => {}} handleBackButton={() => {}} />
<PossibleImpersonationAttackComponent communityName='devteam' handleBackButton={() => {}} />
))
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import PossibleImpersonationAttackComponent from './PossibleImpersonationAttack.
describe('PossibleImpersonationAttack component', () => {
it('renders properly', () => {
const { toJSON } = renderComponent(
<PossibleImpersonationAttackComponent
communityName={'dev'}
handleBackButton={() => {}}
leaveCommunity={() => {}}
/>
<PossibleImpersonationAttackComponent communityName={'dev'} handleBackButton={() => {}} />
)

expect(toJSON()).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -263,59 +259,6 @@ describe('PossibleImpersonationAttack component', () => {
>
This should never happen and we recommend leaving this community immediately!
</Text>
<View
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessible={true}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"alignItems": "center",
"backgroundColor": "#521C74",
"borderRadius": 8,
"justifyContent": "center",
"marginVertical": 12,
"minHeight": 45,
"paddingVertical": 12,
"width": 160,
}
}
testID="button"
>
<Text
color="white"
fontSize={14}
horizontalTextAlign="left"
style={
[
{
"color": "#ffffff",
"fontFamily": "Rubik-Regular",
"fontSize": 14,
"textAlign": "left",
"textAlignVertical": "center",
},
]
}
verticalTextAlign="center"
>
Leave community
</Text>
</View>
</View>
</View>
`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { FC, useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { navigationActions } from '../../store/navigation/navigation.slice'
import { ScreenNames } from '../../const/ScreenNames.enum'
import { capitalizeFirstLetter } from '@quiet/common'
import { communities } from '@quiet/state-manager'
import { nativeServicesActions } from '../../store/nativeServices/nativeServices.slice'
import { PossibleImpersonationAttackScreenProps } from './PossibleImpersonationAttack.types'
import PossibleImpersonationAttackComponent from '../../components/PossibleImpersonationAttack/PossibleImpersonationAttack.component'

Expand All @@ -18,19 +16,9 @@ export const PossibleImpersonationAttackScreen: FC<PossibleImpersonationAttackSc
communityName = capitalizeFirstLetter(community.name)
}

const leaveCommunity = useCallback(() => {
dispatch(nativeServicesActions.leaveCommunity())
}, [dispatch])

const handleBackButton = useCallback(() => {
dispatch(navigationActions.pop())
}, [dispatch])

return (
<PossibleImpersonationAttackComponent
handleBackButton={handleBackButton}
leaveCommunity={leaveCommunity}
communityName={communityName}
/>
)
return <PossibleImpersonationAttackComponent handleBackButton={handleBackButton} communityName={communityName} />
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export interface PossibleImpersonationAttackScreenProps {
export interface PossibleImpersonationAttackComponentProps {
handleBackButton: () => void
communityName: string
leaveCommunity: () => void
}

0 comments on commit 9e3ba4e

Please sign in to comment.