discourse/app/assets/javascripts/admin/addon/models/site-setting.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-11-08 14:13:35 -05:00
import EmberObject from "@ember/object";
import I18n from "I18n";
import Setting from "admin/mixins/setting-object";
2019-11-08 14:13:35 -05:00
import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators";
2015-03-02 12:12:19 -05:00
const SiteSetting = EmberObject.extend(Setting, {
@discourseComputed("setting")
staffLogFilter(setting) {
if (!setting) {
return;
}
return {
subject: setting,
action_name: "change_site_setting",
};
},
});
2015-03-02 12:12:19 -05:00
SiteSetting.reopenClass({
findAll() {
2016-06-30 13:55:44 -04:00
return ajax("/admin/site_settings").then(function (settings) {
2015-03-02 12:12:19 -05:00
// Group the results by category
const categories = {};
settings.site_settings.forEach(function (s) {
if (!categories[s.category]) {
categories[s.category] = [];
}
categories[s.category].pushObject(SiteSetting.create(s));
2015-03-02 12:12:19 -05:00
});
return Object.keys(categories).map(function (n) {
return {
nameKey: n,
name: I18n.t("admin.site_settings.categories." + n),
siteSettings: categories[n],
};
});
});
},
update(key, value, opts = {}) {
2015-03-02 12:12:19 -05:00
const data = {};
data[key] = value;
if (opts["updateExistingUsers"] === true) {
data["update_existing_user"] = true;
}
return ajax(`/admin/site_settings/${key}`, { type: "PUT", data });
2015-03-02 12:12:19 -05:00
},
});
export default SiteSetting;