Skip to content

Conversation

@freyazjiner
Copy link
Member

@freyazjiner freyazjiner commented Aug 4, 2025

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.)
This PR updates the AssignmentSummaryTable to use React Table v8.

Screenshots of your changes (if applicable) image
Associated documentation repository pull request (if applicable)

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration) X

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:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@coveralls
Copy link
Collaborator

coveralls commented Aug 13, 2025

Pull Request Test Coverage Report for Build 17030526515

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 53 of 79 (67.09%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 91.848%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/javascript/Components/assignment_summary_table.jsx 42 68 61.76%
Files with Coverage Reduction New Missed Lines %
app/javascript/Components/assignment_summary_table.jsx 1 59.52%
Totals Coverage Status
Change from base Build 16980327805: -0.04%
Covered Lines: 42121
Relevant Lines: 45145

💛 - Coveralls

Copy link
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@freyazjiner nice work, I left a few comments mainly focused on the implementation.

cell: info => {
let marking_state = "";
switch (row.original.marking_state) {
switch (info.row.original.marking_state) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Call the parameter props, not info (to match the other examples we have).

Also, given the use of the accessorKey, it shouldn't be necessary to access props.row.original.marking_state, instead you should be able to use props.getValue().

default:
// should not get here
marking_state = row.original.marking_state;
marking_state = info.row.original.marking_state;
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment as above

})}
</div>
{row.getIsExpanded() && (
<tr>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really think it makes sense to use <tr>/<td> elements here, since this isn't a "real" table. Instead, please just use a <div> that wraps the subcomponent, e.g.

<div>{renderSubComponent({row})</div>

Unless that looks bad for some reason (provide screenshot).

const renderSubComponent = ({row}) => {
return (
<div>
<h4>{I18n.t("activerecord.models.ta", {count: 2})}</h4>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This count should be equal to the number of graders, not a hard-coded number.

);
return (
<a href={path}>
{info.row.original.group_name}
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above, use the parameter name props throughout, and getValue( as well.

size: 100,
enableResizing: true,
cell: value => value.getValue(),
meta: {className: "number"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn' exactly correct. Look at the values passed in the criteriaColumns state; there are additional attributes that are meant to be used here.

To see the difference in the UI, assign graders to specific criteria (and students) and then login as one of the graders and visit the table. Criteria that haven't been assigned should be greyed out due to the styling.

header: () => I18n.t("activerecord.models.extra_mark.other"),
size: 100,
enableResizing: true,
cell: info => info.getValue(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even though you translated this correctly, I think this is a case where the original code was redundant, so you can just delete this cell attribute and use the react table default.

size: 32,
cell: ({row}) => {
return row.getCanExpand() ? (
<button
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is pretty good, but can be improved:

  1. All styles should go into a CSS file, not be set here

  2. The spread operator (...) is unnecessary. Just do onClick={...} etc. to pass attributes to the button.

  3. Rather than using separate unicode characters, take a look at how the original did it:

    You should be able to copy the styling into our CSS file as well to get the triangle icon to show up.

getColumns = () => {
const columnHelper = createColumnHelper();

const expanderColumn = columnHelper.display({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Overall, this new column definition is good but should be available more generally, not just in this file. Please (1) move it into the table.jsx file and (2) modify the defintion of Table itself so that if a subcomponent renderer prop is passed in (i.e., not undefined), then this column is automatically prepended to the columns passed in as props. This will generalize your work to all tables with subcomponents.

Header: I18n.t("activerecord.attributes.result.marking_state"),
accessor: "marking_state",
Cell: row => {
header: I18n.t("activerecord.attributes.result.marking_state"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this have a () => ?

});

await waitFor(() => {
expect(screen.getByText(I18n.t("activerecord.models.ta", {count: 2}))).toBeInTheDocument();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This count should also not be hard-coded

<div className="rt-tr-group" role="rowgroup" key={row.id}>
<div className="rt-tr -odd" role="row" key={row.id}>
{row.getVisibleCells().map(cell => {
const metaClass = cell.column.columnDef.meta?.className || "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is good, but one of the things you should notice about the criteria column data is the headerClassName field. This should also be handled by the Table component.

import {createColumnHelper} from "@tanstack/react-table";
import Table from "./table/table";

const renderSubComponent = ({row}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this to below the AssignmentSummaryTable class. In general, I prefer having helpers below the main function.

accessorKey: "marking_state",
size: 100,
enableResizing: true,
cell: props => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a problem with the filtering for the column: the options show the "raw" string values (in_progress, not_collected, etc.) instead of the internationalized strings.

To fix this, you can use the same approach that @ch-iv took for the instructor table: post-process the marking state values from the fetched data to transform the raw strings into the I18n.t versions. See https://github.com/MarkUsProject/Markus/blob/master/app/javascript/Components/instructor_table.jsx#L58-L79

Header: I18n.t("activerecord.attributes.result.marking_state"),
accessor: "marking_state",
Cell: row => {
header: I18n.t("activerecord.attributes.result.marking_state"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh right, overall you should not change this function (since it's also used in the SubmissionTable component, which is on an older version of React table). Instead, you can make a copy of the function and move it directly into the assignment_summary file.

Copy link
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@freyazjiner nice work! I just left a few small comments

Changelog.md Outdated
- Updated Python autotest script file to include example of using `pytest.mark` to customize test marks (#7597)
- Refactor `Grader` table in `Users` to use `@tanstack/react-table` v8 (#7598)
- Updated `dependabot.yml` to add React dependency group and increase, remove old webpack ignored versions, and remove open PR limits (#7627)
- Updated the assignment summary table to use `@tanstack/react-table` v8 (#7630)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do a merge from master. When you do, you'll see that there's a new, much smaller "unreleased" section (due to a new release being made). Add this entry to the new section.

id: col.id,
header: () => col.Header,
size: col.size || 100,
meta: {headerClassName: col.headerClassName},
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should include both className and headerClassName here

Copy link
Collaborator

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

Nice work, @freyazjiner!

@david-yz-liu david-yz-liu merged commit 7398e68 into MarkUsProject:master Aug 18, 2025
7 checks passed
@david-yz-liu david-yz-liu added this to the v2.8.1 milestone Aug 18, 2025
donny-wong pushed a commit to donny-wong/Markus that referenced this pull request Sep 10, 2025
@freyazjiner freyazjiner deleted the react-table-v8-assignment-summary branch January 5, 2026 18:35
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.

3 participants