DEV: converts user-status to gjs (#29832)

This commit is contained in:
Joffrey JAFFEUX 2024-11-19 23:24:49 +01:00 committed by GitHub
parent 921416a741
commit ad034a5947
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 64 additions and 54 deletions

View File

@ -1,13 +1,20 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { Input } from "@ember/component";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { service } from "@ember/service"; import { service } from "@ember/service";
import ItsATrap from "@discourse/itsatrap"; import ItsATrap from "@discourse/itsatrap";
import { TrackedObject } from "@ember-compat/tracked-built-ins"; import { TrackedObject } from "@ember-compat/tracked-built-ins";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import DModalCancel from "discourse/components/d-modal-cancel";
import TimeShortcutPicker from "discourse/components/time-shortcut-picker";
import UserStatusPicker from "discourse/components/user-status-picker";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import { import {
TIME_SHORTCUT_TYPES, TIME_SHORTCUT_TYPES,
timeShortcuts, timeShortcuts,
} from "discourse/lib/time-shortcut"; } from "discourse/lib/time-shortcut";
import { i18n } from "discourse-i18n";
export default class UserStatusModal extends Component { export default class UserStatusModal extends Component {
@service currentUser; @service currentUser;
@ -90,4 +97,61 @@ export default class UserStatusModal extends Component {
this.#handleError(e); this.#handleError(e);
} }
} }
<template>
<DModal
@title={{i18n "user_status.set_custom_status"}}
@closeModal={{@closeModal}}
class="user-status"
>
<:body>
<div class="control-group">
<UserStatusPicker @status={{this.status}} />
</div>
{{#unless @model.hidePauseNotifications}}
<div class="control-group pause-notifications">
<label class="checkbox-label">
<Input @type="checkbox" @checked={{@model.pauseNotifications}} />
{{i18n "user_status.pause_notifications"}}
</label>
</div>
{{/unless}}
<div class="control-group control-group-remove-status">
<label class="control-label">
{{i18n "user_status.remove_status"}}
</label>
<TimeShortcutPicker
@timeShortcuts={{this.timeShortcuts}}
@hiddenOptions={{this.hiddenTimeShortcutOptions}}
@customLabels={{this.customTimeShortcutLabels}}
@prefilledDatetime={{this.prefilledDateTime}}
@onTimeSelected={{this.onTimeSelected}}
@_itsatrap={{this._itsatrap}}
/>
</div>
</:body>
<:footer>
<DButton
@label="user_status.save"
@disabled={{this.saveDisabled}}
@action={{this.saveAndClose}}
class="btn-primary"
/>
<DModalCancel @close={{@closeModal}} />
{{#if this.showDeleteButton}}
<DButton
@icon="trash-can"
@action={{this.delete}}
class="delete-status btn-danger"
/>
{{/if}}
</:footer>
</DModal>
</template>
} }

View File

@ -1,54 +0,0 @@
<DModal
@title={{i18n "user_status.set_custom_status"}}
@closeModal={{@closeModal}}
class="user-status"
>
<:body>
<div class="control-group">
<UserStatusPicker @status={{this.status}} />
</div>
{{#unless @model.hidePauseNotifications}}
<div class="control-group pause-notifications">
<label class="checkbox-label">
<Input @type="checkbox" @checked={{@model.pauseNotifications}} />
{{i18n "user_status.pause_notifications"}}
</label>
</div>
{{/unless}}
<div class="control-group control-group-remove-status">
<label class="control-label">
{{i18n "user_status.remove_status"}}
</label>
<TimeShortcutPicker
@timeShortcuts={{this.timeShortcuts}}
@hiddenOptions={{this.hiddenTimeShortcutOptions}}
@customLabels={{this.customTimeShortcutLabels}}
@prefilledDatetime={{this.prefilledDateTime}}
@onTimeSelected={{this.onTimeSelected}}
@_itsatrap={{this._itsatrap}}
/>
</div>
</:body>
<:footer>
<DButton
@label="user_status.save"
@disabled={{this.saveDisabled}}
@action={{this.saveAndClose}}
class="btn-primary"
/>
<DModalCancel @close={{@closeModal}} />
{{#if this.showDeleteButton}}
<DButton
@icon="trash-can"
@action={{this.delete}}
class="delete-status btn-danger"
/>
{{/if}}
</:footer>
</DModal>