Skip to content

Commit 6a0745d

Browse files
committed
chore: fix lint issues
1 parent 4717c7f commit 6a0745d

5 files changed

Lines changed: 55 additions & 46 deletions

File tree

src/generic/DraggableList/DraggableList.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
3-
import {createPortal} from 'react-dom';
3+
import { createPortal } from 'react-dom';
44

55
import {
66
DndContext,
@@ -51,9 +51,9 @@ const DraggableList = ({
5151
}
5252
};
5353

54-
function handleDragStart(event) {
54+
const handleDragStart = (event) => {
5555
setActiveId(event.active.id);
56-
}
56+
};
5757

5858
return (
5959
<DndContext
@@ -73,15 +73,15 @@ const DraggableList = ({
7373
<DragOverlay>
7474
{renderOverlay(activeId)}
7575
</DragOverlay>,
76-
document.body
76+
document.body,
7777
)}
7878
</DndContext>
7979
);
8080
};
8181

8282
DraggableList.defaultProps = {
83-
overlayComponent: undefined,
84-
}
83+
renderOverlay: undefined,
84+
};
8585

8686
DraggableList.propTypes = {
8787
itemList: PropTypes.arrayOf(PropTypes.shape({

src/generic/DraggableList/SortableItem.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const SortableItem = ({
3333
id,
3434
animateLayoutChanges: () => false,
3535
disabled: {
36-
draggable: disabled
37-
}
36+
draggable: disabled,
37+
},
3838
});
3939

4040
const style = {
@@ -56,7 +56,8 @@ const SortableItem = ({
5656
>
5757
<ActionRow style={actionStyle}>
5858
{actions}
59-
{!disabled && <IconButtonWithTooltip
59+
{!disabled && (
60+
<IconButtonWithTooltip
6061
key="drag-to-reorder-icon"
6162
ref={setActivatorNodeRef}
6263
tooltipPlacement="top"
@@ -67,7 +68,8 @@ const SortableItem = ({
6768
alt={intl.formatMessage(messages.tooltipContent)}
6869
{...attributes}
6970
{...listeners}
70-
/>}
71+
/>
72+
)}
7173
</ActionRow>
7274
{children}
7375
</Card>

src/library-authoring/data/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ export async function updateLibraryContainerChildren(
658658
): Promise<LibraryBlockMetadata[]> {
659659
const { data } = await getAuthenticatedHttpClient().patch(
660660
getLibraryContainerChildrenApiUrl(containerId),
661-
{'usage_keys': children},
661+
{ usage_keys: children },
662662
);
663663
return camelCaseObject(data);
664664
}

src/library-authoring/data/apiHooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ export const useUpdateContainerChildren = (containerId?: string) => {
681681
if (!containerId) {
682682
return undefined;
683683
}
684-
return updateLibraryContainerChildren(containerId, usageKeys)
684+
return updateLibraryContainerChildren(containerId, usageKeys);
685685
},
686686
onSettled: () => {
687687
// NOTE: We invalidate the library query here because we need to update the library's

src/library-authoring/units/LibraryUnitBlocks.tsx

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ import { useLibraryRoutes } from '../routes';
2424
import messages from './messages';
2525
import { ToastContext } from '../../generic/toast-context';
2626

27+
interface BlockHeaderProps {
28+
block: LibraryBlockMetadata;
29+
onTagClick: () => void;
30+
}
31+
32+
/** Component header, split out to reuse in drag overlay */
33+
const BlockHeader = ({ block, onTagClick }: BlockHeaderProps) => (
34+
<>
35+
<Stack direction="horizontal" gap={2} className="font-weight-bold">
36+
<Icon src={getItemIcon(block.blockType)} />
37+
{block.displayName}
38+
</Stack>
39+
<ActionRow.Spacer />
40+
<Stack direction="horizontal" gap={3}>
41+
{block.hasUnpublishedChanges && (
42+
<Badge
43+
className="px-2 pt-1"
44+
variant="warning"
45+
>
46+
<Stack direction="horizontal" gap={1}>
47+
<Icon className="mb-1" size="xs" src={Description} />
48+
<FormattedMessage {...messages.draftChipText} />
49+
</Stack>
50+
</Badge>
51+
)}
52+
<TagCount size="sm" count={block.tagsCount} onClick={onTagClick} />
53+
<ComponentMenu usageKey={block.id} />
54+
</Stack>
55+
</>
56+
);
57+
2758
interface LibraryUnitBlocksProps {
2859
/** set to true if it is rendered as preview
2960
* This disables drag and drop
@@ -98,70 +129,46 @@ export const LibraryUnitBlocks = ({ preview }: LibraryUnitBlocksProps) => {
98129
return null;
99130
}
100131
return (
101-
<ActionRow className='bg-light-200 border border-light-500 p-2 rounded'>
102-
<BlockHeader block={block} />
132+
<ActionRow className="bg-light-200 border border-light-500 p-2 rounded">
133+
<BlockHeader block={block} onTagClick={openManageTagsDrawer} />
103134
<IconButton
104135
src={DragIndicator}
105136
variant="light"
106137
iconAs={Icon}
107-
alt={''}
138+
alt=""
108139
/>
109140
</ActionRow>
110141
);
111-
}
112-
113-
/** Component header, split out to reuse in drag overlay */
114-
const BlockHeader = ({block}: {block: LibraryBlockMetadata}) => (
115-
<>
116-
<Stack direction="horizontal" gap={2} className="font-weight-bold">
117-
<Icon src={getItemIcon(block.blockType)} />
118-
{block.displayName}
119-
</Stack>
120-
<ActionRow.Spacer />
121-
<Stack direction="horizontal" gap={3}>
122-
{block.hasUnpublishedChanges && (
123-
<Badge
124-
className="px-2 pt-1"
125-
variant="warning"
126-
>
127-
<Stack direction="horizontal" gap={1}>
128-
<Icon className="mb-1" size="xs" src={Description} />
129-
<FormattedMessage {...messages.draftChipText} />
130-
</Stack>
131-
</Badge>
132-
)}
133-
<TagCount size="sm" count={block.tagsCount} onClick={openManageTagsDrawer} />
134-
<ComponentMenu usageKey={block.id} />
135-
</Stack>
136-
</>
137-
);
142+
};
138143

139144
const renderedBlocks = orderedBlocks?.map((block) => (
140145
<IframeProvider key={block.id}>
141146
<SortableItem
142147
id={block.id}
143148
componentStyle={null}
144-
actions={<BlockHeader block={block} />}
149+
actions={<BlockHeader block={block} onTagClick={openManageTagsDrawer} />}
145150
actionStyle={{
146151
borderRadius: '8px 8px 0px 0px',
147152
padding: '0.5rem 1rem',
148153
background: '#FBFAF9',
149154
borderBottom: 'solid 1px #E1DDDB',
150-
outline: hidePreviewFor === block.id && '2px dashed gray'
155+
outline: hidePreviewFor === block.id && '2px dashed gray',
151156
}}
152157
isClickable
153158
onClick={() => handleComponentSelection(block)}
154159
disabled={preview}
155160
>
156-
{hidePreviewFor !== block.id && <div className={classNames('p-3', {
161+
{hidePreviewFor !== block.id && (
162+
<div className={classNames('p-3', {
157163
'container-mw-md': block.blockType === blockTypes.video,
158164
})}
159165
>
160166
<LibraryBlock
161167
usageKey={block.id}
162168
version={showOnlyPublished ? 'published' : undefined}
163169
/>
164-
</div>}
170+
</div>
171+
)}
165172
</SortableItem>
166173
</IframeProvider>
167174
));

0 commit comments

Comments
 (0)