diff --git a/.ibm/pipelines/value_files/values_showcase-rbac.yaml b/.ibm/pipelines/value_files/values_showcase-rbac.yaml index 8c8a15c58c..0c340ddbf1 100644 --- a/.ibm/pipelines/value_files/values_showcase-rbac.yaml +++ b/.ibm/pipelines/value_files/values_showcase-rbac.yaml @@ -118,6 +118,7 @@ global: entityTabs: - path: "/scorecard" title: Scorecard + titleKey: catalog.entityPage.scorecard.title mountPoint: entity.page.scorecard mountPoints: - mountPoint: entity.page.scorecard/cards diff --git a/dynamic-plugins.default.yaml b/dynamic-plugins.default.yaml index 504cfdc23e..0d17100fe8 100644 --- a/dynamic-plugins.default.yaml +++ b/dynamic-plugins.default.yaml @@ -1326,6 +1326,7 @@ plugins: entityTabs: - path: /workflows title: Workflows + titleKey: catalog.entityPage.workflows.title mountPoint: entity.page.workflows mountPoints: - mountPoint: entity.page.workflows/cards diff --git a/packages/app/src/components/DynamicRoot/DynamicRoot.tsx b/packages/app/src/components/DynamicRoot/DynamicRoot.tsx index a9e8b98c4f..4e394dccf8 100644 --- a/packages/app/src/components/DynamicRoot/DynamicRoot.tsx +++ b/packages/app/src/components/DynamicRoot/DynamicRoot.tsx @@ -443,14 +443,14 @@ export const DynamicRoot = ({ }, []); const entityTabOverrides = entityTabs.reduce( - (acc, { path, title, mountPoint, scope, priority }) => { + (acc, { path, title, titleKey, mountPoint, scope, priority }) => { if (acc[path]) { // eslint-disable-next-line no-console console.warn( `Plugin ${scope} is not configured properly: a tab has already been configured for "${path}", ignoring entry with title: "${title}" and mountPoint: "${mountPoint}"`, ); } else { - acc[path] = { title, mountPoint, priority }; + acc[path] = { title, titleKey, mountPoint, priority }; } return acc; }, diff --git a/packages/app/src/components/catalog/EntityPage/DiagramTabContent.tsx b/packages/app/src/components/catalog/EntityPage/DiagramTabContent.tsx index aff0159da6..3dbeee51cf 100644 --- a/packages/app/src/components/catalog/EntityPage/DiagramTabContent.tsx +++ b/packages/app/src/components/catalog/EntityPage/DiagramTabContent.tsx @@ -27,7 +27,7 @@ export const DiagramTabContent = () => { ((props, ref) => { + const { title, titleKey, path, children, ...otherProps } = props; + const { t } = useTranslation(); + + const translatedText = getTranslatedTextWithFallback(t, titleKey, title); + return ( + + {translatedText} + + ); +}); + export type DynamicEntityTabProps = { path: string; title: string; + titleKey?: string; mountPoint: string; if?: (entity: Entity) => boolean; children?: React.ReactNode; @@ -30,6 +57,7 @@ export type DynamicEntityTabProps = { export const dynamicEntityTab = ({ path, title, + titleKey, mountPoint, children, if: condition, @@ -38,6 +66,12 @@ export const dynamicEntityTab = ({ key={`${path}`} path={path} title={title} + tabProps={{ + component: TranslatedTab, + title: title, + titleKey: titleKey, + path: path, + }} if={entity => (condition ? errorWrappedCondition( diff --git a/packages/app/src/components/catalog/EntityPage/defaultTabs.tsx b/packages/app/src/components/catalog/EntityPage/defaultTabs.tsx index fda8653c69..c3e4875bfd 100644 --- a/packages/app/src/components/catalog/EntityPage/defaultTabs.tsx +++ b/packages/app/src/components/catalog/EntityPage/defaultTabs.tsx @@ -18,62 +18,77 @@ export const defaultTabs: Record< > = { '/': { title: 'Overview', + titleKey: 'catalog.entityPage.overview.title', mountPoint: 'entity.page.overview', }, '/topology': { title: 'Topology', + titleKey: 'catalog.entityPage.topology.title', mountPoint: 'entity.page.topology', }, '/issues': { title: 'Issues', + titleKey: 'catalog.entityPage.issues.title', mountPoint: 'entity.page.issues', }, '/pr': { title: 'Pull/Merge Requests', + titleKey: 'catalog.entityPage.pullRequests.title', mountPoint: 'entity.page.pull-requests', }, '/ci': { title: 'CI', + titleKey: 'catalog.entityPage.ci.title', mountPoint: 'entity.page.ci', }, '/cd': { title: 'CD', + titleKey: 'catalog.entityPage.cd.title', mountPoint: 'entity.page.cd', }, '/kubernetes': { title: 'Kubernetes', + titleKey: 'catalog.entityPage.kubernetes.title', mountPoint: 'entity.page.kubernetes', }, '/image-registry': { title: 'Image Registry', + titleKey: 'catalog.entityPage.imageRegistry.title', mountPoint: 'entity.page.image-registry', }, '/monitoring': { title: 'Monitoring', + titleKey: 'catalog.entityPage.monitoring.title', mountPoint: 'entity.page.monitoring', }, '/lighthouse': { title: 'Lighthouse', + titleKey: 'catalog.entityPage.lighthouse.title', mountPoint: 'entity.page.lighthouse', }, '/api': { title: 'Api', + titleKey: 'catalog.entityPage.api.title', mountPoint: 'entity.page.api', }, '/dependencies': { title: 'Dependencies', + titleKey: 'catalog.entityPage.dependencies.title', mountPoint: 'entity.page.dependencies', }, '/docs': { title: 'Docs', + titleKey: 'catalog.entityPage.docs.title', mountPoint: 'entity.page.docs', }, '/definition': { title: 'Definition', + titleKey: 'catalog.entityPage.definition.title', mountPoint: 'entity.page.definition', }, '/system': { title: 'Diagram', + titleKey: 'catalog.entityPage.diagram.title', mountPoint: 'entity.page.diagram', }, }; diff --git a/packages/app/src/translations/rhdh/de.ts b/packages/app/src/translations/rhdh/de.ts index 56373336fb..df27fbdfc7 100644 --- a/packages/app/src/translations/rhdh/de.ts +++ b/packages/app/src/translations/rhdh/de.ts @@ -43,6 +43,23 @@ export default createTranslationMessages({ 'menuItem.orchestrator': 'Orchestrator', 'menuItem.adoptionInsights': 'Einführungseinblicke', + 'catalog.entityPage.overview.title': 'Übersicht', + 'catalog.entityPage.topology.title': 'Topologie', + 'catalog.entityPage.issues.title': 'Issues', + 'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests', + 'catalog.entityPage.ci.title': 'CI', + 'catalog.entityPage.cd.title': 'CD', + 'catalog.entityPage.kubernetes.title': 'Kubernetes', + 'catalog.entityPage.imageRegistry.title': 'Image Registry', + 'catalog.entityPage.monitoring.title': 'Überwachung', + 'catalog.entityPage.lighthouse.title': 'Lighthouse', + 'catalog.entityPage.api.title': 'API', + 'catalog.entityPage.dependencies.title': 'Abhängigkeiten', + 'catalog.entityPage.docs.title': 'Dokumentation', + 'catalog.entityPage.definition.title': 'Definition', + 'catalog.entityPage.diagram.title': 'Systemdiagramm', + 'catalog.entityPage.workflows.title': 'Workflows', + 'sidebar.menu': 'Menü', 'sidebar.home': 'Startseite', 'sidebar.homeLogo': 'Startseite-Logo', @@ -88,7 +105,6 @@ export default createTranslationMessages({ 'app.learningPaths.title': 'Lernpfade', 'app.learningPaths.error.title': 'Daten konnten nicht abgerufen werden.', 'app.learningPaths.error.unknownError': 'Unbekannter Fehler', - 'app.entityPage.diagram.title': 'Systemdiagramm', 'app.userSettings.infoCard.title': 'RHDH-Metadaten', 'app.userSettings.infoCard.metadataCopied': 'Metadaten in die Zwischenablage kopiert', diff --git a/packages/app/src/translations/rhdh/es.ts b/packages/app/src/translations/rhdh/es.ts index 69b02c99e8..010dad8b6a 100644 --- a/packages/app/src/translations/rhdh/es.ts +++ b/packages/app/src/translations/rhdh/es.ts @@ -43,6 +43,23 @@ export default createTranslationMessages({ 'menuItem.orchestrator': 'Orquestador', 'menuItem.adoptionInsights': 'Insights de adopción', + 'catalog.entityPage.overview.title': 'Resumen', + 'catalog.entityPage.topology.title': 'Topología', + 'catalog.entityPage.issues.title': 'Problemas', + 'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests', + 'catalog.entityPage.ci.title': 'CI', + 'catalog.entityPage.cd.title': 'CD', + 'catalog.entityPage.kubernetes.title': 'Kubernetes', + 'catalog.entityPage.imageRegistry.title': 'Registro de Imágenes', + 'catalog.entityPage.monitoring.title': 'Monitoreo', + 'catalog.entityPage.lighthouse.title': 'Lighthouse', + 'catalog.entityPage.api.title': 'API', + 'catalog.entityPage.dependencies.title': 'Dependencias', + 'catalog.entityPage.docs.title': 'Documentación', + 'catalog.entityPage.definition.title': 'Definición', + 'catalog.entityPage.diagram.title': 'Diagrama del Sistema', + 'catalog.entityPage.workflows.title': 'Flujos de trabajo', + 'sidebar.menu': 'Menú', 'sidebar.home': 'Inicio', 'sidebar.homeLogo': 'Logo de inicio', @@ -89,7 +106,6 @@ export default createTranslationMessages({ 'app.learningPaths.title': 'Rutas de aprendizaje', 'app.learningPaths.error.title': 'No se pudieron obtener los datos.', 'app.learningPaths.error.unknownError': 'Error desconocido', - 'app.entityPage.diagram.title': 'Diagrama del sistema', 'app.userSettings.infoCard.title': 'Metadatos RHDH', 'app.userSettings.infoCard.metadataCopied': 'Metadatos copiados al portapapeles', diff --git a/packages/app/src/translations/rhdh/fr.ts b/packages/app/src/translations/rhdh/fr.ts index b78fe3e8ad..89e602d85e 100644 --- a/packages/app/src/translations/rhdh/fr.ts +++ b/packages/app/src/translations/rhdh/fr.ts @@ -43,6 +43,23 @@ export default createTranslationMessages({ 'menuItem.orchestrator': 'Orchestrateur', 'menuItem.adoptionInsights': "Insights d'adoption", + 'catalog.entityPage.overview.title': 'Aperçu', + 'catalog.entityPage.topology.title': 'Topologie', + 'catalog.entityPage.issues.title': 'Problèmes', + 'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests', + 'catalog.entityPage.ci.title': 'CI', + 'catalog.entityPage.cd.title': 'CD', + 'catalog.entityPage.kubernetes.title': 'Kubernetes', + 'catalog.entityPage.imageRegistry.title': "Registre d'Images", + 'catalog.entityPage.monitoring.title': 'Surveillance', + 'catalog.entityPage.lighthouse.title': 'Lighthouse', + 'catalog.entityPage.api.title': 'API', + 'catalog.entityPage.dependencies.title': 'Dépendances', + 'catalog.entityPage.docs.title': 'Documentation', + 'catalog.entityPage.definition.title': 'Définition', + 'catalog.entityPage.diagram.title': 'Diagramme du Système', + 'catalog.entityPage.workflows.title': 'Flux de travail', + 'sidebar.menu': 'Menu', 'sidebar.home': 'Accueil', 'sidebar.homeLogo': "Logo d'accueil", @@ -89,7 +106,6 @@ export default createTranslationMessages({ 'app.learningPaths.title': "Parcours d'apprentissage", 'app.learningPaths.error.title': 'Impossible de récupérer les données.', 'app.learningPaths.error.unknownError': 'Erreur inconnue', - 'app.entityPage.diagram.title': 'Diagramme système', 'app.userSettings.infoCard.title': 'Métadonnées RHDH', 'app.userSettings.infoCard.metadataCopied': 'Métadonnées copiées dans le presse-papiers', diff --git a/packages/app/src/translations/rhdh/it.ts b/packages/app/src/translations/rhdh/it.ts index b6c64a7927..1762b05536 100644 --- a/packages/app/src/translations/rhdh/it.ts +++ b/packages/app/src/translations/rhdh/it.ts @@ -43,6 +43,23 @@ export default createTranslationMessages({ 'menuItem.orchestrator': 'Orchestratore', 'menuItem.adoptionInsights': 'Insights di adozione', + 'catalog.entityPage.overview.title': 'Panoramica', + 'catalog.entityPage.topology.title': 'Topologia', + 'catalog.entityPage.issues.title': 'Problemi', + 'catalog.entityPage.pullRequests.title': 'Pull/Merge Requests', + 'catalog.entityPage.ci.title': 'CI', + 'catalog.entityPage.cd.title': 'CD', + 'catalog.entityPage.kubernetes.title': 'Kubernetes', + 'catalog.entityPage.imageRegistry.title': 'Registro Immagini', + 'catalog.entityPage.monitoring.title': 'Monitoraggio', + 'catalog.entityPage.lighthouse.title': 'Lighthouse', + 'catalog.entityPage.api.title': 'API', + 'catalog.entityPage.dependencies.title': 'Dipendenze', + 'catalog.entityPage.docs.title': 'Documentazione', + 'catalog.entityPage.definition.title': 'Definizione', + 'catalog.entityPage.diagram.title': 'Diagramma del Sistema', + 'catalog.entityPage.workflows.title': 'Flussi di lavoro', + 'sidebar.menu': 'Menu', 'sidebar.home': 'Home', 'sidebar.homeLogo': 'Logo principale', @@ -88,7 +105,6 @@ export default createTranslationMessages({ 'app.learningPaths.title': 'Percorsi di apprendimento', 'app.learningPaths.error.title': 'Impossibile recuperare i dati.', 'app.learningPaths.error.unknownError': 'Errore sconosciuto', - 'app.entityPage.diagram.title': 'Diagramma di sistema', 'app.userSettings.infoCard.title': 'Metadati RHDH', 'app.userSettings.infoCard.metadataCopied': 'Metadati copiati negli appunti', diff --git a/packages/app/src/translations/rhdh/ref.ts b/packages/app/src/translations/rhdh/ref.ts index 1a2d34ccbc..179a4bbc43 100644 --- a/packages/app/src/translations/rhdh/ref.ts +++ b/packages/app/src/translations/rhdh/ref.ts @@ -103,6 +103,58 @@ export const rhdhMessages = { }, }, }, + catalog: { + entityPage: { + overview: { + title: 'Overview', + }, + topology: { + title: 'Topology', + }, + issues: { + title: 'Issues', + }, + pullRequests: { + title: 'Pull/Merge Requests', + }, + ci: { + title: 'CI', + }, + cd: { + title: 'CD', + }, + kubernetes: { + title: 'Kubernetes', + }, + imageRegistry: { + title: 'Image Registry', + }, + monitoring: { + title: 'Monitoring', + }, + lighthouse: { + title: 'Lighthouse', + }, + api: { + title: 'API', + }, + dependencies: { + title: 'Dependencies', + }, + docs: { + title: 'Docs', + }, + definition: { + title: 'Definition', + }, + diagram: { + title: 'System Diagram', + }, + workflows: { + title: 'Workflows', + }, + }, + }, app: { scaffolder: { title: 'Self-service', @@ -127,11 +179,6 @@ export const rhdhMessages = { unknownError: 'Unknown error', }, }, - entityPage: { - diagram: { - title: 'System Diagram', - }, - }, userSettings: { infoCard: { title: 'RHDH Metadata', diff --git a/packages/app/src/utils/dynamicUI/extractDynamicConfig.ts b/packages/app/src/utils/dynamicUI/extractDynamicConfig.ts index 76f5cf7f33..df807c0497 100644 --- a/packages/app/src/utils/dynamicUI/extractDynamicConfig.ts +++ b/packages/app/src/utils/dynamicUI/extractDynamicConfig.ts @@ -117,6 +117,7 @@ type EntityTab = { mountPoint: string; path: string; title: string; + titleKey?: string; pariority?: number; }; @@ -125,6 +126,7 @@ type EntityTabEntry = { mountPoint: string; path: string; title: string; + titleKey?: string; priority?: number; }; diff --git a/packages/app/src/utils/translations/index.ts b/packages/app/src/utils/translations/index.ts index f0f5b390a1..2d9572bed7 100644 --- a/packages/app/src/utils/translations/index.ts +++ b/packages/app/src/utils/translations/index.ts @@ -1,2 +1,3 @@ export { fetchOverrideTranslations } from './fetchOverrideTranslations'; export { translationResourceGenerator } from './translationResourceGenerator'; +export { getTranslatedTextWithFallback } from './translationUtils'; diff --git a/packages/app/src/utils/translations/translationUtils.ts b/packages/app/src/utils/translations/translationUtils.ts new file mode 100644 index 0000000000..42bad0ee6b --- /dev/null +++ b/packages/app/src/utils/translations/translationUtils.ts @@ -0,0 +1,39 @@ +/* + * Copyright Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { TranslationFunction } from '@backstage/core-plugin-api/alpha'; + +import { rhdhTranslationRef } from '../../translations/rhdh'; + +/** + * Utility function to get translated text with fallback to original text + * + * @param t - Translation function + * @param translationKey - Optional translation key to look up + * @param fallbackText - Text to display if translation key is not provided or translation is not found + * @returns Translated text or fallback text + */ +export const getTranslatedTextWithFallback = ( + t: TranslationFunction, + translationKey: string | undefined, + fallbackText: string, +): string => { + if (!translationKey) { + return fallbackText; + } + + const translation = t(translationKey as keyof typeof t, {}); + return translation !== translationKey ? translation : fallbackText; +}; diff --git a/packages/plugin-utils/src/types.ts b/packages/plugin-utils/src/types.ts index 4bb7de80bf..f5afff0ac3 100644 --- a/packages/plugin-utils/src/types.ts +++ b/packages/plugin-utils/src/types.ts @@ -78,7 +78,7 @@ export type MountPoint = { export type EntityTabOverrides = Record< string, - { title: string; mountPoint: string; priority?: number } + { title: string; titleKey?: string; mountPoint: string; priority?: number } >; export type MountPoints = Record;