Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 97x 97x 97x 97x 97x 193x 193x 193x 193x 192x 192x 192x 193x 188x 188x 191x 193x 188x 188x 193x 191x 148x 68x 68x 68x 68x 148x 90x 90x 90x 20x 20x 20x 20x 90x 97x 97x 97x 97x | import { Category } from '../store/flow-definition';
import { NODE_CONFIG } from './config';
import { SYSTEM_CATEGORIES_ALLOWED_FOR_TRANSLATION } from './categoryUtils';
export function getTranslatableCategoriesForNode(
nodeType: string | undefined,
categories: Category[] | undefined
): Category[] {
if (!nodeType || !categories?.length) {
return [];
}
const config = NODE_CONFIG[nodeType];
const blocked = config?.nonTranslatableCategories;
if (!blocked) {
return [...categories];
}
if (blocked === 'all') {
return categories.filter((category) =>
SYSTEM_CATEGORIES_ALLOWED_FOR_TRANSLATION.has(category.name)
);
}
const blockedSet = new Set(blocked);
return categories.filter(
(category) =>
!blockedSet.has(category.name) ||
SYSTEM_CATEGORIES_ALLOWED_FOR_TRANSLATION.has(category.name)
);
}
export function hasTranslatableCategoriesForNode(
nodeType: string | undefined,
categories: Category[] | undefined
): boolean {
return getTranslatableCategoriesForNode(nodeType, categories).length > 0;
}
|