Store proper contributor profile in IPFS
This commit is contained in:
@@ -1,41 +1,58 @@
|
||||
import Ember from 'ember';
|
||||
import Contributor from 'kredits-web/models/contributor';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
const {
|
||||
Component,
|
||||
isPresent,
|
||||
inject: {
|
||||
service
|
||||
},
|
||||
computed
|
||||
} = Ember;
|
||||
|
||||
id: null,
|
||||
realName: null,
|
||||
address: null,
|
||||
ipfsHash: null,
|
||||
isCore: false,
|
||||
export default Component.extend({
|
||||
|
||||
kredits: service(),
|
||||
|
||||
newContributor: null,
|
||||
inProgress: false,
|
||||
|
||||
isValidId: function() {
|
||||
return Ember.isPresent(this.get('id'));
|
||||
}.property('id'),
|
||||
|
||||
isValidRealName: function() {
|
||||
return Ember.isPresent(this.get('realName'));
|
||||
}.property('realName'),
|
||||
|
||||
isValidAddress: function() {
|
||||
return this.get('kredits.web3Instance').isAddress(this.get('address'));
|
||||
}.property('address'),
|
||||
return this.get('kredits.web3Instance')
|
||||
.isAddress(this.get('newContributor.address'));
|
||||
}.property('newContributor.address'),
|
||||
|
||||
isValid: function() {
|
||||
return this.get('isValidId') && this.get('isValidRealName') && this.get('isValidAddress');
|
||||
}.property('isValidAddress', 'isValidId', 'isValidRealName'),
|
||||
isValidName: function() {
|
||||
return isPresent(this.get('newContributor.name'));
|
||||
}.property('newContributor.name'),
|
||||
|
||||
isValidURL: function() {
|
||||
return isPresent(this.get('newContributor.url'));
|
||||
}.property('newContributor.name'),
|
||||
|
||||
isValidGithubUID: function() {
|
||||
return isPresent(this.get('newContributor.github_uid'));
|
||||
}.property('newContributor.github_uid'),
|
||||
|
||||
isValidGithubUsername: function() {
|
||||
return isPresent(this.get('newContributor.github_username'));
|
||||
}.property('newContributor.github_username'),
|
||||
|
||||
isValidWikiUsername: function() {
|
||||
return isPresent(this.get('newContributor.wiki_username'));
|
||||
}.property('newContributor.wiki_username'),
|
||||
|
||||
isValid: computed.and(
|
||||
'isValidAddress',
|
||||
'isValidName',
|
||||
'isValidGithubUID'
|
||||
),
|
||||
|
||||
reset: function() {
|
||||
this.setProperties({
|
||||
id: null,
|
||||
realName: null,
|
||||
address: null,
|
||||
ipfsHash: null,
|
||||
isCore: true,
|
||||
newContributor: Contributor.create({ kind: 'person' }),
|
||||
inProgress: false
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
actions: {
|
||||
@@ -49,12 +66,7 @@ export default Ember.Component.extend({
|
||||
if (this.get('isValid')) {
|
||||
this.set('inProgress', true);
|
||||
|
||||
this.get('kredits').addContributor(
|
||||
this.get('address'),
|
||||
this.get('realName'),
|
||||
this.get('isCore'),
|
||||
this.get('id')
|
||||
).then(contributor => {
|
||||
this.get('kredits').addContributor(this.get('newContributor')).then(contributor => {
|
||||
this.reset();
|
||||
this.get('contributors').pushObject(contributor);
|
||||
window.scroll(0,0);
|
||||
|
||||
@@ -1,31 +1,59 @@
|
||||
<form {{action "save" on="submit"}}>
|
||||
newContributor: {{newContributor.kredits}}
|
||||
<p>
|
||||
{{input type="checkbox" name="is-core" id="is-core" checked=isCore}}
|
||||
{{input type="checkbox" name="is-core" id="is-core" checked=newContributor.isCore}}
|
||||
<label for="is-core" class="checkbox">
|
||||
Core team member (can add contributors)
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
{{input name="id"
|
||||
type="text"
|
||||
placeholder="GitHub UID (123)"
|
||||
value=id
|
||||
class=(if isValidId 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="realname"
|
||||
type="text"
|
||||
placeholder="GitHub username"
|
||||
value=realName
|
||||
class=(if isValidRealName 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="address"
|
||||
type="text"
|
||||
placeholder="0xF18E631Ea191aE4ebE70046Fcb01a436554421BA4"
|
||||
value=address
|
||||
value=newContributor.address
|
||||
class=(if isValidAddress 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
<select required onchange={{action (mut newContributor.kind) value="target.value"}}>
|
||||
<option value="person" selected={{eq newContributor.kind "person"}}>Person</option>
|
||||
<option value="organization" selected={{eq newContributor.kind "organization"}}>Organization</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
{{input name="name"
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
value=newContributor.name
|
||||
class=(if isValidName 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="url"
|
||||
type="text"
|
||||
placeholder="URL"
|
||||
value=newContributor.url
|
||||
class=(if isValidURL 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="github_uid"
|
||||
type="text"
|
||||
placeholder="GitHub UID (123)"
|
||||
value=newContributor.github_uid
|
||||
class=(if isValidGithubUID 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="github_username"
|
||||
type="text"
|
||||
placeholder="GitHub username"
|
||||
value=newContributor.github_username
|
||||
class=(if isValidGithubUsername 'valid' '')}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="wiki_username"
|
||||
type="text"
|
||||
placeholder="Wiki Username"
|
||||
value=newContributor.wiki_username
|
||||
class=(if isValidWikiUsername 'valid' '')}}
|
||||
</p>
|
||||
<p class="actions">
|
||||
{{input type="submit" value=(if inProgress 'Processing' 'Save') disabled=inProgress}}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user