Skip to content

Commit f390836

Browse files
committed
course: finish all actions and configurations menu items
1 parent ddce4c1 commit f390836

File tree

5 files changed

+114
-86
lines changed

5 files changed

+114
-86
lines changed

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

Lines changed: 76 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -45,64 +45,17 @@ interface Props {
4545
export const ConfigurationPanel: React.FC<Props> = React.memo(
4646
({ name, project_id, settings, configuring_projects }) => {
4747
const actions = useActions<CourseActions>({ name });
48-
const is_commercial = useTypedRedux("customize", "is_commercial");
49-
const kucalc = useTypedRedux("customize", "kucalc");
50-
51-
function render_require_institute_pay() {
52-
if (!is_commercial) return;
53-
return (
54-
<>
55-
<StudentProjectUpgrades
56-
name={name}
57-
is_onprem={false}
58-
is_commercial={is_commercial}
59-
upgrade_goal={settings?.get("upgrade_goal")}
60-
institute_pay={settings?.get("institute_pay")}
61-
student_pay={settings?.get("student_pay")}
62-
site_license_id={settings?.get("site_license_id")}
63-
site_license_strategy={settings?.get("site_license_strategy")}
64-
shared_project_id={settings?.get("shared_project_id")}
65-
disabled={configuring_projects}
66-
settings={settings}
67-
actions={actions.configuration}
68-
/>
69-
<br />
70-
</>
71-
);
72-
}
73-
74-
/**
75-
* OnPrem instances support licenses to be distributed to all student projects.
76-
*/
77-
function render_onprem_upgrade_projects(): React.ReactNode {
78-
if (is_commercial || kucalc !== KUCALC_ON_PREMISES) return;
79-
return (
80-
<>
81-
<StudentProjectUpgrades
82-
name={name}
83-
is_onprem={true}
84-
is_commercial={false}
85-
site_license_id={settings?.get("site_license_id")}
86-
site_license_strategy={settings?.get("site_license_strategy")}
87-
shared_project_id={settings?.get("shared_project_id")}
88-
disabled={configuring_projects}
89-
settings={settings}
90-
actions={actions.configuration}
91-
/>
92-
<br />
93-
</>
94-
);
95-
}
9648

9749
return (
9850
<div className="smc-vfill" style={{ overflowY: "scroll" }}>
9951
<Row>
10052
<Col md={12} style={{ padding: "15px 15px 15px 0" }}>
101-
{is_commercial && (
102-
<StudentPay actions={actions} settings={settings} />
103-
)}
104-
{render_require_institute_pay()}
105-
{render_onprem_upgrade_projects()}
53+
<UpgradeConfiguration
54+
name={name}
55+
settings={settings}
56+
configuring_projects={configuring_projects}
57+
actions={actions}
58+
/>
10659
<br />
10760
<TitleAndDescription
10861
actions={actions}
@@ -162,6 +115,76 @@ export const ConfigurationPanel: React.FC<Props> = React.memo(
162115
},
163116
);
164117

118+
export function UpgradeConfiguration({
119+
name,
120+
settings,
121+
configuring_projects,
122+
actions,
123+
}) {
124+
const is_commercial = useTypedRedux("customize", "is_commercial");
125+
const kucalc = useTypedRedux("customize", "kucalc");
126+
127+
function render_require_institute_pay() {
128+
if (!is_commercial) return;
129+
return (
130+
<>
131+
<StudentProjectUpgrades
132+
name={name}
133+
is_onprem={false}
134+
is_commercial={is_commercial}
135+
upgrade_goal={settings?.get("upgrade_goal")}
136+
institute_pay={settings?.get("institute_pay")}
137+
student_pay={settings?.get("student_pay")}
138+
site_license_id={settings?.get("site_license_id")}
139+
site_license_strategy={settings?.get("site_license_strategy")}
140+
shared_project_id={settings?.get("shared_project_id")}
141+
disabled={configuring_projects}
142+
settings={settings}
143+
actions={actions.configuration}
144+
/>
145+
<br />
146+
</>
147+
);
148+
}
149+
150+
/**
151+
* OnPrem instances support licenses to be distributed to all student projects.
152+
*/
153+
function render_onprem_upgrade_projects(): React.ReactNode {
154+
if (is_commercial || kucalc !== KUCALC_ON_PREMISES) return;
155+
return (
156+
<>
157+
<StudentProjectUpgrades
158+
name={name}
159+
is_onprem={true}
160+
is_commercial={false}
161+
site_license_id={settings?.get("site_license_id")}
162+
site_license_strategy={settings?.get("site_license_strategy")}
163+
shared_project_id={settings?.get("shared_project_id")}
164+
disabled={configuring_projects}
165+
settings={settings}
166+
actions={actions.configuration}
167+
/>
168+
<br />
169+
</>
170+
);
171+
}
172+
173+
return (
174+
<Card
175+
title={
176+
<>
177+
<Icon name="gears" /> Configure Upgrades
178+
</>
179+
}
180+
>
181+
{is_commercial && <StudentPay actions={actions} settings={settings} />}
182+
{render_require_institute_pay()}
183+
{render_onprem_upgrade_projects()}
184+
</Card>
185+
);
186+
}
187+
165188
export function TitleAndDescription({ actions, settings, name }) {
166189
if (settings == null) {
167190
return <Spin />;

src/packages/frontend/course/modals.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
NetworkFilesystem,
2525
RestrictStudentProjects,
2626
TitleAndDescription,
27+
UpgradeConfiguration,
2728
} from "@cocalc/frontend/course/configuration/configuration-panel";
2829
import { Parallel } from "@cocalc/frontend/course/configuration/parallel";
2930
import { Nbgrader } from "@cocalc/frontend/course/configuration/nbgrader";
@@ -69,6 +70,7 @@ export default function Modals(props: Props) {
6970
}
7071
width={800}
7172
>
73+
<br />
7274
<Body
7375
{...props}
7476
students={students}
@@ -140,6 +142,8 @@ function getModal(modal: string) {
140142
return { Body: NetworkFilesystem };
141143
case "env-variables":
142144
return { Body: EnvVariables };
145+
case "upgrades":
146+
return { Body: UpgradeConfiguration };
143147

144148
default:
145149
return {

src/packages/frontend/course/pay-banner.tsx

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ This banner only shows up if commerical is set for hub configuration.
1111
*/
1212

1313
import { CSS, React, useTypedRedux } from "../app-framework";
14-
1514
import { Alert } from "antd";
1615
import { CourseSettingsRecord } from "./store";
17-
import { Icon, Gap } from "../components";
16+
import { Icon } from "../components";
1817

1918
interface PayBannerProps {
2019
settings: CourseSettingsRecord;
2120
num_students: number;
22-
tab: string;
2321
show_config: () => void;
2422
}
2523

2624
export const PayBanner: React.FC<PayBannerProps> = React.memo(
27-
({ settings, num_students, tab, show_config }) => {
25+
({ settings, num_students, show_config }) => {
2826
const is_commercial = useTypedRedux("customize", "is_commercial");
2927

3028
if (!is_commercial) {
@@ -49,52 +47,37 @@ export const PayBanner: React.FC<PayBannerProps> = React.memo(
4947
return <span />;
5048
}
5149

52-
let mesg: JSX.Element, style: CSS;
50+
let style: CSS;
5351
if ((num_students != null ? num_students : 0) >= 20) {
5452
// Show a harsh error.
5553
style = {
5654
background: "red",
5755
color: "white",
5856
fontSize: "16pt",
5957
fontWeight: "bold",
60-
margin: "5px 15px",
58+
margin: "15px",
6159
};
6260
} else {
6361
style = {
6462
fontSize: "12pt",
6563
color: "#666",
66-
margin: "5px 15px",
64+
margin: "15px",
6765
};
6866
}
6967

70-
if (tab === "configuration") {
71-
mesg = (
72-
<span>
73-
Please select either the student pay or institute pay option below.
74-
</span>
75-
);
76-
} else {
77-
mesg = (
78-
<span>
79-
Please open the <a onClick={show_config}>Configuration page</a> for
80-
this course and select a pay option.
81-
</span>
82-
);
83-
}
84-
8568
return (
8669
<Alert
8770
type="warning"
8871
style={style}
8972
message={
90-
<div>
91-
<Icon
92-
name="exclamation-triangle"
93-
style={{ float: "right", marginTop: "3px" }}
94-
/>
73+
<div style={{ display: "flex" }}>
74+
<Icon name="exclamation-triangle" />
75+
<div style={{ flex: 1, textAlign: "center" }}>
76+
<a onClick={show_config}>
77+
Configure either the student or institute pay option...
78+
</a>
79+
</div>
9580
<Icon name="exclamation-triangle" />
96-
<Gap />
97-
{mesg}
9881
</div>
9982
}
10083
/>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,10 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
168168
return (
169169
<PayBanner
170170
show_config={() => {
171-
actions.set_frame_type(id, "course_configuration");
171+
actions.setModal("upgrades");
172172
}}
173173
settings={settings}
174174
num_students={students.size}
175-
tab={desc.get("type", "").slice("course_".length)}
176175
/>
177176
);
178177
}

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const COURSE_MENUS = {
4141
pos: 1,
4242
entries: {
4343
editStudents: ["course-add-student"],
44+
courseUpgrades: ["course-upgrades"],
4445
configCourse: [
4546
"course-title-and-description",
4647
"course-email-invitation",
@@ -51,7 +52,10 @@ const COURSE_MENUS = {
5152
"course-restrict-student-projects",
5253
],
5354
nbgraderConfig: ["course-nbgrader"],
54-
environmentConfig: ["course-network-file-systems", "course-env-variables"],
55+
environmentConfig: [
56+
"course-network-file-systems",
57+
"course-env-variables",
58+
],
5559
},
5660
},
5761
action: {
@@ -73,7 +77,10 @@ const COURSE_MENUS = {
7377
"course-delete-student-projects",
7478
"course-delete-students",
7579
],
76-
sharedProject: ["course-create-shared-project", "course-delete-shared-project"],
80+
sharedProject: [
81+
"course-create-shared-project",
82+
"course-delete-shared-project",
83+
],
7784
},
7885
},
7986
};
@@ -175,6 +182,18 @@ const COMMANDS = {
175182
actions.setModal("env-variables");
176183
},
177184
},
185+
"course-upgrades": {
186+
icon: "gears",
187+
label: "Configure Upgrades (Student or Instructor Pay)",
188+
button: "Upgrades",
189+
title:
190+
"Use a license to upgrade all projects, or require your students to purchase a specific license.",
191+
onClick: ({ props }) => {
192+
const { actions } = props;
193+
actions.setModal("upgrades");
194+
},
195+
},
196+
178197
"course-start-all-projects": {
179198
icon: "bolt",
180199
label: "Start all Student Projects",

0 commit comments

Comments
 (0)