mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 02:24:54 +08:00
DEV: Convert explain-reviewable modal to component-based API (#23274)
# Before <img width="826" alt="Screenshot 2023-08-25 at 12 49 10 PM" src="https://github.com/discourse/discourse/assets/50783505/25c2bf52-33f3-4b18-89c1-9826ed605519"> # After <img width="632" alt="Screenshot 2023-08-25 at 12 52 37 PM" src="https://github.com/discourse/discourse/assets/50783505/0d6697f2-6226-4acc-8aac-031f4645db93">
This commit is contained in:
parent
4ee0f4e5ba
commit
058c8496f0
@ -0,0 +1,72 @@
|
||||
<DModal
|
||||
class="explain-reviewable"
|
||||
@closeModal={{@closeModal}}
|
||||
@title={{i18n "review.explain.title"}}
|
||||
>
|
||||
<:body>
|
||||
<ConditionalLoadingSpinner @condition={{this.loading}}>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{{i18n "review.explain.formula"}}</th>
|
||||
<th>{{i18n "review.explain.subtotal"}}</th>
|
||||
</tr>
|
||||
{{#each this.reviewableExplanation.scores as |s|}}
|
||||
<tr>
|
||||
<td>
|
||||
<ScoreValue @value="1.0" @tagName="" />
|
||||
<ScoreValue
|
||||
@value={{s.type_bonus}}
|
||||
@label="type_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
<ScoreValue
|
||||
@value={{s.take_action_bonus}}
|
||||
@label="take_action_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
<ScoreValue
|
||||
@value={{s.trust_level_bonus}}
|
||||
@label="trust_level_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
<ScoreValue
|
||||
@value={{s.user_accuracy_bonus}}
|
||||
@label="user_accuracy_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
</td>
|
||||
<td class="sum">{{float s.score}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
<tr class="total">
|
||||
<td>{{i18n "review.explain.total"}}</td>
|
||||
<td class="sum">
|
||||
{{float this.reviewableExplanation.total_score}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="thresholds">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{i18n "review.explain.min_score_visibility"}}</td>
|
||||
<td class="sum">
|
||||
{{float this.reviewableExplanation.min_score_visibility}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n "review.explain.score_to_hide"}}</td>
|
||||
<td class="sum">
|
||||
{{float this.reviewableExplanation.hide_post_score}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</ConditionalLoadingSpinner>
|
||||
</:body>
|
||||
<:footer>
|
||||
<DButton @action={{@closeModal}} @label="close" />
|
||||
</:footer>
|
||||
</DModal>
|
@ -0,0 +1,29 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default class ExplainReviewable extends Component {
|
||||
@service store;
|
||||
|
||||
@tracked loading = true;
|
||||
@tracked reviewableExplanation = null;
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.loadExplanation();
|
||||
}
|
||||
|
||||
@action
|
||||
async loadExplanation() {
|
||||
try {
|
||||
const result = await this.store.find(
|
||||
"reviewable-explanation",
|
||||
this.args.model.reviewable.id
|
||||
);
|
||||
this.reviewableExplanation = result;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import { action, set } from "@ember/object";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
import ExplainReviewableModal from "discourse/components/modal/explain-reviewable";
|
||||
|
||||
let _components = {};
|
||||
|
||||
@ -24,6 +25,9 @@ export function addPluginReviewableParam(reviewableType, param) {
|
||||
export default Component.extend({
|
||||
adminTools: optionalService(),
|
||||
dialog: service(),
|
||||
modal: service(),
|
||||
siteSettings: service(),
|
||||
currentUser: service(),
|
||||
tagName: "",
|
||||
updating: null,
|
||||
editing: false,
|
||||
@ -214,10 +218,9 @@ export default Component.extend({
|
||||
|
||||
@action
|
||||
explainReviewable(reviewable, event) {
|
||||
event?.preventDefault();
|
||||
showModal("explain-reviewable", {
|
||||
title: "review.explain.title",
|
||||
model: reviewable,
|
||||
event.preventDefault();
|
||||
this.modal.show(ExplainReviewableModal, {
|
||||
model: { reviewable },
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
import Controller from "@ember/controller";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
loading: null,
|
||||
reviewableExplanation: null,
|
||||
|
||||
onShow() {
|
||||
this.setProperties({ loading: true, reviewableExplanation: null });
|
||||
|
||||
this.store
|
||||
.find("reviewable-explanation", this.model.id)
|
||||
.then((result) => this.set("reviewableExplanation", result))
|
||||
.finally(() => this.set("loading", false));
|
||||
},
|
||||
});
|
@ -18,7 +18,6 @@ const KNOWN_LEGACY_MODALS = [
|
||||
"create-account",
|
||||
"create-invite-bulk",
|
||||
"create-invite",
|
||||
"explain-reviewable",
|
||||
"feature-topic-on-profile",
|
||||
"feature-topic",
|
||||
"flag",
|
||||
|
@ -1,67 +0,0 @@
|
||||
<DModalBody @class="explain-reviewable">
|
||||
<ConditionalLoadingSpinner @condition={{this.loading}}>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{{i18n "review.explain.formula"}}</th>
|
||||
<th>{{i18n "review.explain.subtotal"}}</th>
|
||||
</tr>
|
||||
{{#each this.reviewableExplanation.scores as |s|}}
|
||||
<tr>
|
||||
<td>
|
||||
<ScoreValue @value="1.0" @tagName="" />
|
||||
<ScoreValue
|
||||
@value={{s.type_bonus}}
|
||||
@label="type_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
<ScoreValue
|
||||
@value={{s.take_action_bonus}}
|
||||
@label="take_action_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
<ScoreValue
|
||||
@value={{s.trust_level_bonus}}
|
||||
@label="trust_level_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
<ScoreValue
|
||||
@value={{s.user_accuracy_bonus}}
|
||||
@label="user_accuracy_bonus"
|
||||
@tagName=""
|
||||
/>
|
||||
</td>
|
||||
<td class="sum">{{float s.score}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
<tr class="total">
|
||||
<td>{{i18n "review.explain.total"}}</td>
|
||||
<td class="sum">{{float this.reviewableExplanation.total_score}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="thresholds">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{i18n "review.explain.min_score_visibility"}}</td>
|
||||
<td class="sum">
|
||||
{{float this.reviewableExplanation.min_score_visibility}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n "review.explain.score_to_hide"}}</td>
|
||||
<td class="sum">
|
||||
{{float this.reviewableExplanation.hide_post_score}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</ConditionalLoadingSpinner>
|
||||
|
||||
</DModalBody>
|
||||
|
||||
<div class="modal-footer">
|
||||
<DButton @action={{route-action "closeModal"}} @label="close" />
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user