Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add highlight content card to stepper and individual sets #912

Merged
merged 20 commits into from
Dec 19, 2022

Conversation

brobro10000
Copy link
Member

@brobro10000 brobro10000 commented Dec 5, 2022

Added initial cards for user selection in the highlight stepper content review section.
Added Price at the footer of the cards.
Added API integration with content highlight set items, displaying content highlight set items from highlight set.
Added Trashcan to remove items on the final step of the stepper
Added hyperlink on titles of cards
Added parameters/logics to take into account multiple content types for highlight cards

Added Relevant testing

Updating test reflecting changes and from reference PR #895

Highlight Set items
Screen Shot 2022-12-14 at 11 22 13 AM

Step 2 of Highlight Stepper
Screen Shot 2022-12-14 at 11 24 19 AM

Step 3 of Highlight Stepper
Screen Shot 2022-12-14 at 11 24 40 AM

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

@brobro10000 brobro10000 marked this pull request as ready for review December 7, 2022 14:56
src/components/ContentHighlights/ContentHighlightSet.jsx Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/hooks.js Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/hooks.js Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/hooks.js Outdated Show resolved Hide resolved
@@ -69,7 +69,7 @@ const ContentHighlightStepper = ({ enterpriseId }) => {
const newHighlightSet = {
title: highlightTitle,
isPublished: true,
// TODO: pass along the selected content keys!
content_key: Object.keys(currentSelectedRowIds).map(key => key.split(':')[1]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, while this technically should work, it may not be optimal. That is, you're parsing the content_key from the aggregation_key field for the course. While the latter part of the aggregation_key is the format of content_key that enterprise-catalog expects here, it is a bit risky to assume that the content_key can be derived from the aggregation_key in this way, if that makes sense.

For example, content_key for courses in enterprise-catalog is derived from the key field, whereas content_key for programs/pathways content in enterprise-catalog is derived from the uuid field.

I think what you have now should be fine for now because your assumption is currently true, but we may want to add a TODO comment here to suggest finding a solution of extracting the appropriate content_key value from each selected highlighted content item based on its content type (i.e., key for courses, and uuid for programs/pathways).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might try rubber ducking later on (outside of this PR) on finding a more optimal solution here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving Open as reference in the future

@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Base: 83.65% // Head: 83.73% // Increases project coverage by +0.07% 🎉

Coverage data is based on head (d1d51b0) compared to base (ee876b0).
Patch coverage: 86.17% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #912      +/-   ##
==========================================
+ Coverage   83.65%   83.73%   +0.07%     
==========================================
  Files         391      393       +2     
  Lines        8768     8833      +65     
  Branches     1846     1855       +9     
==========================================
+ Hits         7335     7396      +61     
- Misses       1403     1407       +4     
  Partials       30       30              
Impacted Files Coverage Δ
...ontentHighlights/ContentHighlightCardContainer.jsx 100.00% <ø> (ø)
...nts/ContentHighlights/ContentHighlightsContext.jsx 100.00% <ø> (ø)
...s/ContentHighlights/ContentHighlightsDashboard.jsx 93.33% <ø> (ø)
...mponents/ContentHighlights/HighlightSetSection.jsx 100.00% <ø> (ø)
...ghtStepper/HighlightStepperSelectContentSearch.jsx 83.33% <ø> (ø)
src/data/services/EnterpriseCatalogApiService.js 38.46% <0.00%> (-3.21%) ⬇️
...mponents/ContentHighlights/ContentHighlightSet.jsx 25.00% <25.00%> (-25.00%) ⬇️
...ights/HighlightStepper/ContentHighlightStepper.jsx 87.80% <50.00%> (-1.94%) ⬇️
src/components/ContentHighlights/data/hooks.js 84.44% <71.42%> (-11.39%) ⬇️
src/components/ContentHighlights/data/utils.js 92.30% <92.30%> (ø)
... and 11 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 25 to 27
<Hyperlink destination={hyperlink} target="_blank">
<Truncate lines={3} title={title}>{title}</Truncate>
</Hyperlink>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, not sure a way around this, but it looks like the external link icon wraps onto a 4th line, since the text truncation doesn't consider the Hyperlink icon. And it looks like we can't have Truncate wrap Hyperlink instead.

image

I think for the purpose of this PR we should leave it as you have it, but let's confirm with Alena if this is OK. I personally feel having the external link icon sometimes wrap to a 4th line doesn't look all that clean and would possibly prefer a different approach to indicating opening in a new tab, e.g.:

image

Of course, let's defer to the decision is by Alena.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving open for future reference

src/components/ContentHighlights/ContentHighlightSet.jsx Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/constants.js Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/constants.js Outdated Show resolved Hide resolved
@@ -306,3 +330,68 @@ export const TEST_COURSE_HIGHLIGHTS_DATA = [
],
},
];

export const testCourseData = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clarification] Is this only used by tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it reflects sample data coming from the algolia's search clients hits that have been destructured to Content cards metadata

},
];

export const testCourseAggregation = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clarification] Is this only used by tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this represents the selectedRowIds between state changes of the stepper.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Got it. I wonder if it'd be worth moving these 2 variables intended only for tests into a different file to not confuse with application constants (e.g., data/tests/constants.js)?

}
const cardInfo = {
cardImgSrc: cardImageUrl,
cardLogoSrc: partners?.length === 1 ? partners[0].logoImageUrl : undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: partners is listed as a required prop. if that's the case, we should be able to assume partners.length would work without the ?.. If that breaks tests, the test itself may need to ensure the partners is passed with an empty array vs. undefined.

}
const cardInfo = {
cardImgSrc: cardImageUrl,
cardLogoSrc: partners?.length === 1 ? partners[0].logoImageUrl : undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: partners is listed as a required prop. if that's the case, we should be able to assume partners.length would work without the ?.. If that breaks tests, the test itself may need to ensure the partners is passed with an empty array vs. undefined.

},
];

export const testCourseAggregation = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Got it. I wonder if it'd be worth moving these 2 variables intended only for tests into a different file to not confuse with application constants (e.g., data/tests/constants.js)?

src/components/ContentHighlights/data/hooks.js Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/hooks.js Outdated Show resolved Hide resolved
src/components/ContentHighlights/data/utils.js Outdated Show resolved Hide resolved
import SkeletonContentCard from './SkeletonContentCard';
import { HIGHLIGHTS_CARD_GRID_COLUMN_SIZES } from './data/constants';

const SkeletonContentCardContainer = ({ length, columnSizes }) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: length -> totalItems

const deleteSelectedRowId = useCallback((rowId) => {
const currentRowIds = { ...currentSelectedRowState };
delete currentRowIds[rowId];
setState(s => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can nix the currentSelectedRowState state variable in favor of something like below:

const deleteSelectedRowId = useCallback((rowId) => {
    const currentRowIds = { ...currentSelectedRowState };
    setState((s) => {
      const currentRowIds = { ...s };
      delete currentRowIds[rowId];
      return {
       ...s,
       stepperModal: {
         ...s.stepperModal,
         currentSelectedRowIds: currentRowIds,
       },
      };
    });
});

@brobro10000 brobro10000 merged commit 6d64163 into master Dec 19, 2022
@brobro10000 brobro10000 deleted the hu/ent-6562 branch December 19, 2022 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants