DEV: converts discard-draft modal to gjs (#26637)

This commit is contained in:
Joffrey JAFFEUX 2024-04-17 13:11:50 +02:00 committed by GitHub
parent df373d90fe
commit 552859b0ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 54 additions and 48 deletions

View File

@ -0,0 +1,54 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import i18n from "discourse-common/helpers/i18n";
export default class DiscardDraftModal extends Component {
@action
async discardDraft() {
await this.args.model.onDestroyDraft();
this.args.closeModal();
}
@action
async saveDraftAndClose() {
await this.args.model.onSaveDraft();
this.args.closeModal();
}
<template>
<DModal
@closeModal={{@closeModal}}
class="discard-draft-modal"
@dismissable={{false}}
>
<:body>
<div class="instructions">
{{i18n "post.cancel_composer.confirm"}}
</div>
</:body>
<:footer>
<DButton
@icon="far-trash-alt"
@label="post.cancel_composer.discard"
@action={{this.discardDraft}}
class="btn-danger discard-draft"
/>
{{#if @model.showSaveDraftButton}}
<DButton
@label="post.cancel_composer.save_draft"
@action={{this.saveDraftAndClose}}
class="save-draft"
/>
{{/if}}
<DButton
@label="post.cancel_composer.keep_editing"
@action={{@closeModal}}
class="keep-editing"
/>
</:footer>
</DModal>
</template>
}

View File

@ -1,32 +0,0 @@
<DModal
@closeModal={{@closeModal}}
class="discard-draft-modal"
@dismissable={{false}}
>
<:body>
<div class="instructions">
{{i18n "post.cancel_composer.confirm"}}
</div>
</:body>
<:footer>
<DButton
@icon="far-trash-alt"
@label="post.cancel_composer.discard"
@action={{this.discardDraft}}
class="btn-danger discard-draft"
/>
{{#if @model.showSaveDraftButton}}
<DButton
@label="post.cancel_composer.save_draft"
@action={{this.saveDraftAndClose}}
class="save-draft"
/>
{{/if}}
<DButton
@label="post.cancel_composer.keep_editing"
@action={{@closeModal}}
class="keep-editing"
/>
</:footer>
</DModal>

View File

@ -1,16 +0,0 @@
import Component from "@glimmer/component";
import { action } from "@ember/object";
export default class DiscardDraftModal extends Component {
@action
async discardDraft() {
await this.args.model.onDestroyDraft();
this.args.closeModal();
}
@action
async saveDraftAndClose() {
await this.args.model.onSaveDraft();
this.args.closeModal();
}
}