Skip to content

Commit e4b049d

Browse files
feat: update scss and test cases
1 parent 9ee3892 commit e4b049d

File tree

5 files changed

+89
-60
lines changed

5 files changed

+89
-60
lines changed

src/optimizer-page/CourseOptimizerPage.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe('CourseOptimizerPage', () => {
174174
expect(getByText(messages.headingTitle.defaultMessage)).toBeInTheDocument();
175175
fireEvent.click(getByText(messages.buttonTitle.defaultMessage));
176176
await waitFor(() => {
177-
expect(getByText(scanResultsMessages.noResultsFound.defaultMessage)).toBeInTheDocument();
177+
expect(getByText(scanResultsMessages.noDataCard.defaultMessage)).toBeInTheDocument();
178178
});
179179
});
180180

@@ -380,15 +380,14 @@ describe('CourseOptimizerPage', () => {
380380
});
381381
});
382382

383-
it('should always show broken links section header even when no data', async () => {
383+
it('should always show no scan data message when data is empty', async () => {
384384
axiosMock.onGet(getLinkCheckStatusApiUrl(courseId)).reply(200, mockApiResponseEmpty);
385385
const { getByText } = render(<OptimizerPage />);
386386

387387
fireEvent.click(getByText(messages.buttonTitle.defaultMessage));
388388

389389
await waitFor(() => {
390-
expect(getByText(scanResultsMessages.brokenLinksHeader.defaultMessage)).toBeInTheDocument();
391-
expect(getByText(scanResultsMessages.noResultsFound.defaultMessage)).toBeInTheDocument();
390+
expect(getByText(scanResultsMessages.noDataCard.defaultMessage)).toBeInTheDocument();
392391
});
393392
});
394393

src/optimizer-page/CourseOptimizerPage.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const CourseOptimizerPage: FC<{ courseId: string }> = ({ courseId }) => {
138138
>
139139
<Layout.Element>
140140
<article>
141-
<div className="d-flex flex-wrap justify-content-between align-items-center mb-3 px-3 py-3">
141+
<div className="d-flex flex-wrap justify-content-between align-items-center mb-3 p-3">
142142
<div>
143143
<p className="small text-muted mb-1">Tools</p>
144144
<div className="d-flex align-items-center">
@@ -151,15 +151,14 @@ const CourseOptimizerPage: FC<{ courseId: string }> = ({ courseId }) => {
151151
size="md"
152152
className="px-4 rounded-0 scan-course-btn"
153153
onClick={() => dispatch(startLinkCheck(courseId))}
154-
disabled={(!!linkCheckInProgress) && !errorMessage}
154+
disabled={!!(linkCheckInProgress) && !errorMessage}
155155
>
156156
{linkCheckInProgress && !errorMessage ? (
157157
<>
158158
<Spinner
159159
animation="border"
160160
size="sm"
161-
className="mr-2"
162-
style={{ width: '1rem', height: '1rem' }}
161+
className="mr-2 spinner-icon"
163162
/>
164163
{intl.formatMessage(messages.buttonTitle)}
165164
</>
@@ -168,9 +167,9 @@ const CourseOptimizerPage: FC<{ courseId: string }> = ({ courseId }) => {
168167
)}
169168
</Button>
170169
</div>
171-
<Card style={{ boxShadow: 'none', backgroundColor: 'transparent' }}>
170+
<Card className="scan-card">
172171
<p className="px-3 py-1 small">{intl.formatMessage(messages.description)}</p>
173-
<hr style={{ margin: '0 20px' }} />
172+
<hr />
174173
<Card.Header
175174
className="scan-header h3 px-3 text-black mb-2"
176175
title={intl.formatMessage(messages.scanHeader)}

src/optimizer-page/scan-results/BrokenLinkTable.tsx

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ const LinksCol: FC<{
7070
}) => (
7171
<span className="links-container">
7272
<GoToBlock block={{ url: block.url, displayName: block.displayName || 'Go to block' }} />
73-
<Icon className="arrow-forward-ios" src={ArrowForwardIos} style={{ color: '#8F8F8F' }} />
73+
<Icon className="arrow-forward-ios" src={ArrowForwardIos} />
7474
<BrokenLinkHref href={href} />
7575
{showIcon && linkType && iconsMap[linkType] && (
76-
<div style={{ marginLeft: 'auto', marginRight: '10px' }}>
76+
<div className="icon-container">
7777
<CustomIcon
7878
icon={iconsMap[linkType].icon}
7979
message1={iconsMap[linkType].message1}
@@ -118,59 +118,60 @@ const BrokenLinkTable: FC<BrokenLinkTableProps> = ({
118118
}));
119119
acc.push(...blockPreviousRunLinks);
120120
}
121-
} else {
122-
// Handle broken links with filtering and icons
123-
if (!filters) { return acc; }
121+
return acc;
122+
}
124123

125-
if (
126-
filters.brokenLinks
127-
|| (!filters.brokenLinks && !filters.externalForbiddenLinks && !filters.lockedLinks)
128-
) {
129-
const blockBrokenLinks = block.brokenLinks.map((link) => ({
130-
Links: (
131-
<LinksCol
132-
block={{ url: block.url, displayName: block.displayName || 'Go to block' }}
133-
href={link}
134-
linkType="broken"
135-
/>
136-
),
137-
}));
138-
acc.push(...blockBrokenLinks);
139-
}
124+
// Handle broken links with filtering and icons
125+
if (!filters) { return acc; }
140126

141-
if (
142-
filters.lockedLinks
127+
if (
128+
filters.brokenLinks
143129
|| (!filters.brokenLinks && !filters.externalForbiddenLinks && !filters.lockedLinks)
144-
) {
145-
const blockLockedLinks = block.lockedLinks.map((link) => ({
146-
Links: (
147-
<LinksCol
148-
block={{ url: block.url, displayName: block.displayName || 'Go to block' }}
149-
href={link}
150-
linkType="locked"
151-
/>
152-
),
153-
}));
154-
155-
acc.push(...blockLockedLinks);
156-
}
130+
) {
131+
const blockBrokenLinks = block.brokenLinks.map((link) => ({
132+
Links: (
133+
<LinksCol
134+
block={{ url: block.url, displayName: block.displayName || 'Go to block' }}
135+
href={link}
136+
linkType="broken"
137+
/>
138+
),
139+
}));
140+
acc.push(...blockBrokenLinks);
141+
}
157142

158-
if (
159-
filters.externalForbiddenLinks
143+
if (
144+
filters.lockedLinks
160145
|| (!filters.brokenLinks && !filters.externalForbiddenLinks && !filters.lockedLinks)
161-
) {
162-
const externalForbiddenLinks = block.externalForbiddenLinks.map((link) => ({
163-
Links: (
164-
<LinksCol
165-
block={{ url: block.url, displayName: block.displayName || 'Go to block' }}
166-
href={link}
167-
linkType="manual"
168-
/>
169-
),
170-
}));
146+
) {
147+
const blockLockedLinks = block.lockedLinks.map((link) => ({
148+
Links: (
149+
<LinksCol
150+
block={{ url: block.url, displayName: block.displayName || 'Go to block' }}
151+
href={link}
152+
linkType="locked"
153+
/>
154+
),
155+
}));
156+
157+
acc.push(...blockLockedLinks);
158+
}
171159

172-
acc.push(...externalForbiddenLinks);
173-
}
160+
if (
161+
filters.externalForbiddenLinks
162+
|| (!filters.brokenLinks && !filters.externalForbiddenLinks && !filters.lockedLinks)
163+
) {
164+
const externalForbiddenLinks = block.externalForbiddenLinks.map((link) => ({
165+
Links: (
166+
<LinksCol
167+
block={{ url: block.url, displayName: block.displayName || 'Go to block' }}
168+
href={link}
169+
linkType="manual"
170+
/>
171+
),
172+
}));
173+
174+
acc.push(...externalForbiddenLinks);
174175
}
175176

176177
return acc;

src/optimizer-page/scan-results/ScanResults.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
width: 10px;
242242
height: 10px;
243243
align-self: center;
244+
color: #8F8F8F;
244245
}
245246

246247
.scan-results-active-filters-container {
@@ -337,3 +338,22 @@
337338
.scan-course-btn:focus::before {
338339
border: none !important;
339340
}
341+
342+
.spinner-icon {
343+
width: 1rem;
344+
height: 1rem;
345+
}
346+
347+
.scan-card {
348+
box-shadow: none;
349+
background-color: transparent;
350+
}
351+
352+
.scan-card hr {
353+
margin: 0 20px;
354+
}
355+
356+
.icon-container {
357+
margin-left: auto;
358+
margin-right: 10px;
359+
}

src/optimizer-page/scan-results/ScanResults.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ interface Props {
3939
data: LinkCheckResult | null;
4040
}
4141

42+
const isDataEmpty = (data: LinkCheckResult | null): boolean => {
43+
if (!data) {
44+
return true;
45+
}
46+
const { sections, courseUpdates, customPages } = data;
47+
return (!sections || sections.length === 0)
48+
&& (!courseUpdates || courseUpdates.length === 0)
49+
&& (!customPages || customPages.length === 0);
50+
};
51+
4252
const ScanResults: FC<Props> = ({ data }) => {
4353
const intl = useIntl();
4454
const waffleFlags = useWaffleFlags();
@@ -167,7 +177,7 @@ const ScanResults: FC<Props> = ({ data }) => {
167177
setPrevRunOpenStates(allSectionsForPrevRun ? allSectionsForPrevRun.map(() => false) : []);
168178
}, [allSectionsForBrokenLinks, allSectionsForPrevRun]);
169179

170-
if (!data) {
180+
if (isDataEmpty(data)) {
171181
return <InfoCard text={intl.formatMessage(messages.noDataCard)} />;
172182
}
173183
const handleToggle = (index: number) => {

0 commit comments

Comments
 (0)