Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

[EPIC] Feature discoverability - Beamer #3515

Merged
merged 9 commits into from
Mar 3, 2022
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ REACT_APP_INFURA_TOKEN=
REACT_APP_IPFS_GATEWAY=https://ipfs.io/ipfs
REACT_APP_SENTRY_DSN=
REACT_APP_SAFE_APPS_RPC_INFURA_TOKEN=
REACT_APP_BEAMER_ID=

# For production environments
REACT_APP_INTERCOM_ID=
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@gnosis.pm/safe-apps-sdk-v1": "npm:@gnosis.pm/safe-apps-sdk@0.4.2",
"@gnosis.pm/safe-core-sdk": "^2.0.0",
"@gnosis.pm/safe-deployments": "^1.8.0",
"@gnosis.pm/safe-react-components": "^0.9.7",
"@gnosis.pm/safe-react-components": "^0.9.8",
"@gnosis.pm/safe-react-gateway-sdk": "2.8.3",
"@gnosis.pm/safe-web3-lib": "^1.0.0",
"@material-ui/core": "^4.12.3",
Expand Down
18 changes: 0 additions & 18 deletions src/components/AppLayout/Footer/Footer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Footer from './index'
import CookiesBanner from 'src/components/CookiesBanner'
import { render, fireEvent, screen } from 'src/utils/test-utils'

describe('<Footer>', () => {
Expand Down Expand Up @@ -82,23 +81,6 @@ describe('<Footer>', () => {
expect(cookiePolicyLinkNode).toHaveAttribute('target', '_blank')
})

it('Should show preference cookies banner form when clicks on Preferences Link', () => {
render(
<>
<Footer />
<CookiesBanner />
</>,
)

expect(screen.queryByTestId('cookies-banner-form')).not.toBeInTheDocument()

const preferencesCookiesNode = screen.getByText('Preferences')

fireEvent.click(preferencesCookiesNode)

expect(screen.queryByTestId('cookies-banner-form')).toBeInTheDocument()
})

it('Should show the current Safe React version if its defined in environment variables', () => {
process.env.REACT_APP_APP_VERSION = '1.1.1'

Expand Down
64 changes: 52 additions & 12 deletions src/components/AppLayout/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { lazy, useMemo } from 'react'
import styled from 'styled-components'
import { Divider, IconText } from '@gnosis.pm/safe-react-components'
import { Divider } from '@gnosis.pm/safe-react-components'
import { useDispatch } from 'react-redux'

import List, { ListItemType } from 'src/components/List'
import List, { ListItemType, StyledListItem, StyledListItemText } from 'src/components/List'
import SafeHeader from './SafeHeader'
import { IS_PRODUCTION } from 'src/utils/constants'
import { wrapInSuspense } from 'src/utils/wrapInSuspense'
import ListIcon from 'src/components/List/ListIcon'
import { openCookieBanner } from 'src/logic/cookies/store/actions/openCookieBanner'
import { loadFromCookie } from 'src/logic/cookies/utils'
import { COOKIES_KEY, BannerCookiesType, COOKIE_IDS } from 'src/logic/cookies/model/cookie'

const StyledDivider = styled(Divider)`
margin: 16px -8px 0;
Expand All @@ -15,18 +20,24 @@ const HelpContainer = styled.div`
margin-top: auto;
`

const HelpList = styled.div`
margin: 24px 0;
`

const HelpCenterLink = styled.a`
height: 30px;
width: 166px;
padding: 6px 0 8px 16px;
margin: 14px 0px;
width: 100%;
display: flex;
position: relative;
box-sizing: border-box;
text-align: left;
align-items: center;
padding: 8px 16px;
justify-content: flex-start;
text-decoration: none;
display: block;
border-radius: 8px;

&:hover {
border-radius: 8px;
background-color: ${({ theme }) => theme.colors.background};
box-sizing: content-box;
}
p {
font-family: ${({ theme }) => theme.fonts.fontFamily};
Expand Down Expand Up @@ -57,6 +68,8 @@ const lazyLoad = (path: string): React.ReactElement => {
return wrapInSuspense(<Component />)
}

const isDesktop = process.env.REACT_APP_BUILD_FOR_DESKTOP

const Sidebar = ({
items,
balance,
Expand All @@ -68,6 +81,23 @@ const Sidebar = ({
onNewTransactionClick,
}: Props): React.ReactElement => {
const debugToggle = useMemo(() => (IS_PRODUCTION ? null : lazyLoad('./DebugToggle')), [])
const dispatch = useDispatch()

const handleClick = (): void => {
const cookiesState = loadFromCookie<BannerCookiesType>(COOKIES_KEY)
if (!cookiesState) {
dispatch(openCookieBanner({ cookieBannerOpen: true }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to simplify this action even more. If openCookieBanner is dispatched, you need not send { cookieBannerOpen: true } in the payload at all.

return
}
if (!cookiesState.acceptedSupportAndUpdates) {
dispatch(
openCookieBanner({
cookieBannerOpen: true,
key: COOKIE_IDS.BEAMER,
}),
)
}
}

return (
<>
Expand All @@ -93,9 +123,19 @@ const Sidebar = ({

<StyledDivider />

<HelpCenterLink href="https://help.gnosis-safe.io/en/" target="_blank" title="Help Center of Gnosis Safe">
<IconText text="HELP CENTER" iconSize="md" textSize="md" color="placeHolder" iconType="question" />
</HelpCenterLink>
<HelpList>
{!isDesktop && (
<StyledListItem id="whats-new-button" button onClick={handleClick}>
<ListIcon type="gift" />
<StyledListItemText>What&apos;s new</StyledListItemText>
</StyledListItem>
)}

<HelpCenterLink href="https://help.gnosis-safe.io/en/" target="_blank" title="Help Center of Gnosis Safe">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably out of scope, but have we considered treating links as CONSTANTS and/or centralising them? Would help in the future if need to update any. Maybe worth creating a new issue? cc @katspaugh

<ListIcon type="question" />
<StyledListItemText>Help Center</StyledListItemText>
</HelpCenterLink>
</HelpList>
</HelpContainer>
</>
)
Expand Down
Loading