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
This commit is contained in:
Krzysztof Kotlarek
2024-11-14 10:03:58 +11:00
committed by GitHub
parent b37f6f1edb
commit 42b1ca8f78
29 changed files with 924 additions and 239 deletions

View File

@@ -1,10 +1,10 @@
import EmberObject from "@ember/object";
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 EmberObject {
export default class Permalink extends RestModel {
static findAll(filter) {
return ajax("/admin/permalinks.json", { data: { filter } }).then(function (
permalinks
@@ -13,17 +13,6 @@ export default class Permalink extends EmberObject {
});
}
save() {
return ajax("/admin/permalinks.json", {
type: "POST",
data: {
url: this.url,
permalink_type: this.permalink_type,
permalink_type_value: this.permalink_type_value,
},
});
}
@discourseComputed("category_id")
category(category_id) {
return Category.findById(category_id);
@@ -34,9 +23,8 @@ export default class Permalink extends EmberObject {
return !DiscourseURL.isInternal(external_url);
}
destroy() {
return ajax("/admin/permalinks/" + this.id + ".json", {
type: "DELETE",
});
@discourseComputed("url")
key(url) {
return url.replace("/", "_");
}
}