Skip to content

Commit

Permalink
feat: use Navbar new component
Browse files Browse the repository at this point in the history
  • Loading branch information
lauti7 committed Jan 17, 2024
1 parent fa169d8 commit 132d140
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 125 deletions.
155 changes: 77 additions & 78 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"dcl-catalyst-commons": "^9.0.1",
"decentraland-connect": "^5.2.4",
"decentraland-crypto-fetch": "^1.0.3",
"decentraland-dapps": "^16.34.2",
"decentraland-dapps": "^17.0.0",
"decentraland-transactions": "^1.50.0",
"decentraland-ui": "^4.35.3",
"dotenv": "^10.0.0",
"ethers": "^5.6.8",
"graphql": "^14.7.0",
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/components/Navbar/Navbar.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import { RootState } from '../../modules/reducer'
import { getTransactions } from '../../modules/transaction/selectors'
import {
getIsAuthDappEnabled,
getIsNavbarV2Enabled
} from '../../modules/features/selectors'
import { MapStateProps, MapDispatch, MapDispatchProps } from './Navbar.types'
import Navbar from './Navbar'
import { getCurrentIdentity } from '../../modules/identity/selectors'
import { TransactionStatus } from 'decentraland-dapps/dist/modules/transaction/types'

const mapState = (state: RootState): MapStateProps => ({
location: getLocation(state),
hasPendingTransactions: getTransactions(state).some(tx =>
hasPendingTransactions: getTransactions(state).some((tx: { status: TransactionStatus | null }) =>
isPending(tx.status)
),
identity: getCurrentIdentity(state) || undefined,
isAuthDappEnabled: getIsAuthDappEnabled(state),
isNavbarV2Enabled: getIsNavbarV2Enabled(state)
})

const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({
Expand Down
25 changes: 5 additions & 20 deletions webapp/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React, { useCallback } from 'react'
import { Navbar as BaseNavbar } from 'decentraland-dapps/dist/containers'
import { Navbar2 as BaseNavbar2 } from 'decentraland-dapps/dist/containers'
import { Navbar2Pages } from 'decentraland-ui/dist/components/Navbar2/Navbar2.types'
import { NavbarPages } from 'decentraland-ui/dist/components/Navbar/Navbar.types'
import { config } from '../../config'
import { locations } from '../../modules/routing/locations'
import UserInformation from '../UserInformation'
import { Props } from './Navbar.types'
import './Navbar.css'

const Navbar = (props: Props) => {
const { location, onNavigate, isAuthDappEnabled, isNavbarV2Enabled } = props
const { location, onNavigate, isAuthDappEnabled } = props
const { pathname, search } = location

const handleOnSignIn = useCallback(() => {
Expand All @@ -36,29 +34,16 @@ const Navbar = (props: Props) => {
onNavigate(locations.settings())
}, [onNavigate])

return isNavbarV2Enabled ? (
<BaseNavbar2
return (
<BaseNavbar
{...props}
withNotifications
activePage={Navbar2Pages.MARKETPLACE}
activePage={NavbarPages.MARKETPLACE}
hasActivity={props.hasPendingTransactions}
identity={props.identity}
onSignIn={handleOnSignIn}
onClickAccountSettings={handleOnClickAccount}
/>
) : (
<BaseNavbar
{...props}
withNotifications
activePage="marketplace"
isFullscreen={props.isFullscreen}
isSignIn={pathname === locations.signIn()}
onSignIn={handleOnSignIn}
onClickAccount={handleOnClickAccount}
rightMenu={
<UserInformation identity={props.identity} withNotifications />
}
/>
)
}

Expand Down
4 changes: 1 addition & 3 deletions webapp/src/components/Navbar/Navbar.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch } from 'redux'
import { CallHistoryMethodAction, RouterLocation } from 'connected-react-router'
import { NavbarProps } from 'decentraland-ui'
import { NavbarProps } from 'decentraland-ui/dist/components/Navbar/Navbar.types'
import { AuthIdentity } from '@dcl/crypto'

export type Props = Partial<NavbarProps> & {
Expand All @@ -10,7 +10,6 @@ export type Props = Partial<NavbarProps> & {
onNavigate: (path: string) => void
identity?: AuthIdentity
isAuthDappEnabled: boolean
isNavbarV2Enabled: boolean
}

export type OwnProps = Pick<Props, 'enablePartialSupportAlert'>
Expand All @@ -21,7 +20,6 @@ export type MapStateProps = Pick<
| 'hasPendingTransactions'
| 'identity'
| 'isAuthDappEnabled'
| 'isNavbarV2Enabled'
>
export type MapDispatchProps = Pick<Props, 'onNavigate'>
export type MapDispatch = Dispatch<CallHistoryMethodAction>
7 changes: 0 additions & 7 deletions webapp/src/modules/features/selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
isLoadingFeatureFlags,
getIsBuyCrossChainEnabled,
getIsAuthDappEnabled,
getIsNavbarV2Enabled
} from './selectors'
import { FeatureName } from './types'

Expand Down Expand Up @@ -224,12 +223,6 @@ const waitForInitialLoadingSelectors = [
selector: getIsAuthDappEnabled,
applicationName: ApplicationName.DAPPS
},
{
name: 'navbar-v2',
feature: FeatureName.NAVBAR_V2,
selector: getIsNavbarV2Enabled,
applicationName: ApplicationName.DAPPS
}
]

waitForInitialLoadingSelectors.forEach(
Expand Down
11 changes: 0 additions & 11 deletions webapp/src/modules/features/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,3 @@ export const getIsAuthDappEnabled = (state: RootState) => {
}
return false
}

export const getIsNavbarV2Enabled = (state: RootState) => {
if (hasLoadedInitialFlags(state)) {
return getIsFeatureEnabled(
state,
ApplicationName.DAPPS,
FeatureName.NAVBAR_V2
)
}
return false
}
1 change: 0 additions & 1 deletion webapp/src/modules/features/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ export enum FeatureName {
MARKETPLACE_SERVER = 'marketplace-server',
BUY_CROSS_CHAIN = 'buy-cross-chain',
AUTH_DAPP = 'auth-dapp',
NAVBAR_V2 = 'navbar2_variant'
}

0 comments on commit 132d140

Please sign in to comment.