Skip to content

Commit 7ee50c7

Browse files
committed
course: finish actions menu
1 parent 230c134 commit 7ee50c7

File tree

8 files changed

+203
-119
lines changed

8 files changed

+203
-119
lines changed

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

Lines changed: 66 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -5,121 +5,30 @@
55

66
import { Button, Card, Row, Col, Space } from "antd";
77
// React libraries and Components
8-
import {
9-
React,
10-
Rendered,
11-
useActions,
12-
useStore,
13-
} from "@cocalc/frontend/app-framework";
8+
import { React, useActions, useStore } from "@cocalc/frontend/app-framework";
149
import { plural } from "@cocalc/util/misc";
1510
import { Icon } from "@cocalc/frontend/components";
1611
import { CourseActions } from "../actions";
1712
import type { ProjectMap } from "@cocalc/frontend/todo-types";
18-
import { CourseSettingsRecord, CourseStore } from "../store";
13+
import { CourseStore } from "../store";
1914
import { DeleteAllStudentProjects } from "./delete-all-student-projects";
2015
import { DeleteAllStudents } from "./delete-all-students";
21-
import { DeleteSharedProjectPanel } from "../shared-project/delete-shared-project";
2216
import { TerminalCommandPanel } from "./terminal-command";
2317
import { StudentProjectsStartStopPanel } from "./start-stop-panel";
2418
import EmptyTrash from "./empty-trash";
2519
import { RESEND_INVITE_INTERVAL_DAYS } from "@cocalc/util/consts/invites";
2620

2721
interface Props {
2822
name: string;
29-
settings: CourseSettingsRecord;
3023
project_map: ProjectMap;
3124
configuring_projects?: boolean;
3225
reinviting_students?: boolean;
3326
}
3427

3528
export const ActionsPanel: React.FC<Props> = React.memo(
36-
({
37-
name,
38-
settings,
39-
project_map,
40-
configuring_projects,
41-
reinviting_students,
42-
}) => {
29+
({ name, project_map, configuring_projects, reinviting_students }) => {
4330
const actions = useActions<CourseActions>({ name });
4431

45-
function render_resend_outstanding_email_invites(): Rendered {
46-
return (
47-
<Card
48-
title={
49-
<>
50-
<Icon name="envelope" /> Resend Outstanding Email Invites
51-
</>
52-
}
53-
>
54-
Send another email to every student who didn't sign up yet. This sends
55-
a maximum of one email every {RESEND_INVITE_INTERVAL_DAYS}{" "}
56-
{plural(RESEND_INVITE_INTERVAL_DAYS, "day")}.
57-
<hr />
58-
<Button
59-
disabled={reinviting_students}
60-
onClick={() => {
61-
actions.student_projects.reinvite_oustanding_students();
62-
}}
63-
>
64-
{reinviting_students ? <Icon name="cocalc-ring" spin /> : undefined}{" "}
65-
Reinvite students
66-
</Button>
67-
</Card>
68-
);
69-
}
70-
71-
function render_push_missing_handouts_and_assignments(): Rendered {
72-
return (
73-
<Card
74-
title={
75-
<>
76-
<Icon name="share-square" /> Copy Missing Handouts and Assignments
77-
</>
78-
}
79-
>
80-
If you <b>add new students</b> to your course, you can click this
81-
button to ensure they have all the assignments and handouts that you
82-
have already assigned to other students in the course.
83-
<hr />
84-
<Button
85-
onClick={() => {
86-
actions.configuration.push_missing_handouts_and_assignments();
87-
}}
88-
>
89-
<Icon name="share-square" /> Copy Missing Handouts and Assignments
90-
</Button>
91-
</Card>
92-
);
93-
}
94-
95-
function render_delete_shared_project() {
96-
if (settings.get("shared_project_id")) {
97-
return (
98-
<DeleteSharedProjectPanel
99-
delete={() => actions.shared_project.delete()}
100-
/>
101-
);
102-
}
103-
}
104-
105-
function render_delete_student_projects() {
106-
return (
107-
<DeleteAllStudentProjects
108-
deleteAllStudentProjects={
109-
actions.student_projects.deleteAllStudentProjects
110-
}
111-
/>
112-
);
113-
}
114-
115-
function render_delete_all_students() {
116-
return (
117-
<DeleteAllStudents
118-
deleteAllStudents={actions.students.deleteAllStudents}
119-
/>
120-
);
121-
}
122-
12332
return (
12433
<div className="smc-vfill" style={{ overflowY: "scroll" }}>
12534
<Row>
@@ -136,17 +45,18 @@ export const ActionsPanel: React.FC<Props> = React.memo(
13645
actions={actions}
13746
/>
13847
<br />
139-
{render_resend_outstanding_email_invites()}
48+
<ResendInvites
49+
actions={actions}
50+
reinviting_students={reinviting_students}
51+
/>
14052
<br />
141-
{render_push_missing_handouts_and_assignments()}
53+
<CopyMissingHandoutsAndAssignments actions={actions} />
14254
<br />
14355
<EmptyTrash />
14456
<br />
145-
{render_delete_student_projects()}
57+
<DeleteAllStudentProjects actions={actions} />
14658
<br />
147-
{render_delete_all_students()}
148-
<br />
149-
{render_delete_shared_project()}
59+
<DeleteAllStudents actions={actions} />
15060
</Col>
15161
</Row>
15262
</div>
@@ -252,3 +162,59 @@ export function ReconfigureAllProjects({
252162
</Card>
253163
);
254164
}
165+
166+
export function ResendInvites({
167+
actions,
168+
reinviting_students,
169+
}: {
170+
actions;
171+
reinviting_students?;
172+
}) {
173+
return (
174+
<Card
175+
title={
176+
<>
177+
<Icon name="envelope" /> Resend Outstanding Email Invites
178+
</>
179+
}
180+
>
181+
Send another email to every student who didn't sign up yet. This sends a
182+
maximum of one email every {RESEND_INVITE_INTERVAL_DAYS}{" "}
183+
{plural(RESEND_INVITE_INTERVAL_DAYS, "day")}.
184+
<hr />
185+
<Button
186+
disabled={reinviting_students}
187+
onClick={() => {
188+
actions.student_projects.reinvite_oustanding_students();
189+
}}
190+
>
191+
{reinviting_students ? <Icon name="cocalc-ring" spin /> : undefined}{" "}
192+
Reinvite students
193+
</Button>
194+
</Card>
195+
);
196+
}
197+
198+
export function CopyMissingHandoutsAndAssignments({ actions }) {
199+
return (
200+
<Card
201+
title={
202+
<>
203+
<Icon name="share-square" /> Copy Missing Handouts and Assignments
204+
</>
205+
}
206+
>
207+
If you <b>add new students</b> to your course, you can click this button
208+
to ensure they have all the assignments and handouts that you have already
209+
assigned to other students in the course.
210+
<hr />
211+
<Button
212+
onClick={() => {
213+
actions.configuration.push_missing_handouts_and_assignments();
214+
}}
215+
>
216+
<Icon name="share-square" /> Copy Missing Handouts and Assignments
217+
</Button>
218+
</Card>
219+
);
220+
}

src/packages/frontend/course/configuration/delete-all-student-projects.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import { Icon } from "../../components";
77
import { Button, Card, Popconfirm } from "antd";
88

9-
interface Props {
10-
deleteAllStudentProjects: () => void;
11-
}
12-
13-
export function DeleteAllStudentProjects({ deleteAllStudentProjects }: Props) {
9+
export function DeleteAllStudentProjects({ actions }) {
1410
return (
1511
<Card
1612
title={
@@ -28,7 +24,7 @@ export function DeleteAllStudentProjects({ deleteAllStudentProjects }: Props) {
2824
be removed from the deleted projects immediately.
2925
</div>
3026
}
31-
onConfirm={deleteAllStudentProjects}
27+
onConfirm={() => actions.student_projects.deleteAllStudentProjects()}
3228
okText={"YES, DELETE all Student Projects"}
3329
>
3430
<Button danger>

src/packages/frontend/course/configuration/delete-all-students.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import { Button, Card, Popconfirm } from "antd";
77
import { Icon } from "../../components";
88

9-
interface Props {
10-
deleteAllStudents: () => void;
11-
}
12-
13-
export function DeleteAllStudents({ deleteAllStudents }: Props) {
9+
export function DeleteAllStudents({ actions }) {
1410
return (
1511
<Card
1612
title={
@@ -21,7 +17,7 @@ export function DeleteAllStudents({ deleteAllStudents }: Props) {
2117
>
2218
<Popconfirm
2319
title="All students will be deleted and upgrades removed from their projects."
24-
onConfirm={deleteAllStudents}
20+
onConfirm={() => actions.students.deleteAllStudents()}
2521
okText={"YES, DELETE all Students"}
2622
>
2723
<Button danger>

src/packages/frontend/course/modals.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ import {
77
ReconfigureAllProjects,
88
StartAllProjects,
99
ExportGrades,
10+
ResendInvites,
11+
CopyMissingHandoutsAndAssignments,
1012
} from "@cocalc/frontend/course/configuration/actions-panel";
1113
import type { ProjectMap } from "@cocalc/frontend/todo-types";
1214
import { TerminalCommandPanel } from "@cocalc/frontend/course/configuration/terminal-command";
15+
import EmptyTrash from "@cocalc/frontend/course/configuration/empty-trash";
16+
import { DeleteAllStudentProjects } from "@cocalc/frontend/course/configuration//delete-all-student-projects";
17+
import { DeleteAllStudents } from "@cocalc/frontend/course/configuration//delete-all-students";
18+
import { DeleteSharedProjectPanel } from "@cocalc/frontend/course/shared-project/delete-shared-project";
19+
import { SharedProjectPanel } from "@cocalc/frontend/course/shared-project/shared-project-panel";
1320

1421
interface Props {
1522
frameActions;
@@ -22,6 +29,8 @@ interface Props {
2229
project_id;
2330
configuring_projects?: boolean;
2431
reinviting_students?: boolean;
32+
settings;
33+
redux;
2534
}
2635

2736
export default function Modals(props: Props) {
@@ -83,6 +92,27 @@ function getModal(modal: string) {
8392
case "export-grades":
8493
return { Body: ExportGrades };
8594

95+
case "resend-invites":
96+
return { Body: ResendInvites };
97+
98+
case "copy-missing-handouts-and-assignments":
99+
return { Body: CopyMissingHandoutsAndAssignments };
100+
101+
case "empty-trash":
102+
return { Body: EmptyTrash };
103+
104+
case "delete-student-projects":
105+
return { Body: DeleteAllStudentProjects };
106+
107+
case "delete-students":
108+
return { Body: DeleteAllStudents };
109+
110+
case "delete-shared-project":
111+
return { Body: DeleteSharedProjectPanel };
112+
113+
case "create-shared-project":
114+
return { Body: SharedProjectPanel };
115+
86116
default:
87117
return {
88118
Body: () => (

src/packages/frontend/course/shared-project/delete-shared-project.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
import { Popconfirm, Button, Card } from "antd";
77
import { Icon } from "@cocalc/frontend/components";
88

9-
interface Props {
10-
delete: () => void;
11-
}
12-
13-
export function DeleteSharedProjectPanel(props: Props) {
9+
export function DeleteSharedProjectPanel({ actions, settings }) {
10+
if (!settings.get("shared_project_id")) {
11+
return <Card title={"No Shared Project"}></Card>;
12+
}
1413
return (
1514
<Card
1615
title={
1716
<Popconfirm
1817
title="Are you sure you want to delete the shared project?"
1918
okText="Yes"
2019
cancelText="No"
21-
onConfirm={() => props.delete()}
20+
onConfirm={() => actions.shared_project.delete()}
2221
>
2322
<Button danger>
2423
<Icon name="trash" /> Delete Shared Project...

src/packages/frontend/course/shared-project/shared-project-panel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export const SharedProjectPanel: React.FC<SharedProjectPanelProps> = React.memo(
8282
</div>
8383
<hr />
8484
<DeleteSharedProjectPanel
85-
delete={() => actions.shared_project.delete()}
85+
settings={settings}
86+
actions={actions}
8687
/>
8788
</div>
8889
);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
226226
project_id={project_id}
227227
configuring_projects={configuring_projects}
228228
reinviting_students={reinviting_students}
229+
settings={settings}
230+
redux={redux}
229231
/>
230232
{render_panel()}
231233
</div>

0 commit comments

Comments
 (0)