Skip to content

Commit cb9089a

Browse files
committed
course: add "reconfigure all projects" as a menu item too
1 parent 56bca01 commit cb9089a

File tree

4 files changed

+101
-52
lines changed

4 files changed

+101
-52
lines changed

src/packages/frontend/course/configuration/actions-panel.tsx

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -100,34 +100,6 @@ export const ActionsPanel: React.FC<Props> = React.memo(
100100
);
101101
}
102102

103-
function render_configure_all_projects(): Rendered {
104-
return (
105-
<Card
106-
title={
107-
<>
108-
<Icon name="envelope" /> Reconfigure all Projects
109-
</>
110-
}
111-
>
112-
Ensure all projects have the correct students and TA's, titles and
113-
descriptions set, etc. This will also resend any outstanding email
114-
invitations.
115-
<hr />
116-
<Button
117-
disabled={configuring_projects}
118-
onClick={() => {
119-
actions.configuration.configure_all_projects();
120-
}}
121-
>
122-
{configuring_projects ? (
123-
<Icon name="cocalc-ring" spin />
124-
) : undefined}{" "}
125-
Reconfigure all Projects
126-
</Button>
127-
</Card>
128-
);
129-
}
130-
131103
function render_resend_outstanding_email_invites(): Rendered {
132104
return (
133105
<Card
@@ -233,7 +205,10 @@ export const ActionsPanel: React.FC<Props> = React.memo(
233205
{render_export_grades()}
234206
</Col>
235207
<Col md={12} style={{ padding: "15px" }}>
236-
{render_configure_all_projects()}
208+
<ReconfigureAllProjects
209+
configuring_projects={configuring_projects}
210+
actions={actions}
211+
/>
237212
<br />
238213
{render_resend_outstanding_email_invites()}
239214
<br />
@@ -252,3 +227,35 @@ export const ActionsPanel: React.FC<Props> = React.memo(
252227
);
253228
},
254229
);
230+
231+
export function ReconfigureAllProjects({
232+
actions,
233+
configuring_projects,
234+
}: {
235+
actions;
236+
configuring_projects?: boolean;
237+
}) {
238+
return (
239+
<Card
240+
title={
241+
<>
242+
<Icon name="envelope" /> Reconfigure all Projects
243+
</>
244+
}
245+
>
246+
Ensure all projects have the correct students and TA's, titles and
247+
descriptions set, etc. This will also resend any outstanding email
248+
invitations.
249+
<hr />
250+
<Button
251+
disabled={configuring_projects}
252+
onClick={() => {
253+
actions.configuration.configure_all_projects();
254+
}}
255+
>
256+
{configuring_projects ? <Icon name="cocalc-ring" spin /> : undefined}{" "}
257+
Reconfigure all Projects
258+
</Button>
259+
</Card>
260+
);
261+
}

src/packages/frontend/course/modals.tsx

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import type { StudentsMap } from "./store";
33
import type { UserMap } from "@cocalc/frontend/todo-types";
44
import AddStudents from "@cocalc/frontend/course/students/add-students";
55
import { Icon } from "@cocalc/frontend/components/icon";
6+
import { ReconfigureAllProjects } from "@cocalc/frontend/course/configuration/actions-panel";
67

78
interface Props {
9+
frameActions;
810
actions;
911
modal?: string;
1012
name: string;
1113
students?: StudentsMap;
1214
user_map?: UserMap;
1315
project_id;
16+
configuring_projects?: boolean;
17+
reinviting_students?: boolean;
1418
}
1519

1620
export default function Modals(props: Props) {
@@ -19,30 +23,47 @@ export default function Modals(props: Props) {
1923
return null;
2024
}
2125
const close = () => {
22-
props.actions.setState({ modal: "" });
26+
props.frameActions.setState({ modal: "" });
2327
};
24-
if (modal == "add-students") {
25-
return (
26-
<Modal
27-
onCancel={close}
28-
onOk={close}
29-
cancelButtonProps={{ style: { display: "none" } }}
30-
okText="Close"
31-
open
32-
title={
28+
const { title, Body, icon } = getModal(modal);
29+
30+
return (
31+
<Modal
32+
onCancel={close}
33+
onOk={close}
34+
cancelButtonProps={{ style: { display: "none" } }}
35+
okText="Close"
36+
open
37+
title={
38+
title ? (
3339
<>
34-
<Icon name="users" /> Add Students
40+
{icon && <Icon name={icon} />} {title}
3541
</>
36-
}
37-
width={800}
38-
>
39-
<AddStudents {...props} students={students} user_map={user_map} />
40-
</Modal>
41-
);
42-
} else {
43-
return (
44-
<Alert type="warning" message={<>BUG -- Unknown modal: {modal}</>} />
45-
);
46-
}
42+
) : undefined
43+
}
44+
width={800}
45+
>
46+
<Body {...props} students={students} user_map={user_map} />
47+
</Modal>
48+
);
4749
return null;
4850
}
51+
52+
function getModal(modal: string) {
53+
switch (modal) {
54+
case "add-students":
55+
return { Body: AddStudents, title: "Add Students", icon: "users" };
56+
case "reconfigure-all-projects":
57+
return {
58+
Body: ReconfigureAllProjects,
59+
};
60+
default:
61+
return {
62+
Body: () => (
63+
<Alert type="warning" message={<>BUG -- Unknown modal: {modal}</>} />
64+
),
65+
title: "Error",
66+
icon: "bug",
67+
};
68+
}
69+
}

src/packages/frontend/frame-editors/course-editor/course-panel-wrapper.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,15 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
216216
className="smc-vfill"
217217
>
218218
<Modals
219-
actions={actions}
219+
frameActions={actions}
220+
actions={redux.getActions(name)}
220221
modal={modal}
221222
name={name}
222223
students={students}
223224
user_map={user_map}
224225
project_id={project_id}
226+
configuring_projects={configuring_projects}
227+
reinviting_students={reinviting_students}
225228
/>
226229
{render_panel()}
227230
</div>

src/packages/frontend/frame-editors/course-editor/editor.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const COURSE_MENUS = {
4242
students: ["course-add-student"],
4343
},
4444
},
45+
action: {
46+
label: "Actions",
47+
pos: 1.2,
48+
entries: {
49+
projects: ["course-reconfigure-all-projects"],
50+
},
51+
},
4552
};
4653

4754
const COMMANDS = {
@@ -57,6 +64,17 @@ const COMMANDS = {
5764
actions.setModal("add-students");
5865
},
5966
},
67+
"course-reconfigure-all-projects": {
68+
icon: "mail",
69+
label: "Reconfigure all Projects",
70+
button: "Reconfigure",
71+
title: "Update all projects with correct students, descriptions, etc.",
72+
onClick: ({ props }) => {
73+
const { id, actions } = props;
74+
actions.set_frame_type(id, "course_actions");
75+
actions.setModal("reconfigure-all-projects");
76+
},
77+
},
6078
};
6179

6280
function initMenus() {

0 commit comments

Comments
 (0)