This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
Update org viewer #24
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
54c563b
Update org viewer
bpierre 8ec1ffb
Merge branch 'master' into viewer-update
bpierre 6840215
Merge branch 'master' into viewer-update
bpierre 89ec537
Merge branch 'master' into viewer-update
bpierre e3586ba
ConnectorTheGraph: remove unused dependencies
bpierre 9df4adb
ConnectorTheGraph: default to mainnet subgraph
bpierre bc93338
Connect() => connect() with updated API
bpierre 4195795
Org Viewer update for API changes
bpierre 1e775d5
Update webpack config
bpierre 59f5b22
Merge branch 'master' into viewer-update
bpierre 5b09212
Merge branch 'master' into viewer-update
bpierre 115221e
useCancellableAsync(): set loading to false when done
bpierre a167894
ConnectorTheGraph: use lowercase addresses in queries
bpierre 228a31c
ConnectorTheGraph: Add a comment with the official ENS subgraphs
bpierre 28a8676
Remove unused imports
bpierre f86144c
Org viewer web: add DAO examples for multiple chains
bpierre e810275
Org viewer web: default to staging
bpierre 45e3362
Org viewer web: fix width
bpierre File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 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,136 @@ | ||
/** @jsx jsx */ | ||
import { useEffect, useState } from 'react' | ||
import { css, jsx } from '@emotion/core' | ||
import { connect } from 'plumbery-core' | ||
import Main from './Main' | ||
import OrgApps from './OrgApps' | ||
import OrgInfo from './OrgInfo' | ||
import OrgPermissions from './OrgPermissions' | ||
import TextButton from './TextButton' | ||
import { useCancellableAsync } from './generic-hooks' | ||
|
||
const ORG_ADDRESSES_MAINNET_STAGING = new Map([ | ||
['piedao', '0x0c188b183ff758500d1d18b432313d10e9f6b8a4'], | ||
]) | ||
|
||
const ORG_ADDRESSES_MAINNET = new Map([ | ||
['a1', '0x635193983512c621E6a3E15ee1dbF36f0C0Db8E0'], | ||
]) | ||
|
||
const ORG_ADDRESSES_RINKEBY = new Map([ | ||
['org1', '0x0146414e5a819240963450332f647dfb7c722af4'], | ||
['org2', '0x00018d22ece8b2ea4e9317b93f7dff67385693d8'], | ||
['td.aragonid.eth', '0xa9Aad8e278eECf369c42F78D5A3f2d866DE902C8'], | ||
['hive.aragonid.eth', '0xe520428C232F6Da6f694b121181f907931fD2211'], | ||
['mesh.aragonid.eth', '0xa48300a4E89b59A79452Db7d3CD408Df57f4aa78'], | ||
]) | ||
|
||
const ORG_ADDRESSES = ORG_ADDRESSES_MAINNET_STAGING | ||
|
||
function addressFromOrgName(orgName: string) { | ||
return ( | ||
ORG_ADDRESSES.get(orgName) || | ||
ORG_ADDRESSES.get(`${orgName}.aragonid.eth`) || | ||
orgName | ||
) | ||
} | ||
|
||
function useRouting() { | ||
const [orgName, setOrgName] = useState('') | ||
|
||
const openOrg = (orgName: string) => { | ||
window.location.hash = `/${orgName}` | ||
} | ||
|
||
const openApp = (appAddress: string) => { | ||
window.location.hash = `/${orgName}/${appAddress}` | ||
} | ||
|
||
useEffect(() => { | ||
const onChange = () => { | ||
const org = window.location.hash.match(/^#\/([^\/]+)/)?.[1] | ||
setOrgName(org || '') | ||
} | ||
|
||
onChange() | ||
window.addEventListener('hashchange', onChange) | ||
|
||
return () => { | ||
window.removeEventListener('hashchange', onChange) | ||
} | ||
}, []) | ||
|
||
return { orgName, openOrg, openApp } | ||
} | ||
|
||
export default function App() { | ||
const { openOrg, openApp, orgName } = useRouting() | ||
|
||
useEffect(() => { | ||
openOrg([...ORG_ADDRESSES.keys()][0]) | ||
}, []) | ||
|
||
const [org] = useCancellableAsync( | ||
async () => | ||
connect(addressFromOrgName(orgName.trim()), [ | ||
'thegraph', | ||
{ | ||
daoSubgraphUrl: | ||
'https://api.thegraph.com/subgraphs/name/aragon/aragon-mainnet-staging', | ||
}, | ||
]), | ||
[orgName] | ||
) | ||
|
||
return ( | ||
<Main> | ||
<label> | ||
<div | ||
css={css` | ||
padding-left: 4px; | ||
padding-bottom: 8px; | ||
font-size: 20px; | ||
`} | ||
> | ||
Enter an org location: | ||
</div> | ||
<input | ||
onChange={event => openOrg(event.target.value)} | ||
placeholder="e.g. xyz.aragonid.eth" | ||
type="text" | ||
value={orgName} | ||
css={css` | ||
width: 100%; | ||
padding: 12px; | ||
border: 2px solid #fad4fa; | ||
border-radius: 6px; | ||
font-size: 24px; | ||
outline: 0; | ||
`} | ||
/> | ||
</label> | ||
<div | ||
css={css` | ||
white-space: nowrap; | ||
padding-top: 8px; | ||
padding-left: 4px; | ||
font-size: 20px; | ||
`} | ||
> | ||
Or pick one: | ||
{[...ORG_ADDRESSES.keys()].map((name, index) => ( | ||
<span key={name}> | ||
{index > 0 && <span>, </span>} | ||
<TextButton onClick={() => openOrg(name)}> | ||
{name.match(/^[^\.]+/)?.[0]} | ||
</TextButton> | ||
</span> | ||
))} | ||
. | ||
</div> | ||
<OrgInfo org={org} orgAddress={addressFromOrgName(orgName)} /> | ||
<OrgApps org={org} onOpenApp={openApp} /> | ||
<OrgPermissions org={org} /> | ||
</Main> | ||
) | ||
} |
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.
👀👀
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.
haha yes, I wanted to test its JSX pragma for
css
: https://emotion.sh/docs/css-prop#jsx-pragmaOther than that it’s basically styled-components 😄
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.
Haha yeah, I've used emotion before, this option looks cool for inline styling as well! 😃