Skip to content

Commit 48afebe

Browse files
viv-helixormsbeenavinkarkera
authored
chore(release): sync upstream release/ulmo.1 into release-ulmo (#84)
* fix: support "in progress" status for lib upload When uploading a library archive file during the creation of a new library, the code prior to this commit did not properly handle the "In Progress" state, which is when the celery task doing the archive processing is actively running. Note that this is distinct from the "Pending" state, which is when the task is waiting in the queue to be run (which in practice should almost never happen unless there is an operational issue). Since celery tasks run in-process during local development, the task was always finished by the time that the browser made a call to check on the status. The problem only happened on slower sandboxes, where processing truly runs asynchronously and might take a few seconds. Because this case wasn't handled, the frontend would never poll for updates either, so the upload was basically lost as far as the user was concerned. * feat: add temporary message alert in sections settings tab in libraries (openedx#2734) (openedx#2766) - add temporary message alert in sections settings tab in libraries - increase sidebar width to remove `More` option and display all tabs together (cherry picked from commit 3eeca24) --------- Co-authored-by: David Ormsbee <[email protected]> Co-authored-by: Navin Karkera <[email protected]>
1 parent d94c1e2 commit 48afebe

7 files changed

Lines changed: 53 additions & 5 deletions

File tree

src/library-authoring/LibraryAuthoringPage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
.library-authoring-sidebar {
1515
z-index: 1000; // same as header
16-
flex: 500px 0 0;
16+
flex: 530px 0 0;
1717
position: sticky;
1818
top: 0;
1919
right: 0;

src/library-authoring/containers/ContainerInfo.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
Icon,
99
IconButton,
1010
useToggle,
11+
Alert,
1112
} from '@openedx/paragon';
1213
import React, { useCallback } from 'react';
1314
import { Link } from 'react-router-dom';
14-
import { MoreVert } from '@openedx/paragon/icons';
15+
import { InfoOutline, MoreVert } from '@openedx/paragon/icons';
1516

1617
import { useClipboard } from '@src/generic/clipboard';
1718
import { ContainerType, getBlockType } from '@src/generic/key-utils';
@@ -149,6 +150,15 @@ const ContainerActions = ({
149150
);
150151
};
151152

153+
/* istanbul ignore next */
154+
/* istanbul ignore next */
155+
const ContainerSettings = () => (
156+
<Alert icon={InfoOutline} variant="info">
157+
<p>
158+
<FormattedMessage {...messages.containerSettingsMsg} />
159+
</p>
160+
</Alert>
161+
);
152162
const ContainerInfo = () => {
153163
const intl = useIntl();
154164
const {
@@ -222,7 +232,7 @@ const ContainerInfo = () => {
222232
{renderTab(
223233
CONTAINER_INFO_TABS.Settings,
224234
intl.formatMessage(messages.settingsTabTitle),
225-
// TODO: container settings component
235+
<ContainerSettings />,
226236
)}
227237
</Tabs>
228238
</Stack>

src/library-authoring/containers/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ const messages = defineMessages({
6666
defaultMessage: 'Container actions menu',
6767
description: 'Alt/title text for the container card menu button.',
6868
},
69+
containerSettingsMsg: {
70+
id: 'course-authoring.library-authoring.container.settings.alert.message',
71+
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.',
72+
description: 'Temporary message for settings tab being',
73+
},
6974
menuOpen: {
7075
id: 'course-authoring.library-authoring.menu.open',
7176
defaultMessage: 'Open',

src/library-authoring/create-library/CreateLibrary.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ export const CreateLibrary = ({
253253

254254
{(restoreTaskId || isError || restoreMutation.isError) && (
255255
<div className="mb-4">
256-
{restoreStatus?.state === LibraryRestoreStatus.Pending && (
256+
{(restoreStatus?.state === LibraryRestoreStatus.Pending
257+
|| restoreStatus?.state === LibraryRestoreStatus.InProgress) && (
257258
<Alert variant="info">
258259
{intl.formatMessage(messages.restoreInProgress)}
259260
</Alert>

src/library-authoring/create-library/data/apiHooks.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,34 @@ describe('create library apiHooks', () => {
173173
expect(axiosMock.history.get[0].url).toEqual(`http://localhost:18010/api/libraries/v2/restore/?task_id=${taskId}`);
174174
});
175175

176+
it('should handle in-progress status with refetch interval', async () => {
177+
const taskId = 'in-progress-task-id';
178+
const inProgressResult = {
179+
state: LibraryRestoreStatus.InProgress,
180+
result: null,
181+
error: null,
182+
error_log: null,
183+
};
184+
185+
const expectedResult = {
186+
state: LibraryRestoreStatus.InProgress,
187+
result: null,
188+
error: null,
189+
errorLog: null,
190+
};
191+
192+
axiosMock.onGet(`http://localhost:18010/api/libraries/v2/restore/?task_id=${taskId}`).reply(200, inProgressResult);
193+
194+
const { result } = renderHook(() => useGetLibraryRestoreStatus(taskId), { wrapper });
195+
196+
await waitFor(() => {
197+
expect(result.current.isLoading).toBeFalsy();
198+
});
199+
200+
expect(result.current.data).toEqual(expectedResult);
201+
expect(axiosMock.history.get[0].url).toEqual(`http://localhost:18010/api/libraries/v2/restore/?task_id=${taskId}`);
202+
});
203+
176204
it('should handle failed status', async () => {
177205
const taskId = 'failed-task-id';
178206
const failedResult = {

src/library-authoring/create-library/data/apiHooks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export const useGetLibraryRestoreStatus = (taskId: string) => useQuery<GetLibrar
4141
queryKey: libraryRestoreQueryKeys.restoreStatus(taskId),
4242
queryFn: () => getLibraryRestoreStatus(taskId),
4343
enabled: !!taskId, // Only run the query if taskId is provided
44-
refetchInterval: (query) => (query.state.data?.state === LibraryRestoreStatus.Pending ? 2000 : false),
44+
refetchInterval: (query) => (
45+
(query.state.data?.state === LibraryRestoreStatus.Pending
46+
|| query.state.data?.state === LibraryRestoreStatus.InProgress
47+
) ? 2000 : false),
4548
});
4649

4750
export const useCreateLibraryRestore = () => useMutation<CreateLibraryRestoreResponse, Error, File>({

src/library-authoring/create-library/data/restoreConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface GetLibraryRestoreStatusResponse {
3232

3333
export enum LibraryRestoreStatus {
3434
Pending = 'Pending',
35+
InProgress = 'In Progress',
3536
Succeeded = 'Succeeded',
3637
Failed = 'Failed',
3738
}

0 commit comments

Comments
 (0)