Skip to content

Commit 919a507

Browse files
committed
fix: lint issues
1 parent 258817d commit 919a507

8 files changed

Lines changed: 43 additions & 30 deletions

File tree

src/container-comparison/CompareContainersWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { LoadingSpinner } from '@src/generic/Loading';
1313
import { useContainer, useContainerChildren } from '@src/library-authoring/data/apiHooks';
1414
import { BoldText } from '@src/utils';
1515

16+
import { Container, LibraryBlockMetadata } from '@src/library-authoring/data/api';
1617
import ChildrenPreview from './ChildrenPreview';
1718
import ContainerRow from './ContainerRow';
1819
import { useCourseContainerChildren } from './data/apiHooks';
@@ -21,7 +22,6 @@ import {
2122
} from './types';
2223
import { diffPreviewContainerChildren, isRowClickable } from './utils';
2324
import messages from './messages';
24-
import { Container, LibraryBlockMetadata } from '@src/library-authoring/data/api';
2525

2626
interface ContainerInfoProps {
2727
upstreamBlockId: string;

src/library-authoring/common/context/SidebarContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export const SidebarProvider = ({
204204
if (selectedItemId) {
205205
// if a item is selected that means we have list of items displayed
206206
// which means we can get the index from url and set it.
207-
const indexNumber = indexParam ? Number(indexParam): undefined;
207+
const indexNumber = indexParam ? Number(indexParam) : undefined;
208208
if (selectedItemId.startsWith('lct:')) {
209209
openContainerInfoSidebar(selectedItemId, indexNumber);
210210
} else if (selectedItemId.startsWith('lb:')) {

src/library-authoring/components/ComponentRemover.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const ComponentRemover = ({ usageKey, index, close }: Props) => {
8686
});
8787
};
8888
updateContainerChildrenMutation.mutateAsync(updatedKeys).then(() => {
89-
if (sidebarItemInfo?.id === usageKey && sidebarItemInfo?.index === index) {
89+
if (sidebarItemInfo?.id === usageKey && sidebarItemInfo?.index === index) {
9090
// Close sidebar if current component is open
9191
closeLibrarySidebar();
9292
}
@@ -102,7 +102,7 @@ const ComponentRemover = ({ usageKey, index, close }: Props) => {
102102
});
103103

104104
close();
105-
}
105+
};
106106

107107
const removeText = intl.formatMessage(messages.removeComponentConfirm, {
108108
componentName: <b>{component?.displayName}</b>,
@@ -117,7 +117,7 @@ const ComponentRemover = ({ usageKey, index, close }: Props) => {
117117
title={intl.formatMessage(messages.removeComponentWarningTitle)}
118118
icon={Warning}
119119
description={removeText}
120-
onDeleteSubmit={hasDuplicates ? excludeOneInstance: removeFromContainer}
120+
onDeleteSubmit={hasDuplicates ? excludeOneInstance : removeFromContainer}
121121
btnLabel={intl.formatMessage(messages.componentRemoveButtonLabel)}
122122
buttonVariant="primary"
123123
/>

src/library-authoring/containers/ContainerRemover.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { getBlockType } from '@src/generic/key-utils';
99

1010
import { useSidebarContext } from '../common/context/SidebarContext';
1111
import { useLibraryContext } from '../common/context/LibraryContext';
12-
import { useContainer, useContainerChildren, useRemoveContainerChildren, useUpdateContainerChildren } from '../data/apiHooks';
12+
import {
13+
useContainer, useContainerChildren, useRemoveContainerChildren, useUpdateContainerChildren,
14+
} from '../data/apiHooks';
1315
import messages from '../components/messages';
1416
import { Container } from '../data/api';
1517

src/library-authoring/data/api.mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ export async function mockGetContainerChildren(containerId: string): Promise<api
635635
name = blockType;
636636
typeNamespace = 'lct';
637637
}
638-
let result =Array(numChildren).fill(mockGetContainerChildren.childTemplate).map((child, idx) => (
638+
let result = Array(numChildren).fill(mockGetContainerChildren.childTemplate).map((child, idx) => (
639639
{
640640
...child,
641641
// Generate a unique ID for each child block to avoid "duplicate key" errors in tests

src/library-authoring/data/apiHooks.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -736,29 +736,32 @@ export const useRestoreContainer = (containerId: string) => {
736736
/**
737737
* Get the metadata and children for a container in a library
738738
*/
739-
export const useContainerChildren = <T extends { id: string, isNew?: boolean }>(containerId?: string, published: boolean = false) => (
740-
useQuery({
741-
enabled: !!containerId,
742-
queryKey: libraryAuthoringQueryKeys.containerChildren(containerId!),
743-
queryFn: () => api.getLibraryContainerChildren<T>(containerId!, published),
744-
structuralSharing: (oldData: T[], newData: T[]) => {
739+
export const useContainerChildren = <T extends { id: string, isNew?: boolean }>(
740+
containerId?: string,
741+
published: boolean = false,
742+
) => (
743+
useQuery({
744+
enabled: !!containerId,
745+
queryKey: libraryAuthoringQueryKeys.containerChildren(containerId!),
746+
queryFn: () => api.getLibraryContainerChildren<T>(containerId!, published),
747+
structuralSharing: (oldData: T[], newData: T[]) => {
745748
// This just sets `isNew` flag to new children components
746-
if (oldData) {
747-
const oldDataIds = oldData.map((obj) => obj.id);
748-
// eslint-disable-next-line no-param-reassign
749-
newData = newData.map((newObj) => {
750-
if (!oldDataIds.includes(newObj.id)) {
749+
if (oldData) {
750+
const oldDataIds = oldData.map((obj) => obj.id);
751+
// eslint-disable-next-line no-param-reassign
752+
newData = newData.map((newObj) => {
753+
if (!oldDataIds.includes(newObj.id)) {
751754
// Set isNew = true if we have new child on refetch
752755
// eslint-disable-next-line no-param-reassign
753-
newObj.isNew = true;
754-
}
755-
return newObj;
756-
});
757-
}
758-
return replaceEqualDeep(oldData, newData);
759-
},
760-
})
761-
);
756+
newObj.isNew = true;
757+
}
758+
return newObj;
759+
});
760+
}
761+
return replaceEqualDeep(oldData, newData);
762+
},
763+
})
764+
);
762765

763766
/**
764767
* If you work with `useContentFromSearchIndex`, you can use this

src/library-authoring/section-subsections/LibraryContainerChildren.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ interface ContainerRowProps extends LibraryContainerChildrenProps {
4242
index?: number;
4343
}
4444

45-
const ContainerRow = ({ containerKey, container, readOnly, index }: ContainerRowProps) => {
45+
const ContainerRow = ({
46+
containerKey, container, readOnly, index,
47+
}: ContainerRowProps) => {
4648
const intl = useIntl();
4749
const { showToast } = useContext(ToastContext);
4850
const updateMutation = useUpdateContainer(container.originalId, containerKey);
@@ -166,7 +168,11 @@ export const LibraryContainerChildren = ({ containerKey, readOnly }: LibraryCont
166168
return setOrderedChildren(newChildren || []);
167169
}, [children, setOrderedChildren]);
168170

169-
const handleChildClick = useCallback((child: LibraryContainerMetadataWithUniqueId, numberOfClicks: number, index: number) => {
171+
const handleChildClick = useCallback((
172+
child: LibraryContainerMetadataWithUniqueId,
173+
numberOfClicks: number,
174+
index: number,
175+
) => {
170176
if (readOnly) {
171177
// don't allow interaction if rendered as preview
172178
return;

src/library-authoring/units/LibraryUnitBlocks.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ const BlockHeader = ({ block, index, readOnly }: ComponentBlockProps) => {
126126
};
127127

128128
/** ComponentBlock to render preview of given component under Unit */
129-
const ComponentBlock = ({ block, readOnly, isDragging, index }: ComponentBlockProps) => {
129+
const ComponentBlock = ({
130+
block, readOnly, isDragging, index,
131+
}: ComponentBlockProps) => {
130132
const { showOnlyPublished, openComponentEditor } = useLibraryContext();
131133

132134
const { sidebarItemInfo, openItemSidebar } = useSidebarContext();

0 commit comments

Comments
 (0)