forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add lib v2/legacy tabs in studio home
When lib mode is set to "mixed", both "Libraries" and "Legacy Libraries" tabs are show in the Studio Home. When "Libraries" is clicked, v2 libraries are fetched, when "Legacy Libraries" is clicked, v1 libraries are fetched. When lib mode is set to "v1 only" or "v2 only", only one tab "Libraries" is show and only the respective libraries are fetched when the tab is clicked.
- Loading branch information
1 parent
a585a13
commit 418e561
Showing
8 changed files
with
134 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { getStudioHomeLibrariesV2 } from './api'; | ||
|
||
/** | ||
* Builds the query to fetch list of V2 Libraries | ||
*/ | ||
export const useListStudioHomeV2Libraries = () => ( | ||
useQuery({ | ||
queryKey: ['listV2Libraries'], | ||
queryFn: () => getStudioHomeLibrariesV2(), | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import { Icon, Row } from '@openedx/paragon'; | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
|
||
import { useListStudioHomeV2Libraries } from '../../data/apiHooks'; | ||
import { LoadingSpinner } from '../../../generic/Loading'; | ||
import AlertMessage from '../../../generic/alert-message'; | ||
import CardItem from '../../card-item'; | ||
import messages from '../messages'; | ||
|
||
const LibrariesV2Tab = () => { | ||
const intl = useIntl(); | ||
const { | ||
data, | ||
isLoading, | ||
isError, | ||
} = useListStudioHomeV2Libraries(); | ||
|
||
if (isLoading) { | ||
return ( | ||
<Row className="m-0 mt-4 justify-content-center"> | ||
<LoadingSpinner /> | ||
</Row> | ||
); | ||
} | ||
|
||
return ( | ||
isError ? ( | ||
<AlertMessage | ||
title={intl.formatMessage(messages.librariesTabErrorMessage)} | ||
variant="danger" | ||
description={( | ||
<Row className="m-0 align-items-center"> | ||
<Icon src={Error} className="text-danger-500 mr-1" /> | ||
<span>{intl.formatMessage(messages.librariesTabErrorMessage)}</span> | ||
</Row> | ||
)} | ||
/> | ||
) : ( | ||
<div className="courses-tab"> | ||
{data.map(({ org, slug, title }) => ( | ||
<CardItem | ||
key={`${org}+${slug}`} | ||
isLibraries | ||
displayName={title} | ||
org={org} | ||
number={slug} | ||
// TODO: Pass in the URL | ||
// url={url} | ||
/> | ||
))} | ||
</div> | ||
) | ||
); | ||
}; | ||
|
||
|
||
export default LibrariesV2Tab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters