Skip to content

Commit c21f925

Browse files
committed
course menu: add "start all projects"
1 parent e5bfb10 commit c21f925

File tree

5 files changed

+68
-39
lines changed

5 files changed

+68
-39
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Button, ButtonGroup } from "@cocalc/frontend/antd-bootstrap";
1515
import { plural } from "@cocalc/util/misc";
1616
import { Icon } from "@cocalc/frontend/components";
1717
import { CourseActions } from "../actions";
18-
import { ProjectMap } from "@cocalc/frontend/todo-types";
18+
import type { ProjectMap } from "@cocalc/frontend/todo-types";
1919
import { CourseSettingsRecord, CourseStore } from "../store";
2020
import { DeleteAllStudentProjects } from "./delete-all-student-projects";
2121
import { DeleteAllStudents } from "./delete-all-students";
@@ -42,7 +42,6 @@ export const ActionsPanel: React.FC<Props> = React.memo(
4242
reinviting_students,
4343
}) => {
4444
const actions = useActions<CourseActions>({ name });
45-
const store = useStore<CourseStore>({ name });
4645

4746
/*
4847
* Grade export
@@ -150,18 +149,6 @@ export const ActionsPanel: React.FC<Props> = React.memo(
150149
);
151150
}
152151

153-
function render_start_all_projects() {
154-
const r = store.num_running_projects(project_map);
155-
const n = store.num_students();
156-
return (
157-
<StudentProjectsStartStopPanel
158-
name={name}
159-
num_running_projects={r}
160-
num_students={n}
161-
/>
162-
);
163-
}
164-
165152
function render_delete_shared_project() {
166153
if (settings.get("shared_project_id")) {
167154
return (
@@ -198,7 +185,7 @@ export const ActionsPanel: React.FC<Props> = React.memo(
198185
<div className="smc-vfill" style={{ overflowY: "scroll" }}>
199186
<Row>
200187
<Col md={12} style={{ padding: "15px 15px 15px 0" }}>
201-
{render_start_all_projects()}
188+
<StartAllProjects name={name} project_map={project_map} />
202189
<br />
203190
{render_terminal_command()}
204191
<br />
@@ -228,6 +215,19 @@ export const ActionsPanel: React.FC<Props> = React.memo(
228215
},
229216
);
230217

218+
export function StartAllProjects({ name, project_map }) {
219+
const store = useStore<CourseStore>({ name });
220+
const r = store.num_running_projects(project_map);
221+
const n = store.num_students();
222+
return (
223+
<StudentProjectsStartStopPanel
224+
name={name}
225+
num_running_projects={r}
226+
num_students={n}
227+
/>
228+
);
229+
}
230+
231231
export function ReconfigureAllProjects({
232232
actions,
233233
configuring_projects,

src/packages/frontend/course/configuration/start-stop-panel.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Alert, Card, Row, Col } from "antd";
2-
import { Button, ButtonGroup } from "../../antd-bootstrap";
1+
import { Alert, Button, Card, Row, Col, Space, Spin } from "antd";
32
import { Icon } from "../../components";
43
import { useState, useActions, useRedux } from "../../app-framework";
54
import { CourseActions } from "../actions";
@@ -49,8 +48,7 @@ export const StudentProjectsStartStopPanel: React.FC<Props> = ({
4948
type={type}
5049
message={
5150
<div>
52-
{capitalize(state_name)} all projects...{" "}
53-
<Icon name="cocalc-ring" spin />
51+
{capitalize(state_name)} all projects... <Spin />
5452
<br />
5553
<Button
5654
onClick={() =>
@@ -75,20 +73,21 @@ export const StudentProjectsStartStopPanel: React.FC<Props> = ({
7573
disruptive)?
7674
<br />
7775
<br />
78-
<ButtonGroup>
76+
<Space>
77+
<Button onClick={() => set_confirm_stop_all_projects(false)}>
78+
Cancel
79+
</Button>
7980
<Button
80-
bsStyle="warning"
81+
danger
82+
type="primary"
8183
onClick={() => {
8284
set_confirm_stop_all_projects(false);
8385
actions.student_projects.action_all_student_projects("stop");
8486
}}
8587
>
8688
<Icon name="PoweroffOutlined" /> Stop all
8789
</Button>
88-
<Button onClick={() => set_confirm_stop_all_projects(false)}>
89-
Cancel
90-
</Button>
91-
</ButtonGroup>
90+
</Space>
9291
</div>
9392
}
9493
/>
@@ -105,20 +104,20 @@ export const StudentProjectsStartStopPanel: React.FC<Props> = ({
105104
ensure the projects are already running when the students open them.
106105
<br />
107106
<br />
108-
<ButtonGroup>
107+
<Space>
108+
<Button onClick={() => set_confirm_start_all_projects(false)}>
109+
Cancel
110+
</Button>{" "}
109111
<Button
110-
bsStyle="primary"
112+
type="primary"
111113
onClick={() => {
112114
set_confirm_start_all_projects(false);
113115
actions.student_projects.action_all_student_projects("start");
114116
}}
115117
>
116118
<Icon name="bolt" /> Start all
117119
</Button>
118-
<Button onClick={() => set_confirm_start_all_projects(false)}>
119-
Cancel
120-
</Button>
121-
</ButtonGroup>
120+
</Space>
122121
</div>
123122
}
124123
/>
@@ -142,7 +141,7 @@ export const StudentProjectsStartStopPanel: React.FC<Props> = ({
142141
</Row>
143142
<Row style={{ marginTop: "10px" }}>
144143
<Col md={24}>
145-
<ButtonGroup>
144+
<Space>
146145
<Button
147146
onClick={() => set_confirm_start_all_projects(true)}
148147
disabled={
@@ -165,7 +164,7 @@ export const StudentProjectsStartStopPanel: React.FC<Props> = ({
165164
>
166165
<Icon name="PoweroffOutlined" /> Stop all...
167166
</Button>
168-
</ButtonGroup>
167+
</Space>
169168
</Col>
170169
</Row>
171170
<Row style={{ marginTop: "10px" }}>

src/packages/frontend/course/modals.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ 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";
6+
import {
7+
ReconfigureAllProjects,
8+
StartAllProjects,
9+
} from "@cocalc/frontend/course/configuration/actions-panel";
10+
import type { ProjectMap } from "@cocalc/frontend/todo-types";
711

812
interface Props {
913
frameActions;
@@ -12,14 +16,15 @@ interface Props {
1216
name: string;
1317
students?: StudentsMap;
1418
user_map?: UserMap;
19+
project_map?: ProjectMap;
1520
project_id;
1621
configuring_projects?: boolean;
1722
reinviting_students?: boolean;
1823
}
1924

2025
export default function Modals(props: Props) {
21-
const { students, user_map, modal } = props;
22-
if (students == null || user_map == null || !modal) {
26+
const { students, user_map, project_map, modal } = props;
27+
if (students == null || user_map == null || project_map == null || !modal) {
2328
return null;
2429
}
2530
const close = () => {
@@ -43,7 +48,12 @@ export default function Modals(props: Props) {
4348
}
4449
width={800}
4550
>
46-
<Body {...props} students={students} user_map={user_map} />
51+
<Body
52+
{...props}
53+
students={students}
54+
user_map={user_map}
55+
project_map={project_map}
56+
/>
4757
</Modal>
4858
);
4959
return null;
@@ -53,6 +63,10 @@ function getModal(modal: string) {
5363
switch (modal) {
5464
case "add-students":
5565
return { Body: AddStudents, title: "Add Students", icon: "users" };
66+
case "start-all-projects":
67+
return {
68+
Body: StartAllProjects,
69+
};
5670
case "reconfigure-all-projects":
5771
return {
5872
Body: ReconfigureAllProjects,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
222222
name={name}
223223
students={students}
224224
user_map={user_map}
225+
project_map={project_map}
225226
project_id={project_id}
226227
configuring_projects={configuring_projects}
227228
reinviting_students={reinviting_students}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/*
7-
Spec for editing Jupyter notebooks via a frame tree.
7+
Spec for editing courses via a frame tree.
88
*/
99

1010
import { set } from "@cocalc/util/misc";
@@ -46,7 +46,10 @@ const COURSE_MENUS = {
4646
label: "Actions",
4747
pos: 1.2,
4848
entries: {
49-
projects: ["course-reconfigure-all-projects"],
49+
projects: [
50+
"course-start-all-projects",
51+
"course-reconfigure-all-projects",
52+
],
5053
},
5154
},
5255
};
@@ -64,6 +67,18 @@ const COMMANDS = {
6467
actions.setModal("add-students");
6568
},
6669
},
70+
"course-start-all-projects": {
71+
icon: "bolt",
72+
label: "Start all Student Projects",
73+
button: "Start All",
74+
title:
75+
"You can start all projects associated with this course so they are immediately ready for your students to use.",
76+
onClick: ({ props }) => {
77+
const { id, actions } = props;
78+
actions.set_frame_type(id, "course_actions");
79+
actions.setModal("start-all-projects");
80+
},
81+
},
6782
"course-reconfigure-all-projects": {
6883
icon: "mail",
6984
label: "Reconfigure all Projects",

0 commit comments

Comments
 (0)