Skip to content

Commit 2129c22

Browse files
committed
course: work in progress implementing configuration copying
1 parent ccac54e commit 2129c22

File tree

4 files changed

+48
-27
lines changed

4 files changed

+48
-27
lines changed

src/packages/frontend/course/configuration/mirror.tsx renamed to src/packages/frontend/course/configuration/configuration-copying.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1+
/*
2+
Configuration copying.
3+
4+
- List one or more other course files (TODO: also support other projects that you have access to).
5+
- Select which configuration to share (and parameters)
6+
- Click a button to copy the configuration from this course
7+
to the target courses.
8+
*/
9+
110
import { Alert, Button, Card, Checkbox, Input, Space, Spin } from "antd";
211
import { Icon } from "@cocalc/frontend/components";
312
import { useEffect, useState } from "react";
413
import { pathExists } from "@cocalc/frontend/project/directory-selector";
514
import { redux, useTypedRedux } from "@cocalc/frontend/app-framework";
615
interface Props {
7-
checked?: boolean;
8-
setChecked: (checked: boolean) => void;
9-
path?: string;
10-
setPath: (path: string) => void;
11-
project_id: string;
16+
settings;
17+
project_id;
18+
actions;
1219
}
1320

14-
export default function Mirror({
15-
checked,
16-
setChecked,
17-
path,
18-
setPath,
21+
export default function ConfigurationCopying({
22+
settings,
1923
project_id,
24+
actions,
2025
}: Props) {
21-
const [path0, setPath0] = useState<string>(path ?? "");
26+
const checked = !!settings.get("mirror_config");
27+
const setChecked = (mirror_config: boolean) => {
28+
actions.set({ mirror_config, table: "settings" });
29+
};
30+
const path = settings.get("mirror_config_path") ?? "";
31+
const [path0, setPath0] = useState<string>(path);
32+
const setPath = (mirror_config_path) => {
33+
actions.set({ mirror_config_path, table: "settings" });
34+
};
2235
const [exists, setExists] = useState<boolean | null>(null);
2336
const [loading, setLoading] = useState<boolean>(false);
2437
const directoryListings = useTypedRedux(
@@ -56,7 +69,7 @@ export default function Mirror({
5669
<Card
5770
title={
5871
<>
59-
<Icon name="envelope" /> Configuration Mirroring
72+
<Icon name="envelope" /> Configuration Copying
6073
</>
6174
}
6275
>
@@ -65,7 +78,7 @@ export default function Mirror({
6578
checked={checked}
6679
onChange={(e) => setChecked((e.target as any).checked)}
6780
>
68-
Mirror Configuration From Another Course
81+
Copying Configuration to Other Courses
6982
</Checkbox>
7083
</div>
7184
{checked && (
@@ -137,7 +150,7 @@ export default function Mirror({
137150
<span style={{ color: "#666" }}>
138151
If this box is checked and you fill in the filename of another
139152
course (in this project), then when you make configuration changes
140-
to <i>that course</i>, those changes can be easily copied to this
153+
to <i>this course</i>, they can be easily copied to this other
141154
course. The configuration parameters that are mirrored are:
142155
<ul>
143156
<li>Payment and licensing configuration</li>

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { DatastoreConfig } from "./datastore-config";
3131
import { KUCALC_ON_PREMISES } from "@cocalc/util/db-schema/site-defaults";
3232
import { EnvironmentVariablesConfig } from "./envvars-config";
3333
import StudentPay from "./student-pay";
34-
//import Mirror from "./mirror";
34+
import ConfigurationCopying from "./configuration-copying";
3535
import ShowError from "@cocalc/frontend/components/error";
3636

3737
interface Props {
@@ -103,18 +103,12 @@ export function ConfigurationPanel({
103103
settings={settings}
104104
project_id={project_id}
105105
/>
106-
{/*<br />
107-
<Mirror
108-
checked={!!settings.get("mirror_config")}
109-
setChecked={(mirror_config: boolean) => {
110-
actions.set({ mirror_config, table: "settings" });
111-
}}
112-
path={settings.get("mirror_config_path")}
113-
setPath={(mirror_config_path) => {
114-
actions.set({ mirror_config_path, table: "settings" });
115-
}}
116-
project_id={project_id}
117-
/>*/}
106+
<br />
107+
<ConfigurationCopying
108+
actions={actions}
109+
settings={settings}
110+
project_id={project_id}
111+
/>
118112
</Col>
119113
</Row>
120114
</div>

src/packages/frontend/course/modals.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
UpgradeConfiguration,
2828
ConfigureSoftwareEnvironment,
2929
} from "@cocalc/frontend/course/configuration/configuration-panel";
30+
import ConfigurationCopying from "@cocalc/frontend/course/configuration/configuration-copying";
3031
import { Parallel } from "@cocalc/frontend/course/configuration/parallel";
3132
import { Nbgrader } from "@cocalc/frontend/course/configuration/nbgrader";
3233
import { AddAssignments } from "@cocalc/frontend/course/assignments/assignments-panel";
@@ -157,6 +158,8 @@ function getModal(modal: string) {
157158
return { Body: UpgradeConfiguration };
158159
case "software-environment":
159160
return { Body: ConfigureSoftwareEnvironment };
161+
case "configuration-copying":
162+
return { Body: ConfigurationCopying };
160163

161164
default:
162165
return {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const COURSE_MENUS = {
6161
"course-network-file-systems",
6262
"course-env-variables",
6363
],
64+
courseSharing: ["course-configuration-copying"],
6465
},
6566
},
6667
action: {
@@ -216,6 +217,16 @@ const COMMANDS = {
216217
actions.setModal("env-variables");
217218
},
218219
},
220+
"course-configuration-copying": {
221+
icon: "clone",
222+
label: "Copy Course Configuration",
223+
button: "Copy Conf",
224+
title: "Easily copy configuration from this course to other courses.",
225+
onClick: ({ props }) => {
226+
const { actions } = props;
227+
actions.setModal("configuration-copying");
228+
},
229+
},
219230
"course-upgrades": {
220231
icon: "gears",
221232
label: "Configure Upgrades (Student or Instructor Pay)",

0 commit comments

Comments
 (0)