Path: blob/master/src/packages/frontend/editors/task-editor/history-viewer.tsx
1691 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6History viewer for Tasks notebooks --- very similar to same file in jupyter/ directory. Refactor!7*/89import { Checkbox } from "antd";10import { fromJS, Map } from "immutable";11import TaskList from "./list";12import { useState } from "../../app-framework";13import { cmp } from "@cocalc/util/misc";14import { Tasks } from "./types";1516const SHOW_DONE_STYLE = {17fontSize: "12pt",18color: "#666",19padding: "5px 15px",20borderBottom: "1px solid lightgrey",21} as const;2223export function TasksHistoryViewer({ doc, project_id, path, font_size }) {24const [show_done, set_show_done] = useState(false);2526function render_task_list(doc) {27let tasks: Tasks = Map();28const v: [number | undefined, string][] = [];29doc.get().forEach((task) => {30const task_id = task.get("task_id");31tasks = tasks.set(task_id, task);32if ((show_done || !task.get("done")) && !task.get("deleted")) {33v.push([task.get("last_edited"), task_id]);34}35});36v.sort((a, b) => -cmp(a[0], b[0]));37const visible = fromJS(v.map((x) => x[1]));3839return (40<TaskList41path={path}42project_id={project_id}43tasks={tasks}44visible={visible}45read_only={true}46font_size={font_size}47/>48);49}5051return (52<div53style={{54display: "flex",55flexDirection: "column",56height: "100%",57overflowY: "hidden",58}}59>60<div style={SHOW_DONE_STYLE}>61<Checkbox62checked={show_done}63onChange={() => set_show_done(!show_done)}64>65Show finished tasks66</Checkbox>67</div>68{doc == null ? <span>Unknown version</span> : render_task_list(doc)}69</div>70);71}727374