Skip to content

Commit 2030294

Browse files
committed
course: title and description in menu
1 parent f1def33 commit 2030294

File tree

5 files changed

+89
-87
lines changed

5 files changed

+89
-87
lines changed

src/packages/frontend/components/text-input.tsx

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

6-
import { Form, Input } from "antd";
6+
import { Button, Form, Input } from "antd";
77
import React, { useEffect } from "react";
8-
9-
import { Button } from "@cocalc/frontend/antd-bootstrap";
108
import { CSS } from "@cocalc/frontend/app-framework";
119
import { Icon } from "./icon";
1210

@@ -65,9 +63,9 @@ export const TextInput: React.FC<Props> = React.memo(
6563
<Form.Item>
6664
<Button
6765
style={{ marginBottom: "15px" }}
68-
bsStyle="success"
66+
type="primary"
6967
onClick={saveChange}
70-
bsSize={size === "small" ? "xsmall" : undefined}
68+
size={size}
7169
>
7270
<Icon name="save" /> Save
7371
</Button>

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

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

66
import { debounce } from "lodash";
7-
import { Card, Row, Col } from "antd";
7+
import { Card, Row, Col, Spin } from "antd";
88
import {
99
React,
1010
redux,
@@ -17,7 +17,6 @@ import { contains_url } from "@cocalc/util/misc";
1717
import {
1818
Icon,
1919
LabeledRow,
20-
Loading,
2120
MarkdownInput,
2221
TextInput,
2322
ErrorDisplay,
@@ -54,51 +53,6 @@ export const ConfigurationPanel: React.FC<Props> = React.memo(
5453
const is_commercial = useTypedRedux("customize", "is_commercial");
5554
const kucalc = useTypedRedux("customize", "kucalc");
5655

57-
/*
58-
* Editing title/description
59-
*/
60-
function render_title_desc_header() {
61-
return (
62-
<>
63-
<Icon name="header" /> Title and Description
64-
</>
65-
);
66-
}
67-
68-
function render_title_description() {
69-
if (settings == null) {
70-
return <Loading />;
71-
}
72-
return (
73-
<Card title={render_title_desc_header()}>
74-
<LabeledRow label="Title">
75-
<TextInput
76-
text={settings.get("title") ?? ""}
77-
on_change={(title) => actions.configuration.set_title(title)}
78-
/>
79-
</LabeledRow>
80-
<LabeledRow label="Description">
81-
<MarkdownInput
82-
persist_id={name + "course-description"}
83-
attach_to={name}
84-
rows={6}
85-
default_value={settings.get("description")}
86-
on_save={(desc) => actions.configuration.set_description(desc)}
87-
/>
88-
</LabeledRow>
89-
<hr />
90-
<span style={{ color: "#666" }}>
91-
Set the course title and description here. When you change the title
92-
or description, the corresponding title and description of each
93-
student project will be updated. The description is set to this
94-
description, and the title is set to the student name followed by
95-
this title. Use the description to provide additional information
96-
about the course, e.g., a link to the main course website.
97-
</span>
98-
</Card>
99-
);
100-
}
101-
10256
/*
10357
* Custom invitation email body
10458
*/
@@ -247,7 +201,11 @@ export const ConfigurationPanel: React.FC<Props> = React.memo(
247201
{render_require_institute_pay()}
248202
{render_onprem_upgrade_projects()}
249203
<br />
250-
{render_title_description()}
204+
<TitleAndDescription
205+
actions={actions}
206+
settings={settings}
207+
name={name}
208+
/>
251209
<br />
252210
{render_email_invite_body()}
253211
<br />
@@ -293,3 +251,43 @@ export const ConfigurationPanel: React.FC<Props> = React.memo(
293251
);
294252
},
295253
);
254+
255+
export function TitleAndDescription({ actions, settings, name }) {
256+
if (settings == null) {
257+
return <Spin />;
258+
}
259+
return (
260+
<Card
261+
title={
262+
<>
263+
<Icon name="header" /> Course Title and Description
264+
</>
265+
}
266+
>
267+
<LabeledRow label="Title">
268+
<TextInput
269+
text={settings.get("title") ?? ""}
270+
on_change={(title) => actions.configuration.set_title(title)}
271+
/>
272+
</LabeledRow>
273+
<LabeledRow label="Description">
274+
<MarkdownInput
275+
persist_id={name + "course-description"}
276+
attach_to={name}
277+
rows={6}
278+
default_value={settings.get("description")}
279+
on_save={(desc) => actions.configuration.set_description(desc)}
280+
/>
281+
</LabeledRow>
282+
<hr />
283+
<span style={{ color: "#666" }}>
284+
Set the course title and description here. When you change the title or
285+
description, the corresponding title and description of each student
286+
project will be updated. The description is set to this description, and
287+
the title is set to the student name followed by this title. Use the
288+
description to provide additional information about the course, e.g., a
289+
link to the main course website.
290+
</span>
291+
</Card>
292+
);
293+
}

src/packages/frontend/course/modals.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { DeleteAllStudentProjects } from "@cocalc/frontend/course/configuration/
1717
import { DeleteAllStudents } from "@cocalc/frontend/course/configuration//delete-all-students";
1818
import { DeleteSharedProjectPanel } from "@cocalc/frontend/course/shared-project/delete-shared-project";
1919
import { SharedProjectPanel } from "@cocalc/frontend/course/shared-project/shared-project-panel";
20+
import { TitleAndDescription } from "@cocalc/frontend/course/configuration/configuration-panel";
2021

2122
interface Props {
2223
frameActions;
@@ -113,6 +114,9 @@ function getModal(modal: string) {
113114
case "create-shared-project":
114115
return { Body: SharedProjectPanel };
115116

117+
case "title-and-description":
118+
return { Body: TitleAndDescription };
119+
116120
default:
117121
return {
118122
Body: () => (

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const COURSE_MENUS = {
3939
label: menu.edit,
4040
pos: 1,
4141
entries: {
42+
config: ["course-title-and-description"],
4243
students: ["course-add-student"],
4344
},
4445
},
@@ -68,7 +69,6 @@ const COURSE_MENUS = {
6869

6970
const COMMANDS = {
7071
"course-add-student": {
71-
pos: 1,
7272
icon: "users",
7373
label: "Add Students",
7474
button: "+Student",
@@ -80,6 +80,16 @@ const COMMANDS = {
8080
actions.setModal("add-students");
8181
},
8282
},
83+
"course-title-and-description": {
84+
icon: "header",
85+
label: "Course Title and Description...",
86+
button: "Title",
87+
title: "Set the course title and description.",
88+
onClick: ({ props }) => {
89+
const { actions } = props;
90+
actions.setModal("title-and-description");
91+
},
92+
},
8393
"course-start-all-projects": {
8494
icon: "bolt",
8595
label: "Start all Student Projects",

src/packages/frontend/markdown/markdown-input/main.tsx

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
// 3rd Party Libraries
77
import { markdown_to_html } from "../index";
8-
import { Button, ButtonToolbar, FormControl, FormGroup } from "react-bootstrap";
98
import { Tip } from "@cocalc/frontend/components/tip";
109
import { Icon } from "@cocalc/frontend/components/icon";
11-
10+
import { Button, Input, Space } from "antd";
1211
// Internal Libraries
1312
import {
1413
Component,
1514
React,
16-
ReactDOM,
1715
rclass,
1816
redux,
1917
rtypes,
@@ -30,11 +28,11 @@ export function init(): void {
3028
}
3129
redux.createStore<MarkdownWidgetStoreState, MarkdownWidgetStore>(
3230
info.name,
33-
MarkdownWidgetStore
31+
MarkdownWidgetStore,
3432
);
3533
redux.createActions<MarkdownWidgetStoreState, MarkdownWidgetActions>(
3634
info.name,
37-
MarkdownWidgetActions
35+
MarkdownWidgetActions,
3836
);
3937
}
4038

@@ -109,7 +107,7 @@ class MarkdownInput0 extends Component<
109107

110108
getActions() {
111109
return redux.getActions<MarkdownWidgetStoreState, MarkdownWidgetActions>(
112-
info.name
110+
info.name,
113111
);
114112
}
115113

@@ -137,7 +135,7 @@ class MarkdownInput0 extends Component<
137135
if (this.props.persist_id != null) {
138136
this.getActions().set_value(
139137
this.props.persist_id,
140-
value ?? this.state.value
138+
value ?? this.state.value,
141139
);
142140
}
143141
};
@@ -189,8 +187,10 @@ class MarkdownInput0 extends Component<
189187
keydown = (e) => {
190188
if (e.keyCode === 27) {
191189
this.cancel();
192-
} else if (e.keyCode === 13 && e.shiftKey) {
193-
this.save();
190+
} else if (e.keyCode === 13) {
191+
if (this.props.rows == 1 || e.shiftKey) {
192+
this.save();
193+
}
194194
}
195195
};
196196

@@ -208,24 +208,16 @@ class MarkdownInput0 extends Component<
208208
const tip = <span>{TIP_TEXT}</span>;
209209
return (
210210
<div>
211-
<form onSubmit={this.save} style={{ marginBottom: "-20px" }}>
212-
<FormGroup>
213-
<FormControl
214-
autoFocus={this.props.autoFocus ?? true}
215-
ref="input"
216-
componentClass="textarea"
217-
rows={this.props.rows ?? 4}
218-
placeholder={this.props.placeholder}
219-
value={this.state.value}
220-
onChange={() => {
221-
const value = ReactDOM.findDOMNode(this.refs.input)?.value;
222-
if (value == null) return;
223-
this.set_value(value);
224-
}}
225-
onKeyDown={this.keydown}
226-
/>
227-
</FormGroup>
228-
</form>
211+
<Input.TextArea
212+
autoFocus={this.props.autoFocus ?? true}
213+
rows={this.props.rows ?? 4}
214+
placeholder={this.props.placeholder}
215+
value={this.state.value}
216+
onChange={(e) => {
217+
this.set_value(e.target.value);
218+
}}
219+
onKeyDown={this.keydown}
220+
/>
229221
<div style={{ paddingTop: "8px", color: "#666" }}>
230222
<Tip title="Use Markdown" tip={tip}>
231223
Format using{" "}
@@ -234,10 +226,13 @@ class MarkdownInput0 extends Component<
234226
</a>
235227
</Tip>
236228
</div>
237-
<ButtonToolbar style={{ paddingBottom: "5px" }}>
229+
<Space style={{ paddingBottom: "5px" }}>
230+
<Button key="cancel" onClick={this.cancel}>
231+
Cancel
232+
</Button>
238233
<Button
239234
key="save"
240-
bsStyle="success"
235+
type="primary"
241236
onClick={this.save}
242237
disabled={
243238
this.props.save_disabled ??
@@ -246,10 +241,7 @@ class MarkdownInput0 extends Component<
246241
>
247242
<Icon name="edit" /> Save
248243
</Button>
249-
<Button key="cancel" onClick={this.cancel}>
250-
Cancel
251-
</Button>
252-
</ButtonToolbar>
244+
</Space>
253245
</div>
254246
);
255247
} else {

0 commit comments

Comments
 (0)