Skip to content

Commit 783f859

Browse files
committed
fix: lint and typing issues
1 parent c647e92 commit 783f859

36 files changed

Lines changed: 195 additions & 151 deletions

src/CourseAuthoringContext.tsx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { getConfig } from '@edx/frontend-platform';
22
import { createContext, useContext, useMemo } from 'react';
33
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
4-
import { CourseDetailsData } from './data/api';
5-
import { useCourseDetails, useWaffleFlags } from './data/apiHooks';
6-
import { RequestStatus, RequestStatusType } from './data/constants';
74
import { useCreateCourseBlock } from '@src/course-outline/data/apiHooks';
85
import { getCourseItem } from '@src/course-outline/data/api';
96
import { useDispatch, useSelector } from 'react-redux';
107
import { addSection, addSubsection, updateSavingStatus } from '@src/course-outline/data/slice';
118
import { addNewSectionQuery, addNewSubsectionQuery, addNewUnitQuery } from '@src/course-outline/data/thunk';
129
import { useNavigate } from 'react-router';
1310
import { getOutlineIndexData } from '@src/course-outline/data/selectors';
11+
import { RequestStatus, RequestStatusType } from './data/constants';
12+
import { useCourseDetails, useWaffleFlags } from './data/apiHooks';
13+
import { CourseDetailsData } from './data/api';
1414

1515
export type CourseAuthoringContextData = {
1616
/** The ID of the current course */
@@ -113,23 +113,21 @@ export const CourseAuthoringProvider = ({
113113
*/
114114
const handleAddUnitFromLibrary = useCreateCourseBlock(openUnitPage);
115115

116-
const context = useMemo<CourseAuthoringContextData>(() => {
117-
return {
118-
courseId,
119-
courseUsageKey,
120-
courseDetails,
121-
courseDetailStatus,
122-
canChangeProviders,
123-
handleNewSectionSubmit,
124-
handleNewSubsectionSubmit,
125-
handleNewUnitSubmit,
126-
handleAddSectionFromLibrary,
127-
handleAddSubsectionFromLibrary,
128-
handleAddUnitFromLibrary,
129-
getUnitUrl,
130-
openUnitPage,
131-
};
132-
}, [
116+
const context = useMemo<CourseAuthoringContextData>(() => ({
117+
courseId,
118+
courseUsageKey,
119+
courseDetails,
120+
courseDetailStatus,
121+
canChangeProviders,
122+
handleNewSectionSubmit,
123+
handleNewSubsectionSubmit,
124+
handleNewUnitSubmit,
125+
handleAddSectionFromLibrary,
126+
handleAddSubsectionFromLibrary,
127+
handleAddUnitFromLibrary,
128+
getUnitUrl,
129+
openUnitPage,
130+
}), [
133131
courseId,
134132
courseUsageKey,
135133
courseDetails,

src/CourseAuthoringPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const CourseAuthoringPage = ({ children }: Props) => {
5858
title={courseTitle}
5959
contextId={courseId}
6060
containerProps={{
61-
size: "fluid",
61+
size: 'fluid',
6262
}}
6363
/>
6464
)

src/authz/data/apiHooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export const useUserPermissions = (
3232
enabled: boolean = true,
3333
) => useQuery<PermissionValidationAnswer, Error>({
3434
queryKey: adminConsoleQueryKeys.permissions(permissions),
35-
queryFn: enabled ? () => validateUserPermissions(permissions): skipToken,
35+
queryFn: enabled ? () => validateUserPermissions(permissions) : skipToken,
3636
retry: false,
3737
});

src/course-outline/drag-helper/CourseItemOverlay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Col, Icon, Row } from '@openedx/paragon';
22
import { ArrowRight, DragIndicator } from '@openedx/paragon/icons';
33
import { ContainerType } from '@src/generic/key-utils';
4-
import { getItemStatusBorder } from '../utils';
4+
import { getItemStatusBorder, ItemBadgeStatusValue } from '../utils';
55

66
interface ItemProps {
77
displayName: string;
8-
status: string;
8+
status: ItemBadgeStatusValue;
99
}
1010

1111
interface CourseItemOverlayProps extends ItemProps {

src/course-outline/drag-helper/utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('possibleSubsectionMoves', () => {
2626
{ actions: { draggable: true } },
2727
{ actions: { draggable: true } },
2828
{ actions: { draggable: true } },
29-
];
29+
] as unknown as XBlock[];
3030

3131
const createMoveFunction = possibleSubsectionMoves(
3232
mockSections,
@@ -39,7 +39,7 @@ describe('possibleSubsectionMoves', () => {
3939
const mockNonDraggableSubsections = [
4040
{ actions: { draggable: false } },
4141
{ actions: { draggable: true } },
42-
];
42+
] as unknown as XBlock[];
4343

4444
const createMove = possibleSubsectionMoves(
4545
mockSections,

src/course-outline/header-navigations/HeaderActions.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ const HeaderActions = ({
8181
<Dropdown.Menu className="mt-1">
8282
{Object.entries(sidebarPages).filter(([, page]) => !page.hideFromActionMenu)
8383
.map(([key, page]: [OutlineSidebarPageKeys, SidebarPage]) => (
84-
<Dropdown.Item
85-
key={key}
86-
onClick={() => setCurrentPageKey(key)}
87-
>
88-
<Stack direction="horizontal" gap={2}>
89-
<Icon src={page.icon} />
90-
{page.title}
91-
</Stack>
92-
</Dropdown.Item>
93-
))}
84+
<Dropdown.Item
85+
key={key}
86+
onClick={() => setCurrentPageKey(key)}
87+
>
88+
<Stack direction="horizontal" gap={2}>
89+
<Icon src={page.icon} />
90+
{page.title}
91+
</Stack>
92+
</Dropdown.Item>
93+
))}
9494
</Dropdown.Menu>
9595
</Dropdown>
9696

src/course-outline/hooks.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getSavingStatus as getGenericSavingStatus } from '@src/generic/data/sel
99
import { RequestStatus } from '@src/data/constants';
1010
import { useUnlinkDownstream } from '@src/generic/unlink-modal';
1111

12+
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
1213
import { COURSE_BLOCK_NAMES } from './constants';
1314
import {
1415
setCurrentItem,
@@ -57,7 +58,6 @@ import {
5758
syncDiscussionsTopics,
5859
} from './data/thunk';
5960
import { containerComparisonQueryKeys } from '../container-comparison/data/apiHooks';
60-
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
6161

6262
const useCourseOutline = ({ courseId }) => {
6363
const dispatch = useDispatch();

src/course-outline/outline-sidebar/AddSidebar.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { SchoolOutline } from '@openedx/paragon/icons';
33

44
import { SidebarContent, SidebarSection, SidebarTitle } from '@src/generic/sidebar';
55

6-
import messages from './messages';
76
import contentMessages from '@src/library-authoring/add-content/messages';
87
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
9-
import { ComponentPicker } from '../../library-authoring';
10-
import { ContentType } from '../../library-authoring/routes';
118
import { SidebarFilters } from '@src/library-authoring/library-filters/SidebarFilters';
12-
import { Button, Stack, Tab, Tabs } from '@openedx/paragon';
9+
import {
10+
Button, Stack, Tab, Tabs,
11+
} from '@openedx/paragon';
1312
import { getItemIcon } from '@src/generic/block-type-utils';
1413
import { useSelector } from 'react-redux';
1514
import { getSectionsList } from '@src/course-outline/data/selectors';
@@ -18,6 +17,9 @@ import { ComponentSelectedEvent } from '@src/library-authoring/common/context/Co
1817
import { COMPONENT_TYPES } from '@src/generic/block-type-utils/constants';
1918
import { ContainerType } from '@src/generic/key-utils';
2019
import { XBlock } from '@src/data/types';
20+
import { ContentType } from '../../library-authoring/routes';
21+
import { ComponentPicker } from '../../library-authoring';
22+
import messages from './messages';
2123

2224
type ContainerTypes = 'unit' | 'subsection' | 'section';
2325

@@ -37,7 +39,7 @@ const getLastEditableParent = (blockList: Array<XBlock>) => {
3739
index++;
3840
}
3941
return undefined;
40-
}
42+
};
4143

4244
/** Add Content Button */
4345
const AddContentButton = ({ name, blockType } : AddContentButtonProps) => {
@@ -68,7 +70,7 @@ const AddContentButton = ({ name, blockType } : AddContentButtonProps) => {
6870
default:
6971
// istanbul ignore next: unreachable
7072
throw new Error(`Unrecognized block type ${blockType}`);
71-
};
73+
}
7274
}, [
7375
blockType,
7476
handleNewSectionSubmit,
@@ -84,7 +86,7 @@ const AddContentButton = ({ name, blockType } : AddContentButtonProps) => {
8486
className="m-2"
8587
iconBefore={getItemIcon(blockType)}
8688
onClick={onCreateContent}
87-
disabled={(!lastSection && blockType==='subsection') || (!lastSubsection && blockType==='unit')}
89+
disabled={(!lastSection && blockType === 'subsection') || (!lastSubsection && blockType === 'unit')}
8890
>
8991
{name}
9092
</Button>
@@ -99,21 +101,21 @@ const AddNewContent = () => {
99101
<AddContentButton
100102
key="section"
101103
name={intl.formatMessage(contentMessages.sectionButton)}
102-
blockType='section'
104+
blockType="section"
103105
/>
104106
<AddContentButton
105107
key="subsection"
106108
name={intl.formatMessage(contentMessages.subsectionButton)}
107-
blockType='subsection'
109+
blockType="subsection"
108110
/>
109111
<AddContentButton
110112
key="unit"
111113
name={intl.formatMessage(contentMessages.unitButton)}
112-
blockType='unit'
114+
blockType="unit"
113115
/>
114116
</Stack>
115117
);
116-
}
118+
};
117119

118120
/** Add Existing Content Tab Section */
119121
const ShowLibraryContent = () => {
@@ -160,7 +162,7 @@ const ShowLibraryContent = () => {
160162
default:
161163
// istanbul ignore next: unreachable
162164
throw new Error(`Unrecognized block type ${blockType}`);
163-
};
165+
}
164166
}, [
165167
courseUsageKey,
166168
handleAddSectionFromLibrary,
@@ -171,9 +173,9 @@ const ShowLibraryContent = () => {
171173
]);
172174

173175
const allowedBlocks = useMemo(() => {
174-
let blocks: ContainerTypes[] = ['section'];
175-
if (lastSection) blocks.push('subsection');
176-
if (lastSubsection) blocks.push('unit');
176+
const blocks: ContainerTypes[] = ['section'];
177+
if (lastSection) { blocks.push('subsection'); }
178+
if (lastSubsection) { blocks.push('unit'); }
177179
return blocks;
178180
}, [lastSection, lastSubsection, sectionsList]);
179181

@@ -188,7 +190,7 @@ const ShowLibraryContent = () => {
188190
onComponentSelected={onComponentSelected}
189191
/>
190192
);
191-
}
193+
};
192194

193195
/** Tabs Component */
194196
const AddTabs = () => {
@@ -209,7 +211,7 @@ const AddTabs = () => {
209211
</Tab>
210212
</Tabs>
211213
);
212-
}
214+
};
213215

214216
/** Main Sidebar Component */
215217
export const AddSidebar = () => {

src/course-outline/outline-sidebar/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const messages = defineMessages({
104104
id: 'course-authoring.course-outline.sidebar.sidebar-section-add.add-existing-tab',
105105
defaultMessage: 'Add Existing',
106106
description: 'Tab title for adding existing library components in outline using sidebar',
107-
}
107+
},
108108
});
109109

110110
export default messages;

src/course-outline/section-card/SectionCard.test.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ jest.mock('@src/course-unit/data/apiHooks', () => ({
1616
}),
1717
}));
1818

19+
jest.mock('@src/CourseAuthoringContext', () => ({
20+
useCourseAuthoringContext: () => ({
21+
courseId: 5,
22+
handleAddSubsectionFromLibrary: jest.fn(),
23+
handleNewSubsectionSubmit: jest.fn(),
24+
}),
25+
}));
26+
1927
const unit = {
2028
id: 'block-v1:UNIX+UX1+2025_T3+type@unit+block@0',
2129
};
@@ -95,10 +103,8 @@ const renderComponent = (props?: object, entry = '/course/:courseId') => render(
95103
onEditSectionSubmit={onEditSectionSubmit}
96104
onDuplicateSubmit={jest.fn()}
97105
isSectionsExpanded
98-
onNewSubsectionSubmit={jest.fn()}
99106
isSelfPaced={false}
100107
isCustomRelativeDatesActive={false}
101-
onAddSubsectionFromLibrary={jest.fn()}
102108
resetScrollState={jest.fn()}
103109
{...props}
104110
>

0 commit comments

Comments
 (0)