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

Profile #810

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
67e0955
add framework for conditionally rendering profiles
Schwartz10 May 27, 2019
c7f8a43
paste in profile logic, add necessary deps
Schwartz10 May 28, 2019
1a5b4d4
integrate login flow
Schwartz10 May 28, 2019
1575eed
fix lint errors
Schwartz10 May 28, 2019
9363df5
display profile of address passed in url bar
Schwartz10 May 28, 2019
dae6839
use aragon client log function, remove unused code
Schwartz10 May 28, 2019
2cff5e1
cleanup
Schwartz10 May 28, 2019
cfac065
add IPFS dep
Schwartz10 May 28, 2019
0b44d16
implement useProfile hook, cleanup, bug fix
Schwartz10 May 29, 2019
2b63124
fix linter warning
Schwartz10 May 29, 2019
7692d33
fix merge conflicts
Schwartz10 May 29, 2019
2310f3f
fetch verified accounts
Schwartz10 May 29, 2019
76bbba9
replaced rems with pixels
rkzel May 30, 2019
ccaf97f
Merge pull request #2 from openworklabs/69-use-pixels
Schwartz10 May 30, 2019
1a99ec8
Fix padding on TextArea
chadoh May 30, 2019
2b46b69
Only render Website if filled in
chadoh May 30, 2019
c576bee
Profiles: do not shorten ethereum address
chadoh May 30, 2019
30bf449
Profiles: style Education History to design
chadoh May 31, 2019
4e7f881
Profiles/main info: Fix alignment & consistency
chadoh May 31, 2019
39e9cd9
Profiles/avatar: improve placeholder
chadoh May 31, 2019
cb02b85
Profile: right-align education edit buttons
chadoh Jun 4, 2019
7f40106
Merge pull request #3 from openworklabs/ui-true
Schwartz10 Jun 13, 2019
dfca3d7
remove profile code
Schwartz10 Jun 13, 2019
ee76fbe
update deps
Schwartz10 Jun 13, 2019
bc0d6a2
fix linter errors
Schwartz10 Jun 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
"author": "Aragon Institution MTU <[email protected]>",
"dependencies": {
"3box": "^1.8.3",
"@aragon/templates-tokens": "^1.2.1",
"@aragon/ui": "^0.38.1",
"@aragon/wrapper": "^5.0.0-rc.7",
Expand All @@ -30,9 +31,12 @@
"eth-provider": "^0.2.0",
"file-saver": "^2.0.1",
"history": "^4.7.2",
"ipfs-http-client": "^32.0.1",
"lodash.clonedeep": "^4.5.0",
"lodash.memoize": "^4.1.2",
"lodash.throttle": "^4.1.1",
"lodash.uniqby": "^4.7.0",
"moment": "^2.24.0",
"onecolor": "^3.0.5",
"prop-types": "^15.6.2",
"react": "^16.8.6",
Expand All @@ -49,6 +53,7 @@
"resolve-pathname": "^3.0.0",
"styled-components": "^4.1.3",
"underscore": "1.8.3",
"uuid": "^3.3.2",
"web3": "1.0.0-beta.33",
"web3-utils": "1.0.0-beta.33"
},
Expand Down Expand Up @@ -85,6 +90,7 @@
"ui-assets": "copy-aragon-ui-assets -n aragon-ui ./build",
"start": "node scripts/start",
"start:local": "node scripts/launch-local",
"start:with:profiles": "cross-env WITH_PROFILES=true node scripts/start",
"start:mainnet": "cross-env REACT_APP_ETH_NETWORK_TYPE=main npm start",
"start:rinkeby": "npm start",
"start:staging": "cross-env REACT_APP_ENS_REGISTRY_ADDRESS=0xfe03625ea880a8cba336f9b5ad6e15b0a3b5a939 npm start",
Expand Down
10 changes: 6 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,7 @@ class App extends React.Component {
log('transaction bag', transactionBag)
this.setState({ transactionBag })
},
onSignatures: signatureBag => {
log('signature bag', signatureBag)
this.setState({ signatureBag })
},
onSignatures: this.onSignatures,
onIdentityIntent: async identityIntent => {
// set the state for modifying a specific address identity
let name = null
Expand Down Expand Up @@ -351,6 +348,10 @@ class App extends React.Component {
return this.state.wrapper.requestAddressIdentityModification(address)
}

onSignatures = signatureBag => {
this.setState({ signatureBag })
}

render() {
const {
account,
Expand Down Expand Up @@ -444,6 +445,7 @@ class App extends React.Component {
locator={locator}
onRequestAppsReload={this.handleRequestAppsReload}
onRequestEnable={enableWallet}
onSignatures={this.onSignatures}
permissionsLoading={permissionsLoading}
repos={repos}
signatureBag={signatureBag}
Expand Down
15 changes: 14 additions & 1 deletion src/Wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import styled from 'styled-components'
import memoize from 'lodash.memoize'
import { useViewport } from '@aragon/ui'
import { AppCenter, Permissions, Settings } from './apps'
import { AppCenter, Permissions, Settings, Profile } from './apps'
import AppIFrame from './components/App/AppIFrame'
import App404 from './components/App404/App404'
import Home from './components/Home/Home'
Expand All @@ -26,6 +26,7 @@ import {
import { getAppPath } from './routing'
import { APPS_STATUS_LOADING, DAO_STATUS_LOADING } from './symbols'
import { addressesEqual } from './web3-utils'
import { withProfiles } from './repo-utils'

class Wrapper extends React.PureComponent {
static propTypes = {
Expand All @@ -43,6 +44,7 @@ class Wrapper extends React.PureComponent {
locator: PropTypes.object.isRequired,
onRequestAppsReload: PropTypes.func.isRequired,
onRequestEnable: PropTypes.func.isRequired,
onSignatures: PropTypes.func.isRequired,
permissionsLoading: PropTypes.bool.isRequired,
repos: PropTypes.arrayOf(RepoType).isRequired,
transactionBag: PropTypes.object,
Expand Down Expand Up @@ -372,6 +374,7 @@ class Wrapper extends React.PureComponent {
connected,
daoAddress,
locator,
onSignatures,
permissionsLoading,
repos,
walletNetwork,
Expand Down Expand Up @@ -438,6 +441,16 @@ class Wrapper extends React.PureComponent {
)
}

if (withProfiles && instanceId === 'profile') {
return (
<Profile
account={account}
onSignatures={onSignatures}
parts={locator.parts}
/>
)
}

// AppLoader will display a loading screen in that case
if (!wrapper || appsLoading) {
return null
Expand Down
9 changes: 9 additions & 0 deletions src/apps/Profile/ipfs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ipfsClient from 'ipfs-http-client'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used js-ipfs-ctl to find out if there is a local ipfs daemon running, maybe check before going for infura?


const infuraIpfs = ipfsClient({
host: 'ipfs.infura.io',
port: '5001',
protocol: 'https',
})

export default infuraIpfs
125 changes: 125 additions & 0 deletions src/apps/Profile/modules/3box-LD.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { isIPFS } from 'ipfs-http-client'

import {
worksFor,
schoolAffiliation,
homeLocation,
schemaDotOrgImage,
} from './things'

const usedFields = new Set([
'name',
'jobTitle',
'homeLocation',
'affiliation',
'url',
'description',
'image',
'worksFor',
])

const handleJobTitle = publicProfile => {
if (publicProfile.job) {
const { job } = publicProfile
delete publicProfile.job
return { ...publicProfile, jobTitle: job }
}
return publicProfile
}

const handleEmployer = publicProfile => {
if (publicProfile.employer) {
const { employer } = publicProfile
delete publicProfile.employer
return { ...publicProfile, worksFor: worksFor(employer) }
}
return publicProfile
}

const handleEducation = publicProfile => {
const hasEducation = !!publicProfile.school
if (!hasEducation) return publicProfile

const affiliation = publicProfile.affiliation || []

return {
...publicProfile,
affiliation: schoolAffiliation(publicProfile.school, affiliation),
}
}

const handleWebsite = publicProfile => {
if (publicProfile.website) {
const { website } = publicProfile
delete publicProfile.website
return { ...publicProfile, url: website }
}
return publicProfile
}

const handleLocation = publicProfile => {
if (publicProfile.location) {
const { location } = publicProfile
delete publicProfile.location
return {
...publicProfile,
homeLocation: homeLocation(location),
}
}

return publicProfile
}

const handlePerson = publicProfile => {
const isPerson =
publicProfile['@type'] === 'Person' &&
publicProfile['@context'] === 'http://schema.org/'

if (isPerson) return publicProfile
return {
...publicProfile,
'@type': 'Person',
'@context': 'http://schema.org/',
}
}

export const handleImage = publicProfile => {
const hasImage = !!publicProfile.image && publicProfile.image.length > 0
if (!hasImage) return publicProfile
const isProperlyTyped =
Array.isArray(publicProfile.image) &&
publicProfile.image.length > 0 &&
publicProfile.image[0].contentUrl &&
typeof publicProfile.image[0].contentUrl === 'object'

const cid = isProperlyTyped && publicProfile.image[0].contentUrl['/']
const isIPLD = isIPFS.cid(cid)

if (isIPLD) {
delete publicProfile.image
return { ...publicProfile, image: schemaDotOrgImage(cid) }
}
throw new Error('unknown image type passed')
}

/* prettier-ignore */
export const format = publicProfile => {
const formattedProfile =
handlePerson(
handleLocation(
handleWebsite(
handleEducation(
handleEmployer(
handleJobTitle(
handleImage({ ...publicProfile })))))))
return formattedProfile
}

export const populateFormValue = publicProfile => {
const strippedObject = {}
Object.keys(publicProfile)
.filter(field => usedFields.has(field))
.forEach(field => (strippedObject[field] = publicProfile[field]))

return strippedObject
}
Loading