-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added new user menu * fix: updated deps * feat: added new navbar * merge with master * fix: comments * fix: removed unused library * fix: package.json * fix: comments --------- Co-authored-by: Kevin Szuchet <31735779+kevinszuchet@users.noreply.github.com>
- Loading branch information
1 parent
a095769
commit d9e9c1d
Showing
17 changed files
with
414 additions
and
3,130 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import * as React from 'react' | ||
import { Navbar as BaseNavbar } from 'decentraland-dapps/dist/containers' | ||
import UserInformation from 'components/UserInformation' | ||
import UserMenu from 'components/UserMenu' | ||
import { Props } from './Navbar.types' | ||
|
||
export default class Navbar extends React.PureComponent<Props> { | ||
render() { | ||
let props = this.props | ||
|
||
if (props.isConnected) { | ||
props = { ...props, rightMenu: <UserMenu /> } | ||
} | ||
if (props.isNewNavbarEnabled) { | ||
props = { ...props, rightMenu: <UserInformation /> } | ||
} | ||
return <BaseNavbar activePage="builder" {...props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { NavbarProps } from 'decentraland-ui' | ||
import { Dispatch } from 'redux' | ||
|
||
export type Props = NavbarProps | ||
export type Props = Partial<NavbarProps> & { isNewNavbarEnabled: boolean } | ||
|
||
export type MapStateProps = Pick<Props, 'isConnected'> | ||
export type MapStateProps = Pick<Props, 'isConnected' | 'isNewNavbarEnabled'> | ||
export type MapDispatchProps = Pick<Props, 'onSignIn'> | ||
export type MapDispatch = Dispatch | ||
export type OwnProps = Partial<Props> |
26 changes: 26 additions & 0 deletions
26
src/components/UserInformation/UserInformation.container.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { connect } from 'react-redux' | ||
import { push } from 'connected-react-router' | ||
import { isPending } from 'decentraland-dapps/dist/modules/transaction/utils' | ||
import { isConnected, isConnecting } from 'decentraland-dapps/dist/modules/wallet/selectors' | ||
import { RootState } from '../../modules/common/types' | ||
import { openLogin } from 'modules/login/actions' | ||
import { getTransactions } from '../../modules/transaction/selectors' | ||
import { locations } from '../../routing/locations' | ||
import { MapStateProps, MapDispatch, MapDispatchProps } from './UserInformation.types' | ||
import UserMenu from './UserInformation' | ||
|
||
const mapState = (state: RootState): MapStateProps => { | ||
return { | ||
isSignedIn: isConnected(state), | ||
isSigningIn: isConnecting(state), | ||
hasActivity: getTransactions(state).some(tx => isPending(tx.status)) | ||
} | ||
} | ||
|
||
const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({ | ||
onClickActivity: () => dispatch(push(locations.activity())), | ||
onClickSettings: () => dispatch(push(locations.settings())), | ||
onSignIn: () => dispatch(openLogin()) | ||
}) | ||
|
||
export default connect(mapState, mapDispatch)(UserMenu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react' | ||
import { UserInformation as BaseUserMenu } from 'decentraland-dapps/dist/containers' | ||
import { Props } from './UserInformation.types' | ||
|
||
const UserInformation = (props: Props) => { | ||
const { onClickMyAssets, onClickSettings, onSignIn, ...baseProps } = props | ||
|
||
return <BaseUserMenu {...baseProps} onClickMyAssets={onClickMyAssets} onClickSettings={onClickSettings} onSignIn={onSignIn} /> | ||
} | ||
|
||
export default React.memo(UserInformation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Dispatch } from 'redux' | ||
import { CallHistoryMethodAction } from 'connected-react-router' | ||
import { UserInformationComponentProps } from 'decentraland-ui' | ||
import { OpenLoginModalAction } from 'modules/login/actions' | ||
|
||
export type Props = Partial<UserInformationComponentProps> & { | ||
onClickSettings: () => void | ||
onClickActivity: () => void | ||
} | ||
|
||
export type MapStateProps = Pick<Props, 'isSignedIn' | 'isSigningIn' | 'hasActivity'> | ||
export type MapDispatchProps = Pick<Props, 'onClickActivity' | 'onClickSettings' | 'onSignOut' | 'onSignIn'> | ||
export type MapDispatch = Dispatch<CallHistoryMethodAction | OpenLoginModalAction> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import UserInformation from './UserInformation.container' | ||
|
||
export default UserInformation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { action } from 'typesafe-actions' | ||
|
||
// Open Login | ||
export const OPEN_LOGIN_MODAL = 'Open Login Modal' | ||
export const openLogin = () => action(OPEN_LOGIN_MODAL, {}) | ||
export type OpenLoginModalAction = ReturnType<typeof openLogin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ConnectWalletSuccessAction, CONNECT_WALLET_SUCCESS, CONNECT_WALLET_FAILURE } from 'decentraland-dapps/dist/modules/wallet/actions' | ||
import { put, race, select, take, takeEvery } from 'redux-saga/effects' | ||
import { isLoggedIn } from 'modules/identity/selectors' | ||
import { openModal, CloseModalAction, CLOSE_MODAL, closeModal } from '../modal/actions' | ||
import { OpenLoginModalAction, OPEN_LOGIN_MODAL } from './actions' | ||
|
||
function* handleOpenLoginModal(_action: OpenLoginModalAction) { | ||
const address: string = yield select(isLoggedIn) | ||
|
||
if (!address) { | ||
yield put(openModal('LoginModal')) | ||
|
||
const { | ||
success, | ||
close | ||
}: { | ||
success: ConnectWalletSuccessAction | ||
failure: ConnectWalletSuccessAction | ||
close: CloseModalAction | ||
} = yield race({ | ||
success: take(CONNECT_WALLET_SUCCESS), | ||
failure: take(CONNECT_WALLET_FAILURE), | ||
close: take(CLOSE_MODAL) | ||
}) | ||
|
||
if (close) { | ||
return | ||
} | ||
|
||
if (success) { | ||
yield put(closeModal('LoginModal')) | ||
} | ||
} | ||
} | ||
|
||
export function* loginSaga() { | ||
yield takeEvery(OPEN_LOGIN_MODAL, handleOpenLoginModal) | ||
} |
d9e9c1d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder – ./
builder-git-master-decentraland1.vercel.app
builder-decentraland1.vercel.app