-
Notifications
You must be signed in to change notification settings - Fork 273
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
New style permissions #899
Merged
Merged
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
9b77227
OrgView: provide the app width
bpierre a9b55a1
Permissions: add permissionsByRole()
bpierre 677c524
Add usePermissions() and usePermissionsPerRole()
bpierre 38d15fd
LocalIdentityBadge: coding style
bpierre e529371
Permissions new style - initial version
bpierre d73ce4b
Permissions: manage role + filter by action
bpierre d6aedb3
Fix syntax
bpierre 4471abb
Permissions: remove dead code since we don't have the entity view any…
sohkai 6394c73
Permissions: prefer 'appAddress' over 'proxyAddress' and remove redun…
sohkai 969cad9
Permissions: fix lint
sohkai ba6ef62
Merge branch 'newstyle' into newstyle-permissions
sohkai f132e23
OrgView: add proptypes
sohkai 26cc9bc
useAppWidth: refactor into its own hook inside apps/
sohkai 8c514fc
Permissions: remove more assumptions about selecting by entity
sohkai 5310385
Permissions: clarify how scroll to top works
sohkai 013958b
Permissions: update to new Button API
sohkai e8b98b9
Permissions: remove unused components
sohkai 424968e
AppCard: use Tag and adjust styles
sohkai 0021a2d
Permissions: search by app name and role name
sohkai e70826b
Permissions: align entity type dropdown with other apps
sohkai 054b5e7
Permissions: small AppPermissions tweaks and fixes
sohkai 123e90c
Permissions: don't add extra left padding to permissions table if no …
sohkai 6af5797
Permissions: avoid showing permissions table heading in smaller layouts
sohkai d09c1b1
Permissions: update assign and manage panels to new DropDown
sohkai 2491f84
Permissions: add empty filtered state
sohkai 878ea11
Permissions: prefer 'appAddress' over 'proxyAddress' when referring t…
sohkai e957fe1
Permissions: remove more dead code
sohkai bc71a61
Permissions: update Tag API to prefer 'label' prop over children
sohkai 5393bc9
Permissions: update text styles
sohkai 8c5c0c7
Permissions: add PermissionsIdentityBadge to handle any and burned en…
sohkai 6db3923
cosmetic: alphabetize definitions in prop-types
sohkai 8a605f0
AppCard: remove custom CSS on Tag
bpierre f15c5e2
Permissions header: fix text wrap / overflow
bpierre efd370c
Move AppCard to its own component
bpierre 6d7ac94
Permissions search: debounce updates
bpierre e8736c1
PermissionsIdentityBadge: extend LocalIdentityBadge proptypes
bpierre 53d1de8
Memoize PermissionsView
bpierre 16796f0
Move the tabs state one level up to keep it between screens
bpierre 25365b0
Routing: add a local path for apps
bpierre 60b9314
Permissions: use a local path
bpierre 88435a4
Merge branch 'newstyle' into newstyle-permissions
bpierre 93a63e8
Remove direct window.location.hash manipulations
bpierre 9cff7b6
Missing hook dependency
bpierre c23294a
Remove one more window.location.hash
bpierre 1f84578
Merge branch 'newstyle' into newstyle-permissions
bpierre ddc5835
ESLint
bpierre 294d46a
ESLint
bpierre a320208
Routing: remove spurious trailing slashes on navigation
sohkai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,56 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Button, Table, TableRow, Text, Viewport } from '@aragon/ui' | ||
import LocalIdentityBadge from '../../components/IdentityBadge/LocalIdentityBadge' | ||
import { TableHeader, TableCell, FirstTableCell, LastTableCell } from './Table' | ||
import { PermissionsConsumer } from '../../contexts/PermissionsContext' | ||
import { AppType, EthereumAddressType } from '../../prop-types' | ||
import Section from './Section' | ||
import { BackButton, Bar, textStyle } from '@aragon/ui' | ||
import { AppType } from '../../prop-types' | ||
import { usePermissionsByRole } from '../../contexts/PermissionsContext' | ||
import EmptyBlock from './EmptyBlock' | ||
import AppInstanceLabel from '../../components/AppInstanceLabel' | ||
import EntityPermissions from './EntityPermissions' | ||
import AppRoles from './AppRoles' | ||
import PermissionsView from './PermissionsView' | ||
|
||
class AppPermissions extends React.PureComponent { | ||
static propTypes = { | ||
address: EthereumAddressType.isRequired, | ||
app: AppType, // may not be available if still loading | ||
loading: PropTypes.bool.isRequired, | ||
onManageRole: PropTypes.func.isRequired, | ||
} | ||
render() { | ||
const { app, loading, address, onManageRole } = this.props | ||
return ( | ||
<PermissionsConsumer> | ||
{({ revokePermission, getAppPermissions }) => { | ||
const appPermissions = getAppPermissions(app) | ||
return ( | ||
<React.Fragment> | ||
<AppRoles | ||
app={app} | ||
loading={loading} | ||
onManageRole={onManageRole} | ||
/> | ||
<Section title="Permissions set on this app"> | ||
{loading || appPermissions.length === 0 ? ( | ||
<EmptyBlock> | ||
{loading | ||
? 'Loading app permissions…' | ||
: 'No permissions set.'} | ||
</EmptyBlock> | ||
) : ( | ||
<Viewport> | ||
{({ below }) => ( | ||
<Table | ||
noSideBorders={below('medium')} | ||
header={ | ||
<TableRow> | ||
<TableHeader | ||
title="Action" | ||
style={{ width: '20%' }} | ||
/> | ||
<TableHeader title="Allowed for" /> | ||
<TableHeader /> | ||
</TableRow> | ||
} | ||
> | ||
{appPermissions.map(({ role, entity }, i) => ( | ||
<Row | ||
key={i} | ||
role={role} | ||
entity={entity} | ||
proxyAddress={address} | ||
onRevoke={revokePermission} | ||
/> | ||
))} | ||
</Table> | ||
)} | ||
</Viewport> | ||
)} | ||
</Section> | ||
<EntityPermissions | ||
title="Permissions granted to this app" | ||
noPermissionsLabel="No permissions granted." | ||
address={address} | ||
loading={loading} | ||
onRevoke={revokePermission} | ||
/> | ||
</React.Fragment> | ||
) | ||
}} | ||
</PermissionsConsumer> | ||
) | ||
} | ||
} | ||
function AppPermissions({ app, loading, onBack, onManageRole }) { | ||
const permissions = usePermissionsByRole() | ||
|
||
class Row extends React.Component { | ||
static propTypes = { | ||
entity: PropTypes.object.isRequired, | ||
onRevoke: PropTypes.func.isRequired, | ||
proxyAddress: EthereumAddressType.isRequired, | ||
role: PropTypes.object.isRequired, | ||
if (loading) { | ||
return <EmptyBlock>Loading permissions…</EmptyBlock> | ||
} | ||
|
||
handleRevoke = () => { | ||
const { onRevoke, role, entity, proxyAddress } = this.props | ||
onRevoke({ | ||
proxyAddress, | ||
roleBytes: role.bytes, | ||
entityAddress: entity.address, | ||
}) | ||
} | ||
renderEntity() { | ||
const { entity } = this.props | ||
if (!entity) { | ||
return 'Unknown' | ||
} | ||
if (entity.type === 'app') { | ||
return <AppInstanceLabel app={entity.app} proxyAddress={entity.address} /> | ||
} | ||
const appPermissions = permissions.filter( | ||
permission => | ||
permission.app && permission.app.proxyAddress === app.proxyAddress | ||
) | ||
|
||
return ( | ||
<LocalIdentityBadge | ||
entity={entity.type === 'any' ? 'Any account' : entity.address} | ||
/> | ||
) | ||
if (appPermissions.length === 0) { | ||
return <EmptyBlock>No permissions found.</EmptyBlock> | ||
} | ||
render() { | ||
const { role } = this.props | ||
return ( | ||
<TableRow> | ||
<FirstTableCell> | ||
<Text weight="bold">{role ? role.name : 'Unknown'}</Text> | ||
</FirstTableCell> | ||
<TableCell>{this.renderEntity()}</TableCell> | ||
<LastTableCell align="right"> | ||
<Button | ||
mode="outline" | ||
emphasis="negative" | ||
compact | ||
onClick={this.handleRevoke} | ||
|
||
return ( | ||
<React.Fragment> | ||
<Bar> | ||
<BackButton onClick={onBack} /> | ||
</Bar> | ||
<PermissionsView | ||
heading={ | ||
<span | ||
css={` | ||
${textStyle('body2')} | ||
font-weight: 600; | ||
`} | ||
> | ||
Revoke | ||
</Button> | ||
</LastTableCell> | ||
</TableRow> | ||
) | ||
} | ||
Available permissions | ||
</span> | ||
} | ||
onManageRole={onManageRole} | ||
permissions={appPermissions} | ||
showApps={false} | ||
/> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
AppPermissions.propTypes = { | ||
app: AppType, // may not be available if still loading | ||
loading: PropTypes.bool.isRequired, | ||
onManageRole: PropTypes.func.isRequired, | ||
onBack: PropTypes.func.isRequired, | ||
} | ||
|
||
export default AppPermissions |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this needed? Shouldn't
body2
take care of the correctfont-weight
?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.
The designs had them at a different
font-weight
than the default (400).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.
Then my suggestion would be to revisit the designs so that these are in sync, it seems a bit arbitrary that this
body2
text has a differentfont-weight
cc @dizzypaty
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.
Yes we need to add some variants I think (e.g.
body2-bold
).