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: allow dragging blocks across parents in outline #859

Merged
merged 26 commits into from
Mar 19, 2024

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Mar 2, 2024

EDX_PLATFORM_REPOSITORY: https://github.com/openedx/edx-platform.git
EDX_PLATFORM_VERSION: master

TUTOR_GROVE_WAFFLE_FLAGS:
  - name: contentstore.new_studio_mfe.use_new_course_outline_page
    everyone: true

Description:
This PR modifies drag-n-drop of elements in outline to support possibility of dragging elements across different parent elements.

Test instructions:

  • Get devstack up and running using make {lms,cms}-up.
  • Start npm devserver in this repo using npm start.
  • Go to outline page of any course via cms and update port to 2001.
  • Drag and drop sections, subsections and units and confirm that they can be dropped in other parent elements similar to legacy.
  • PR also updates move up and down menu action to support moving across parents.

Private-ref: BB-8634

Closes: #851

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 2, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Mar 2, 2024

Thanks for the pull request, @navinkarkera! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@navinkarkera navinkarkera force-pushed the navin/course-outline/dragndrop branch from 704792b to da9fd27 Compare March 2, 2024 08:22
@navinkarkera navinkarkera marked this pull request as ready for review March 2, 2024 08:26
@navinkarkera navinkarkera requested a review from a team as a code owner March 2, 2024 08:26
Copy link

codecov bot commented Mar 2, 2024

Codecov Report

Attention: Patch coverage is 92.97753% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 91.87%. Comparing base (6ae9cda) to head (ecf01cd).
Report is 6 commits behind head on master.

Files Patch % Lines
src/course-outline/drag-helper/utils.js 88.69% 12 Missing and 1 partial ⚠️
src/course-outline/drag-helper/DraggableList.jsx 90.58% 8 Missing ⚠️
.../course-outline/subsection-card/SubsectionCard.jsx 83.33% 2 Missing ⚠️
src/course-outline/page-alerts/PageAlerts.jsx 95.83% 1 Missing ⚠️
src/course-outline/section-card/SectionCard.jsx 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #859      +/-   ##
==========================================
- Coverage   91.88%   91.87%   -0.02%     
==========================================
  Files         562      574      +12     
  Lines        9776    10078     +302     
  Branches     2085     2157      +72     
==========================================
+ Hits         8983     9259     +276     
- Misses        766      791      +25     
- Partials       27       28       +1     

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

@navinkarkera navinkarkera force-pushed the navin/course-outline/dragndrop branch from da9fd27 to 4c724b6 Compare March 4, 2024 11:05
@mphilbrick211
Copy link

@openedx/2u-tnl

@arbrandes arbrandes self-requested a review March 4, 2024 16:59
@arbrandes arbrandes added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Mar 4, 2024
@arbrandes
Copy link
Contributor

Is there a feature flag to set to get the new experience without going to port 2001 manually?

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@navinkarkera
Copy link
Contributor Author

@arbrandes No, we don't have a flag yet. You can set new_studio_mfe.use_new_home_page waffle
flag to go to the new MFE home page, but the individual courses still take you to legacy UI.

@KristinAoki Maybe we can add a flag similar to ENABLE_UNIT_PAGE in this repo and redirect user to new outline if it is set.

@arbrandes
Copy link
Contributor

@navinkarkera, ok, and yes, I think an MFE-specific environment variable would be nice to have.

In the meantime, what would be the correct link from the sandbox course page? (Or from a tutor deployment, for that matter.)

@KristinAoki
Copy link
Member

To get to the outline page you can enable contentstore.new_studio_mfe.use_new_course_outline_page. This will allow page redirects when you try to hit the legacy page.

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Wow, this one's a doozy! Congrats! And it works quite nicely in the sandbox, too.

I do have a couple of nits, however.

return null;
};

/* istanbul ignore next */
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this very hard to test? I don't mean to block the PR because of it, but I feel like we should at least explain why we're not testing it in a comment.

The same goes for other instances in this PR.

Copy link
Contributor Author

@navinkarkera navinkarkera Mar 11, 2024

Choose a reason for hiding this comment

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

@arbrandes Ahh, I meant to write a comment about it, but then forgot. I have ignored two functions from coverage, i.e., unitDragOver and subsectionDragOver. For some weird reason, dragEnd handler is not being triggered by dnd-kit while testing them.

I had already spent quite some time testing the functions related to moving/dragging blocks which doesn't work with jsdom easily as it does not implement getClientBoundingRect and renders all elements on top of each other at (0, 0) position. So I had to mock collisionDetection function which helped me test movement of blocks inside its own parent as well as across parents.

The main functions responsible to move units & subsections across parents are tested, just these functions which determine the new index and parent are ignored.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it makes sense.

I still can't find the explanation in the code, though. Did you add it? If not, I would suggest adding it at the first occurrence of the istanbul ignore next of each file where this occurs. (I expect it's just this file.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arbrandes Done.

src/course-outline/drag-helper/DraggableList.jsx Outdated Show resolved Hide resolved
@navinkarkera navinkarkera force-pushed the navin/course-outline/dragndrop branch from 4c724b6 to d201cb4 Compare March 11, 2024 07:18
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@navinkarkera
Copy link
Contributor Author

@arbrandes @KristinAoki Thanks! Addressed your feedback, can you please take a look once again.

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Just looking for a code comment on why we're not testing some bits.

return null;
};

/* istanbul ignore next */
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it makes sense.

I still can't find the explanation in the code, though. Did you add it? If not, I would suggest adding it at the first occurrence of the istanbul ignore next of each file where this occurs. (I expect it's just this file.)

@@ -57,6 +57,34 @@ const messages = defineMessages({
id: 'course-authoring.course-outline.page-alert.generic-error.description',
defaultMessage: 'Unable to {actionName} {type}. Please try again.',
},
newFileAlertTitle: {
id: 'course-authoring.course-outline.page-alert.paste-alert.new-files.title',
defaultMessage: 'New {newFilesLen, plural, one {file} other {files}} added to Files.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty soon we'll start linting for messages that don't have descriptions. It's an important part of i18n, as it makes the lives of translators much easier. I'm not going to block PRs on this until openedx/frontend-build#516 merges, but consider this friendly heads-up. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arbrandes That is great. Although I cannot add descriptions to all messages files in the repo, I added them to this file as a start.

@navinkarkera navinkarkera force-pushed the navin/course-outline/dragndrop branch from d201cb4 to a75dfbd Compare March 14, 2024 06:28
@navinkarkera navinkarkera requested a review from a team as a code owner March 14, 2024 06:28
@navinkarkera navinkarkera requested a review from arbrandes March 14, 2024 06:30
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@navinkarkera
Copy link
Contributor Author

@KristinAoki I think this is ready to be merged (squash and merge).
cc: @arbrandes

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! (In particular, thank you for adding descriptions to the i18n messages!)

@arbrandes arbrandes merged commit da68fb8 into openedx:master Mar 19, 2024
6 checks passed
@openedx-webhooks
Copy link

@navinkarkera 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@navinkarkera navinkarkera deleted the navin/course-outline/dragndrop branch July 17, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-sandbox open-craft-grove should create a sandbox environment from this PR open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Some problems with drag and drop functionality
6 participants