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/configuration/empty-trash.tsx
Views: 687
import { Card, Button } from "antd";1import { Icon } from "@cocalc/frontend/components";2import {3useFrameContext,4useMemo,5useRedux,6} from "@cocalc/frontend/app-framework";7import { CourseActions } from "../actions";8import { plural } from "@cocalc/util/misc";910export default function EmptyTrash() {11const { actions } = useFrameContext();12const courseActions = (actions as any).course_actions as CourseActions;13const { name } = courseActions;14const assignments = useRedux([name, "assignments"]);15const students = useRedux([name, "students"]);16const handouts = useRedux([name, "handouts"]);17const num = useMemo(() => {18const num = {19assignments: 0,20students: 0,21handouts: 0,22total: 0,23desc: "Purge Deleted",24};25if (assignments) {26for (const [, assignment] of assignments) {27if (assignment.get("deleted")) {28num.assignments += 1;29}30}31}32if (students) {33for (const [, student] of students) {34if (student.get("deleted")) {35num.students += 1;36}37}38}39if (handouts) {40for (const [, handout] of handouts) {41if (handout.get("deleted")) {42num.handouts += 1;43}44}45}46num.total = num.students + num.assignments + num.handouts;47num.desc = `Purge ${num.students} deleted ${plural(48num.students,49"student",50)}, ${num.assignments} ${plural(num.assignments, "assignment")}, and ${51num.handouts52} ${plural(num.handouts, "handout")}`;53return num;54}, [assignments, students, handouts]);5556return (57<Card58title={59<>60<Icon name="trash" /> Empty Trash: {num.desc}61</>62}63>64{num.total == 0 ? (65"You have no deleted students, assignments or handouts."66) : (67<>68When you delete students, assignments or handouts, they can be shown69again by clicking "Show xx deleted students/assignments/handouts" in70the corresponding tab of your course, then clicking undelete. You can71purge these deleted students, assignments and handouts below.72<div style={{ marginTop: "15px", textAlign: "center" }}>73<Button74onClick={() => {75courseActions.configuration.purgeDeleted();76}}77>78{num.desc}79</Button>80</div>81</>82)}83</Card>84);85}868788