mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
UX: Use '-' as default category slug (#8607)
This replaces the default slug from 'ID-category' to '-'.
This commit is contained in:
parent
4f677854d3
commit
6279d0e8b5
|
@ -266,12 +266,8 @@ Category.reopenClass({
|
|||
result = Category.slugFor(parentCategory) + separator;
|
||||
}
|
||||
|
||||
const id = get(category, "id"),
|
||||
slug = get(category, "slug");
|
||||
|
||||
return !slug || slug.trim().length === 0
|
||||
? `${result}${id}-category`
|
||||
: result + slug;
|
||||
const slug = get(category, "slug");
|
||||
return !slug || slug.trim().length === 0 ? `${result}-` : result + slug;
|
||||
},
|
||||
|
||||
list() {
|
||||
|
|
|
@ -17,13 +17,13 @@ QUnit.test("slugFor", assert => {
|
|||
);
|
||||
slugFor(
|
||||
store.createRecord("category", { id: 123, slug: "" }),
|
||||
"123-category",
|
||||
"It returns id-category for empty strings"
|
||||
"-",
|
||||
"It returns - for empty slugs"
|
||||
);
|
||||
slugFor(
|
||||
store.createRecord("category", { id: 456 }),
|
||||
"456-category",
|
||||
"It returns id-category for undefined slugs"
|
||||
"-",
|
||||
"It returns - for undefined slugs"
|
||||
);
|
||||
slugFor(
|
||||
store.createRecord("category", { slug: "熱帶風暴畫眉" }),
|
||||
|
@ -46,14 +46,14 @@ QUnit.test("slugFor", assert => {
|
|||
|
||||
slugFor(
|
||||
store.createRecord("category", { id: 555, parentCategory: parentCategory }),
|
||||
"darth/555-category",
|
||||
"darth/-",
|
||||
"it uses the parent slug before the child and then uses id"
|
||||
);
|
||||
|
||||
parentCategory.set("slug", null);
|
||||
slugFor(
|
||||
store.createRecord("category", { id: 555, parentCategory: parentCategory }),
|
||||
"345-category/555-category",
|
||||
"-/-",
|
||||
"it uses the parent before the child and uses ids for both"
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user