@messagevisor/catalog 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-Cx9rnVIG.js +73 -0
- package/dist/index.html +1 -1
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +573 -311
- package/lib/node/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api.spec.ts +46 -1
- package/src/api.ts +29 -1
- package/src/node/index.spec.ts +369 -50
- package/src/node/index.ts +443 -66
- package/src/pages/EntityDetailPage.tsx +15 -4
- package/src/types.ts +1 -0
- package/dist/assets/index-BJS9aW0t.js +0 -73
|
@@ -1149,7 +1149,8 @@ export function EntityDetailPage() {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
1151
1151
|
const entity = detail.entity as Record<string, any>;
|
|
1152
|
-
const
|
|
1152
|
+
const { manifest } = useCatalog();
|
|
1153
|
+
const tabs = getTabs(type, baseRoute, manifest.features?.duplicates === true);
|
|
1153
1154
|
|
|
1154
1155
|
return (
|
|
1155
1156
|
<div>
|
|
@@ -1178,7 +1179,7 @@ export function EntityDetailPage() {
|
|
|
1178
1179
|
);
|
|
1179
1180
|
}
|
|
1180
1181
|
|
|
1181
|
-
function getTabs(type: string, baseRoute: string) {
|
|
1182
|
+
function getTabs(type: string, baseRoute: string, duplicatesEnabled = false) {
|
|
1182
1183
|
const shared = [
|
|
1183
1184
|
{ label: "Overview", to: baseRoute, end: true },
|
|
1184
1185
|
{ label: "History", to: `${baseRoute}/history` },
|
|
@@ -1189,7 +1190,7 @@ function getTabs(type: string, baseRoute: string) {
|
|
|
1189
1190
|
shared[0],
|
|
1190
1191
|
{ label: "Formats", to: `${baseRoute}/formats` },
|
|
1191
1192
|
{ label: "Examples", to: `${baseRoute}/examples` },
|
|
1192
|
-
{ label: "Duplicates", to: `${baseRoute}/duplicates` },
|
|
1193
|
+
...(duplicatesEnabled ? [{ label: "Duplicates", to: `${baseRoute}/duplicates` }] : []),
|
|
1193
1194
|
shared[1],
|
|
1194
1195
|
];
|
|
1195
1196
|
}
|
|
@@ -2895,6 +2896,7 @@ function SortArrow(props: { active: boolean; direction: SortDirection }) {
|
|
|
2895
2896
|
|
|
2896
2897
|
export function LocaleDuplicatesTab() {
|
|
2897
2898
|
const { detail, setKey } = useEntityDetail();
|
|
2899
|
+
const { manifest } = useCatalog();
|
|
2898
2900
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
2899
2901
|
const [duplicates, setDuplicates] = React.useState<LocaleDuplicates | null>(null);
|
|
2900
2902
|
const [error, setError] = React.useState<string | null>(null);
|
|
@@ -2905,6 +2907,7 @@ export function LocaleDuplicatesTab() {
|
|
|
2905
2907
|
});
|
|
2906
2908
|
const localeDirection = (detail.entity as Record<string, any>).direction as string | undefined;
|
|
2907
2909
|
const searchQuery = searchParams.get("q") ?? "";
|
|
2910
|
+
const duplicatesEnabled = manifest.features?.duplicates === true;
|
|
2908
2911
|
|
|
2909
2912
|
function toggleDuplicateValue(duplicate: DuplicateTranslationValue) {
|
|
2910
2913
|
const duplicateHash = hashTranslationValue(duplicate.value);
|
|
@@ -2922,6 +2925,10 @@ export function LocaleDuplicatesTab() {
|
|
|
2922
2925
|
}
|
|
2923
2926
|
|
|
2924
2927
|
React.useEffect(() => {
|
|
2928
|
+
if (!duplicatesEnabled) {
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2925
2932
|
let cancelled = false;
|
|
2926
2933
|
|
|
2927
2934
|
setDuplicates(null);
|
|
@@ -2943,7 +2950,7 @@ export function LocaleDuplicatesTab() {
|
|
|
2943
2950
|
return () => {
|
|
2944
2951
|
cancelled = true;
|
|
2945
2952
|
};
|
|
2946
|
-
}, [detail.key, setKey]);
|
|
2953
|
+
}, [detail.key, duplicatesEnabled, setKey]);
|
|
2947
2954
|
|
|
2948
2955
|
React.useEffect(() => {
|
|
2949
2956
|
if (!duplicates || typeof window === "undefined") {
|
|
@@ -2973,6 +2980,10 @@ export function LocaleDuplicatesTab() {
|
|
|
2973
2980
|
|
|
2974
2981
|
useScrollToHash([duplicates?.duplicateValues.length, expandedDuplicateHashes.length]);
|
|
2975
2982
|
|
|
2983
|
+
if (!duplicatesEnabled) {
|
|
2984
|
+
return <Navigate to=".." replace />;
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2976
2987
|
if (error) {
|
|
2977
2988
|
return <EmptyState title="Unable to load duplicate translations" description={error} />;
|
|
2978
2989
|
}
|