mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: converts grant-badge to gjs (#29842)
This commit is contained in:
parent
7cf28fec7b
commit
8271010387
@ -1,6 +1,11 @@
|
|||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { tracked } from "@glimmer/tracking";
|
import { tracked } from "@glimmer/tracking";
|
||||||
|
import { fn, hash } from "@ember/helper";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||||
|
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
|
||||||
|
import DButton from "discourse/components/d-button";
|
||||||
|
import DModal from "discourse/components/d-modal";
|
||||||
import { extractError } from "discourse/lib/ajax-error";
|
import { extractError } from "discourse/lib/ajax-error";
|
||||||
import {
|
import {
|
||||||
grantableBadges,
|
grantableBadges,
|
||||||
@ -10,6 +15,7 @@ import Badge from "discourse/models/badge";
|
|||||||
import UserBadge from "discourse/models/user-badge";
|
import UserBadge from "discourse/models/user-badge";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
|
import ComboBox from "select-kit/components/combo-box";
|
||||||
|
|
||||||
export default class GrantBadgeModal extends Component {
|
export default class GrantBadgeModal extends Component {
|
||||||
@tracked loading = true;
|
@tracked loading = true;
|
||||||
@ -54,6 +60,7 @@ export default class GrantBadgeModal extends Component {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
async performGrantBadge() {
|
async performGrantBadge() {
|
||||||
try {
|
try {
|
||||||
@ -79,4 +86,41 @@ export default class GrantBadgeModal extends Component {
|
|||||||
this.saving = false;
|
this.saving = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<DModal
|
||||||
|
@bodyClass="grant-badge"
|
||||||
|
@closeModal={{@closeModal}}
|
||||||
|
@flash={{this.flash}}
|
||||||
|
@flashType={{this.flashType}}
|
||||||
|
@title={{i18n "admin.badges.grant_badge"}}
|
||||||
|
class="grant-badge-modal"
|
||||||
|
{{didInsert this.loadBadges}}
|
||||||
|
>
|
||||||
|
<:body>
|
||||||
|
<ConditionalLoadingSpinner @condition={{this.loading}}>
|
||||||
|
{{#if this.noAvailableBadges}}
|
||||||
|
<p>{{i18n "admin.badges.no_badges"}}</p>
|
||||||
|
{{else}}
|
||||||
|
<p>
|
||||||
|
<ComboBox
|
||||||
|
@value={{this.selectedBadgeId}}
|
||||||
|
@content={{this.availableBadges}}
|
||||||
|
@onChange={{fn (mut this.selectedBadgeId)}}
|
||||||
|
@options={{hash filterable=true none="badges.none"}}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
{{/if}}
|
||||||
|
</ConditionalLoadingSpinner>
|
||||||
|
</:body>
|
||||||
|
<:footer>
|
||||||
|
<DButton
|
||||||
|
@disabled={{this.buttonDisabled}}
|
||||||
|
@action={{this.performGrantBadge}}
|
||||||
|
@label="admin.badges.grant"
|
||||||
|
class="btn-primary"
|
||||||
|
/>
|
||||||
|
</:footer>
|
||||||
|
</DModal>
|
||||||
|
</template>
|
||||||
}
|
}
|
@ -1,34 +0,0 @@
|
|||||||
<DModal
|
|
||||||
@bodyClass="grant-badge"
|
|
||||||
@closeModal={{@closeModal}}
|
|
||||||
@flash={{this.flash}}
|
|
||||||
@flashType={{this.flashType}}
|
|
||||||
@title={{i18n "admin.badges.grant_badge"}}
|
|
||||||
class="grant-badge-modal"
|
|
||||||
{{did-insert this.loadBadges}}
|
|
||||||
>
|
|
||||||
<:body>
|
|
||||||
<ConditionalLoadingSpinner @condition={{this.loading}}>
|
|
||||||
{{#if this.noAvailableBadges}}
|
|
||||||
<p>{{i18n "admin.badges.no_badges"}}</p>
|
|
||||||
{{else}}
|
|
||||||
<p>
|
|
||||||
<ComboBox
|
|
||||||
@value={{this.selectedBadgeId}}
|
|
||||||
@content={{this.availableBadges}}
|
|
||||||
@onChange={{fn (mut this.selectedBadgeId)}}
|
|
||||||
@options={{hash filterable=true none="badges.none"}}
|
|
||||||
/>
|
|
||||||
</p>
|
|
||||||
{{/if}}
|
|
||||||
</ConditionalLoadingSpinner>
|
|
||||||
</:body>
|
|
||||||
<:footer>
|
|
||||||
<DButton
|
|
||||||
@disabled={{this.buttonDisabled}}
|
|
||||||
@action={{this.performGrantBadge}}
|
|
||||||
@label="admin.badges.grant"
|
|
||||||
class="btn-primary"
|
|
||||||
/>
|
|
||||||
</:footer>
|
|
||||||
</DModal>
|
|
Loading…
Reference in New Issue
Block a user