refactor: 💡 port confirmation service and components into core
This commit is contained in:
26 files changed
+59
-17
No files matched your search
@@ -0,0 +1,6 @@
|
||||
{{#each this.confirm.pending as |confirmation|}}
|
||||
{{yield
|
||||
confirmation
|
||||
(fn this.accept confirmation)
|
||||
(fn this.deny confirmation)}}
|
||||
{{/each}}
|
||||
@@ -0,0 +1,38 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
/**
|
||||
* A component that yields for each pending confirmation in the confirmations
|
||||
* service, passing the confirmation instance, a confirm action, and a dismiss
|
||||
* action. Useful for rendering confirm modals and awaiting user action.
|
||||
*/
|
||||
export default class PendingConfirmationsComponent extends Component {
|
||||
// =services
|
||||
|
||||
@service confirm;
|
||||
|
||||
// =actions
|
||||
|
||||
/**
|
||||
* Accepts the passed confirmation.
|
||||
* @param {Confirmation} confirmation
|
||||
* @return {Confirmation}
|
||||
*/
|
||||
@action
|
||||
accept(confirmation) {
|
||||
confirmation.confirm();
|
||||
return confirmation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Denies the passed confirmation.
|
||||
* @param {Confirmation} confirmation
|
||||
* @return {Confirmation}
|
||||
*/
|
||||
@action
|
||||
deny(confirmation) {
|
||||
confirmation.dismiss();
|
||||
return confirmation;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user