1313 */
1414
1515import * as React from 'react' ;
16- import { Link , Navigate , useNavigate , useParams , useSearchParams } from 'react-router-dom' ;
16+ import { Link , Navigate , useLocation , useNavigate , useParams , useSearchParams } from 'react-router-dom' ;
1717import { Plus , Search , RefreshCw , AlertTriangle , Lock , Copy } from 'lucide-react' ;
1818import {
1919 Button ,
@@ -51,6 +51,9 @@ import { Empty, EmptyTitle, EmptyDescription, EmptyValue } from '@object-ui/comp
5151import { PageShell , WritabilityBadge } from './PageShell.js' ;
5252import { PageHeader } from '../../layout/PageHeader.js' ;
5353import { useInSetupApp } from '../../console/setupApp.js' ;
54+ import { useExpressionContext } from '../../providers/ExpressionProvider.js' ;
55+ import { useObjectTranslation } from '@object-ui/i18n' ;
56+ import { navEntryTitle } from './navEntryTitle.js' ;
5457import { getIcon } from '../../utils/getIcon.js' ;
5558import { MetadataTypeActions } from './MetadataTypeActions.js' ;
5659import { CreatePackageDialog } from './PackagesPage.js' ;
@@ -187,6 +190,11 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
187190 // the description. Read off the route's `:appName`; the same page anywhere
188191 // else (the directory, Studio's "Open in Setup" target) keeps its shell.
189192 const inSetup = useInSetupApp ( ) ;
193+ // objectstack#27356 — under Setup the header names the page as the sidebar
194+ // entry that opens it does ("Positions"); the type's label otherwise.
195+ const { app } = useExpressionContext ( ) ;
196+ const location = useLocation ( ) ;
197+ const { t : navT , language } = useObjectTranslation ( ) ;
190198 // objectui#12183 — under a wall the security catalog is the platform
191199 // operator's: the server refuses this caller every write of the type,
192200 // whatever it holds (`catalog-scope.ts`). Not keyed on the scope: the server's
@@ -577,6 +585,13 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
577585 config . bundleMemberField ,
578586 ) ;
579587 const typeLabel = translateMetadataType ( type , locale , entry ?. label ?? type ) ;
588+ const setupTitle =
589+ ( inSetup && navEntryTitle ( app , `/apps/${ appName } ` , location . pathname , location . search , navT , language ) ) || typeLabel ;
590+ // objectstack#27356 — under Setup the label leads the identity cell, with the
591+ // API name beneath it, in place of a separate Label column.
592+ const primaryKey = config . primaryKey ?? 'name' ;
593+ const labelColumn = inSetup && columns [ 0 ] ?. key === primaryKey ? columns . find ( ( c ) => c . key === 'label' ) : undefined ;
594+ const shownColumns = labelColumn ? columns . filter ( ( c ) => c !== labelColumn ) : columns ;
580595 // The type offers SOME runtime write channel (the editors' type tier), and —
581596 // in the environment scope — the caller holds the capability the metadata
582597 // door requires. The server refuses either way; this is the half that says
@@ -826,13 +841,13 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
826841 }
827842 >
828843 < tr className = { HEAD_ROW_TINT } >
829- { columns . map ( ( c ) => (
844+ { shownColumns . map ( ( c , ci ) => (
830845 < th
831846 key = { c . key }
832847 className = { cn ( 'px-3 text-left font-medium' , inSetup ? 'h-9 py-0' : 'py-2' ) }
833848 style = { c . width ? { width : c . width } : undefined }
834849 >
835- { localizeColumnLabel ( c ) }
850+ { localizeColumnLabel ( ci === 0 && labelColumn ? labelColumn : c ) }
836851 </ th >
837852 ) ) }
838853 < th className = { cn ( 'px-3 text-right font-medium w-[80px]' , inSetup ? 'h-9 py-0' : 'py-2' ) } > { t ( 'engine.list.col.source' , locale ) } </ th >
@@ -910,9 +925,11 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
910925 HOVER_ROW_TINT ,
911926 ) }
912927 >
913- { columns . map ( ( c , ci ) => {
928+ { shownColumns . map ( ( c , ci ) => {
914929 const value = row . item [ c . key ] ;
915930 const cell = c . render ? c . render ( value , row . item ) : defaultCell ( value ) ;
931+ const labelValue = labelColumn ? row . item [ labelColumn . key ] : undefined ;
932+ const hasLabel = labelValue != null && labelValue !== '' ;
916933 return (
917934 < td key = { c . key } className = { cellClass } >
918935 { ci === 0 ? (
@@ -935,12 +952,32 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
935952 < AlertTriangle className = "w-3.5 h-3.5 text-amber-600 dark:text-amber-400 shrink-0" />
936953 </ span >
937954 ) }
938- < Link
939- to = { rowHref }
940- className = "text-primary hover:underline font-mono"
941- >
942- { cell }
943- </ Link >
955+ { labelColumn && hasLabel ? (
956+ < span className = "min-w-0" >
957+ < Link to = { rowHref } className = "text-primary hover:underline" >
958+ { labelColumn . render ? labelColumn . render ( labelValue , row . item ) : defaultCell ( labelValue ) }
959+ </ Link >
960+ < span
961+ className = "block font-mono text-xs text-muted-foreground"
962+ data-testid = "metadata-row-api-name"
963+ >
964+ { cell }
965+ </ span >
966+ </ span >
967+ ) : (
968+ < Link
969+ to = { rowHref }
970+ className = "text-primary hover:underline font-mono"
971+ >
972+ { cell }
973+ </ Link >
974+ ) }
975+ </ span >
976+ ) : inSetup && c . key === 'description' && typeof value === 'string' && value !== '' ? (
977+ // objectstack#27356 — two lines at most, so a row
978+ // stays a row on a phone; the whole text on hover.
979+ < span className = "line-clamp-2" title = { value } >
980+ { cell }
944981 </ span >
945982 ) : (
946983 cell
@@ -1068,7 +1105,7 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
10681105 return (
10691106 < div className = "flex flex-col h-full overflow-hidden" >
10701107 < PageHeader
1071- title = { typeLabel }
1108+ title = { setupTitle }
10721109 // `createElement`, not a JSX tag: the looked-up icon is a value
10731110 // (the convention ObjectView set).
10741111 icon = { React . createElement ( getIcon ( config . iconName ?? 'layers' ) , { className : 'h-4 w-4' } ) }
0 commit comments