Skip to content

Commit

Permalink
frontend: MainInfoSection: Correctly handle null backLink
Browse files Browse the repository at this point in the history
This fix explicitly handles the null case in getBackLink() to ensure
that no back button will be shown, as defined in MainInfoSectionProps.

Fixes: #2033

Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
  • Loading branch information
skoeva committed Jun 14, 2024
1 parent 8e8f58c commit f119bcd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,7 @@

exports[`Storyshots Notifications List 1`] = `
<div>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall MuiButton-textSizeSmall MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall MuiButton-textSizeSmall MuiButton-colorPrimary css-w7fpvq-MuiButtonBase-root-MuiButton-root"
tabindex="0"
type="button"
>
<span
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeSmall css-y6rp3m-MuiButton-startIcon"
>
<span />
</span>
<p
class="MuiTypography-root MuiTypography-body1 css-1ezega9-MuiTypography-root"
style="padding-top: 3px;"
>
Back
</p>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>

<div
class="MuiBox-root css-j1fy4m"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,7 @@

exports[`Storyshots Settings General 1`] = `
<div>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall MuiButton-textSizeSmall MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall MuiButton-textSizeSmall MuiButton-colorPrimary css-w7fpvq-MuiButtonBase-root-MuiButton-root"
tabindex="0"
type="button"
>
<span
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeSmall css-y6rp3m-MuiButton-startIcon"
>
<span />
</span>
<p
class="MuiTypography-root MuiTypography-body1 css-1ezega9-MuiTypography-root"
style="padding-top: 3px;"
>
Back
</p>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>

<div
class="MuiBox-root css-j1fy4m"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function MainInfoSection(props: MainInfoSectionProps) {
const header = typeof headerSection === 'function' ? headerSection(resource) : headerSection;

function getBackLink() {
if (backLink === null) {
return false;
}

if (!!backLink || backLink === '') {
return backLink;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/common/SectionBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function SectionBox(props: SectionBoxProps) {

return (
<>
{actualBackLink !== undefined && <BackLink to={actualBackLink} />}
{actualBackLink && <BackLink to={actualBackLink} />}
<Box py={0} {...outterBoxProps}>
{title && titleElem}
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,7 @@ exports[`Storyshots crd/CustomResourceDetails No Error 1`] = `
<div
class="MuiBox-root css-p0cik4"
>
<button
class="MuiButtonBase-root MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall MuiButton-textSizeSmall MuiButton-colorPrimary MuiButton-root MuiButton-text MuiButton-textPrimary MuiButton-sizeSmall MuiButton-textSizeSmall MuiButton-colorPrimary css-w7fpvq-MuiButtonBase-root-MuiButton-root"
tabindex="0"
type="button"
>
<span
class="MuiButton-icon MuiButton-startIcon MuiButton-iconSizeSmall css-y6rp3m-MuiButton-startIcon"
>
<span />
</span>
<p
class="MuiTypography-root MuiTypography-body1 css-1ezega9-MuiTypography-root"
style="padding-top: 3px;"
>
Back
</p>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>

<div
class="MuiBox-root css-j1fy4m"
>
Expand Down

0 comments on commit f119bcd

Please sign in to comment.