-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add option to withdraw sessions (#4686)
- Loading branch information
1 parent
769fcac
commit eed712a
Showing
8 changed files
with
57 additions
and
71 deletions.
There are no files selected for viewing
File renamed without changes.
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 |
---|---|---|
@@ -1,44 +1,33 @@ | ||
import Controller from '@ember/controller'; | ||
import { computed, action } from '@ember/object'; | ||
import moment from 'moment'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class extends Controller { | ||
|
||
@computed('model.endsAt') | ||
get isUpcoming() { | ||
let endAt = this.model.endsAt; | ||
if (endAt < moment()) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@action | ||
openProposalDeleteModal() { | ||
this.set('isProposalDeleteModalOpen', true); | ||
openProposalWithdrawModal() { | ||
this.set('isProposalWithdrawModalOpen', true); | ||
} | ||
|
||
@action | ||
deleteProposal() { | ||
async withdrawProposal() { | ||
this.set('isLoading', true); | ||
this.model.destroyRecord() | ||
.then(() => { | ||
this.transitionToRoute('my-sessions.index'); | ||
this.notify.success(this.l10n.t('Proposal has been deleted successfully.'), | ||
{ | ||
id: 'prop_del' | ||
}); | ||
}) | ||
.catch(() => { | ||
this.notify.error(this.l10n.t('An unexpected error has occurred.'), | ||
{ | ||
id: 'view_unex_error' | ||
}); | ||
}) | ||
.finally(() => { | ||
this.set('isLoading', false); | ||
this.set('isProposalDeleteModalOpen', false); | ||
}); | ||
this.model.set('state', 'withdrawn'); | ||
try { | ||
await this.model.save(); | ||
this.transitionToRoute('my-sessions.index'); | ||
this.notify.success(this.l10n.t('Proposal has been withdrawn successfully.'), | ||
{ | ||
id: 'prop_withdraw' | ||
}); | ||
} catch (e) { | ||
console.error('Error while withdrawing session', e); | ||
this.notify.error(this.l10n.t('An unexpected error has occurred.'), | ||
{ | ||
id: 'view_unex_error' | ||
}); | ||
} finally { | ||
this.set('isLoading', false); | ||
this.set('isProposalWithdrawModalOpen', false); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
app/templates/components/modals/proposal-withdraw-modal.hbs
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,21 @@ | ||
<div class="header"> | ||
{{t 'Are you sure you would like to withdraw this proposal?'}} | ||
<div class="muted small text"> | ||
{{t 'This action is final and cannot be reverted.'}} | ||
</div> | ||
</div> | ||
<div class="content"> | ||
<div class="field"> | ||
<div class="label"> | ||
{{t 'Proceeding forward will withdraw the proposal titled:'}} {{this.proposalName}} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="actions"> | ||
<button type="button" class="ui black button" {{action 'close'}}> | ||
{{t 'Cancel'}} | ||
</button> | ||
<button type="button" class="ui red button" {{action this.withdrawProposal}}> | ||
{{t 'Withdraw Proposal'}} | ||
</button> | ||
</div> |
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
eed712a
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.
Successfully deployed to the following URLs: