mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 05:02:24 +08:00
c34f8b65cb
As of #23867 this is now a real package, so updating the imports to use the real package name, rather than relying on the alias. The name change in the package name is because `I18n` is not a valid name as NPM packages must be all lowercase. This commit also introduces an eslint rule to prevent importing from the old I18n path. For themes/plugins, the old 'i18n' name remains functional.
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import Component from "@ember/component";
|
|
import { action, computed } from "@ember/object";
|
|
import { reads } from "@ember/object/computed";
|
|
import { inject as service } from "@ember/service";
|
|
import discourseComputed from "discourse-common/utils/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);
|
|
return value;
|
|
}
|
|
|
|
@action
|
|
reset() {
|
|
this.dialog.yesNoConfirm({
|
|
message: I18n.t("admin.customize.email_style.reset_confirm", {
|
|
fieldName: I18n.t(`admin.customize.email_style.${this.fieldName}`),
|
|
}),
|
|
didConfirm: () => {
|
|
this.styles.setField(
|
|
this.fieldName,
|
|
this.styles.get(`default_${this.fieldName}`)
|
|
);
|
|
this.notifyPropertyChange("editorContents");
|
|
},
|
|
});
|
|
}
|
|
}
|