-
Notifications
You must be signed in to change notification settings - Fork 323
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
website: Switch between LTR and RTL prereq tree directions #3842
website: Switch between LTR and RTL prereq tree directions #3842
Conversation
…quisite/dependent tree
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@zehata is attempting to deploy a commit to the modsbot's projects Team on Vercel. A member of the Team first needs to authorize it. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3842 +/- ##
==========================================
+ Coverage 54.52% 54.81% +0.28%
==========================================
Files 274 276 +2
Lines 6076 6132 +56
Branches 1455 1470 +15
==========================================
+ Hits 3313 3361 +48
- Misses 2763 2771 +8 ☔ View full report in Codecov by Sentry. |
bd7c8aa is technically outside the scope of this PR, but if it makes codecov happy then so be it. |
…-left-to-right-prerequisites-trees
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.
Great job on this! Just some minor review comments and this should be good to go :)
I understand that it's been a while since you submitted the change -- would you like to continue working on this PR? If not, I could make the requested changes and merge it for you.
website/src/reducers/settings.ts
Outdated
@@ -40,6 +41,7 @@ const defaultSettingsState: SettingsState = { | |||
moduleTableOrder: 'exam', | |||
beta: false, | |||
loadDisqusManually: false, | |||
prereqTreeOnLeft: 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.
Can we retain the original behaviour and set this to false? I don't think it's a great idea to change the default.
website/src/actions/settings.ts
Outdated
@@ -92,3 +92,11 @@ export function setLoadDisqusManually(status: boolean) { | |||
payload: status, | |||
}; | |||
} | |||
|
|||
export const TOGGLE_PREREQ_TREE_DIRECTION = 'TOGGLE_PREREQ_TREE_DIRECTION' as const; | |||
export function togglePreReqTreeDirection(status: boolean) { |
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.
Could you rename status
to something more informative like isOnLeft
? It might also be better to rename togglePreReqTreeDirection
to setPreReqTreeOnLeft
<>{reverse ? [...children].reverse() : children}</> | ||
); | ||
|
||
export default ConditionalReverse; |
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.
Let's memoize this component with React.memo
|
||
getModuleCondensed: (moduleCode: ModuleCode) => ModuleCondensed | undefined; | ||
}; | ||
|
||
interface TreeDisplay { | ||
layer: number; | ||
node: PrereqTree; | ||
isPrereq?: boolean; | ||
prereqTreeOnLeft?: boolean; |
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.
Could you give prereqTreeOnLeft
a default value (i.e. false
) where necessary instead of leaving it as undefined
? I personally don't like having unnecessarily-possibly-undefined values.
@@ -83,39 +85,45 @@ const unwrapLayer = (node: PrereqTree) => { | |||
const Branch: React.FC<{ | |||
nodes: PrereqTree[]; | |||
layer: number; | |||
prereqTreeOnLeft?: boolean; |
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.
Same comment as above above giving prereqTreeOnLeft
a default value.
…-left-to-right-prerequisites-trees
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 went ahead and made the requested changes. Thanks for your contribution! Also appreciate you adding the tests
@zwliew MB, sorry about that, I was not paying attention to the PR because I thought it was exam seasons 😅 GH also didn't ping me on your comments, so I would have to sort out my notifs. |
It's all good! |
Context
Fixes #3202 Prerequisite tree right-to-left progression is confusing
Implementation
This PR extends PR #3840's implementation and adds a toggle for the user to choose whether they prefer the prerequisite to appear on the left or the right. Setting defaults to prerequisites on the left, which is the requested specifications for #3202. Please note that this branch diverges from the branch in PR #3840 and cannot both be merged.
While Issue #3203 specifications does not ask for ability to toggle, some users like myself may have already gotten used to prerequisites on the right. However, I do agree that the prerequisites on the right seems to be more intuitive.
I also took the chance to fix some confusing naming in the code, like the trees having class names that were opposite of what they contained. The fix for the truncation bug in PR #3840 is also carried over.
Credits to @sciffany for copywriting and initial implementation, to @li-kai for implementation feedback and to @alvynben for implementation and test cases.
UI tests
Settings toggle:
Single prerequisite/dependents:
Left
![image](https://private-user-images.githubusercontent.com/16816749/379394567-6b8c55cb-f219-4b59-8745-b1faede74645.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjIzNzYsIm5iZiI6MTczOTg2MjA3NiwicGF0aCI6Ii8xNjgxNjc0OS8zNzkzOTQ1NjctNmI4YzU1Y2ItZjIxOS00YjU5LTg3NDUtYjFmYWVkZTc0NjQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MDExNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3NzIxYTQwNDZkNTVmNDdkNzIwMmNjMTk2NDg1ZmFhYzAxZTY3ZjExYTMyMGNmM2I0MDAzNTA2NWM3NWJiZjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.BO5Ni_Ig4KpMF4KZdKRDrpcvT-aE58sos2ZYwbfaCp0)
Right, i.e. original layout (unchanged)
![image](https://private-user-images.githubusercontent.com/16816749/379394542-21525c80-6037-4632-b089-a7e5c8263775.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjIzNzYsIm5iZiI6MTczOTg2MjA3NiwicGF0aCI6Ii8xNjgxNjc0OS8zNzkzOTQ1NDItMjE1MjVjODAtNjAzNy00NjMyLWIwODktYTdlNWM4MjYzNzc1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MDExNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVkNzcxODAwYmU4ZWYwNmUxZWJlMGU2MGFiNTU0YzkwMDA3NjE5ZWQ3N2Q1ODdiMzJkZDVmYmZiOGEwODY0M2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.LAUi3PLEWhtjEFmmON2ecMWUl7bemhIdEncdmUi-wfc)
Complex prerequisite/dependents with uneven layers and uneven letters in module codes
Left
![image](https://private-user-images.githubusercontent.com/16816749/379394605-10c126d5-369d-4327-bb60-cd68305c1092.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjIzNzYsIm5iZiI6MTczOTg2MjA3NiwicGF0aCI6Ii8xNjgxNjc0OS8zNzkzOTQ2MDUtMTBjMTI2ZDUtMzY5ZC00MzI3LWJiNjAtY2Q2ODMwNWMxMDkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MDExNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIxZDQ4ZGRjN2Y3NDY1NGVkOGNkNGM1YzhlNzUxY2IwNzhhM2MwZjllYzIyODUwNjdkYzYwYmNiMzQyM2E5YTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Vgcv04kQ_vJy36sAFAlnFLJ2ZayH6-jy_eIe5lSeJDg)
Prefixed prerequisites
Side effect fixes:
This also fixes misaligned module trees as a side effect
![image](https://private-user-images.githubusercontent.com/16816749/380371299-8525f96e-444c-40a5-9356-8276720545ab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NjIzNzYsIm5iZiI6MTczOTg2MjA3NiwicGF0aCI6Ii8xNjgxNjc0OS8zODAzNzEyOTktODUyNWY5NmUtNDQ0Yy00MGE1LTkzNTYtODI3NjcyMDU0NWFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA3MDExNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE5MjcxODRmZmY4Y2U0YzZkODYxZjFjYmE0N2EwZWI3YzA1MTk5ODI3NzIxODM5ZmIxNmJmNzg2NDIyYmYzOGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.qDFhi2E9QUnVNPszaNUntbQfzD-Ocpc6tngf5HuwCjc)
Other Information
Any questions you may have
Is there a tele group specific for development?
Letting us know that you're new to this (so we know how much to help out)
Again, been almost 3 years since I touched any web dev. Sorry in advance if I had missed out anything.