|
| 1 | +diff --git a/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx b/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx |
| 2 | +index 8bcef4d..2551e92 100644 |
| 3 | +--- a/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx |
| 4 | ++++ b/src/components/molecules/EnrichedTable/organisms/EnrichedTable/utils.tsx |
| 5 | +@@ -22,6 +22,15 @@ import { TableFactory } from '../../molecules' |
| 6 | + import { ShortenedTextWithTooltip, FilterDropdown, TrimmedTags, TextAlignContainer, TinyButton } from './atoms' |
| 7 | + import { TInternalDataForControls } from './types' |
| 8 | + |
| 9 | ++const getPluralForm = (singular: string): string => { |
| 10 | ++ // If already ends with 's', add 'es' |
| 11 | ++ if (singular.endsWith('s')) { |
| 12 | ++ return `${singular}es` |
| 13 | ++ } |
| 14 | ++ // Otherwise just add 's' |
| 15 | ++ return `${singular}s` |
| 16 | ++} |
| 17 | ++ |
| 18 | + export const getCellRender = ({ |
| 19 | + value, |
| 20 | + record, |
| 21 | +@@ -255,7 +264,7 @@ export const getEnrichedColumnsWithControls = ({ |
| 22 | + key: 'controls', |
| 23 | + className: 'controls', |
| 24 | + width: 60, |
| 25 | +- render: (value: TInternalDataForControls) => { |
| 26 | ++ render: (value: TInternalDataForControls, record: unknown) => { |
| 27 | + return ( |
| 28 | + // <TextAlignContainer $align="right" className="hideable"> |
| 29 | + <TextAlignContainer $align="center"> |
| 30 | +@@ -279,10 +288,19 @@ export const getEnrichedColumnsWithControls = ({ |
| 31 | + domEvent.stopPropagation() |
| 32 | + domEvent.preventDefault() |
| 33 | + if (key === 'edit') { |
| 34 | ++ // Special case: redirect tenantmodules from core.cozystack.io to apps.cozystack.io with plural form |
| 35 | ++ let apiGroupAndVersion = value.apiGroupAndVersion |
| 36 | ++ let typeName = value.typeName |
| 37 | ++ if (apiGroupAndVersion?.startsWith('core.cozystack.io/') && typeName === 'tenantmodules') { |
| 38 | ++ const appsApiVersion = apiGroupAndVersion.replace('core.cozystack.io/', 'apps.cozystack.io/') |
| 39 | ++ const pluralTypeName = getPluralForm(value.entryName) |
| 40 | ++ apiGroupAndVersion = appsApiVersion |
| 41 | ++ typeName = pluralTypeName |
| 42 | ++ } |
| 43 | + navigate( |
| 44 | + `${baseprefix}/${value.cluster}${value.namespace ? `/${value.namespace}` : ''}${ |
| 45 | + value.syntheticProject ? `/${value.syntheticProject}` : '' |
| 46 | +- }/${value.pathPrefix}/${value.apiGroupAndVersion}/${value.typeName}/${value.entryName}?backlink=${ |
| 47 | ++ }/${value.pathPrefix}/${apiGroupAndVersion}/${typeName}/${value.entryName}?backlink=${ |
| 48 | + value.backlink |
| 49 | + }`, |
| 50 | + ) |
0 commit comments