-
Notifications
You must be signed in to change notification settings - Fork 274
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
Closed
Profile #810
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 c7f8a43
paste in profile logic, add necessary deps
Schwartz10 1a5b4d4
integrate login flow
Schwartz10 1575eed
fix lint errors
Schwartz10 9363df5
display profile of address passed in url bar
Schwartz10 dae6839
use aragon client log function, remove unused code
Schwartz10 2cff5e1
cleanup
Schwartz10 cfac065
add IPFS dep
Schwartz10 0b44d16
implement useProfile hook, cleanup, bug fix
Schwartz10 2b63124
fix linter warning
Schwartz10 7692d33
fix merge conflicts
Schwartz10 2310f3f
fetch verified accounts
Schwartz10 76bbba9
replaced rems with pixels
rkzel ccaf97f
Merge pull request #2 from openworklabs/69-use-pixels
Schwartz10 1a99ec8
Fix padding on TextArea
chadoh 2b46b69
Only render Website if filled in
chadoh c576bee
Profiles: do not shorten ethereum address
chadoh 30bf449
Profiles: style Education History to design
chadoh 4e7f881
Profiles/main info: Fix alignment & consistency
chadoh 39e9cd9
Profiles/avatar: improve placeholder
chadoh cb02b85
Profile: right-align education edit buttons
chadoh 7f40106
Merge pull request #3 from openworklabs/ui-true
Schwartz10 dfca3d7
remove profile code
Schwartz10 ee76fbe
update deps
Schwartz10 bc0d6a2
fix linter errors
Schwartz10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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" | ||
}, | ||
|
@@ -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", | ||
|
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,9 @@ | ||
import ipfsClient from 'ipfs-http-client' | ||
|
||
const infuraIpfs = ipfsClient({ | ||
host: 'ipfs.infura.io', | ||
port: '5001', | ||
protocol: 'https', | ||
}) | ||
|
||
export default infuraIpfs |
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,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 | ||
} |
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.
I've used
js-ipfs-ctl
to find out if there is a local ipfs daemon running, maybe check before going for infura?