Skip to content

Conversation

ahtesham-quraish
Copy link
Contributor

Description

Replace connect with useSelector() and useDispatch() 5/5 #2318

Supporting information

Link to other information about the change, such as GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

Please provide detailed step-by-step instructions for manually testing this change.

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.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Deprecated propTypes, defaultProps, and injectIntl patterns are not used in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Imports avoid using ../. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

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

Thanks for the pull request, @ahtesham-quraish!

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
🔘 Submit a signed contributor agreement (CLA)

⚠️ We ask all contributors to the Open edX project to submit a signed contributor agreement or indicate their institutional affiliation.
Please see the CONTRIBUTING file for more information.

If you've signed an agreement in the past, you may need to re-sign.
See The New Home of the Open edX Codebase for details.

Once you've signed the CLA, please allow 1 business day for it to be processed.
After this time, you can re-run the CLA check by adding a comment below that you have signed it.
If the CLA check continues to fail, you can tag the @openedx/cla-problems team in a comment for further assistance.

🔘 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.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Sep 4, 2025
@ahtesham-quraish ahtesham-quraish force-pushed the ahtesham/#2318 branch 2 times, most recently from 1edb908 to eb34199 Compare September 4, 2025 09:51
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.74%. Comparing base (2fb04d6) to head (61fd599).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2423      +/-   ##
==========================================
+ Coverage   94.63%   94.74%   +0.11%     
==========================================
  Files        1180     1192      +12     
  Lines       26151    27049     +898     
  Branches     5818     6039     +221     
==========================================
+ Hits        24747    25628     +881     
- Misses       1333     1347      +14     
- Partials       71       74       +3     

☔ 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.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Needs Tests Run or CLA Signed in Contributions Sep 10, 2025
@brian-smith-tcril
Copy link
Contributor

I'm going to try closing and re-opening this PR to see if it resolves the CLA check issue

@github-project-automation github-project-automation bot moved this from Needs Tests Run or CLA Signed to Done in Contributions Sep 11, 2025
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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


export const mapDispatchToProps = {
importTranscript: thunkActions.video.importTranscript,
setOpen: PropTypes.func.isRequired,
};

export const ImportTranscriptCardInternal = ImportTranscriptCard; // For testing only
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
export const ImportTranscriptCardInternal = ImportTranscriptCard; // For testing only

Please get rid of this Internal alias - it's not needed anymore :)

);

ImportTranscriptCard.defaultProps = {
setOpen: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This default was just totally wrong, right? setOpen is supposed to be a function.

@@ -2,27 +2,22 @@ import React from 'react';
import {
render, screen, fireEvent, initializeMocks,
} from '@src/testUtils';
import * as ReactRedux from 'react-redux';
import { ImportTranscriptCardInternal as ImportTranscriptCard } from './ImportTranscriptCard';
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
import { ImportTranscriptCardInternal as ImportTranscriptCard } from './ImportTranscriptCard';
import { ImportTranscriptCard } from './ImportTranscriptCard';


const LanguageSelector = ({
index, // For a unique id for the form control
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can you please leave in this comment "For a unique id for the form control" explaining what index is ? Ideally use JSDoc syntax so it will show up on hover in people's IDEs.

@@ -95,12 +103,25 @@ const LanguageSelector = ({
<Dropdown.Menu>
{Object.entries(videoTranscriptLanguages).map(([lang, text]) => {
if (language === lang) {
return (<Dropdown.Item>{text}<Icon className="text-primary-500" src={Check} /></Dropdown.Item>);
return (
<Dropdown.Item key={lang}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for catching the missing key here.

Comment on lines 217 to 226
TranscriptWidget.propTypes = {
// redux
transcripts: PropTypes.arrayOf(PropTypes.string).isRequired,
transcripts: PropTypes.arrayOf(PropTypes.string),
selectedVideoTranscriptUrls: PropTypes.shape(),
allowTranscriptDownloads: PropTypes.bool.isRequired,
showTranscriptByDefault: PropTypes.bool.isRequired,
allowTranscriptImport: PropTypes.bool.isRequired,
updateField: PropTypes.func.isRequired,
isUploadError: PropTypes.bool.isRequired,
isDeleteError: PropTypes.bool.isRequired,
allowTranscriptDownloads: PropTypes.bool,
showTranscriptByDefault: PropTypes.bool,
allowTranscriptImport: PropTypes.bool,
updateField: PropTypes.func,
isUploadError: PropTypes.bool,
isDeleteError: PropTypes.bool,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Please delete this whole thing - TranscriptWidget no longer accepts any props.

Comment on lines 213 to 215
TranscriptWidget.defaultProps = {
selectedVideoTranscriptUrls: {},
};
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
TranscriptWidget.defaultProps = {
selectedVideoTranscriptUrls: {},
};

Comment on lines +228 to +229
export const TranscriptWidgetInternal = TranscriptWidget;
export default TranscriptWidget;
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
export const TranscriptWidgetInternal = TranscriptWidget;
export default TranscriptWidget;
export { TranscriptWidget };

import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { useSelector } from 'react-redux';// ✅ adjust import path depending on your setup
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
import { useSelector } from 'react-redux';// ✅ adjust import path depending on your setup
import { useSelector } from 'react-redux';

??

@@ -0,0 +1,64 @@
import { editorRender, type PartialEditorState } from '@src/editors/editorTestRender';
import { screen } from '@testing-library/react';
import { initializeMocks } from '../../../../../../../testUtils';
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
import { initializeMocks } from '../../../../../../../testUtils';
import { initializeMocks } from '@src/testUtils';

@bradenmacdonald
Copy link
Contributor

@ahtesham-quraish Can you please also update the PR "Testing instructions" with instructions for how to test this manually? I want to make sure the editor components are still working after the refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants