Skip to content

Upgrade AG Grid to v34 and rewrite leaderboard routing #3319

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 24 commits into from
Aug 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"@tremor/react": "^1.8.2",
"ace-builds": "^1.42.1",
"acorn": "^8.9.0",
"ag-grid-community": "^32.3.1",
"ag-grid-react": "^32.3.1",
"ag-grid-community": "^34.1.1",
"ag-grid-react": "^34.1.1",
"array-move": "^4.0.0",
"browserfs": "^1.4.3",
"classnames": "^2.3.2",
Expand Down
41 changes: 41 additions & 0 deletions src/bootstrap/agGrid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
CellStyleModule,
ClientSideRowModelModule,
ColumnApiModule,
ColumnAutoSizeModule,
CsvExportModule,
DateFilterModule,
InfiniteRowModelModule,
type Module,
ModuleRegistry,
PaginationModule,
RowDragModule,
TextEditorModule,
TextFilterModule,
ValidationModule
} from 'ag-grid-community';

const productionModules: readonly Module[] = [
CellStyleModule,
ClientSideRowModelModule,
ColumnApiModule,
ColumnAutoSizeModule,
CsvExportModule,
DateFilterModule,
InfiniteRowModelModule,
PaginationModule,
RowDragModule,
TextEditorModule,
TextFilterModule,
ValidationModule
];

export const initializeAgGridModules = () => {
const modulesToLoad = [...productionModules];

// Load helpful warnings in development mode
if (process.env.NODE_ENV === 'development') {
modulesToLoad.push(ValidationModule);
}
ModuleRegistry.registerModules(modulesToLoad);
};
33 changes: 33 additions & 0 deletions src/bootstrap/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as Sentry from '@sentry/react';
import { useEffect } from 'react';
import {
createRoutesFromChildren,
matchRoutes,
useLocation,
useNavigationType
} from 'react-router';
import Constants from 'src/commons/utils/Constants';
import { store } from 'src/pages/createStore';

export const initializeSentryLogging = () => {
if (!Constants.sentryDsn) {
return;
}
Sentry.init({
dsn: Constants.sentryDsn,
environment: Constants.sourceAcademyEnvironment,
release: `cadet-frontend@${Constants.sourceAcademyVersion}`,
integrations: [
Sentry.reactRouterV7BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes
}),
Sentry.replayIntegration()
]
});
const userId = store.getState().session.userId;
Sentry.setUser(typeof userId !== 'undefined' ? { id: userId.toString() } : null);
};
16 changes: 8 additions & 8 deletions src/commons/sourceRecorder/SourceRecorderTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'ag-grid-community/styles/ag-grid.css';

import {
Divider,
FormGroup,
Expand All @@ -9,6 +7,7 @@ import {
SpinnerSize
} from '@blueprintjs/core';
import { ColDef, GridApi, GridReadyEvent } from 'ag-grid-community';
import { themeBalham } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import { sortBy } from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -62,7 +61,7 @@ class SourcecastTable extends React.Component<SourceRecorderTableProps, State> {
},
minWidth: 200,
suppressMovable: true,
suppressMenu: true,
suppressHeaderMenuButton: true,
cellStyle: {
'text-align': 'left'
},
Expand All @@ -73,15 +72,15 @@ class SourcecastTable extends React.Component<SourceRecorderTableProps, State> {
field: 'title',
minWidth: 100,
suppressMovable: true,
suppressMenu: true,
suppressHeaderMenuButton: true,
hide: !!this.props.handleSetSourcecastData
},
{
headerName: 'Uploader',
field: 'uploader.name',
minWidth: 150,
suppressMovable: true,
suppressMenu: true,
suppressHeaderMenuButton: true,
cellStyle: {
'text-align': 'center'
}
Expand All @@ -91,7 +90,7 @@ class SourcecastTable extends React.Component<SourceRecorderTableProps, State> {
valueGetter: params => getStandardDate(params.data.inserted_at),
minWidth: 150,
suppressMovable: true,
suppressMenu: true
suppressHeaderMenuButton: true
},
{
headerName: 'Share',
Expand All @@ -102,7 +101,7 @@ class SourcecastTable extends React.Component<SourceRecorderTableProps, State> {
},
minWidth: 80,
suppressMovable: true,
suppressMenu: true
suppressHeaderMenuButton: true
},
{
headerName: 'Delete',
Expand All @@ -115,7 +114,7 @@ class SourcecastTable extends React.Component<SourceRecorderTableProps, State> {
maxWidth: 100,
sortable: false,
suppressMovable: true,
suppressMenu: true,
suppressHeaderMenuButton: true,
cellStyle: {
'text-align': 'center'
},
Expand Down Expand Up @@ -169,6 +168,7 @@ class SourcecastTable extends React.Component<SourceRecorderTableProps, State> {
<div className="SourcecastTable">
<div className="ag-grid-parent">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={this.state.columnDefs}
defaultColDef={this.defaultColumnDefs}
Expand Down
31 changes: 4 additions & 27 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,22 @@ import 'src/i18n/i18n';
import 'src/styles/index.scss';

import { Button, OverlaysProvider } from '@blueprintjs/core';
import * as Sentry from '@sentry/react';
import { setModulesStaticURL } from 'js-slang/dist/modules/loader';
import { useEffect } from 'react';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import {
createRoutesFromChildren,
matchRoutes,
useLocation,
useNavigationType
} from 'react-router';
import Constants, { Links } from 'src/commons/utils/Constants';
import { showWarningMessage } from 'src/commons/utils/notifications/NotificationsHelper';
import { register as registerServiceWorker } from 'src/commons/utils/RegisterServiceWorker';
import { triggerSyncLogs } from 'src/features/eventLogging/client';
import { store } from 'src/pages/createStore';

import { initializeAgGridModules } from './bootstrap/agGrid';
import { initializeSentryLogging } from './bootstrap/sentry';
import ApplicationWrapper from './commons/application/ApplicationWrapper';
import { createInBrowserFileSystem } from './pages/fileSystem/createInBrowserFileSystem';

if (Constants.sentryDsn) {
Sentry.init({
dsn: Constants.sentryDsn,
environment: Constants.sourceAcademyEnvironment,
release: `cadet-frontend@${Constants.sourceAcademyVersion}`,
integrations: [
Sentry.reactRouterV7BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes
}),
Sentry.replayIntegration()
]
});
const userId = store.getState().session.userId;
Sentry.setUser(typeof userId !== 'undefined' ? { id: userId.toString() } : null);
}
initializeSentryLogging();
initializeAgGridModules();

const rootContainer = document.getElementById('root') as HTMLElement;
const root = createRoot(rootContainer);
Expand Down
23 changes: 17 additions & 6 deletions src/pages/academy/academyRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import { assessmentRegExp, gradingRegExp, teamRegExp } from 'src/features/academ
import { GuardedRoute } from 'src/routes/routeGuard';

import { store } from '../createStore';
import {
contestLeaderboardLoader,
leaderboardLoader
} from '../leaderboard/subcomponents/leaderboardUtils';

const notFoundPath = 'not_found';

const Assessment = () => import('../../commons/assessment/Assessment');
const Game = () => import('./game/Game');
const Sourcecast = () => import('../sourcecast/Sourcecast');
const Achievement = () => import('../achievement/Achievement');
const Leaderboard = () => import('../leaderboard/Leaderboard');
const OverallLeaderboardWrapper = () =>
import('../leaderboard/subcomponents/OverallLeaderboardWrapper');
const OverallLeaderboard = () => import('../leaderboard/subcomponents/OverallLeaderboard');
const ContestLeaderboardWrapper = () =>
import('../leaderboard/subcomponents/ContestLeaderboardWrapper');
const NotFound = () => import('../notFound/NotFound');
Expand Down Expand Up @@ -78,9 +80,18 @@ const getCommonAcademyRoutes = (): RouteObject[] => {
},
{ path: 'sourcecast/:sourcecastId?', lazy: Sourcecast },
{ path: 'achievements/*', lazy: Achievement },
{ path: 'leaderboard/overall', lazy: OverallLeaderboardWrapper },
{ path: 'leaderboard/contests/*', lazy: ContestLeaderboardWrapper },
{ path: 'leaderboard/*', lazy: Leaderboard },
{
path: 'leaderboard',
loader: leaderboardLoader,
children: [
{ path: 'overall', lazy: OverallLeaderboard },
{
path: 'contests/:contestId?/:leaderboardType',
loader: contestLeaderboardLoader,
lazy: ContestLeaderboardWrapper
}
]
},
{ path: '*', lazy: NotFound }
];
};
Expand Down
3 changes: 0 additions & 3 deletions src/pages/academy/adminPanel/AdminPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-balham.css';

import { Button, Divider, H1, Intent, Tab, Tabs } from '@blueprintjs/core';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useDispatch } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Position
} from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { ColDef } from 'ag-grid-community';
import { type ColDef, themeBalham } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import { uniqBy } from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -50,8 +50,9 @@ const AddStoriesUserPanel: React.FC<Props> = props => {
const { CSVReader } = useCSVReader();

const grid = (
<div className="Grid ag-grid-parent ag-theme-balham">
<div className="Grid">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={columnDefs}
defaultColDef={defaultColumnDefs}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/academy/adminPanel/subcomponents/AddUserPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Position
} from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { ColDef } from 'ag-grid-community';
import { type ColDef, themeBalham } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import { uniqBy } from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -50,8 +50,9 @@ const AddUserPanel: React.FC<Props> = props => {
const { CSVReader } = useCSVReader();

const grid = (
<div className="Grid ag-grid-parent ag-theme-balham">
<div className="Grid">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={columnDefs}
defaultColDef={defaultColumnDefs}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Button, H2 } from '@blueprintjs/core';
import {
CellValueChangedEvent,
ColDef,
GridApi,
GridReadyEvent,
RowDragEvent
type CellValueChangedEvent,
type ColDef,
type GridApi,
type GridReadyEvent,
type RowDragEvent,
themeBalham
} from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import { cloneDeep, isEqual } from 'lodash';
Expand Down Expand Up @@ -316,8 +317,9 @@ const AssessmentConfigPanel: WithImperativeApi<
};

const grid = (
<div className="Grid ag-grid-parent ag-theme-balham">
<div className="Grid">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={columnDefs}
defaultColDef={defaultColumnDefs}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, H2 } from '@blueprintjs/core';
import { ColDef, GridApi, GridReadyEvent } from 'ag-grid-community';
import { type ColDef, type GridApi, type GridReadyEvent, themeBalham } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import React from 'react';
import { StoriesRole } from 'src/commons/application/ApplicationTypes';
Expand Down Expand Up @@ -65,8 +65,9 @@ const StoriesUserConfigPanel: React.FC<Props> = props => {
};

const grid = (
<div className="Grid ag-grid-parent ag-theme-balham">
<div className="Grid">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={columnDefs}
defaultColDef={defaultColumnDefs}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, H2 } from '@blueprintjs/core';
import { ColDef, GridApi, GridReadyEvent } from 'ag-grid-community';
import { type ColDef, type GridApi, type GridReadyEvent, themeBalham } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import React from 'react';
import { Role } from 'src/commons/application/ApplicationTypes';
Expand Down Expand Up @@ -66,8 +66,9 @@ const UserConfigPanel: React.FC<Props> = props => {
};

const grid = (
<div className="Grid ag-grid-parent ag-theme-balham">
<div className="Grid">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={columnDefs}
defaultColDef={defaultColumnDefs}
Expand Down
8 changes: 3 additions & 5 deletions src/pages/academy/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-balham.css';

import { ColDef } from 'ag-grid-community';
import { type ColDef, themeBalham } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import { startCase } from 'lodash';
import React from 'react';
Expand Down Expand Up @@ -31,8 +28,9 @@ const Dashboard: React.FC = () => {

const content = (
<div className="Dashboard">
<div className="Grid ag-grid-parent ag-theme-balham">
<div className="Grid">
<AgGridReact
theme={themeBalham}
domLayout="autoHeight"
columnDefs={columnDefs}
defaultColDef={defaultColumnDefs}
Expand Down
Loading
Loading