mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: add transformer for default category view setting (#31264)
This allows us to set custom values here, like "Voting" from the topic voting plugin: https://github.com/discourse/discourse-topic-voting/pull/232
This commit is contained in:
parent
088ac0331e
commit
08b8439e21
@ -4,6 +4,7 @@ import { buildCategoryPanel } from "discourse/components/edit-category-panel";
|
|||||||
import { setting } from "discourse/lib/computed";
|
import { setting } from "discourse/lib/computed";
|
||||||
import { SEARCH_PRIORITIES } from "discourse/lib/constants";
|
import { SEARCH_PRIORITIES } from "discourse/lib/constants";
|
||||||
import discourseComputed from "discourse/lib/decorators";
|
import discourseComputed from "discourse/lib/decorators";
|
||||||
|
import { applyMutableValueTransformer } from "discourse/lib/transformer";
|
||||||
import { i18n } from "discourse-i18n";
|
import { i18n } from "discourse-i18n";
|
||||||
|
|
||||||
const categorySortCriteria = [];
|
const categorySortCriteria = [];
|
||||||
@ -49,12 +50,23 @@ export default class EditCategorySettings extends buildCategoryPanel(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed("category.id", "category.custom_fields")
|
||||||
availableViews() {
|
availableViews(categoryId, customFields) {
|
||||||
return [
|
const views = [
|
||||||
{ name: i18n("filters.latest.title"), value: "latest" },
|
{ name: i18n("filters.latest.title"), value: "latest" },
|
||||||
{ name: i18n("filters.top.title"), value: "top" },
|
{ name: i18n("filters.top.title"), value: "top" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const context = {
|
||||||
|
categoryId,
|
||||||
|
customFields,
|
||||||
|
};
|
||||||
|
|
||||||
|
return applyMutableValueTransformer(
|
||||||
|
"category-available-views",
|
||||||
|
views,
|
||||||
|
context
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
|
@ -7,6 +7,7 @@ export const BEHAVIOR_TRANSFORMERS = Object.freeze([
|
|||||||
|
|
||||||
export const VALUE_TRANSFORMERS = Object.freeze([
|
export const VALUE_TRANSFORMERS = Object.freeze([
|
||||||
// use only lowercase names
|
// use only lowercase names
|
||||||
|
"category-available-views",
|
||||||
"category-description-text",
|
"category-description-text",
|
||||||
"category-display-name",
|
"category-display-name",
|
||||||
"composer-service-cannot-submit-post",
|
"composer-service-cannot-submit-post",
|
||||||
|
Loading…
Reference in New Issue
Block a user