Skip to content

Commit

Permalink
fix: User menu lists (decentraland#1836)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio authored Jun 20, 2023
1 parent 8acd3e0 commit 0758f49
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
7 changes: 5 additions & 2 deletions webapp/src/components/UserMenu/UserMenu.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
isConnecting
} from 'decentraland-dapps/dist/modules/wallet/selectors'
import { getTransactions } from '../../modules/transaction/selectors'
import { getIsListsV1Enabled } from '../../modules/features/selectors'
import { locations } from '../../modules/routing/locations'
import { RootState } from '../../modules/reducer'
import UserMenu from './UserMenu'
Expand All @@ -16,15 +17,17 @@ const mapState = (state: RootState): MapStateProps => {
isSignedIn: isConnected(state),
isSigningIn: isConnecting(state),
isActivity: getLocation(state).pathname === locations.activity(),
hasActivity: getTransactions(state).some(tx => isPending(tx.status))
hasActivity: getTransactions(state).some(tx => isPending(tx.status)),
isListV1Enabled: getIsListsV1Enabled(state)
}
}

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
onClickActivity: () => dispatch(push(locations.activity())),
onClickSettings: () => dispatch(push(locations.settings())),
onClickMyAssets: () => dispatch(push(locations.defaultCurrentAccount())),
onClickMyLists: () => dispatch(push(locations.defaultList()))
onClickMyLists: () => dispatch(push(locations.defaultList())),
onClickMyListsV1: () => dispatch(push(locations.lists()))
})

export default connect(mapState, mapDispatch)(UserMenu)
16 changes: 13 additions & 3 deletions webapp/src/components/UserMenu/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { Icon } from 'decentraland-ui'
import { Props } from './UserMenu.types'

const UserMenu = (props: Props) => {
const { onClickMyAssets, onClickMyLists, ...baseProps } = props
const {
onClickMyAssets,
onClickMyLists,
isListV1Enabled,
onClickMyListsV1,
...baseProps
} = props

const menuItems = useMemo(
() => (
Expand All @@ -14,13 +20,17 @@ const UserMenu = (props: Props) => {
<Icon name="briefcase"></Icon>
{t('user_menu.my_assets')}
</li>
<li onClick={onClickMyLists} role="button" data-testid="my-lists">
<li
onClick={isListV1Enabled ? onClickMyListsV1 : onClickMyLists}
role="button"
data-testid="my-lists"
>
<Icon name="bookmark"></Icon>
{t('user_menu.my_lists')}
</li>
</>
),
[onClickMyAssets, onClickMyLists]
[isListV1Enabled, onClickMyAssets, onClickMyLists, onClickMyListsV1]
)

return <BaseUserMenu {...baseProps} menuItems={menuItems} />
Expand Down
14 changes: 12 additions & 2 deletions webapp/src/components/UserMenu/UserMenu.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ import { UserMenuProps } from 'decentraland-ui'
export type Props = Partial<UserMenuProps> & {
onClickMyAssets: () => void
onClickMyLists: () => void
onClickMyListsV1: () => void
isListV1Enabled: boolean
}

export type MapStateProps = Pick<
Props,
'isSignedIn' | 'isSigningIn' | 'isActivity' | 'hasActivity'
| 'isSignedIn'
| 'isSigningIn'
| 'isActivity'
| 'hasActivity'
| 'isListV1Enabled'
>
export type MapDispatchProps = Pick<
Props,
'onClickActivity' | 'onClickSettings' | 'onClickMyAssets' | 'onClickMyLists'
| 'onClickActivity'
| 'onClickSettings'
| 'onClickMyAssets'
| 'onClickMyLists'
| 'onClickMyListsV1'
>
export type MapDispatch = Dispatch<CallHistoryMethodAction>

0 comments on commit 0758f49

Please sign in to comment.