mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 10:13:47 +08:00
42b1ca8f78
Redesign the permalinks page to follow the UX guide. In addition, the ability to edit permalinks was added. This change includes: - move to RestModel - added Validations - update endpoint and clear old values after the update - system specs and improvements for unit tests
31 lines
824 B
JavaScript
31 lines
824 B
JavaScript
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";
|
|
|
|
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("/", "_");
|
|
}
|
|
}
|