diff --git a/assets/src/components/apps/Apps.tsx b/assets/src/components/apps/Apps.tsx index db70dfd609..4e5b3c13d6 100644 --- a/assets/src/components/apps/Apps.tsx +++ b/assets/src/components/apps/Apps.tsx @@ -178,6 +178,8 @@ export default function Apps() { return ( diff --git a/assets/src/components/apps/app/components/Component.tsx b/assets/src/components/apps/app/components/Component.tsx index b55593880e..f36b68c8bc 100644 --- a/assets/src/components/apps/app/components/Component.tsx +++ b/assets/src/components/apps/app/components/Component.tsx @@ -22,6 +22,7 @@ export default function Component({ tags.reduce((acc, { name, value }) => ({ ...acc, [name]: value }), {}) @@ -34,45 +36,66 @@ export function LabelsAnnotationsRow({ export function LabelsAnnotationsTag({ name, value }: LabelPair) { return ( - + {name} {value && `: ${value}`} ) } +function renderLabel(label: Maybe) { + return ( + <> + {label?.name} + {label?.value && `: ${label.value}`} + + ) +} + export function LabelsAnnotations({ metadata: { labels, annotations }, ...props }: { metadata: MetadataT } & CardProps) { + const theme = useTheme() + + const hasLabels = labels && labels?.length > 0 + const hasAnnotations = annotations && annotations.length > 0 + const hasData = hasLabels || hasAnnotations + + if (!hasData) { + return null + } + return ( - + - - {labels?.map(label => ( - + - ))} - - - {annotations?.map(annotation => ( - + )} + {hasAnnotations && ( + + - ))} - + + )} - + ) } diff --git a/assets/src/components/cluster/containers/Container.tsx b/assets/src/components/cluster/containers/Container.tsx index e03219f3dd..ba87b2470e 100644 --- a/assets/src/components/cluster/containers/Container.tsx +++ b/assets/src/components/cluster/containers/Container.tsx @@ -85,6 +85,7 @@ export default function Container() { const match = useMatch('/pods/:namespace/:name/shell/:container/:subpath') const subpath = match?.params?.subpath || '' + const currentTab = DIRECTORY.find(({ path }) => path === subpath) const { data, error } = useQuery<{ pod: Pod }>(POD_INFO_Q, { variables: { name, namespace }, @@ -148,7 +149,7 @@ export default function Container() { return ( diff --git a/assets/src/components/cluster/nodes/Node.tsx b/assets/src/components/cluster/nodes/Node.tsx index 5834fef03f..bd60f5b079 100644 --- a/assets/src/components/cluster/nodes/Node.tsx +++ b/assets/src/components/cluster/nodes/Node.tsx @@ -61,7 +61,7 @@ export default function Node() { stateRef={tabStateRef} as={( (({ theme, maxCols = MAX_COLS }) => ({ - ...makeGrid({ maxCols, minColWidth: 186, gap: theme.spacing.xlarge }), - padding: theme.spacing.large, +export const CARD_CONTENT_MAX_WIDTH = 1526 + +const MetadataGridGrid = styled.div<{ maxCols: number }>(({ theme, maxCols = MAX_COLS }) => ({ + ...makeGrid({ + maxCols, + minColWidth: 186, + gap: theme.spacing.xlarge, + }), })) +export function MetadataCard({ children, ...props }: CardProps) { + return ( + + {/* 1526 is magic number which is the card's width when screen is 1940px wide */} +
{children} +
+
+ ) +} + export function MetadataGrid(props) { const numChildren = Children.count(props.children) - const maxCols = (numChildren < MAX_COLS) ? numChildren : MAX_COLS + const maxCols = numChildren < MAX_COLS ? numChildren : MAX_COLS return ( - + + + ) } diff --git a/assets/src/components/utils/layout/ResponsivePageFullWidth.tsx b/assets/src/components/utils/layout/ResponsivePageFullWidth.tsx index d2bb6cd1d6..928e77056a 100644 --- a/assets/src/components/utils/layout/ResponsivePageFullWidth.tsx +++ b/assets/src/components/utils/layout/ResponsivePageFullWidth.tsx @@ -1,5 +1,4 @@ import { ResponsiveLayoutPage } from 'components/utils/layout/ResponsiveLayoutPage' -import { useTheme } from 'styled-components' import { ComponentProps } from 'react' import { ScrollablePage } from './ScrollablePage' @@ -9,8 +8,6 @@ export function ResponsivePageFullWidth({ children, ...props }: ComponentProps) { - const theme = useTheme() - return ( {children} diff --git a/assets/src/components/utils/layout/ScrollablePage.tsx b/assets/src/components/utils/layout/ScrollablePage.tsx index be7d77d6af..c90dd2020d 100644 --- a/assets/src/components/utils/layout/ScrollablePage.tsx +++ b/assets/src/components/utils/layout/ScrollablePage.tsx @@ -7,17 +7,38 @@ import ConsolePageTitle from './ConsolePageTitle' const ScrollablePageContent = styled.div<{ scrollable?: boolean extraStyles?: CSSProperties -}>(({ theme, scrollable, extraStyles }) => ({ + maxContentWidth?: number + fullWidth?: boolean +}>(({ + theme, scrollable, extraStyles, maxContentWidth, fullWidth, +}) => ({ + position: 'relative', height: '100%', maxHeight: '100%', width: '100%', overflowY: scrollable ? 'auto' : 'hidden', overflowX: 'hidden', - paddingTop: theme.spacing.medium, paddingRight: scrollable ? theme.spacing.small : 0, - paddingBottom: scrollable ? theme.spacing.xxlarge : theme.spacing.large, - ...(extraStyles ?? {}), - position: 'relative', + ...(scrollable ? { scrollbarGutter: 'stable' } : {}), + ...(scrollable && fullWidth + ? { + paddingRight: theme.spacing.large - 6, + } + : {}), + '& > .widthLimiter': { + width: '100%', + paddingTop: theme.spacing.medium, + paddingBottom: scrollable ? theme.spacing.xxlarge : theme.spacing.large, + ...(!scrollable + ? { + height: '100%', + } + : {}), + ...(maxContentWidth + ? { maxWidth: maxContentWidth, marginLeft: 'auto', marginRight: 'auto' } + : {}), + ...(extraStyles ?? {}), + }, })) const ScrollShadow = styled.div(({ theme }) => ({ @@ -38,6 +59,8 @@ export function ScrollablePage({ contentStyles, children, scrollable = true, + maxContentWidth, + fullWidth, ...props }: { heading: ReactNode @@ -45,25 +68,37 @@ export function ScrollablePage({ contentStyles?: CSSProperties children: ReactNode scrollable?: boolean + maxContentWidth?: number + fullWidth?: boolean } & FlexProps) { return ( <> {heading && ( -
- {scrollable && } - +
- {headingContent} - + {scrollable && } + + {headingContent} + +
)} - {children} +
{children}
) diff --git a/assets/src/utils/makeGrid.ts b/assets/src/utils/makeGrid.ts index f0397c0d18..71733811c5 100644 --- a/assets/src/utils/makeGrid.ts +++ b/assets/src/utils/makeGrid.ts @@ -1,12 +1,16 @@ +import { CSSProperties } from 'styled-components' + export function makeGrid({ gap, maxCols, minColWidth, + maxColWidth, }: { gap: number maxCols: number minColWidth: number -}) { + maxColWidth?: number +}): CSSProperties { const gapCount = maxCols - 1 const totalGapWidth = gapCount * gap @@ -14,5 +18,10 @@ export function makeGrid({ display: 'grid', gridTemplateColumns: `repeat(auto-fill, minmax(max(${minColWidth}px, calc((100% - ${totalGapWidth}px) / ${maxCols})), 1fr))`, gap, + ...(maxColWidth + ? { + maxWidth: maxCols * maxColWidth + totalGapWidth, + } + : {}), } }