Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/task-editor/desc-visible.tsx
1691 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/*
7
Summary line about what is being shown.
8
*/
9
10
import { plural } from "@cocalc/util/misc";
11
import { LocalViewStateMap } from "./types";
12
13
interface Props {
14
num_visible?: number;
15
num_tasks?: number;
16
local_view_state: LocalViewStateMap;
17
search_desc: string;
18
}
19
20
export function DescVisible({
21
num_visible,
22
num_tasks,
23
local_view_state,
24
search_desc,
25
}: Props) {
26
function render_checked() {
27
const v: string[] = [];
28
for (let type of ["done", "deleted"]) {
29
if (local_view_state.get(`show_${type}`)) {
30
v.push(type);
31
}
32
}
33
if (v.length === 0) {
34
return;
35
}
36
return (
37
<span style={{ color: "#666", marginLeft: "10px" }}>
38
Including{" "}
39
<b>
40
<i>{v.join(" and ")}</i>
41
</b>{" "}
42
tasks.
43
</span>
44
);
45
}
46
47
if (num_visible == null || local_view_state == null || num_tasks == null) {
48
return <span />;
49
}
50
return (
51
<div style={{ marginTop: "12.5px", fontWeight: 500 }}>
52
<span style={{ color: "#666" }}>
53
{num_visible} matching {plural(num_visible, "task")}.
54
</span>
55
{search_desc && (
56
<span style={{ color: "#666", marginLeft: "10px" }}>
57
Tasks that match{" "}
58
<b>
59
<i>{search_desc}</i>
60
</b>
61
.
62
</span>
63
)}
64
{render_checked()}
65
</div>
66
);
67
}
68
69