{localUpdateAlertCount > 0 && (
)}
-
-
+
+
{renderBeforeChildren()}
-
-
+
+
{renderAfterChildren()}
@@ -181,12 +225,14 @@ export const CompareContainersWidget = ({
isReadyToSyncIndividually = false,
}: ContainerInfoProps) => {
const [currentContainerState, setCurrentContainerState] = useState({
- upstreamBlockId,
- downstreamBlockId,
- parent: [],
- });
+ upstreamBlockId,
+ downstreamBlockId,
+ parent: [],
+ state: 'modified',
+ });
const { data } = useCourseContainerChildren(downstreamBlockId, true);
let localUpdateAlertBlockName = '';
@@ -213,9 +259,11 @@ export const CompareContainersWidget = ({
setCurrentContainerState((prev) => ({
upstreamBlockId: row.id!,
downstreamBlockId: row.downstreamId!,
+ state: row.state,
parent: [...prev.parent, {
upstreamBlockId: prev.upstreamBlockId,
downstreamBlockId: prev.downstreamBlockId,
+ state: prev.state,
}],
}));
};
@@ -230,6 +278,7 @@ export const CompareContainersWidget = ({
return {
upstreamBlockId: prevParent!.upstreamBlockId,
downstreamBlockId: prevParent!.downstreamBlockId,
+ state: prevParent!.state,
parent: prev.parent.slice(0, -1),
};
});
@@ -240,6 +289,7 @@ export const CompareContainersWidget = ({
upstreamBlockId={currentContainerState.upstreamBlockId}
downstreamBlockId={currentContainerState.downstreamBlockId}
parent={currentContainerState.parent}
+ state={currentContainerState.state}
onRowClick={onRowClick}
onBackBtnClick={onBackBtnClick}
localUpdateAlertCount={localUpdateAlertCount}
diff --git a/src/container-comparison/ContainerRow.test.tsx b/src/container-comparison/ContainerRow.test.tsx
index dfd811a6f2..669c9a7c78 100644
--- a/src/container-comparison/ContainerRow.test.tsx
+++ b/src/container-comparison/ContainerRow.test.tsx
@@ -29,20 +29,6 @@ describe('', () => {
)).toBeInTheDocument();
});
- test('is not clickable when state !== modified', async () => {
- const onClick = jest.fn();
- render();
- const titleDiv = await screen.findByText('Test title');
- const card = titleDiv.closest('.clickable');
- expect(card).toBe(null);
- });
-
test('calls onClick when clicked', async () => {
const onClick = jest.fn();
const user = userEvent.setup();
diff --git a/src/container-comparison/data/api.mock.ts b/src/container-comparison/data/api.mock.ts
index e27e23681f..49dccb95fc 100644
--- a/src/container-comparison/data/api.mock.ts
+++ b/src/container-comparison/data/api.mock.ts
@@ -8,7 +8,7 @@ import * as unitApi from '@src/course-unit/data/api';
* This mock returns a fixed response for the given container ID.
*/
export async function mockGetCourseContainerChildren(containerId: string): Promise {
- const numChildren: number = 3;
+ let numChildren: number = 3;
let blockType: string;
let displayName: string;
let upstreamReadyToSyncChildrenInfo: UpstreamReadyToSyncChildrenInfo[] = [];
@@ -61,8 +61,9 @@ export async function mockGetCourseContainerChildren(containerId: string): Promi
case mockGetCourseContainerChildren.subsectionIdLoading:
return new Promise(() => { });
default:
- blockType = 'unit';
- displayName = 'subsection block 00';
+ blockType = 'section';
+ displayName = 'section block 00';
+ numChildren = 0;
break;
}
const children = Array(numChildren).fill(mockGetCourseContainerChildren.childTemplate).map((child, idx) => (
diff --git a/src/container-comparison/data/apiHooks.ts b/src/container-comparison/data/apiHooks.ts
index 053ee47fab..dd78e37a99 100644
--- a/src/container-comparison/data/apiHooks.ts
+++ b/src/container-comparison/data/apiHooks.ts
@@ -11,7 +11,10 @@ export const containerComparisonQueryKeys = {
/**
* Key for a single container
*/
- container: (usageKey: string, getUpstreamInfo: boolean) => {
+ container: (getUpstreamInfo: boolean, usageKey?: string) => {
+ if (usageKey === undefined) {
+ return [undefined, undefined, getUpstreamInfo.toString()];
+ }
const courseKey = getCourseKey(usageKey);
return [...containerComparisonQueryKeys.course(courseKey), usageKey, getUpstreamInfo.toString()];
},
@@ -21,6 +24,7 @@ export const useCourseContainerChildren = (usageKey?: string, getUpstreamInfo?:
useQuery({
enabled: !!usageKey,
queryFn: () => getCourseContainerChildren(usageKey!, getUpstreamInfo),
- queryKey: containerComparisonQueryKeys.container(usageKey!, getUpstreamInfo || false),
+ // If we first get data with a valid `usageKey` and then the `usageKey` changes to undefined, an error occurs.
+ queryKey: containerComparisonQueryKeys.container(getUpstreamInfo || false, usageKey),
})
);
diff --git a/src/container-comparison/index.scss b/src/container-comparison/index.scss
new file mode 100644
index 0000000000..cc47033f0a
--- /dev/null
+++ b/src/container-comparison/index.scss
@@ -0,0 +1,10 @@
+.compare-changes-widget {
+ .compare-card {
+ min-height: 350px;
+ }
+
+ .big-icon {
+ height: 68px;
+ width: 68px;
+ }
+}
diff --git a/src/container-comparison/messages.ts b/src/container-comparison/messages.ts
index 1a8e61d2cb..549824c90d 100644
--- a/src/container-comparison/messages.ts
+++ b/src/container-comparison/messages.ts
@@ -86,6 +86,16 @@ const messages = defineMessages({
defaultMessage: 'The only change is to {count, plural, one {text block {blockName} which has been edited} other {{count} text blocks which have been edited}} in this course. Accepting will not remove local edits.',
description: 'Alert to show if the only change is on text components with local overrides.',
},
+ newContainer: {
+ id: 'course-authoring.container-comparison.new-container.text',
+ defaultMessage: 'This {containerType} is new',
+ description: 'Text to show in the comparison when a container is new.',
+ },
+ deletedContainer: {
+ id: 'course-authoring.container-comparison.deleted-container.text',
+ defaultMessage: 'This {containerType} has been removed',
+ description: 'Text to show in the comparison when a container is removed.',
+ },
});
export default messages;
diff --git a/src/container-comparison/utils.ts b/src/container-comparison/utils.ts
index ab0fa14439..2d4ddb4d21 100644
--- a/src/container-comparison/utils.ts
+++ b/src/container-comparison/utils.ts
@@ -132,7 +132,7 @@ export function diffPreviewContainerChildren div > div.highlight) {