Skip to content

Refactor frontend part 6 #2800

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

Merged
merged 36 commits into from
Mar 17, 2024
Merged

Refactor frontend part 6 #2800

merged 36 commits into from
Mar 17, 2024

Conversation

RichDom2185
Copy link
Member

@RichDom2185 RichDom2185 commented Feb 21, 2024

Description

Focuses on fixing bugs (regressions), improving type safety, and removing dead code.

Please refer to commit history for list of changes.

Fixes #2797, though ideally we should not be hardcoding them (i.e., it's not a true "fix" of the root cause).

Also bans the following via ESLint rules (thus technically a breaking change – though the codebase has been updated to ensure everything is compliant):

  • React.FunctionComponent → use React.FC for succinctness
  • useSelector → use useTypedSelector for type-safety

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Checklist

  • I have tested this code
  • I have updated the documentation

This was missed during the initial migration.
Dependents include the associated types and tests.
@RichDom2185 RichDom2185 self-assigned this Feb 21, 2024
Improves correctness and consistency.
It was causing the tests to fail.
@coveralls
Copy link

coveralls commented Feb 21, 2024

Pull Request Test Coverage Report for Build 8312500534

Details

  • 65 of 173 (37.57%) changed or added relevant lines in 118 files are covered.
  • 37 unchanged lines in 28 files lost coverage.
  • Overall coverage decreased (-0.001%) to 38.457%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/commons/achievement/AchievementCard.tsx 0 1 0.0%
src/commons/achievement/AchievementCommentCard.tsx 0 1 0.0%
src/commons/achievement/AchievementFilter.tsx 0 1 0.0%
src/commons/achievement/AchievementManualEditor.tsx 1 2 50.0%
src/commons/achievement/AchievementOverview.tsx 0 1 0.0%
src/commons/achievement/AchievementView.tsx 0 1 0.0%
src/commons/achievement/card/AchievementXp.tsx 0 1 0.0%
src/commons/achievement/control/achievementEditor/AchievementAdder.tsx 0 1 0.0%
src/commons/achievement/control/achievementEditor/AchievementUuidCopier.tsx 0 1 0.0%
src/commons/achievement/control/achievementEditor/achievementSettings/EditableGoalUuids.tsx 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
src/commons/fileSystemView/FileSystemViewFileName.tsx 1 1.75%
src/commons/achievement/view/AchievementViewGoal.tsx 1 0.0%
src/commons/achievement/control/GoalEditor.tsx 1 0.0%
src/pages/missionControl/MissionControl.tsx 1 0.0%
src/pages/academy/adminPanel/subcomponents/CourseConfigPanel.tsx 1 3.23%
src/commons/achievement/AchievementCard.tsx 1 0.0%
src/commons/fileSystemView/FileSystemViewFileNode.tsx 1 2.86%
src/commons/achievement/control/goalEditor/EditableDate.tsx 1 0.0%
src/pages/academy/grading/subcomponents/GradingSubmissionFilters.tsx 1 0.0%
src/commons/achievement/control/AchievementEditor.tsx 1 0.0%
Totals Coverage Status
Change from base Build 8308710135: -0.001%
Covered Lines: 5669
Relevant Lines: 13798

💛 - Coveralls

Copy link
Contributor

@sayomaki sayomaki left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! However, there are a few slight issues/changes that I would like to see, besides that everything else seems fine to me.

@RichDom2185 RichDom2185 marked this pull request as ready for review March 16, 2024 16:36
* Use `React.FC` type for components
* Type props as `Props` unless exported
* Place props type immediately above component
* Use lambda functions for components
* Destructure props in function parameter
* Use types for props, not interfaces
* Combine unnecessary `OwnProps` to props type
* Remove unused exports of props types

Remaining components will be migrated in the future.
* Type props as `Props` unless exported
* Place props type immediately above component
Also removed some unnecessary `useState` type arguments.
Also removed some unnecessary `useState` type arguments.
Prefer the more succint `React.FC` instead.
We want to always use `useTypedSelector` for type-safety.
Copy link
Member Author

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

I've looked through the changes on every file one more time and all seems good – almost all the changes are simple typing/convention refactors anyway (not logic refactors) so besides bumping dependencies, there is no concern for a regression.

@RichDom2185 RichDom2185 merged commit 7e1f581 into master Mar 17, 2024
@RichDom2185 RichDom2185 deleted the fe-refactor-6 branch March 17, 2024 03:19
CYX22222003 pushed a commit that referenced this pull request Mar 22, 2024
* Add generic type argument to column definitions

Improves type safety.

* Migrate bp4 classes to bp5

This was missed during the initial migration.

* Remove unused `AcademyReducer` and dependents

Dependents include the associated types and tests.

* Update imports

Improves correctness and consistency.

* Fix lint

* Undo test import change

It was causing the tests to fail.

* Remove unnecessay `loadContentDispatch` sometimes

This is now no longer needed since we made the prop optional.

* Update test snapshots

* Make component typings more consistent

* Standardize to lambda function
* Standardize to `React.FC` typing
* Remove unnecessary props parameter typing
* Destructure props directly in function parameter

* Bump dependencies

* Fix class name typo

* Change relative import to project-based import

* Bump dependencies

* Update test snapshots

* Standardize typings

* Use `React.FC` type for components
* Type props as `Props` unless exported
* Place props type immediately above component
* Use lambda functions for components
* Destructure props in function parameter
* Use types for props, not interfaces
* Combine unnecessary `OwnProps` to props type
* Remove unused exports of props types

Remaining components will be migrated in the future.

* Remove unnecessary generic type arguments

* Standardize ControlBar components typings

* Type props as `Props` unless exported
* Place props type immediately above component

* Standardize more component typings

Also removed some unnecessary `useState` type arguments.

* Fix compile error

* Standardize remaining component typings

Also removed some unnecessary `useState` type arguments.

* Ban `React.FunctionComponent` type

Prefer the more succint `React.FC` instead.

* Ban `useSelector` import

We want to always use `useTypedSelector` for type-safety.
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.

Incorrect CSS namespace in hardcoded frontend classes
3 participants