discourse/app/assets/javascripts/admin/addon/models/permalink.js

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

31 lines
824 B
JavaScript
Raw Normal View History

2016-07-01 01:55:44 +08:00
import { ajax } from "discourse/lib/ajax";
import DiscourseURL from "discourse/lib/url";
import Category from "discourse/models/category";
import RestModel from "discourse/models/rest";
import discourseComputed from "discourse-common/utils/decorators";
2019-11-09 03:13:35 +08:00
export default class Permalink extends RestModel {
static findAll(filter) {
return ajax("/admin/permalinks.json", { data: { filter } }).then(function (
permalinks
) {
return permalinks.map((p) => Permalink.create(p));
});
}
@discourseComputed("category_id")
category(category_id) {
return Category.findById(category_id);
}
@discourseComputed("external_url")
linkIsExternal(external_url) {
return !DiscourseURL.isInternal(external_url);
}
@discourseComputed("url")
key(url) {
return url.replace("/", "_");
}
}