mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-25 09:58:44 +08:00
`discourse-common` was created in the past to share logic between the 'wizard' app and the main 'discourse' app. Since then, the wizard has been consolidated into the main app, so the separation of `discourse-common` is no longer useful. This commit moves `discourse-common/(lib|utils)/*` into `discourse/lib/*`, adds shims for the imports, and updates existing uses in core.
36 lines
1,003 B
JavaScript
Vendored
36 lines
1,003 B
JavaScript
Vendored
import { ajax } from "discourse/lib/ajax";
|
|
import discourseComputed from "discourse/lib/decorators";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import Category from "discourse/models/category";
|
|
import RestModel from "discourse/models/rest";
|
|
|
|
export default class Permalink extends RestModel {
|
|
static findAll(filter) {
|
|
return ajax("/admin/permalinks.json").then(function (permalinks) {
|
|
let allLinks = permalinks.map((p) => Permalink.create(p));
|
|
|
|
let filteredLinks = filter
|
|
? allLinks.filter(
|
|
(p) => p.url.includes(filter) || p.external_url?.includes(filter)
|
|
)
|
|
: allLinks;
|
|
|
|
return { allLinks, filteredLinks };
|
|
});
|
|
}
|
|
|
|
@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("/", "_");
|
|
}
|
|
}
|