-
Notifications
You must be signed in to change notification settings - Fork 251
Added loading icon for instructor table #7602
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
Added loading icon for instructor table #7602
Conversation
|
@david-yz-liu Hi David, do you mind looking at my current loading icon to see if my implementation has any issues? Thank you! |
Pull Request Test Coverage Report for Build 17863161339Details
💛 - Coveralls |
|
Hi @chickenwaddle77, the loading spinner looks okay to me, though what I suggest you do is prepare a few different visual options for your presentation tomorrow and get feedback from the other students about what they think look best |
Sounds good I will do that. Thanks! |
…sts to check student_table, ta_table, instructor_table
|
@david-yz-liu Hi David, I've been trying to resolve an issue with the NoDataComponent that shows up above my custom spinner for the react v6 table. I've been trying different ways to remove it during loading (and only keep it when no data is available). Do you know how to fix this? Thank you! |
|
Hi @chickenwaddle77, you indeed encountered an interesting problem. How I investigated this was to look directly at the relevant source code for React Table v6: https://github.com/TanStack/table/blob/v6/src/index.js#L850-L851. It looks like you'll need to also provide a Then in the |
… table-loading merge with upstream
Thank you David, I will read this and implement the changes! |
|
Hi @david-yz-liu, I was wondering if you can help me with the I've tried to:
I was wondering if the default table has something different that Jest can't see when testing? Thanks! |
|
@chickenwaddle77 the current CI run doesn't illustrate the error you're referring to (look at https://github.com/MarkUsProject/Markus/actions/runs/16983377732/job/48147695080?pr=7602). Fix the error first and show your best effort to get the test to pass, and ensure that the error you're seeing locally also appears on the GitHub Actions CI. |
|
@david-yz-liu Hi David, I've completed the Jest testing for the Loading components and fixed the errors. Turns out the error was that There are also a few tables that are not exported but they use a factory method to construct them. Do you also want me to test those? Thanks! |
compose.yaml
Outdated
| - localhost:host-gateway | ||
| ports: | ||
| - '3000:3000' | ||
| - '3336:3336' |
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'm not sure what purpose this is serving, but it doesn't belong in this PR
| // timers: "real", | ||
|
|
||
| // A map from regular expressions to paths to transformers | ||
| transform: {"\\.[jt]sx?$": "babel-jest"}, |
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 shouldn't be changed. If you got a compilation error with the new package, add it to transformIgnorePatterns.
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 you missed this comment (what I'm saying is that there should not be any changes to this file).
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.
Oops sorry, I thought I added this change in.
| FilterComponent: textFilter, | ||
| NoDataComponent: customNoDataComponent, | ||
| noDataProps: customNoDataProps, | ||
| // noDataText: customNoDataText, |
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 this change is a good idea, please go ahead and delete the code (rather than comment it out)
| (noDataText === "" ? ( | ||
| <div | ||
| className="flex gap-4" | ||
| style={{ |
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.
All style should go in CSS files; you can add classes to these elements to trigger CSS rules
| <Table | ||
| data={this.state.data} | ||
| columns={this.columns} | ||
| noDataText={this.state.loading ? "" : I18n.t("tas.empty_table")} |
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 change should be reverted; it shouldn't matter what the noDataText is if this.state.loading is true, since you've modified the code to not display the "no data" component in this case.
| render() { | ||
| const {data, loading} = this.state; | ||
| const effectiveLoadingComponent = | ||
| process.env.NODE_ENV === "test" |
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.
There should not be code that's conditional on the environment. You should remove this code and use a different approach to resolve the problem you are encountering with the tests.
You said:
Turns out the error was that
ReactTableDefaultsis not being used in Jest so it does not configure a customLoadingComponentfor us.
I'm guessing here you meant that the code in react_config.js. Any code that you want to be executed for the tests can be added to jest_after_env_setup.js.
|
Hi @david-yz-liu, sorry I took a bit of time. I was a little confused on how to fix some issues with the Jest tests. Because I deleted |
|
Hi @david-yz-liu, I was wondering what I can do about the testing coverage? Thanks! |
david-yz-liu
left a comment
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.
@chickenwaddle77 nice work! I left a few more comments for review; please work on those, but don't worry about the test coverage right now.
Changelog.md
Outdated
| ### 🔧 Internal changes | ||
| - Updated the assignment summary table to use `@tanstack/react-table` v8 (#7630) | ||
| - Updated Github Actions CI to use cache-apt-pkgs to speed up workflow runs (#7645) | ||
| - Added new loading spinner icon for tables (#7602) |
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.
Move this to the "Enhancements" section
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.
Hi David, there was no Enhancements section so I moved it to "New features and improvements." Please let me know if that was what you meant.
| */ | ||
|
|
||
| export function customLoadingProp(props) { | ||
| const {loading} = props; |
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.
You can simplify this code by using the same syntax as in other functions below:
export function customLoadingProp({loading}) {
...| // timers: "real", | ||
|
|
||
| // A map from regular expressions to paths to transformers | ||
| transform: {"\\.[jt]sx?$": "babel-jest"}, |
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 you missed this comment (what I'm saying is that there should not be any changes to this file).
| return {loading: state.loading, data: state.data}; | ||
| } | ||
|
|
||
| // export function customNoDataText(props) { |
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.
Delete this function since it's unused
| @@ -1,5 +1,5 @@ | |||
| import React from "react"; | |||
|
|
|||
| import {ReactTableDefaults} from "react-table"; | |||
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 import is unused and should be removed
| import ReactTable from "react-table"; | ||
| import {faPencil, faTrashCan} from "@fortawesome/free-solid-svg-icons"; | ||
| import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; | ||
| import {ReactTableDefaults} from "react-table"; |
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
| filterable: false, | ||
| }, | ||
| ]} | ||
| noDataText={I18n.t("students.empty_table")} |
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 line should be moved back to Line 240 (look at where it is in the original code), as there isn't actually a change.
| loading={this.state.loading} | ||
| ref={r => (this.checkboxTable = r)} | ||
| data={data.students} | ||
| data={this.state.loading ? [] : data.students} |
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 change is unnecessary (whether or not the loading spinner appears should depend only on the loading prop, and not the value of the data prop)
| NoDataComponent: customNoDataComponent, | ||
| noDataProps: customNoDataProps, | ||
| LoadingComponent: customLoadingProp, | ||
| loadingText: null, |
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 don't think this prop (loadingText) is being used anywhere. Assuming this is a change from an earlier version of this PR, you can remove it.
| }), | ||
| }); | ||
| render(<StudentTable selection={[]} course_id={1} />); | ||
| await act(async () => { |
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 know you mentioned encountering issues with the Jest tests, but this change is suspicious. I am skeptical that this is a good change to make, so please revert it (and the similar change in ta_table.test.jsx). If there are failing tests I'll look into it and give you some advice about next steps.
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 it is working fine without the await act function now. The problem was probably not how the test is checking for components but that ReactTableDefaults was not called in the jest environment. Sorry I didn't think of reverting this change back.
|
I think there is a jest error, I will fix tonight. |
|
I was checking out the previous commit head and figuring out what was wrong. I think I accidentally deleted one of the |
david-yz-liu
left a comment
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.
@chickenwaddle77 nice work! I made a small styling change, but that's about it. Thanks for all of your work on this, and I appreciate you wrapping this up. 🎉
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
Added loading icon for custom Table prop when front-end is fetching.
Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)