mirror of
https://github.com/discourse/discourse.git
synced 2024-12-04 23:23:49 +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.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import Component from "@glimmer/component";
|
|
import { tracked } from "@glimmer/tracking";
|
|
import { action } from "@ember/object";
|
|
import { inject as service } from "@ember/service";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import I18n from "discourse-i18n";
|
|
|
|
export default class Reseed extends Component {
|
|
@service dialog;
|
|
|
|
@tracked loading = true;
|
|
@tracked reseeding = false;
|
|
@tracked categories = null;
|
|
@tracked topics = null;
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.loadReseed();
|
|
}
|
|
|
|
@action
|
|
async loadReseed() {
|
|
try {
|
|
const result = await ajax("/admin/customize/reseed");
|
|
this.categories = result.categories;
|
|
this.topics = result.topics;
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
}
|
|
|
|
_extractSelectedIds(items) {
|
|
return items.filter((item) => item.selected).map((item) => item.id);
|
|
}
|
|
|
|
@action
|
|
async reseed() {
|
|
try {
|
|
this.reseeding = true;
|
|
await ajax("/admin/customize/reseed", {
|
|
data: {
|
|
category_ids: this._extractSelectedIds(this.categories),
|
|
topic_ids: this._extractSelectedIds(this.topics),
|
|
},
|
|
type: "POST",
|
|
});
|
|
|
|
this.flash = null;
|
|
this.args.closeModal();
|
|
} catch {
|
|
this.flash = I18n.t("generic_error");
|
|
} finally {
|
|
this.reseeding = false;
|
|
}
|
|
}
|
|
}
|