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

Raised for testing purpose - Contains all code of GSoC 2024 #5946

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

Conversation

omChauhanDev
Copy link
Contributor

What this PR does

This pr is created for testing all training modification features.
Eg: how they work over production server

@ragesoss
Copy link
Member

ragesoss commented Sep 6, 2024

This is an impressive set of functionality.

I've done some initial testing, and there are a few UX problems that I think will need to be fixed before this is ready to deploy.

  • There needs to be a way to edit an existing slide. Since we are not supporting slide deletion, it's important to be able to change the wiki page for an existing slide, so that misconfiguring a new slide will not render the slide slug unusable.
  • The wiki page field should automatically handle input that is a meta.wikimedia.org full URL instead of just a page name. Copying and pasting the full URL from a wiki is a common pattern in the dashboard, and it's not obvious whether a user ought to use a URL or just a page title.

@ragesoss
Copy link
Member

ragesoss commented Sep 6, 2024

I also encountered a JS error when entering 'reorder' mode on an existing module's index page:

TypeError: Cannot read properties of null (reading 'split')
    at DraggableSlide (draggableSlide.jsx:68:1)
    at renderWithHooks (react-dom.development.js:16305:18)
    at mountIndeterminateComponent (react-dom.development.js:20069:13)
    at beginWork (react-dom.development.js:21582:16)
    at beginWork$1 (react-dom.development.js:27421:14)
    at performUnitOfWork (react-dom.development.js:26552:12)
    at workLoopSync (react-dom.development.js:26461:5)
    at renderRootSync (react-dom.development.js:26429:7)
    at recoverFromConcurrentError (react-dom.development.js:25845:20)
    at performSyncWorkOnRoot (react-dom.development.js:26091:20)
    at flushSyncCallbacks (react-dom.development.js:12042:22)
    at eval (react-dom.development.js:25646:13)

@ragesoss ragesoss marked this pull request as draft September 6, 2024 19:53
@omChauhanDev
Copy link
Contributor Author

Fixing this error and also reducing some unnecessary lines of code of 'reordering slides' pr. Then will move on to incorporating the listed changes to make it perfect for deployment.

@omChauhanDev
Copy link
Contributor Author

omChauhanDev commented Sep 17, 2024

sir, where you found this error as, I tried replicating this error in my browser console but found nothing
kindly have a look : Video

@omChauhanDev omChauhanDev marked this pull request as ready for review September 18, 2024 10:47
@omChauhanDev omChauhanDev marked this pull request as draft September 18, 2024 11:18
@omChauhanDev
Copy link
Contributor Author

@ragesoss sir, kindly have a look

@ragesoss
Copy link
Member

Hmm... I still hit that same error. I'm doing this in wiki_education mode, with freshly reloaded training modules, and any time I click 'Change Order' on the index page of one of the YAML-backed modules, it throws a JS error and the React-rendered sidebar disappears.

@omChauhanDev omChauhanDev force-pushed the feature/ordering-slides-of-training-module branch from 596a1a4 to 9125c59 Compare November 6, 2024 20:42
@omChauhanDev
Copy link
Contributor Author

@ragesoss sir, kindly verify that js error that we have encountered earlier is not happening now ?

@ragesoss
Copy link
Member

ragesoss commented Nov 7, 2024

Yep! That fixes the error. Thanks!

I will continue testing from here, this week or next.

@ragesoss
Copy link
Member

ragesoss commented Nov 26, 2024

I spotted a layout bug. Some change within the TOC makes the two-digit slide numbers only show the last digit.

numbering

invalid
invalid,
label,
spacer
Copy link
Member

Choose a reason for hiding this comment

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

What is this for? It doesn't look like this property gets used in any components that use TextAreaInput.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a custom label that can be be given to text_area component. Sir, we are using this in our modals of 'creating library', 'creating categories' and 'adding modules'.
Whenever there is any error like no text provided by user, or exceeded the max limit of characters, then along with the boundaries of text_area_input.jsx this label also becomes red.
Eg :
image

case SET_TRAINING_MODE:
return {
...state,
editMode: JSON.parse(mainDiv.getAttribute('data-training_mode')).editMode
Copy link
Member

Choose a reason for hiding this comment

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

This seems like violation of the Redux state model, as it changes state based on things outside of the current state and the data included in the action object (so it's not a pure function). Although it wouldn't actual be mutable normally, I think it still ought to be refactored so that reading from the DOM happens outside of the reducer and the editMode value is included in the action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for catching that Redux violation. I've refactored the code to maintain reducer purity by moving the DOM interaction out of the reducer. The editMode value is now read in the action creator and passed through the action's payload. The reducer now only depends on the state and action parameters, following Redux's pure function principles.

@ragesoss
Copy link
Member

I found that the Edit Mode button is present and works even for logged out users. It should be limited to admins initially, and we might open it to any logged in user later on, but not logged out users.

@ragesoss
Copy link
Member

I get this error when clicking Remove Slide from a module index page (of a module that was originally from yaml):

Uncaught TypeError: Cannot read properties of null (reading 'split')
    at SelectableBox (selectable_box.jsx:20:1)
    at renderWithHooks (react-dom.development.js:16305:18)
    at mountIndeterminateComponent (react-dom.development.js:20069:13)
    at beginWork (react-dom.development.js:21582:16)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:14)
    at HTMLUnknownElement.sentryWrapped (helpers.js:89:23)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at beginWork$1 (react-dom.development.js:27446:7)
    at performUnitOfWork (react-dom.development.js:26552:12)
    at workLoopSync (react-dom.development.js:26461:5)
    at renderRootSync (react-dom.development.js:26429:7)
    at performSyncWorkOnRoot (react-dom.development.js:26080:20)
    at flushSyncCallbacks (react-dom.development.js:12042:22)
    at eval (react-dom.development.js:25646:13)

@omChauhanDev omChauhanDev force-pushed the feature/ordering-slides-of-training-module branch from bcf80c0 to 7f5b45a Compare December 4, 2024 08:10
@omChauhanDev
Copy link
Contributor Author

@ragesoss Sir, I’ve added these updates :

  1. Slide editing is now enabled to allow changes to the wiki page for existing slides, ensuring misconfigured slides remain usable.

  2. The wiki page field also accepts both full URLs and page titles for better usability.

Kindly review and let me know if there’s anything else we can add or fix before we are ready for deployment.

@ragesoss ragesoss marked this pull request as ready for review January 27, 2025 18:30
@ragesoss
Copy link
Member

I've done some more testing and turned up a few things.

I'm able to reorder slides now, yay!

From the index of a module (which has content from .yml files), I click the edit icon for a slide. If I change the title and do not enter anything for the (blank) wiki_page field, I get a console error upon clicking Update:

edit_slide.jsx:69 slide Changed {slug: '', title: '', wiki_page: ''}
helpers.js:104 Uncaught TypeError: Cannot read properties of null (reading 'trim')
    at validateFields (edit_slide.jsx:83:1)
    at submitHandler (edit_slide.jsx:96:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:14)
    at HTMLUnknownElement.sentryWrapped (helpers.js:89:23)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:25)
    at executeDispatch (react-dom.development.js:9041:3)
    at processDispatchQueueItemsInOrder (react-dom.development.js:9073:7)
    at processDispatchQueue (react-dom.development.js:9086:5)
    at dispatchEventsForPlugins (react-dom.development.js:9097:3)
    at eval (react-dom.development.js:9288:12)
    at batchedUpdates$1 (react-dom.development.js:26135:12)
    at batchedUpdates (react-dom.development.js:3991:12)
    at dispatchEventForPluginEventSystem (react-dom.development.js:9287:3)
    at dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay (react-dom.development.js:6465:5)
    at dispatchEvent (react-dom.development.js:6457:5)
    at dispatchDiscreteEvent (react-dom.development.js:6430:5)
    at HTMLDivElement.sentryWrapped (helpers.js:89:23)
validateFields @ edit_slide.jsx:83
submitHandler @ edit_slide.jsx:96
callCallback @ react-dom.development.js:4164
sentryWrapped @ helpers.js:89
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
eval @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26135
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
sentryWrapped @ helpers.js:89
helpers.js:104 Uncaught TypeError: Cannot read properties of null (reading 'trim')
    at validateFields (edit_slide.jsx:83:1)
    at submitHandler (edit_slide.jsx:96:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:14)
    at HTMLUnknownElement.sentryWrapped (helpers.js:89:23)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:25)
    at executeDispatch (react-dom.development.js:9041:3)
    at processDispatchQueueItemsInOrder (react-dom.development.js:9073:7)
    at processDispatchQueue (react-dom.development.js:9086:5)
    at dispatchEventsForPlugins (react-dom.development.js:9097:3)
    at eval (react-dom.development.js:9288:12)
    at batchedUpdates$1 (react-dom.development.js:26135:12)
    at batchedUpdates (react-dom.development.js:3991:12)
    at dispatchEventForPluginEventSystem (react-dom.development.js:9287:3)
    at dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay (react-dom.development.js:6465:5)
    at dispatchEvent (react-dom.development.js:6457:5)
    at dispatchDiscreteEvent (react-dom.development.js:6430:5)
    at HTMLDivElement.sentryWrapped (helpers.js:89:23)
validateFields @ edit_slide.jsx:83
submitHandler @ edit_slide.jsx:96
callCallback @ react-dom.development.js:4164
sentryWrapped @ helpers.js:89
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
eval @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26135
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
sentryWrapped @ helpers.js:89
fetch.js:59 

If I add a wiki_slide value to that empty field, the above error does not occur and the content is successfully loaded from the wiki, but the wiki_slide value is not persisted in the database record; it's still wiki_slide: nil.

This might be only an issue because I'm testing in a cross-config way, using wiki_education: false but with some training content loaded in wiki_education: true mode. Even so, it's likely to cause trouble. If editing is not valid for .yml-based slides, then the edit UI should not be available in that situation.

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