-
Notifications
You must be signed in to change notification settings - Fork 154
refactor: Replace connect with useSelector() and useDispatch() 5/5 #2318 #2423
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @ahtesham-quraish! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
1edb908
to
eb34199
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
eb34199
to
61fd599
Compare
I'm going to try closing and re-opening this PR to see if it resolves the CLA check issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ahtesham-quraish.
|
||
export const mapDispatchToProps = { | ||
importTranscript: thunkActions.video.importTranscript, | ||
setOpen: PropTypes.func.isRequired, | ||
}; | ||
|
||
export const ImportTranscriptCardInternal = ImportTranscriptCard; // For testing only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const ImportTranscriptCardInternal = ImportTranscriptCard; // For testing only |
Please get rid of this Internal
alias - it's not needed anymore :)
); | ||
|
||
ImportTranscriptCard.defaultProps = { | ||
setOpen: true, |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { ImportTranscriptCardInternal as ImportTranscriptCard } from './ImportTranscriptCard'; | |
import { ImportTranscriptCard } from './ImportTranscriptCard'; |
|
||
const LanguageSelector = ({ | ||
index, // For a unique id for the form control |
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
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.
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, | ||
}; |
There was a problem hiding this comment.
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.
TranscriptWidget.defaultProps = { | ||
selectedVideoTranscriptUrls: {}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TranscriptWidget.defaultProps = { | |
selectedVideoTranscriptUrls: {}, | |
}; |
export const TranscriptWidgetInternal = TranscriptWidget; | ||
export default TranscriptWidget; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { initializeMocks } from '../../../../../../../testUtils'; | |
import { initializeMocks } from '@src/testUtils'; |
@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. |
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.
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:
.ts
,.tsx
).propTypes
,defaultProps
, andinjectIntl
patterns are not used in any new or modified code.src/testUtils.tsx
(specificallyinitializeMocks
)apiHooks.ts
in this repo for examples.messages.ts
files have adescription
for translators to use.../
. To import from parent folders, use@src
, e.g.import { initializeMocks } from '@src/testUtils';
instead offrom '../../../../testUtils'