-
Notifications
You must be signed in to change notification settings - Fork 78
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
Hide Columns #624
Hide Columns #624
Conversation
… and some consistency changes
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.
Sorry for taking so long to review. I missed the notification.
Great feature and works well. There are only some code quality issues.
My main issue is that there's so much separate state management and duplication going on. It's difficult to parse logic that should be relatively straightforward. Instead of having slightly different and separate states, try to put it all in one place, have named types, and translate it at the very end when you use it if really necessary.
Also, remember to merge. (I know it's my fault that there's a commit on main
)
apps/antalmanac/src/components/RightPane/CoursePane/CoursePaneButtonRow.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/CoursePane/CoursePaneButtonRow.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/CoursePane/CoursePaneButtonRow.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/CoursePane/CoursePaneButtonRow.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/SectionTable/SectionTable.tsx
Outdated
Show resolved
Hide resolved
* refactor: completed column filtering * style: use eye icon for columns * fix: use react `createRoot`, fix ui errors * style: small margin and padding
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.
I think the changes look fine. I'll wait for the preview deployment to finish before merging.
apps/antalmanac/src/components/RightPane/CoursePane/CoursePaneButtonRow.tsx
Show resolved
Hide resolved
Bumping this PR, seems like all that's left is to fix some merge conflicts |
wait, stop |
What are you doing, don't do this useEffect(() => {
const updateHighlight = useCallback(() => {
setAddedCourse(AppStore.getAddedSectionCodes().has(`${section.sectionCode} ${term}`));
}, [setAddedCourse, AppStore.getAddedSectionCodes]);
const checkAndDisplayScheduleConflict = () => {
if (AppStore.getCourseEventsInCalendar().length < 1) {
setScheduleConflict(false);
return;
} |
Don't invoke hooks inside of other hooks |
💀 I did a whoopsie |
Ok, fine, give me a bit to fix it |
Sorry 'bout all that nonsense, hopefully this latest commit should resolve the issues, but I'll test on the staging instance // read over the code again right now! |
Ok no like. The entire strategy for figuring out conflicts is just wrong. There shouldn't even be a useEffect + useState. The entire logic should be a single useMemo |
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.
Ok, code is fixed. I have to go so I can't immediately verify the behavior live. Somebody else please review 🙏
TLDR:
Please don't write bad code. And if you don't know React, try consulting somebody that does before approving React code.
apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx
Outdated
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx
Show resolved
Hide resolved
apps/antalmanac/src/components/RightPane/SectionTable/SectionTableBody.tsx
Outdated
Show resolved
Hide resolved
I'll eventually move this into the original PR body, but for now, this is why I removed colorAndDelete: Previously, const SectionTableBody = withStyles(styles)((props: SectionTableBodyProps) => {
const { classes, section, courseDetails, term,
colorAndDelete /*ALWAYS false in courseRenderPane*/,
allowHighlight, scheduleNames } = props;
const [addedCourse, setAddedCourse] = useState(colorAndDelete);
{...}
// Immediately resets addedCourse
useEffect(() => {
const updateHighlight = () => {
const doAdd = AppStore.getAddedSectionCodes().has(`${section.sectionCode} ${term}`);
setAddedCourse(doAdd);
}; The new callback doesn't immediately setAddedCourse, so instead we should just set the default useState to: const [addedCourse, setAddedCourse] = useState(
AppStore.getAddedSectionCodes().has(`${section.sectionCode} ${term}`)
); Doing so eliminates the need for the |
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.
Ok good enough, if it breaks prod I'll fix it later. 🚀
Summary
Columns can now be shown/hidden through a dropdown menu in the Course Render Pane
Columns
CoursePaneButtonRow
RightPaneStore.ts
Removing ConditionalWrapper
ConditionalWrapper.tsx
has been removed in favor of plain conditional rendering logic.Removing colorAndDelete
colorAndDelete
, used in SectionTableBody (and related files) has been removed in favor of more reasonably calculating the proper value foraddedCourse
insectionTableBody.tsx
Previously,
sectionTableBody.tsx
would always passcolorAndDelete
as false, but then immediately recalculate it with the addedCourse state when it rendered:The new callback doesn't immediately setAddedCourse, so instead we should just set the default useState to:
Doing so eliminates the need for the
colorAndDelete
prop!Index.ts changes
index.tsx
to an async functionRefactor scheduleConflict
calendarizeHelpers.ts
to assist in calculating scheduleConflictsTest Plan
Issues
Zotcourse parity a la #440