diff --git a/fakeyou/src/v2/view/_common/CategoryBreadcrumb.tsx b/fakeyou/src/v2/view/_common/CategoryBreadcrumb.tsx
new file mode 100644
index 0000000000..e51ba5e7e7
--- /dev/null
+++ b/fakeyou/src/v2/view/_common/CategoryBreadcrumb.tsx
@@ -0,0 +1,92 @@
+import { faChevronRight, faExclamationCircle } from '@fortawesome/free-solid-svg-icons';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import React from 'react';
+import { TtsCategory } from '../../api/category/ListTtsCategories';
+
+export interface Props {
+ // This is a list of categories in order: [grandparent/root, parent, child/leaf]
+ categoryHierarchy: TtsCategory[]
+ isCategoryMod: boolean,
+}
+
+export function CategoryBreadcrumb(props: Props) {
+
+ if (props.categoryHierarchy.length === 0) {
+ return null;
+ }
+
+ let parentCount = 0;
+ let hierarchyWarning = null;
+
+ let breadcrumbs = props.categoryHierarchy
+ .map((category, index) => {
+ let deletedWarning = null;
+ let notApprovedWarning = null;
+ let modelsNotAllowedWarning = null;
+
+ if (!!category.maybe_super_category_token) {
+ parentCount++;
+ }
+
+ if (!!category.category_deleted_at) {
+ deletedWarning = (
+ <>
+
+ Deleted category
+
+
+
+ >
+ )
+ }
+
+ if (!category.is_mod_approved) {
+ notApprovedWarning = (
+ <>
+
+ Not Mod Approved
+
+
+
+ >
+ )
+ }
+
+ const isLeaf = index === props.categoryHierarchy.length - 1;
+
+ if (isLeaf && !category.can_directly_have_models) {
+ modelsNotAllowedWarning = (
+ <>
+
+ Models not directly allowed
+
+
+
+ >
+ )
+ }
+
+ return (
+ <> {category.name} {deletedWarning} {modelsNotAllowedWarning} {notApprovedWarning}>
+ )
+ })
+ .reduce((acc, cur) => <>{acc} {cur}>)
+
+ if (props.isCategoryMod && parentCount !== props.categoryHierarchy.length - 1) {
+ hierarchyWarning = (
+ <>
+
+ Bad parent category in chain
+
+
+
+ >
+ )
+ }
+
+ return (
+ <>
+ {hierarchyWarning} {breadcrumbs}
+ >
+ )
+}
diff --git a/fakeyou/src/v2/view/tts/tts_model_view/TtsModelViewFc.tsx b/fakeyou/src/v2/view/tts/tts_model_view/TtsModelViewFc.tsx
index 2ffb46fd2c..4e071ef2d1 100644
--- a/fakeyou/src/v2/view/tts/tts_model_view/TtsModelViewFc.tsx
+++ b/fakeyou/src/v2/view/tts/tts_model_view/TtsModelViewFc.tsx
@@ -14,9 +14,8 @@ import { GravatarFc } from '../../_common/GravatarFc';
import { GetTtsModelUseCount } from '../../../api/tts/GetTtsModelUseCount';
import { BackLink } from '../../_common/BackLink';
import { ListTtsCategoriesForModel, ListTtsCategoriesForModelIsError, ListTtsCategoriesForModelIsOk, TtsModelCategory } from '../../../api/category/ListTtsCategoriesForModel';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faChevronRight, faExclamationCircle } from '@fortawesome/free-solid-svg-icons';
import { ListTtsCategories, ListTtsCategoriesIsError, ListTtsCategoriesIsOk, TtsCategory } from '../../../api/category/ListTtsCategories';
+import { CategoryBreadcrumb } from '../../_common/CategoryBreadcrumb';
interface Props {
sessionWrapper: SessionWrapper,
@@ -293,7 +292,6 @@ function TtsModelViewFc(props: Props) {
if (showCategorySection) {
let modelCategories = null;
- // TODO: Should be a shared component
if (assignedCategories.length !== 0) {
modelCategories = (
<>
@@ -305,81 +303,11 @@ function TtsModelViewFc(props: Props) {
assignedCategoriesByTokenMap,
category.category_token);
- let breadcrumbs = <>>;
- let parentCount = 0;
- let hierarchyWarning = null;
-
- if (categoryHierarchy.length !== 0) {
- breadcrumbs = categoryHierarchy
- .map((category, index) => {
- let deletedWarning = null;
- let notApprovedWarning = null;
- let modelsNotAllowedWarning = null;
-
- if (!!category.maybe_super_category_token) {
- parentCount++;
- }
-
- if (!!category.category_deleted_at) {
- deletedWarning = (
- <>
-
- Deleted category
-
-
-
- >
- )
- }
-
- if (!category.is_mod_approved) {
- notApprovedWarning = (
- <>
-
- Not Mod Approved
-
-
-
- >
- )
- }
-
- const isLeaf = index === categoryHierarchy.length - 1;
-
- if (isLeaf && !category.can_directly_have_models) {
- modelsNotAllowedWarning = (
- <>
-
- Models not directly allowed
-
-
-
- >
- )
- }
-
- return (
- <> {category.name} {deletedWarning} {modelsNotAllowedWarning} {notApprovedWarning}>
- )
- })
- .reduce((acc, cur) => <>{acc} {cur}>)
- }
-
- if (isCategoryModerator && parentCount !== categoryHierarchy.length - 1) {
- hierarchyWarning = (
- <>
-
- Bad parent category in chain
-
-
-
- >
- )
- }
-
return (
<>
- {hierarchyWarning} {breadcrumbs}
+
+
+
>
);
})}