feat: show sync button on section/subsections [FC-0097] (#2324)

- Adds the sync button on section/subsection cards
This commit is contained in:
Chris Chávez
2025-08-21 16:38:16 -05:00
committed by GitHub
parent 8e680dc8d4
commit 0c88fd6da9
9 changed files with 228 additions and 30 deletions

View File

@@ -19,7 +19,7 @@ import { useQueryClient } from '@tanstack/react-query';
import { Loop } from '@openedx/paragon/icons';
import messages from './messages';
import previewChangesMessages from '../course-unit/preview-changes/messages';
import { courseLibrariesQueryKeys, useEntityLinks } from './data/apiHooks';
import { invalidateLinksQuery, useEntityLinks } from './data/apiHooks';
import {
SearchContextProvider, SearchKeywordsField, useSearchContext, BlockTypeLabel, Highlight, SearchSortWidget,
} from '../search-manager';
@@ -189,7 +189,7 @@ const ItemReviewList = ({
const reloadLinks = useCallback((usageKey: string) => {
const courseKey = outOfSyncItemsByKey[usageKey].downstreamContextKey;
queryClient.invalidateQueries({ queryKey: courseLibrariesQueryKeys.courseLibraries(courseKey) });
invalidateLinksQuery(queryClient, courseKey);
}, [outOfSyncItemsByKey]);
const postChange = (accept: boolean) => {

View File

@@ -3,7 +3,7 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL;
export const getEntityLinksByDownstreamContextUrl = () => `${getApiBaseUrl()}/api/contentstore/v2/downstreams-all/`;
export const getEntityLinksByDownstreamContextUrl = () => `${getApiBaseUrl()}/api/contentstore/v2/downstreams/`;
export const getEntityLinksSummaryByDownstreamContextUrl = (downstreamContextKey: string) => `${getApiBaseUrl()}/api/contentstore/v2/downstreams/${downstreamContextKey}/summary`;
export interface PaginatedData<T> {

View File

@@ -1,4 +1,5 @@
import {
type QueryClient,
useQuery,
} from '@tanstack/react-query';
import { getEntityLinksSummaryByDownstreamContext, getEntityLinks } from './api';
@@ -70,3 +71,12 @@ export const useEntityLinksSummaryByDownstreamContext = (courseId?: string) => (
enabled: courseId !== undefined,
})
);
/**
* Ivalidates the downstream links query for a course
*/
export const invalidateLinksQuery = (queryClient: QueryClient, courseId: string) => {
queryClient.invalidateQueries({
queryKey: courseLibrariesQueryKeys.courseLibraries(courseId),
});
};