Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/library-authoring/LibraryAuthoringPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

.library-authoring-sidebar {
z-index: 1000; // same as header
flex: 500px 0 0;
flex: 530px 0 0;
position: sticky;
top: 0;
right: 0;
Expand Down
14 changes: 12 additions & 2 deletions src/library-authoring/containers/ContainerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {
Icon,
IconButton,
useToggle,
Alert,
} from '@openedx/paragon';
import React, { useCallback } from 'react';
import { Link } from 'react-router-dom';
import { MoreVert } from '@openedx/paragon/icons';
import { InfoOutline, MoreVert } from '@openedx/paragon/icons';

import { useClipboard } from '@src/generic/clipboard';
import { ContainerType, getBlockType } from '@src/generic/key-utils';
Expand Down Expand Up @@ -149,6 +150,15 @@ const ContainerActions = ({
);
};

/* istanbul ignore next */
/* istanbul ignore next */
const ContainerSettings = () => (
<Alert icon={InfoOutline} variant="info">
<p>
<FormattedMessage {...messages.containerSettingsMsg} />
</p>
</Alert>
);
const ContainerInfo = () => {
const intl = useIntl();
const {
Expand Down Expand Up @@ -222,7 +232,7 @@ const ContainerInfo = () => {
{renderTab(
CONTAINER_INFO_TABS.Settings,
intl.formatMessage(messages.settingsTabTitle),
// TODO: container settings component
<ContainerSettings />,
)}
</Tabs>
</Stack>
Expand Down
5 changes: 5 additions & 0 deletions src/library-authoring/containers/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ const messages = defineMessages({
defaultMessage: 'Container actions menu',
description: 'Alt/title text for the container card menu button.',
},
containerSettingsMsg: {
id: 'course-authoring.library-authoring.container.settings.alert.message',
defaultMessage: 'Section settings cannot be configured within Libraries and must be set within a course. In a future release, Libraries may support configuring some settings.',
description: 'Temporary message for settings tab being',
},
menuOpen: {
id: 'course-authoring.library-authoring.menu.open',
defaultMessage: 'Open',
Expand Down
3 changes: 2 additions & 1 deletion src/library-authoring/create-library/CreateLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export const CreateLibrary = ({

{(restoreTaskId || isError || restoreMutation.isError) && (
<div className="mb-4">
{restoreStatus?.state === LibraryRestoreStatus.Pending && (
{(restoreStatus?.state === LibraryRestoreStatus.Pending
|| restoreStatus?.state === LibraryRestoreStatus.InProgress) && (
<Alert variant="info">
{intl.formatMessage(messages.restoreInProgress)}
</Alert>
Expand Down
28 changes: 28 additions & 0 deletions src/library-authoring/create-library/data/apiHooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,34 @@ describe('create library apiHooks', () => {
expect(axiosMock.history.get[0].url).toEqual(`http://localhost:18010/api/libraries/v2/restore/?task_id=${taskId}`);
});

it('should handle in-progress status with refetch interval', async () => {
const taskId = 'in-progress-task-id';
const inProgressResult = {
state: LibraryRestoreStatus.InProgress,
result: null,
error: null,
error_log: null,
};

const expectedResult = {
state: LibraryRestoreStatus.InProgress,
result: null,
error: null,
errorLog: null,
};

axiosMock.onGet(`http://localhost:18010/api/libraries/v2/restore/?task_id=${taskId}`).reply(200, inProgressResult);

const { result } = renderHook(() => useGetLibraryRestoreStatus(taskId), { wrapper });

await waitFor(() => {
expect(result.current.isLoading).toBeFalsy();
});

expect(result.current.data).toEqual(expectedResult);
expect(axiosMock.history.get[0].url).toEqual(`http://localhost:18010/api/libraries/v2/restore/?task_id=${taskId}`);
});

it('should handle failed status', async () => {
const taskId = 'failed-task-id';
const failedResult = {
Expand Down
5 changes: 4 additions & 1 deletion src/library-authoring/create-library/data/apiHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export const useGetLibraryRestoreStatus = (taskId: string) => useQuery<GetLibrar
queryKey: libraryRestoreQueryKeys.restoreStatus(taskId),
queryFn: () => getLibraryRestoreStatus(taskId),
enabled: !!taskId, // Only run the query if taskId is provided
refetchInterval: (query) => (query.state.data?.state === LibraryRestoreStatus.Pending ? 2000 : false),
refetchInterval: (query) => (
(query.state.data?.state === LibraryRestoreStatus.Pending
|| query.state.data?.state === LibraryRestoreStatus.InProgress
) ? 2000 : false),
});

export const useCreateLibraryRestore = () => useMutation<CreateLibraryRestoreResponse, Error, File>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface GetLibraryRestoreStatusResponse {

export enum LibraryRestoreStatus {
Pending = 'Pending',
InProgress = 'In Progress',
Succeeded = 'Succeeded',
Failed = 'Failed',
}
Expand Down
Loading