Skip to content

Commit 238eaa4

Browse files
style(duplication): partial refactor to typescript
- remove duplicableItemTypes/itemSelectorPanels dependencies
1 parent db4f206 commit 238eaa4

38 files changed

Lines changed: 1593 additions & 1915 deletions

client/app/bundles/course/duplication/components/IndentedCheckbox.jsx

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { CSSProperties, FC, ReactNode } from 'react';
2+
import { Checkbox, CheckboxProps, FormControlLabel } from '@mui/material';
3+
4+
const styles = {
5+
tabSize: 15,
6+
};
7+
8+
interface IndentedCheckboxProps extends CheckboxProps {
9+
indentLevel?: number;
10+
children?: ReactNode;
11+
label: JSX.Element | string;
12+
}
13+
14+
const IndentedCheckbox: FC<IndentedCheckboxProps> = ({
15+
indentLevel = 0,
16+
children = [],
17+
label,
18+
...props
19+
}) => {
20+
const checkboxStyle: CSSProperties = {
21+
marginLeft: indentLevel * styles.tabSize,
22+
};
23+
if (children && Array.isArray(children) && children.length > 0) {
24+
checkboxStyle.width = 'auto';
25+
}
26+
27+
return (
28+
<div className="flex items-center">
29+
<FormControlLabel
30+
className="py-2 px-0 w-auto"
31+
control={
32+
<Checkbox className="py-0 px-2" style={checkboxStyle} {...props} />
33+
}
34+
label={<b>{label}</b>}
35+
/>
36+
{children}
37+
</div>
38+
);
39+
};
40+
41+
export default IndentedCheckbox;

client/app/bundles/course/duplication/components/TypeBadge/index.jsx

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { FC } from 'react';
2+
import { defineMessages, MessageDescriptor } from 'react-intl';
3+
import { Typography } from '@mui/material';
4+
5+
import { DuplicableItemType } from 'course/duplication/types';
6+
import useTranslation from 'lib/hooks/useTranslation';
7+
8+
const translations: Record<DuplicableItemType, MessageDescriptor> =
9+
defineMessages({
10+
ASSESSMENT: {
11+
id: 'course.duplication.TypeBadge.assessment',
12+
defaultMessage: 'Assessment',
13+
},
14+
CATEGORY: {
15+
id: 'course.duplication.TypeBadge.category',
16+
defaultMessage: 'Category',
17+
},
18+
TAB: {
19+
id: 'course.duplication.TypeBadge.tab',
20+
defaultMessage: 'Tab',
21+
},
22+
SURVEY: {
23+
id: 'course.duplication.TypeBadge.survey',
24+
defaultMessage: 'Survey',
25+
},
26+
ACHIEVEMENT: {
27+
id: 'course.duplication.TypeBadge.achievement',
28+
defaultMessage: 'Achievement',
29+
},
30+
FOLDER: {
31+
id: 'course.duplication.TypeBadge.folder',
32+
defaultMessage: 'Folder',
33+
},
34+
MATERIAL: {
35+
id: 'course.duplication.TypeBadge.material',
36+
defaultMessage: 'Material',
37+
},
38+
VIDEO: {
39+
id: 'course.duplication.TypeBadge.video',
40+
defaultMessage: 'Video',
41+
},
42+
VIDEO_TAB: {
43+
id: 'course.duplication.TypeBadge.video_tab',
44+
defaultMessage: 'Tab',
45+
},
46+
});
47+
48+
const TypeBadge: FC<{ text?: string; itemType: DuplicableItemType }> = ({
49+
text,
50+
itemType,
51+
}) => {
52+
const { t } = useTranslation();
53+
54+
return (
55+
<Typography
56+
className="px-2 py-1 border border-solid rounded-md mr-3"
57+
fontWeight="inherit"
58+
variant="caption"
59+
>
60+
{text || t(translations[itemType])}
61+
</Typography>
62+
);
63+
};
64+
65+
export default TypeBadge;

client/app/bundles/course/duplication/constants.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
import mirrorCreator from 'mirror-creator';
22

3-
// These are mirrored in app/helpers/course/object_duplications_helper.rb
4-
export const duplicableItemTypes = mirrorCreator([
5-
'ASSESSMENT',
6-
'TAB',
7-
'CATEGORY',
8-
'SURVEY',
9-
'ACHIEVEMENT',
10-
'FOLDER',
11-
'MATERIAL',
12-
'VIDEO',
13-
'VIDEO_TAB',
14-
]);
15-
16-
// These are mirrored in app/helpers/course/object_duplications_helper.rb
17-
export const itemSelectorPanels = mirrorCreator([
18-
'ASSESSMENTS',
19-
'SURVEYS',
20-
'ACHIEVEMENTS',
21-
'MATERIALS',
22-
'VIDEOS',
23-
]);
24-
25-
export const formNames = mirrorCreator(['NEW_COURSE']);
26-
273
const actionTypes = mirrorCreator([
284
'LOAD_OBJECTS_LIST_REQUEST',
295
'LOAD_OBJECTS_LIST_SUCCESS',

client/app/bundles/course/duplication/pages/Duplication/DuplicateAllButton.jsx

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)