-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into hu/ent-6501
- Loading branch information
Showing
32 changed files
with
811 additions
and
191 deletions.
There are no files selected for viewing
45 changes: 23 additions & 22 deletions
45
src/components/ContentHighlights/ContentHighlightCardContainer.jsx
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 |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import React from 'react'; | ||
import { CardGrid } from '@edx/paragon'; | ||
import { camelCaseObject } from '@edx/frontend-platform'; | ||
import ContentHighlightSetCard from './ContentHighlightSetCard'; | ||
import { TEST_COURSE_HIGHLIGHTS_DATA } from './data/constants'; | ||
import React, { useContext } from 'react'; | ||
import { Stack } from '@edx/paragon'; | ||
|
||
const ContentHighlightCardContainer = () => ( | ||
<CardGrid | ||
columnSizes={{ | ||
xs: 12, | ||
lg: 6, | ||
xl: 4, | ||
}} | ||
> | ||
{camelCaseObject(TEST_COURSE_HIGHLIGHTS_DATA).map(({ title, uuid, isPublished }) => ( | ||
<ContentHighlightSetCard | ||
key={uuid} | ||
title={title} | ||
highlightUUID={uuid} | ||
isPublished={isPublished} | ||
import { useHighlightSetsForCuration } from './data/hooks'; | ||
import { EnterpriseAppContext } from '../EnterpriseApp/EnterpriseAppContextProvider'; | ||
import HighlightSetSection from './HighlightSetSection'; | ||
|
||
const ContentHighlightCardContainer = () => { | ||
const { enterpriseCuration: { enterpriseCuration } } = useContext(EnterpriseAppContext); | ||
const highlightSets = useHighlightSetsForCuration(enterpriseCuration); | ||
|
||
return ( | ||
<Stack gap={4}> | ||
<HighlightSetSection | ||
title="Published" | ||
highlightSets={highlightSets.published} | ||
/> | ||
))} | ||
</CardGrid> | ||
); | ||
<HighlightSetSection | ||
title="Drafts" | ||
highlightSets={highlightSets.draft} | ||
/> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default ContentHighlightCardContainer; |
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
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
64 changes: 21 additions & 43 deletions
64
src/components/ContentHighlights/ContentHighlightsDashboard.jsx
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 |
---|---|---|
@@ -1,62 +1,40 @@ | ||
import React from 'react'; | ||
import React, { useContext } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Container } from '@edx/paragon'; | ||
import ZeroStateHighlights from './ZeroState'; | ||
import CurrentContentHighlights from './CurrentContentHighlights'; | ||
import ContentHighlightHelmet from './ContentHighlightHelmet'; | ||
// import { TEST_COURSE_HIGHLIGHTS_DATA } from './data/constants'; | ||
import { EnterpriseAppContext } from '../EnterpriseApp/EnterpriseAppContextProvider'; | ||
|
||
const ContentHighlightsDashboard = ({ highlightSets }) => { | ||
const ContentHighlightsDashboardBase = ({ children }) => ( | ||
<Container fluid className="my-5"> | ||
<ContentHighlightHelmet title="Highlights" /> | ||
{children} | ||
</Container> | ||
); | ||
|
||
ContentHighlightsDashboardBase.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
const ContentHighlightsDashboard = () => { | ||
const { enterpriseCuration: { enterpriseCuration } } = useContext(EnterpriseAppContext); | ||
const highlightSets = enterpriseCuration?.highlightSets; | ||
const hasContentHighlights = highlightSets?.length > 0; | ||
/* uncomment out import and 1 of the following conditions to test behavior */ | ||
// const hasContentHighlights = TEST_COURSE_HIGHLIGHTS_DATA.length > 0; | ||
// const hasContentHighlights = false; | ||
|
||
if (!hasContentHighlights) { | ||
return ( | ||
<Container fluid className="mt-5"> | ||
<ContentHighlightHelmet title="Highlights" /> | ||
<ContentHighlightsDashboardBase> | ||
<ZeroStateHighlights /> | ||
</Container> | ||
</ContentHighlightsDashboardBase> | ||
); | ||
} | ||
|
||
return ( | ||
<Container fluid className="mt-5"> | ||
<ContentHighlightHelmet title="Highlights" /> | ||
<ContentHighlightsDashboardBase> | ||
<CurrentContentHighlights /> | ||
</Container> | ||
</ContentHighlightsDashboardBase> | ||
); | ||
}; | ||
|
||
ContentHighlightsDashboard.propTypes = { | ||
highlightSets: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
title: PropTypes.string, | ||
isPublished: PropTypes.bool, | ||
enterpriseCuration: PropTypes.string, | ||
highlightedContent: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
contentKey: PropTypes.string, | ||
contentType: PropTypes.string, | ||
title: PropTypes.string, | ||
cardImageUrl: PropTypes.string, | ||
authoringOrganizations: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
uuid: PropTypes.string, | ||
name: PropTypes.string, | ||
logoImageUrl: PropTypes.string, | ||
}), | ||
), | ||
}), | ||
), | ||
}), | ||
), | ||
}; | ||
|
||
ContentHighlightsDashboard.defaultProps = { | ||
highlightSets: null, | ||
}; | ||
|
||
export default ContentHighlightsDashboard; |
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
10 changes: 2 additions & 8 deletions
10
src/components/ContentHighlights/CurrentContentHighlightItemsHeader.jsx
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,55 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { CardGrid } from '@edx/paragon'; | ||
|
||
import ContentHighlightSetCard from './ContentHighlightSetCard'; | ||
|
||
const HighlightSetSection = ({ | ||
title: sectionTitle, | ||
highlightSets, | ||
}) => { | ||
if (highlightSets.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div> | ||
<h3 className="mb-3">{sectionTitle}</h3> | ||
<CardGrid | ||
columnSizes={{ | ||
xs: 12, | ||
lg: 6, | ||
xl: 4, | ||
}} | ||
> | ||
{highlightSets.map(({ | ||
title, | ||
uuid, | ||
isPublished, | ||
highlightedContentUuids, | ||
}) => ( | ||
<ContentHighlightSetCard | ||
key={uuid} | ||
title={title} | ||
highlightUUID={uuid} | ||
isPublished={isPublished} | ||
itemCount={highlightedContentUuids.length} | ||
imageCapSrc="https://source.unsplash.com/360x200/?cat,dog" | ||
/> | ||
))} | ||
</CardGrid> | ||
</div> | ||
); | ||
}; | ||
|
||
HighlightSetSection.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
highlightSets: PropTypes.arrayOf(PropTypes.shape({ | ||
title: PropTypes.string.isRequired, | ||
uuid: PropTypes.string.isRequired, | ||
isPublished: PropTypes.bool.isRequired, | ||
highlightedContentUuids: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
})).isRequired, | ||
}; | ||
|
||
export default HighlightSetSection; |
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 @@ | ||
|
Oops, something went wrong.