Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/course/shared-project/shared-project-panel.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/4import { UsergroupAddOutlined } from "@ant-design/icons";5import { Button, Card, Popconfirm } from "antd";6import { FormattedMessage, useIntl } from "react-intl";78import { AppRedux, useActions } from "@cocalc/frontend/app-framework";9import { Icon, Paragraph } from "@cocalc/frontend/components";10import { course } from "@cocalc/frontend/i18n";11import { CancelText } from "@cocalc/frontend/i18n/components";12import { CourseActions } from "../actions";13import { CourseSettingsRecord } from "../store";14import { DeleteSharedProjectPanel } from "./delete-shared-project";1516interface SharedProjectPanelProps {17settings: CourseSettingsRecord;18redux: AppRedux;19name: string;20close?: Function;21}2223export function SharedProjectPanel({24settings,25redux,26name,27close,28}: SharedProjectPanelProps) {29const intl = useIntl();3031const actions = useActions<CourseActions>({ name });3233const haveSharedProject = !!settings.get("shared_project_id");3435function panel_header_text(): string {36return intl.formatMessage(37{38id: "course.shared-project-panel.header",39defaultMessage: `{haveSharedProject, select,40true {Shared project that everybody can fully use}41other {Optionally create a shared project for everybody}}`,42},43{ haveSharedProject },44);45}4647function render_content() {48if (haveSharedProject) {49return render_has_shared_project();50} else {51return render_no_shared_project();52}53}5455const icuVals = {56b: (c) => <b>{c}</b>,57i: (c) => <i>{c}</i>,58p: (c) => <Paragraph>{c}</Paragraph>,59secondary: (c) => <Paragraph type="secondary">{c}</Paragraph>,60};6162function render_has_shared_project() {63return (64<>65<FormattedMessage66id="course.shared-project-panel.have_project.message"67defaultMessage={`68<p>69You created a common shared project, which everybody – students and70all collaborators on this project (your TAs and other instructors)71– have <b>write</b> access to. Use this project for collaborative72in-class labs, course-wide chat rooms, and making miscellaneous73materials available for students to experiment with together.74</p>75<secondary>76When you created the shared project, everybody who has already77created an account is added as a collaborator to the project.78Whenever you re-open this course, any students or collaborators on79the project that contains this course will be added to the shared80project.81</secondary>`}82values={icuVals}83/>84<br />85<div style={{ textAlign: "center" }}>86<Button onClick={open_project} size={"large"} type={"primary"}>87<FormattedMessage88id="course.shared-project-panel.have_project.button"89defaultMessage={"Open shared project"}90/>91</Button>92</div>93<hr />94<DeleteSharedProjectPanel95settings={settings}96actions={actions}97close={close}98/>99</>100);101}102103function open_project(): void {104redux.getActions("projects").open_project({105project_id: settings.get("shared_project_id"),106});107close?.();108}109110function render_no_shared_project() {111return (112<div>113<FormattedMessage114id="course.shared-project-panel.create_project.message"115defaultMessage={`116<p>117<i>Optionally</i> create a single common shared project, which118everybody – students and all collaborators on this project (your119TAs and other instructors) – will have <b>write</b> access to. This120can be useful for collaborative in-class labs, course-wide chat121rooms, and making miscellanous materials available for students to122experiment with together.123</p>124<secondary>125When you create the shared project, everybody who has already126created an account is added as a collaborator to the project.127Whenever you re-open this course, any students or collaborators on128the project that contains this course will be added to the shared129project.130</secondary>131<secondary>132After you create the shared project, you should upgrade that project via a license as well.133</secondary>`}134values={icuVals}135/>136<br />137<Popconfirm138title={139<div style={{ maxWidth: "400px" }}>140<FormattedMessage141id="course.shared-project-panel.create_project.confirmation"142defaultMessage={`Are you sure you want to create a shared project143and add all students in this course as collaborators?`}144/>145</div>146}147onConfirm={() => {148const actions = redux.getActions(name) as CourseActions;149if (actions != null) {150actions.shared_project.create();151close?.();152}153}}154okText={intl.formatMessage(course.create_shared_project)}155cancelText={<CancelText />}156>157<Button size={"large"} icon={<UsergroupAddOutlined />}>158{intl.formatMessage(course.create_shared_project)}...159</Button>160</Popconfirm>161</div>162);163}164165return (166<div className="smc-vfill" style={{ overflow: "auto" }}>167<Card168style={{ maxWidth: "800px", margin: "auto" }}169title={170<>171<Icon name="users" /> {panel_header_text()}172</>173}174>175{render_content()}176</Card>177</div>178);179}180181182