DEV: Convert theme-change modal to component-based API (#22964)

# Before
<img width="575" alt="Screenshot 2023-08-03 at 1 35 47 PM" src="https://github.com/discourse/discourse/assets/50783505/b4ae1487-bef8-40d4-8949-902e36303d43">

# After
<img width="897" alt="Screenshot 2023-08-03 at 1 41 21 PM" src="https://github.com/discourse/discourse/assets/50783505/a37c5fe1-eee5-4e0a-8b0a-66aebbaf2342">

This modal could still use some design love. I will raise this internally.
This commit is contained in:
Isaac Janzen 2023-08-03 15:01:40 -05:00 committed by GitHub
parent 999aaa35a7
commit d2502c9a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 37 deletions

View File

@ -0,0 +1,13 @@
<DModal
@title={{i18n "admin.logs.staff_actions.modal_title"}}
@closeModal={{@closeModal}}
@bodyClass="theme-change-modal-body"
class="history-modal"
>
<:body>
{{html-safe this.diff}}
</:body>
<:footer>
<DButton class="btn-primary" @action={{@closeModal}} @label="close" />
</:footer>
</DModal>

View File

@ -0,0 +1,21 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
export default class AdminThemeChangeComponent extends Component {
@tracked diff;
constructor() {
super(...arguments);
this.loadDiff();
}
@action
async loadDiff() {
const diff = await ajax(
`/admin/logs/staff_action_logs/${this.args.model.staffActionLog.id}/diff`
);
this.diff = diff.side_by_side;
}
}

View File

@ -6,8 +6,13 @@ import { exportEntity } from "discourse/lib/export-csv";
import { outputExportResult } from "discourse/lib/export-result"; import { outputExportResult } from "discourse/lib/export-result";
import { scheduleOnce } from "@ember/runloop"; import { scheduleOnce } from "@ember/runloop";
import showModal from "discourse/lib/show-modal"; import showModal from "discourse/lib/show-modal";
import { inject as service } from "@ember/service";
import ThemeChangeModal from "../components/modal/theme-change";
export default class AdminLogsStaffActionLogsController extends Controller { export default class AdminLogsStaffActionLogsController extends Controller {
@service modal;
@service store;
queryParams = ["filters"]; queryParams = ["filters"];
model = null; model = null;
filters = null; filters = null;
@ -161,11 +166,6 @@ export default class AdminLogsStaffActionLogsController extends Controller {
@action @action
showCustomDetailsModal(model, event) { showCustomDetailsModal(model, event) {
event?.preventDefault(); event?.preventDefault();
let modal = showModal("admin-theme-change", { this.modal.show(ThemeChangeModal, { model: { staffActionLog: model } });
model,
admin: true,
modalClass: "history-modal",
});
modal.loadDiff();
} }
} }

View File

@ -1,17 +0,0 @@
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { ajax } from "discourse/lib/ajax";
export default class AdminThemeChangeController extends Controller.extend(
ModalFunctionality
) {
loadDiff() {
this.set("loading", true);
ajax(
"/admin/logs/staff_action_logs/" + this.get("model.id") + "/diff"
).then((diff) => {
this.set("loading", false);
this.set("diff", diff.side_by_side);
});
}
}

View File

@ -1,12 +0,0 @@
<div>
<DModalBody @title="admin.logs.staff_actions.modal_title">
{{html-safe this.diff}}
</DModalBody>
<div class="modal-footer">
<DButton
@class="btn-primary"
@action={{route-action "closeModal"}}
@label="close"
/>
</div>
</div>

View File

@ -49,7 +49,6 @@ const KNOWN_LEGACY_MODALS = [
"topic-summary", "topic-summary",
"user-status", "user-status",
"admin-penalize-user", "admin-penalize-user",
"admin-theme-change",
"site-setting-default-categories", "site-setting-default-categories",
"admin-badge-preview", "admin-badge-preview",
"admin-edit-badge-groupings", "admin-edit-badge-groupings",

View File

@ -1,7 +1,7 @@
// styles that apply to the popup that appears when you show the edit history of a post // styles that apply to the popup that appears when you show the edit history of a post
.modal.history-modal { .modal.history-modal {
.modal-body { .modal-body:not(.theme-change-modal-body) {
max-height: 70vh; max-height: 70vh;
} }