Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom labels all around #637

Closed
6 changes: 4 additions & 2 deletions src/apps/Permissions/AppPermissions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Button, Table, TableRow, Text, Viewport } from '@aragon/ui'
import IdentityBadge from '../../components/IdentityBadge'
import CustomLabelIdentityBadge from '../../components/CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import { TableHeader, TableCell, FirstTableCell, LastTableCell } from './Table'
import { PermissionsConsumer } from '../../contexts/PermissionsContext'
import { AppType, EthereumAddressType } from '../../prop-types'
Expand Down Expand Up @@ -107,9 +107,11 @@ class Row extends React.Component {
if (entity.type === 'app') {
return <AppInstanceLabel app={entity.app} proxyAddress={entity.address} />
}

return (
<IdentityBadge
<CustomLabelIdentityBadge
entity={entity.type === 'any' ? 'Any account' : entity.address}
address={entity.address}
/>
)
}
Expand Down
12 changes: 7 additions & 5 deletions src/apps/Permissions/AppRoles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { Button, Table, TableRow, Text, Viewport } from '@aragon/ui'
import { AppType, EthereumAddressType } from '../../prop-types'
import { TableHeader, TableCell, FirstTableCell, LastTableCell } from './Table'
import IdentityBadge from '../../components/IdentityBadge'
import CustomLabelIdentityBadge from '../../components/CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import { PermissionsConsumer } from '../../contexts/PermissionsContext'
import Section from './Section'
import EmptyBlock from './EmptyBlock'
Expand Down Expand Up @@ -98,10 +98,12 @@ class RoleRow extends React.Component {
<AppInstanceLabel app={manager.app} proxyAddress={manager.address} />
)
}
if (manager.type === 'burn') {
return <IdentityBadge entity={'Discarded'} />
}
return <IdentityBadge entity={manager.address} />
return (
<CustomLabelIdentityBadge
address={manager.address}
entity={manager.type === 'burn' ? 'Discarded' : manager.address}
/>
)
}
render() {
const { role, manager } = this.props
Expand Down
11 changes: 8 additions & 3 deletions src/apps/Permissions/Home/EntityRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
breakpoint,
theme,
} from '@aragon/ui'
import IdentityBadge from '../../../components/IdentityBadge'
import CustomLabelIdentityBadge from '../../../components/CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import AppInstanceLabel from '../AppInstanceLabel'
import ViewDetailsButton from './ViewDetailsButton'
import { FirstTableCell, LastTableCell } from '../Table'
Expand Down Expand Up @@ -42,12 +42,17 @@ class EntityRow extends React.PureComponent {
}
renderEntity(entity) {
if (entity.type === 'any') {
return <IdentityBadge entity="Any account" />
return <CustomLabelIdentityBadge entity="Any account" />
}
if (entity.type === 'app' && entity.app.name) {
return <AppInstanceLabel app={entity.app} proxyAddress={entity.address} />
}
return <IdentityBadge entity={entity.address} />
return (
<CustomLabelIdentityBadge
address={entity.address}
entity={entity.address}
/>
)
}
roleTitle({ role, roleBytes, appEntity, proxyAddress }) {
if (!appEntity || !appEntity.app) {
Expand Down
12 changes: 7 additions & 5 deletions src/apps/Permissions/ManageRolePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Button,
breakpoint,
} from '@aragon/ui'
import IdentityBadge from '../../components/IdentityBadge'
import CustomLabelIdentityBadge from '../../components/CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import { PermissionsConsumer } from '../../contexts/PermissionsContext'
import { isBurnEntity } from '../../permissions'
import { AppType } from '../../prop-types'
Expand Down Expand Up @@ -246,10 +246,12 @@ class ManageRolePanel extends React.PureComponent {
<AppInstanceLabel app={manager.app} proxyAddress={manager.address} />
)
}
if (manager.type === 'burn') {
return <IdentityBadge entity="Discarded" />
}
return <IdentityBadge entity={manager.address} />
return (
<CustomLabelIdentityBadge
address={manager.address}
entity={manager.type === 'burn' ? 'Discarded' : manager.address}
/>
)
}

render() {
Expand Down
5 changes: 3 additions & 2 deletions src/apps/Permissions/NavigationItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Badge, Viewport } from '@aragon/ui'
import IdentityBadge from '../../components/IdentityBadge'
import CustomLabelIdentityBadge from '../../components/CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import { EthereumAddressType } from '../../prop-types'

const NavigationItem = ({ title, badge, address, entity }) => {
Expand All @@ -13,7 +13,8 @@ const NavigationItem = ({ title, badge, address, entity }) => {
<Main>
<Title>{title}</Title>
{above('medium') && isEntity && (
<IdentityBadge
<CustomLabelIdentityBadge
address={address}
entity={entity && entity.type === 'any' ? 'Any account' : address}
/>
)}
Expand Down
68 changes: 9 additions & 59 deletions src/apps/Settings/DaoSettings.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {
Badge,
Button,
IdentityBadge,
Text,
Viewport,
font,
theme,
} from '@aragon/ui'
import { CustomLabelModalConsumer } from '../../components/CustomLabelModal/CustomLabelModalManager'
import { resolve } from '../../mockCustomLabelsManager'
import { Button, Text, Viewport, theme } from '@aragon/ui'
import CustomLabelIdentityBadge from '../../components/CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import { appIds, network } from '../../environment'
import { sanitizeNetworkType } from '../../network-config'
import { AppType, DaoAddressType, EthereumAddressType } from '../../prop-types'
Expand Down Expand Up @@ -75,53 +66,11 @@ class DaoSettings extends React.PureComponent {
{checksummedDaoAddr ? (
<Wrap>
<Label>Address</Label>
<CustomLabelModalConsumer>
{({ showCustomLabelModal }) => (
<IdentityBadge
customLabel={resolve(checksummedDaoAddr) || ''}
entity={checksummedDaoAddr}
shorten={shortAddresses}
popoverAction={{
label: `${
resolve(checksummedDaoAddr) ? 'Edit' : 'Add'
} custom label`,
onClick: () => showCustomLabelModal(checksummedDaoAddr),
title: resolve(checksummedDaoAddr) ? (
<div
css={`
display: grid;
align-items: center;
grid-template-columns: auto 1fr;
padding-right: 24px;
`}
>
<span
css={`
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`}
>
{resolve(checksummedDaoAddr)}
</span>
<Badge
css={`
margin-left: 16px;
text-transform: uppercase;
${font({ size: 'xxsmall' })};
`}
>
Custom label
</Badge>
</div>
) : (
''
),
}}
/>
)}
</CustomLabelModalConsumer>
<CustomLabelIdentityBadge
address={checksummedDaoAddr}
entity={checksummedDaoAddr}
shorten={shortAddresses}
/>
</Wrap>
) : (
<p>Resolving DAO address…</p>
Expand Down Expand Up @@ -202,7 +151,8 @@ class DaoSettings extends React.PureComponent {
{name}
{tags.length > 0 ? ` (${tags.join(', ')})` : ''}
</Label>
<IdentityBadge
<CustomLabelIdentityBadge
address={checksummedProxyAddress}
entity={checksummedProxyAddress}
shorten={shortAddresses}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Badge, IdentityBadge, font } from '@aragon/ui'
import { CustomLabelModalConsumer } from '../../components/CustomLabelModal/CustomLabelModalManager'
import { resolve } from '../../mockCustomLabelsManager'

const CustomLabelIdentityBadge = ({ address, ...props }) => (
<CustomLabelModalConsumer>
{({ showCustomLabelModal }) => (
<IdentityBadge
{...props}
customLabel={resolve(address) || ''}
address={address}
popoverAction={{
label: `${resolve(address) ? 'Edit' : 'Add'} custom label`,
onClick: () => showCustomLabelModal(address),
title: resolve(address) ? (
<Wrap>
<Address>{resolve(address)}</Address>
<StyledBadge>Custom label</StyledBadge>
</Wrap>
) : (
'Address'
),
}}
/>
)}
</CustomLabelModalConsumer>
)

CustomLabelIdentityBadge.propTypes = {
address: PropTypes.string,
}

const Wrap = styled.div`
display: grid;
align-items: center;
grid-template-columns: auto 1fr;
padding-right: 24px;
`

const Address = styled.span`
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`

const StyledBadge = styled(Badge)`
margin-left: 16px;
text-transform: uppercase;
${font({ size: 'xxsmall' })};
`

export default CustomLabelIdentityBadge
5 changes: 3 additions & 2 deletions src/components/SignerPanel/ActionPathsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components'
import { Info, RadioList, SafeLink } from '@aragon/ui'
import SignerButton from './SignerButton'
import AddressLink from './AddressLink'
import IdentityBadge from '../IdentityBadge'
import CustomLabelIdentityBadge from '../CustomLabelIdentityBadge/CustomLabelIdentityBadge'
import providerString from '../../provider-strings'

const RADIO_ITEM_TITLE_LENGTH = 30
Expand Down Expand Up @@ -57,7 +57,8 @@ class ActionPathsContent extends React.Component {
margin-right: 4px;
`}
>
<IdentityBadge
<CustomLabelIdentityBadge
address={value}
entity={type === 'any-account' ? 'Any account' : value}
fontSize="small"
/>
Expand Down