mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 16:16:44 +08:00

`discourse-common` was created in the past to share logic between the 'wizard' app and the main 'discourse' app. Since then, the wizard has been consolidated into the main app, so the separation of `discourse-common` is no longer useful. This commit moves `discourse-common/(lib|utils)/*` into `discourse/lib/*`, adds shims for the imports, and updates existing uses in core.
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import Component from "@ember/component";
|
|
import { action, computed } from "@ember/object";
|
|
import { reads } from "@ember/object/computed";
|
|
import { service } from "@ember/service";
|
|
import discourseComputed from "discourse/lib/decorators";
|
|
import { i18n } from "discourse-i18n";
|
|
|
|
export default class EmailStylesEditor extends Component {
|
|
@service dialog;
|
|
|
|
@reads("fieldName") editorId;
|
|
|
|
@discourseComputed("fieldName")
|
|
currentEditorMode(fieldName) {
|
|
return fieldName === "css" ? "scss" : fieldName;
|
|
}
|
|
|
|
@discourseComputed("fieldName", "styles.html", "styles.css")
|
|
resetDisabled(fieldName) {
|
|
return (
|
|
this.get(`styles.${fieldName}`) ===
|
|
this.get(`styles.default_${fieldName}`)
|
|
);
|
|
}
|
|
|
|
@computed("styles", "fieldName")
|
|
get editorContents() {
|
|
return this.styles[this.fieldName];
|
|
}
|
|
|
|
set editorContents(value) {
|
|
this.styles.setField(this.fieldName, value);
|
|
}
|
|
|
|
@action
|
|
reset() {
|
|
this.dialog.yesNoConfirm({
|
|
message: i18n("admin.customize.email_style.reset_confirm", {
|
|
fieldName: i18n(`admin.customize.email_style.${this.fieldName}`),
|
|
}),
|
|
didConfirm: () => {
|
|
this.styles.setField(
|
|
this.fieldName,
|
|
this.styles.get(`default_${this.fieldName}`)
|
|
);
|
|
this.notifyPropertyChange("editorContents");
|
|
},
|
|
});
|
|
}
|
|
}
|