Merge pull request #108 from 67P/feature/add_contributor

Fix/update adding contributors
This commit was merged in pull request #108.
This commit is contained in:
2019-04-29 12:44:15 +01:00
committed by GitHub
7 changed files with 42 additions and 34 deletions
+14 -11
View File
@@ -2,7 +2,6 @@ import Component from '@ember/component';
import { and, notEmpty } from '@ember/object/computed';
import { inject as service } from '@ember/service';
export default Component.extend({
kredits: service(),
@@ -14,6 +13,7 @@ export default Component.extend({
isValidURL: notEmpty('url'),
isValidGithubUID: notEmpty('github_uid'),
isValidGithubUsername: notEmpty('github_username'),
isValidGiteaUsername: notEmpty('gitea_username'),
isValidWikiUsername: notEmpty('wiki_username'),
isValid: and(
'isValidAccount',
@@ -21,10 +21,11 @@ export default Component.extend({
'isValidGithubUID'
),
inProgress: false,
init () {
this._super(...arguments);
// Default attributes used by reset
this.set('attributes', {
account: null,
name: null,
@@ -32,8 +33,8 @@ export default Component.extend({
url: null,
github_username: null,
github_uid: null,
wiki_username: null,
isCore: false
gitea_username: null,
wiki_username: null
});
},
@@ -53,17 +54,19 @@ export default Component.extend({
return;
}
let attributes = Object.keys(this.attributes);
let contributor = this.getProperties(attributes);
let saved = this.save(contributor);
const attributes = Object.keys(this.attributes);
const contributor = this.getProperties(attributes);
// The promise handles inProgress
this.set('inProgress', saved);
this.set('inProgress', true);
saved.then(() => {
this.save(contributor).then(() => {
this.reset();
window.scroll(0,0);
window.alert('Contributor added.');
}).catch(err => {
console.log(err);
window.alert('Something went wrong. Please check the browser console.');
}).finally(() => {
this.set('inProgress', false);
});
}
}
+9 -11
View File
@@ -1,13 +1,4 @@
<form {{action "submit" on="submit"}}>
<p>
{{input name="is-core"
type="checkbox"
id="is-core"
checked=isCore}}
<label for="is-core" class="checkbox">
Core team member (can add contributors)
</label>
</p>
<p>
{{input name="account"
type="text"
@@ -49,6 +40,13 @@
value=github_username
class=(if isValidGithubUsername "valid" "")}}
</p>
<p>
{{input name="gitea_username"
type="text"
placeholder="Gitea username"
value=gitea_username
class=(if isValidGiteaUsername "valid" "")}}
</p>
<p>
{{input name="wiki_username"
type="text"
@@ -58,7 +56,7 @@
</p>
<p class="actions">
{{input type="submit"
disabled=(is-pending inProgress)
value=(if (is-pending inProgress) "Processing" "Save")}}
disabled=inProgress
value=(if inProgress "Processing" "Save")}}
</p>
</form>
+1 -1
View File
@@ -12,7 +12,7 @@
<tr class="metadata {{if (is-current-user contributor) "current-user"}} {{if contributor.showMetadata "visible"}}">
<td colspan="2">
<ul>
<li><a href="https://testnet.etherscan.io/address/{{contributor.account}}">Inspect Ethereum transactions</a></li>
<li><a href="https://rinkeby.etherscan.io/address/{{contributor.account}}">Inspect Ethereum transactions</a></li>
{{#if contributor.ipfsHash}}
<li><a href="https://ipfs.io/ipfs/{{contributor.ipfsHash}}">Inspect IPFS profile</a></li>
{{/if}}