Skip to content

feat: create section and subsection in library #2013

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented May 21, 2025

Description

Adds create section and subsection buttons in sidebar.

Useful information to include:

  • Which edX user roles will this change impact? Common user roles are "Course Author"

image

image

Supporting information

Testing instructions

  • Use New button in library authoring page.
  • Verify that new section, subsection and unit buttons work.
  • Verify that the above buttons work as expected in collections as well, i.e., after creating container, it should be linked with the collection.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 21, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented May 21, 2025

Thanks for the pull request, @navinkarkera!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link

codecov bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 97.80220% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.95%. Comparing base (65605bf) to head (54ada1b).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/library-authoring/add-content/AddContent.tsx 91.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2013      +/-   ##
==========================================
- Coverage   93.96%   93.95%   -0.01%     
==========================================
  Files        1155     1155              
  Lines       24128    24169      +41     
  Branches     5115     5242     +127     
==========================================
+ Hits        22671    22709      +38     
+ Misses       1389     1383       -6     
- Partials       68       77       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@navinkarkera navinkarkera force-pushed the navin/fal-4170/create-section-subsection branch from c5cf00a to 54ada1b Compare May 22, 2025 06:37
@navinkarkera navinkarkera marked this pull request as ready for review May 22, 2025 06:47
@navinkarkera navinkarkera requested review from rpenido and ChrisChV May 22, 2025 06:48
Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work, @navinkarkera!

  • I tested this using the instructions from the PR
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

I just added some nits.

Unit = 'unit',
/**
* Vertical is the old name for Unit. Generally, **please avoid using this term entirely in any libraries code** or
* Chapter, Sequential and Vertical is the old name for Unit.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
* Chapter, Sequential and Vertical is the old name for Unit.
* Chapter, Sequential and Vertical are the old names for Section, Subsection and Unit.

const unitId = 'lct:orf1:lib1:unit:test-1';
renderWithUnit(unitId);

expect(await screen.findByRole('button', { name: 'Text' })).toBeInTheDocument();
screen.debug();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
screen.debug();

Comment on lines +44 to +58
createUnitModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-unit.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Unit modal form',
},
createSubsectionModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-subsection.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Subsection modal form',
},
createSectionModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-section.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Section modal form',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about removing the common strings here?

Suggested change
createUnitModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-unit.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Unit modal form',
},
createSubsectionModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-subsection.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Subsection modal form',
},
createSectionModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-section.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Section modal form',
},
createContainerModalNamePlaceholder: {
id: 'course-authoring.library-authoring.modals.create-container.form.name.placeholder',
defaultMessage: 'Give a descriptive title',
description: 'Placeholder of the Name field of the Create Container modal form',
},

Comment on lines +149 to +151
if (insideSection) {
// Should only allow adding subsections
return [subsectionButtonData];
Copy link
Contributor

Choose a reason for hiding this comment

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

To fix coverage and not let us forget it later:

Suggested change
if (insideSection) {
// Should only allow adding subsections
return [subsectionButtonData];
// istanbul ignore if: not implemented
if (insideSection) {
// Should only allow adding subsections
throw new Error('Not implemented');
// return [subsectionButtonData];

Comment on lines +153 to +155
if (insideSubsection) {
// Should only allow adding units
return [unitButtonData];
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Suggested change
if (insideSubsection) {
// Should only allow adding units
return [unitButtonData];
// istanbul ignore if: not implemented
if (insideSubsection) {
// Should only allow adding units
throw new Error('Not implemented');
// return [unitButtonData];

return (
<>
{(collectionId || unitId) && componentPicker && (
{visibleContentTypes.map((contentType) => (
<AddContentButton contentType={contentType} onCreateContent={onCreateContent} />
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing key

Suggested change
<AddContentButton contentType={contentType} onCreateContent={onCreateContent} />
<AddContentButton key={contentType} contentType={contentType} onCreateContent={onCreateContent} />

Nice refactor, btw! 👍

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label May 22, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions May 22, 2025
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to In Eng Review in Contributions May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core contributor PR author is a Core Contributor (who may or may not have write access to this repo). FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: In Eng Review
Development

Successfully merging this pull request may close these issues.

4 participants