Skip to content

Commit 5a2411f

Browse files
fix(settingsMenu): Version (#35096)
1 parent 078c170 commit 5a2411f

File tree

2 files changed

+44
-39
lines changed

2 files changed

+44
-39
lines changed

superset-frontend/src/features/home/Menu.test.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,26 @@ test('should render the About section and version_string, sha or build_number wh
492492
});
493493
userEvent.hover(screen.getByText('Settings'));
494494
const about = await screen.findByText('About');
495-
const version = await screen.findAllByText(`Version: ${version_string}`);
496-
const sha = await screen.findAllByText(`SHA: ${version_sha}`);
497-
const build = await screen.findAllByText(`Build: ${build_number}`);
495+
496+
// The version information is rendered as combined text in a single element
497+
// Use getAllByText to get all matching elements and check the first one
498+
const versionTexts = await screen.findAllByText(
499+
(_, element) =>
500+
element?.textContent?.includes(`Version: ${version_string}`) ?? false,
501+
);
502+
const shaTexts = await screen.findAllByText(
503+
(_, element) =>
504+
element?.textContent?.includes(`SHA: ${version_sha}`) ?? false,
505+
);
506+
const buildTexts = await screen.findAllByText(
507+
(_, element) =>
508+
element?.textContent?.includes(`Build: ${build_number}`) ?? false,
509+
);
510+
498511
expect(about).toBeInTheDocument();
499-
expect(version[0]).toBeInTheDocument();
500-
expect(sha[0]).toBeInTheDocument();
501-
expect(build[0]).toBeInTheDocument();
512+
expect(versionTexts[0]).toBeInTheDocument();
513+
expect(shaTexts[0]).toBeInTheDocument();
514+
expect(buildTexts[0]).toBeInTheDocument();
502515
});
503516

504517
test('should render the Documentation link when available', async () => {

superset-frontend/src/features/home/RightMenu.tsx

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
Typography,
4040
TelemetryPixel,
4141
} from '@superset-ui/core/components';
42-
import type { MenuItem } from '@superset-ui/core/components/Menu';
42+
import type { ItemType, MenuItem } from '@superset-ui/core/components/Menu';
4343
import { ensureAppRoot } from 'src/utils/pathUtils';
4444
import { findPermission } from 'src/utils/findPermission';
4545
import { isUserAdmin } from 'src/dashboard/util/permissionUtils';
@@ -63,14 +63,6 @@ import {
6363

6464
const extensionsRegistry = getExtensionsRegistry();
6565

66-
const versionInfoStyles = (theme: SupersetTheme) => css`
67-
padding: ${theme.sizeUnit * 1.5}px ${theme.sizeUnit * 4}px
68-
${theme.sizeUnit * 4}px ${theme.sizeUnit * 7}px;
69-
color: ${theme.colorText};
70-
font-size: ${theme.fontSizeSM}px;
71-
white-space: nowrap;
72-
`;
73-
7466
const StyledDiv = styled.div<{ align: string }>`
7567
display: flex;
7668
height: 100%;
@@ -520,42 +512,42 @@ const RightMenu = ({
520512
if (navbarRight.version_string || navbarRight.version_sha) {
521513
items.push({ type: 'divider', key: 'version-info-divider' });
522514

523-
items.push({
515+
const aboutItem: ItemType = {
524516
type: 'group',
525517
label: t('About'),
526518
key: 'about-section',
527519
children: [
528520
{
529521
key: 'about-info',
522+
style: { height: 'auto', minHeight: 'auto' },
530523
label: (
531-
<div className="about-section">
532-
{navbarRight.show_watermark && (
533-
<div css={versionInfoStyles}>
534-
{t('Powered by Apache Superset')}
535-
</div>
536-
)}
537-
{navbarRight.version_string && (
538-
<div css={versionInfoStyles}>
539-
{t('Version')}: {navbarRight.version_string}
540-
</div>
541-
)}
542-
{navbarRight.version_sha && (
543-
<div css={versionInfoStyles}>
544-
{t('SHA')}: {navbarRight.version_sha}
545-
</div>
546-
)}
547-
{navbarRight.build_number && (
548-
<div css={versionInfoStyles}>
549-
{t('Build')}: {navbarRight.build_number}
550-
</div>
551-
)}
524+
<div
525+
css={(theme: SupersetTheme) => css`
526+
font-size: ${theme.fontSizeSM}px;
527+
color: ${theme.colorTextSecondary || theme.colorText};
528+
white-space: pre-wrap;
529+
padding: ${theme.sizeUnit}px ${theme.sizeUnit * 2}px;
530+
`}
531+
>
532+
{[
533+
navbarRight.show_watermark &&
534+
t('Powered by Apache Superset'),
535+
navbarRight.version_string &&
536+
`${t('Version')}: ${navbarRight.version_string}`,
537+
navbarRight.version_sha &&
538+
`${t('SHA')}: ${navbarRight.version_sha}`,
539+
navbarRight.build_number &&
540+
`${t('Build')}: ${navbarRight.build_number}`,
541+
]
542+
.filter(Boolean)
543+
.join('\n')}
552544
</div>
553545
),
554546
},
555547
],
556-
});
548+
};
549+
items.push(aboutItem);
557550
}
558-
559551
return items;
560552
};
561553

0 commit comments

Comments
 (0)