Skip to content

Commit

Permalink
Identity - Improve LocalIdentityBadge (#673)
Browse files Browse the repository at this point in the history
* Use only the entity prop in LocalIdentityBadge

Fixes #672

* Fix linting error
  • Loading branch information
2color committed Apr 1, 2019
1 parent b58a777 commit 6122a85
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/apps/Permissions/AppPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class Row extends React.Component {
return (
<LocalIdentityBadge
entity={entity.type === 'any' ? 'Any account' : entity.address}
address={entity.address}
/>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/apps/Permissions/AppRoles.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class RoleRow extends React.Component {
}
return (
<LocalIdentityBadge
address={manager.address}
entity={manager.type === 'burn' ? 'Discarded' : manager.address}
/>
)
Expand Down
4 changes: 1 addition & 3 deletions src/apps/Permissions/Home/EntityRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class EntityRow extends React.PureComponent {
if (entity.type === 'app' && entity.app.name) {
return <AppInstanceLabel app={entity.app} proxyAddress={entity.address} />
}
return (
<LocalIdentityBadge address={entity.address} entity={entity.address} />
)
return <LocalIdentityBadge entity={entity.address} />
}
roleTitle({ role, roleBytes, appEntity, proxyAddress }) {
if (!appEntity || !appEntity.app) {
Expand Down
1 change: 0 additions & 1 deletion src/apps/Permissions/ManageRolePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ class ManageRolePanel extends React.PureComponent {
}
return (
<LocalIdentityBadge
address={manager.address}
entity={manager.type === 'burn' ? 'Discarded' : manager.address}
/>
)
Expand Down
1 change: 0 additions & 1 deletion src/apps/Permissions/NavigationItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const NavigationItem = ({ title, badge, address, entity }) => {
<Title>{title}</Title>
{above('medium') && isEntity && (
<LocalIdentityBadge
address={address}
entity={entity && entity.type === 'any' ? 'Any account' : address}
/>
)}
Expand Down
2 changes: 0 additions & 2 deletions src/apps/Settings/DaoSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class DaoSettings extends React.PureComponent {
<Wrap>
<Label>Address</Label>
<LocalIdentityBadge
address={checksummedDaoAddr}
entity={checksummedDaoAddr}
shorten={shortAddresses}
/>
Expand Down Expand Up @@ -152,7 +151,6 @@ class DaoSettings extends React.PureComponent {
{tags.length > 0 ? ` (${tags.join(', ')})` : ''}
</Label>
<LocalIdentityBadge
address={checksummedProxyAddress}
entity={checksummedProxyAddress}
shorten={shortAddresses}
/>
Expand Down
12 changes: 9 additions & 3 deletions src/components/LocalIdentityBadge/LocalIdentityBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Badge, IdentityBadge, font } from '@aragon/ui'
import { LocalIdentityModalContext } from '../LocalIdentityModal/LocalIdentityModalManager'
import { isAddress } from '../../web3-utils'
import {
IdentityContext,
identityEventTypes,
} from '../IdentityManager/IdentityManager'

const LocalIdentityBadge = ({ address, ...props }) => {
const LocalIdentityBadge = ({ entity, ...props }) => {
const address = isAddress(entity) ? entity : null
if (address === null) {
return <IdentityBadge {...props} customLabel={entity} />
}

const { resolve, identityEvents$ } = React.useContext(IdentityContext)
const { showLocalIdentityModal } = React.useContext(LocalIdentityModalContext)
const [label, setLabel] = React.useState()
Expand Down Expand Up @@ -56,7 +62,7 @@ const LocalIdentityBadge = ({ address, ...props }) => {
<IdentityBadge
{...props}
customLabel={label || ''}
address={address}
entity={address}
popoverAction={{
label: `${label ? 'Edit' : 'Add'} custom label`,
onClick: handleClick,
Expand All @@ -76,7 +82,7 @@ const LocalIdentityBadge = ({ address, ...props }) => {
}

LocalIdentityBadge.propTypes = {
address: PropTypes.string,
entity: PropTypes.string,
}

const Wrap = styled.div`
Expand Down
9 changes: 3 additions & 6 deletions src/components/LocalIdentityModal/LocalIdentityModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import EscapeOutside from '../EscapeOutside/EscapeOutside'

const LocalIdentityModal = ({ opened, ...props }) => {
const { showModal, hideModal } = React.useContext(ModalContext)
React.useEffect(
() => {
opened ? showModal(Modal, props) : hideModal()
},
[opened]
)
React.useEffect(() => {
opened ? showModal(Modal, props) : hideModal()
}, [opened])

return null
}
Expand Down
1 change: 0 additions & 1 deletion src/components/SignerPanel/ActionPathsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ActionPathsContent extends React.Component {
`}
>
<LocalIdentityBadge
address={value}
entity={type === 'any-account' ? 'Any account' : value}
fontSize="small"
/>
Expand Down

0 comments on commit 6122a85

Please sign in to comment.