Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/chat/thread-resolve-button.tsx
14422 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020-2026 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/*
7
"Resolve" affordance shown next to the ThreadAnchorButton at the top of
8
an anchored thread's side chat. Mirrors the inline marker-tail check so
9
the user doesn't have to find the marker in the source first.
10
11
Editor-agnostic at the UI level: only renders when the host editor
12
exposes `resolveChatMarker(hash)` (currently only LaTeX); other editors
13
can ignore this and the button silently hides.
14
*/
15
16
import { Button, Popconfirm, Tooltip } from "antd";
17
18
import { Icon } from "@cocalc/frontend/components";
19
import { COLORS } from "@cocalc/util/theme";
20
21
import type { ChatActions } from "./actions";
22
23
interface Props {
24
anchorId: string;
25
actions: ChatActions;
26
}
27
28
const BUTTON_STYLE = {
29
// Match the green of the inline tail's check icon so the visual ties
30
// these two entry points together as the "resolve" action.
31
background: COLORS.BS_GREEN_LL,
32
borderColor: COLORS.ANTD_GREEN,
33
color: COLORS.BS_GREEN_D,
34
} as const;
35
36
export function ThreadResolveButton({ anchorId, actions }: Props) {
37
const editorActions = actions.frameTreeActions as any;
38
if (
39
editorActions == null ||
40
typeof editorActions.resolveChatMarker !== "function"
41
) {
42
return null;
43
}
44
return (
45
<Popconfirm
46
title="Resolve chat and remove marker?"
47
description={
48
<div style={{ maxWidth: 320 }}>
49
Marks the chat thread as <b>resolved</b> and removes every{" "}
50
<code>% chat: …</code> marker from all files. The thread is kept in{" "}
51
<code>.sage-chat</code> as a read-only archive.
52
</div>
53
}
54
okText="Resolve"
55
cancelText="Cancel"
56
onConfirm={() => {
57
void editorActions.resolveChatMarker(anchorId);
58
}}
59
placement="bottomRight"
60
>
61
<Tooltip title="Resolve this chat (mark TODO done) and remove its markers">
62
<Button style={BUTTON_STYLE} icon={<Icon name="check-circle" />} />
63
</Tooltip>
64
</Popconfirm>
65
);
66
}
67
68