Skip to content

Commit fff05d8

Browse files
committed
course: make it so all lists are virtualized. This should fix #6698 among other things
1 parent 2bee4d3 commit fff05d8

File tree

7 files changed

+35
-33
lines changed

7 files changed

+35
-33
lines changed

src/packages/frontend/course/assignments/assignment-student-list.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export function StudentListForAssignment({
130130
function render_students() {
131131
return (
132132
<ScrollableList
133+
virtualize
133134
rowCount={student_list.length}
134135
rowRenderer={({ key }) => render_student_info(key)}
135136
rowKey={(index) => student_list[index]}

src/packages/frontend/course/assignments/assignment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export function Assignment({
340340
<DebounceInput
341341
debounceTimeout={500}
342342
element={Input as any}
343-
placeholder={"Find students..."}
343+
placeholder={"Filter students..."}
344344
value={student_search}
345345
onChange={(e) => set_student_search(e.target.value)}
346346
/>

src/packages/frontend/course/assignments/assignments-panel.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ export function AssignmentsPanel(props: Props) {
7272
);
7373

7474
// search query to restrict which assignments are shown.
75-
const [search, set_search] = useState<string>("");
75+
const pageFilter = useRedux(name, "pageFilter");
76+
const filter = pageFilter?.get("assignments") ?? "";
77+
const setFilter = (filter: string) => {
78+
course_actions.setPageFilter("assignments", filter);
79+
};
80+
7681
// whether or not to show deleted assignments on the bottom
7782
const [show_deleted, set_show_deleted] = useState<boolean>(false);
7883

@@ -95,7 +100,7 @@ export function AssignmentsPanel(props: Props) {
95100
({ list, num_omitted } = util.compute_match_list({
96101
list,
97102
search_key: "path",
98-
search: search.trim(),
103+
search: filter.trim(),
99104
}));
100105

101106
if (active_assignment_sort.get("column_name") === "due_date") {
@@ -122,7 +127,7 @@ export function AssignmentsPanel(props: Props) {
122127
num_omitted,
123128
num_deleted,
124129
};
125-
}, [assignments, active_assignment_sort, show_deleted, search]);
130+
}, [assignments, active_assignment_sort, show_deleted, filter]);
126131

127132
function render_sort_link(column_name: string, display_name: string) {
128133
return (
@@ -189,6 +194,7 @@ export function AssignmentsPanel(props: Props) {
189194
}
190195
return (
191196
<ScrollableList
197+
virtualize
192198
rowCount={assignments.length}
193199
rowRenderer={({ key, index }) => render_assignment(key, index)}
194200
rowKey={(index) => assignments[index]?.assignment_id ?? ""}
@@ -249,7 +255,7 @@ export function AssignmentsPanel(props: Props) {
249255
style={styles.show_hide_deleted({ needs_margin: num_shown > 0 })}
250256
onClick={() => {
251257
set_show_deleted(true);
252-
set_search("");
258+
setFilter("");
253259
}}
254260
>
255261
<Tip
@@ -268,8 +274,8 @@ export function AssignmentsPanel(props: Props) {
268274
return (
269275
<div style={{ marginBottom: "15px" }}>
270276
<FoldersToolbar
271-
search={search}
272-
search_change={(value) => set_search(value)}
277+
search={filter}
278+
search_change={setFilter}
273279
num_omitted={num_omitted}
274280
project_id={project_id}
275281
items={assignments}

src/packages/frontend/course/common/folders-tool-bar.tsx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,9 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
// BUG:
7-
//
8-
// - this code is buggy since the SearchInput component below is NOT controlled,
9-
// but some of the code assumes it is, which makes no sense.
10-
// E.g., there is a clear_search prop that is passed in, which is
11-
// nonsense, because the state of the search is local to the
12-
// SearchInput. That's why the calls to clear
13-
// the search in all the code below are all broken.
14-
//
15-
166
import { useCallback, useMemo } from "react";
17-
import { SearchInput } from "@cocalc/frontend/components";
18-
import { Space } from "antd";
19-
import * as immutable from "immutable";
20-
import { COLORS } from "@cocalc/util/theme";
7+
import { Input, Space } from "antd";
8+
import type { Map as iMap } from "immutable";
219
import { SEARCH_STYLE } from "./consts";
2210
import { MultipleAddSearch } from "./multiple-add-search";
2311

@@ -26,7 +14,7 @@ interface FoldersToolbarProps {
2614
search_change: (search_value: string) => void; // search_change(current_search_value)
2715
num_omitted?: number;
2816
project_id: string;
29-
items: immutable.Map<string, any>;
17+
items: iMap<string, any>;
3018
add_folders: (folders: string[]) => void; // add_folders (Iterable<T>)
3119
item_name: string;
3220
plural_item_name: string;
@@ -43,17 +31,17 @@ export function FoldersToolbar({
4331
}: FoldersToolbarProps) {
4432
return (
4533
<Space>
46-
<SearchInput
47-
placeholder={`Find ${plural_item_name}...`}
48-
default_value={propsSearch}
49-
on_change={search_change}
34+
<Input.Search
35+
allowClear
36+
placeholder={`Filter ${plural_item_name}...`}
37+
value={propsSearch}
38+
onChange={(e) => search_change(e.target.value)}
5039
style={SEARCH_STYLE}
5140
/>
5241
{num_omitted ? (
5342
<h5
5443
style={{
5544
textAlign: "center",
56-
color: COLORS.GRAY_L,
5745
marginTop: "5px",
5846
}}
5947
>

src/packages/frontend/course/common/student-assignment-info.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export function StudentAssignmentInfo({
375375
</div>,
376376
);
377377
}
378-
return v;
378+
return <Space>{v}</Space>;
379379
} else {
380380
return (
381381
<Button

src/packages/frontend/course/handouts/handout-student-list.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function StudentListForHandout({
6161
function render_students() {
6262
return (
6363
<ScrollableList
64+
virtualize
6465
rowCount={student_list.length}
6566
rowRenderer={({ key }) => render_student_info(key)}
6667
rowKey={(index) => student_list[index]}

src/packages/frontend/course/handouts/handouts-panel.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ export function HandoutsPanel({
4444
);
4545

4646
const [show_deleted, set_show_deleted] = useState<boolean>(false);
47-
const [search, set_search] = useState<string>("");
47+
48+
const pageFilter = useRedux(name, "pageFilter");
49+
const filter = pageFilter?.get("handouts") ?? "";
50+
const setFilter = (filter: string) => {
51+
actions.setPageFilter("handouts", filter);
52+
};
4853

4954
function get_handout(id: string): HandoutRecord {
5055
const handout = handouts.get(id);
@@ -61,7 +66,7 @@ export function HandoutsPanel({
6166
({ list, num_omitted } = util.compute_match_list({
6267
list,
6368
search_key: "path",
64-
search: search.trim(),
69+
search: filter.trim(),
6570
}));
6671

6772
({ list, num_deleted } = util.order_list({
@@ -101,7 +106,7 @@ export function HandoutsPanel({
101106
style={styles.show_hide_deleted({ needs_margin: num_shown > 0 })}
102107
onClick={() => {
103108
set_show_deleted(true);
104-
set_search("");
109+
setFilter("");
105110
}}
106111
>
107112
<Tip
@@ -139,6 +144,7 @@ export function HandoutsPanel({
139144
}
140145
return (
141146
<ScrollableList
147+
virtualize
142148
rowCount={handouts.length}
143149
rowRenderer={({ key, index }) => render_handout(key, index)}
144150
rowKey={(index) => handouts[index]?.handout_id ?? ""}
@@ -180,8 +186,8 @@ export function HandoutsPanel({
180186

181187
const header = (
182188
<FoldersToolbar
183-
search={search}
184-
search_change={(value) => set_search(value)}
189+
search={filter}
190+
search_change={setFilter}
185191
num_omitted={num_omitted}
186192
project_id={project_id}
187193
items={handouts}

0 commit comments

Comments
 (0)