From 53f13e4a6366eb56acebe6d672b06ec063fd5881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Thu, 7 Mar 2024 16:48:37 +0100 Subject: [PATCH 1/8] Move reimbursement items to separate component --- .../reimbursement-item/component.js | 19 ++++++++++ .../reimbursement-item/template.hbs | 34 +++++++++++++++++ .../reimbursement-list/component.js | 13 ------- .../reimbursement-list/template.hbs | 37 +------------------ 4 files changed, 55 insertions(+), 48 deletions(-) create mode 100644 app/components/reimbursement-item/component.js create mode 100644 app/components/reimbursement-item/template.hbs diff --git a/app/components/reimbursement-item/component.js b/app/components/reimbursement-item/component.js new file mode 100644 index 0000000..1ada034 --- /dev/null +++ b/app/components/reimbursement-item/component.js @@ -0,0 +1,19 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; +import config from 'kredits-web/config/environment'; + +export default class ReimbursementItemComponent extends Component { + @service kredits; + + get ipfsGatewayUrl () { + return config.ipfs.gatewayUrl; + } + + @action + veto (id) { + this.kredits.vetoReimbursement(id).then(transaction => { + console.debug('[controllers:budget] Veto submitted to chain: '+transaction.hash); + }); + } +} diff --git a/app/components/reimbursement-item/template.hbs b/app/components/reimbursement-item/template.hbs new file mode 100644 index 0000000..96828de --- /dev/null +++ b/app/components/reimbursement-item/template.hbs @@ -0,0 +1,34 @@ +
  • +

    + + + + + Expenses covered by {{@reimbursement.contributor.name}} + +

    +

    + + {{sats-to-btc @reimbursement.amount}}BTC +

    + + + +
    +

    + +

    +

    + + Inspect IPFS data + + {{#if this.kredits.currentUserIsCore}} + + {{/if}} +

    +
    +
  • diff --git a/app/components/reimbursement-list/component.js b/app/components/reimbursement-list/component.js index 79c260d..34f7820 100644 --- a/app/components/reimbursement-list/component.js +++ b/app/components/reimbursement-list/component.js @@ -1,23 +1,10 @@ import Component from '@glimmer/component'; import { sort } from '@ember/object/computed'; -import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -import config from 'kredits-web/config/environment'; export default class ReimbursementListComponent extends Component { @service kredits; itemSorting = Object.freeze(['pendingStatus:asc', 'id:desc']); @sort('args.items', 'itemSorting') itemsSorted; - - get ipfsGatewayUrl () { - return config.ipfs.gatewayUrl; - } - - @action - veto (id) { - this.kredits.vetoReimbursement(id).then(transaction => { - console.debug('[controllers:budget] Veto submitted to chain: '+transaction.hash); - }); - } } diff --git a/app/components/reimbursement-list/template.hbs b/app/components/reimbursement-list/template.hbs index 50dcedf..98cd41f 100644 --- a/app/components/reimbursement-list/template.hbs +++ b/app/components/reimbursement-list/template.hbs @@ -1,38 +1,5 @@ \ No newline at end of file From af309ff682ac6f32e2010f9b3c1c52f52804c1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Thu, 7 Mar 2024 17:04:50 +0100 Subject: [PATCH 2/8] Hide veto button for confirmed reimbursements --- app/components/reimbursement-item/component.js | 12 ++++++++++++ app/components/reimbursement-item/template.hbs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/components/reimbursement-item/component.js b/app/components/reimbursement-item/component.js index 1ada034..51e8b82 100644 --- a/app/components/reimbursement-item/component.js +++ b/app/components/reimbursement-item/component.js @@ -10,6 +10,18 @@ export default class ReimbursementItemComponent extends Component { return config.ipfs.gatewayUrl; } + get isConfirmed () { + return (this.args.reimbursement.confirmedAt - this.kredits.currentBlock) <= 0; + } + + get isUnconfirmed () { + return !this.isConfirmed; + } + + get showVetoButton () { + return this.isUnconfirmed && this.kredits.currentUserIsCore; + } + @action veto (id) { this.kredits.vetoReimbursement(id).then(transaction => { diff --git a/app/components/reimbursement-item/template.hbs b/app/components/reimbursement-item/template.hbs index 96828de..e3f4140 100644 --- a/app/components/reimbursement-item/template.hbs +++ b/app/components/reimbursement-item/template.hbs @@ -24,7 +24,7 @@ class="button small" target="_blank" rel="noopener noreferrer"> Inspect IPFS data - {{#if this.kredits.currentUserIsCore}} + {{#if this.showVetoButton}} From 49b3825af462af75144591ec199d5f88ce8d0bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Thu, 14 Mar 2024 17:48:23 +0100 Subject: [PATCH 3/8] Show confirmation block for confirmed reimbursements --- app/components/confirmed-in/template.hbs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/components/confirmed-in/template.hbs b/app/components/confirmed-in/template.hbs index 44614dc..65ac4f0 100644 --- a/app/components/confirmed-in/template.hbs +++ b/app/components/confirmed-in/template.hbs @@ -1,3 +1,5 @@ -{{#unless this.isConfirmed}} +{{#if this.isConfirmed}} +Confirmed at block {{@confirmedAtBlock}} (~ {{this.confirmedInHumanTime}} ago) +{{else}} Confirming in {{this.confirmedInBlocks}} blocks (~ {{this.confirmedInHumanTime}}) -{{/unless}} +{{/if}} From 3ee140723ca76482bdfe10c665d5236f4d079e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Thu, 14 Mar 2024 17:49:12 +0100 Subject: [PATCH 4/8] Hide line items by default for confirmed reimbursements --- app/components/reimbursement-item/component.js | 14 ++++++++++++++ app/components/reimbursement-item/template.hbs | 5 ++++- app/components/reimbursement-list/template.hbs | 2 +- app/styles/_item-list.scss | 10 ++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/components/reimbursement-item/component.js b/app/components/reimbursement-item/component.js index 51e8b82..8afcee0 100644 --- a/app/components/reimbursement-item/component.js +++ b/app/components/reimbursement-item/component.js @@ -1,10 +1,19 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; import config from 'kredits-web/config/environment'; export default class ReimbursementItemComponent extends Component { @service kredits; + @tracked showExpenseDetails = false; + + constructor(owner, args) { + super(owner, args); + if (this.isUnconfirmed && !this.args.reimbursement.vetoed) { + this.showExpenseDetails = true; + } + } get ipfsGatewayUrl () { return config.ipfs.gatewayUrl; @@ -22,6 +31,11 @@ export default class ReimbursementItemComponent extends Component { return this.isUnconfirmed && this.kredits.currentUserIsCore; } + @action + toggleExpenseDetails () { + this.showExpenseDetails = !this.showExpenseDetails; + } + @action veto (id) { this.kredits.vetoReimbursement(id).then(transaction => { diff --git a/app/components/reimbursement-item/template.hbs b/app/components/reimbursement-item/template.hbs index e3f4140..7a2276d 100644 --- a/app/components/reimbursement-item/template.hbs +++ b/app/components/reimbursement-item/template.hbs @@ -1,5 +1,6 @@
  • + class="{{item-status @reimbursement}}" + {{on "click" this.toggleExpenseDetails}}>

    @@ -13,7 +14,9 @@ {{sats-to-btc @reimbursement.amount}}BTC

    + {{#if this.showExpenseDetails}} + {{/if}}

    diff --git a/app/components/reimbursement-list/template.hbs b/app/components/reimbursement-list/template.hbs index 98cd41f..3988acc 100644 --- a/app/components/reimbursement-list/template.hbs +++ b/app/components/reimbursement-list/template.hbs @@ -1,4 +1,4 @@ -