Path: blob/master/src/packages/frontend/editors/task-editor/editor.tsx
1691 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6Top-level react component for task list7*/89import { Button } from "antd";10import { fromJS } from "immutable";11import { Col, Row } from "@cocalc/frontend/antd-bootstrap";12import { useEditorRedux } from "@cocalc/frontend/app-framework";13import { Loading } from "@cocalc/frontend/components";14import { Icon } from "@cocalc/frontend/components/icon";15import { TaskActions } from "./actions";16import { DescVisible } from "./desc-visible";17import { Find } from "./find";18import { HashtagBar } from "./hashtag-bar";19import { Headings } from "./headings";20import { HEADINGS, is_sortable } from "./headings-info";21import TaskList from "./list";22import { TaskState } from "./types";2324interface Props {25actions: TaskActions;26path: string;27project_id: string;28desc;29read_only?: boolean;30}3132export function TaskEditor({33actions,34path,35project_id,36desc,37read_only,38}: Props) {39const useEditor = useEditorRedux<TaskState>({ project_id, path });40const tasks = useEditor("tasks");41const visible = desc.get("data-visible");42const local_task_state = desc.get("data-local_task_state") ?? fromJS({});43const local_view_state = desc.get("data-local_view_state") ?? fromJS({});44const hashtags = desc.get("data-hashtags");45const current_task_id = desc.get("data-current_task_id");46const counts = desc.get("data-counts");47const search_terms = desc.get("data-search_terms");48const search_desc = desc.get("data-search_desc");49const focus_find_box = desc.get("data-focus_find_box");5051if (tasks == null || visible == null) {52return (53<div54style={{55fontSize: "40px",56textAlign: "center",57padding: "15px",58color: "#999",59}}60>61<Loading />62</div>63);64}6566return (67<div className={"smc-vfill"}>68<Row>69<Col md={7} style={{ display: "flex", marginTop: "5px" }}>70<Button71style={{ marginLeft: "5px" }}72onClick={() => {73actions.new_task();74}}75>76<Icon name="plus-circle" /> New Task77</Button>78<Find79style={{ flex: 1 }}80actions={actions}81local_view_state={local_view_state}82counts={counts}83focus_find_box={focus_find_box}84/>85</Col>86<Col md={5}>87<DescVisible88num_visible={visible?.size}89num_tasks={tasks?.size}90local_view_state={local_view_state}91search_desc={search_desc}92/>93</Col>94</Row>95<Row>96<Col md={12}>97{hashtags != null && (98<HashtagBar99actions={actions}100hashtags={hashtags}101selected_hashtags={local_view_state.get("selected_hashtags")}102/>103)}104</Col>105</Row>106<Headings actions={actions} sort={local_view_state.get("sort")} />107<div style={{ paddingTop: "5px" }} />108{visible.size == 0 ? (109<a110onClick={actions.new_task}111style={{112fontSize: "40px",113textAlign: "center",114padding: "15px",115}}116>117Create a task...118</a>119) : (120<TaskList121actions={actions}122path={path}123project_id={project_id}124tasks={tasks}125visible={visible}126current_task_id={current_task_id}127local_task_state={local_task_state}128scrollState={(local_view_state as any).get("scrollState")?.toJS?.()}129font_size={desc.get("font_size")}130sortable={131!read_only &&132is_sortable(133local_view_state.getIn(["sort", "column"]) ?? HEADINGS[0],134)135}136read_only={read_only}137selected_hashtags={local_view_state.get("selected_hashtags")}138search_terms={search_terms}139/>140)}141</div>142);143}144145146