mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
DEV: Convert admin component definitions to native class syntax (#20311)
This conversion was achieved using the ember-native-class-codemod, plus a handful of manual fixes/tweaks
This commit is contained in:
@ -1,17 +1,19 @@
|
||||
import { action, computed } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { reads } from "@ember/object/computed";
|
||||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { reads } from "@ember/object/computed";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default Component.extend({
|
||||
dialog: service(),
|
||||
editorId: reads("fieldName"),
|
||||
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) {
|
||||
@ -19,36 +21,36 @@ export default Component.extend({
|
||||
this.get(`styles.${fieldName}`) ===
|
||||
this.get(`styles.default_${fieldName}`)
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
@discourseComputed("styles", "fieldName")
|
||||
editorContents: {
|
||||
get(styles, fieldName) {
|
||||
return styles[fieldName];
|
||||
},
|
||||
set(value, styles, fieldName) {
|
||||
styles.setField(fieldName, value);
|
||||
return value;
|
||||
},
|
||||
},
|
||||
@computed("styles", "fieldName")
|
||||
get editorContents() {
|
||||
return this.styles[this.fieldName];
|
||||
}
|
||||
|
||||
actions: {
|
||||
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");
|
||||
},
|
||||
});
|
||||
},
|
||||
save() {
|
||||
this.attrs.save();
|
||||
},
|
||||
},
|
||||
});
|
||||
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");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
save() {
|
||||
this.attrs.save();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user