discourse/app/assets/javascripts/admin/addon/models/permalink.js
Krzysztof Kotlarek 42b1ca8f78
UX: redesign admin permalinks page (#29634)
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
2024-11-14 10:03:58 +11:00

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("/", "_");
}
}