Skip to content

Commit 6dc05b7

Browse files
committed
chat: fix tooltips and make things correct/cleaner
- not sure I like the semantics though!
1 parent 6d53422 commit 6dc05b7

File tree

3 files changed

+90
-89
lines changed

3 files changed

+90
-89
lines changed

src/packages/frontend/chat/chat-log.tsx

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Render all the messages in the chat.
88
*/
99

10-
import { Alert } from "antd";
10+
import { Alert, Button } from "antd";
1111
import { Set as immutableSet } from "immutable";
1212
import { MutableRefObject, useEffect, useMemo, useRef } from "react";
1313
import { Virtuoso, VirtuosoHandle } from "react-virtuoso";
@@ -17,7 +17,7 @@ import {
1717
useRedux,
1818
useTypedRedux,
1919
} from "@cocalc/frontend/app-framework";
20-
import { VisibleMDLG } from "@cocalc/frontend/components";
20+
import { Icon, VisibleMDLG } from "@cocalc/frontend/components";
2121
import useVirtuosoScrollHook from "@cocalc/frontend/components/virtuoso-scroll-hook";
2222
import { HashtagBar } from "@cocalc/frontend/editors/task-editor/hashtag-bar";
2323
import {
@@ -164,6 +164,7 @@ export function ChatLog({
164164
num={messages.size - numFolded - sortedDates.length}
165165
search={search}
166166
filterRecentH={filterRecentH}
167+
actions={actions}
167168
/>
168169
)}
169170
<MessageList
@@ -343,36 +344,44 @@ interface NotShowingProps {
343344
num: number;
344345
search: string;
345346
filterRecentH: number;
347+
actions;
346348
}
347349

348-
function NotShowing({ num, search, filterRecentH }: NotShowingProps) {
350+
function NotShowing({ num, search, filterRecentH, actions }: NotShowingProps) {
349351
if (num <= 0) return null;
350352

351353
const timespan =
352354
filterRecentH > 0 ? hoursToTimeIntervalHuman(filterRecentH) : null;
353355

354356
return (
355357
<Alert
356-
style={{ margin: "0" }}
358+
style={{ marginBottom: "5px" }}
359+
showIcon
357360
type="warning"
358-
closable
359-
banner
360-
key="not_showing"
361361
message={
362-
<b>
363-
WARNING: Hiding {num} {plural(num, "messages")}
364-
{search.trim()
365-
? ` that ${
366-
num != 1 ? "do" : "does"
367-
} not match search for '${search.trim()}'`
368-
: ""}
369-
{timespan
370-
? ` ${
371-
search.trim() ? "and" : "that"
372-
} were not sent in the past ${timespan}`
373-
: ""}
374-
.
375-
</b>
362+
<div style={{ display: "flex", alignItems: "center" }}>
363+
<b style={{ flex: 1 }}>
364+
WARNING: Hiding {num} {plural(num, "message")} in threads
365+
{search.trim()
366+
? ` that ${
367+
num != 1 ? "do" : "does"
368+
} not match search for '${search.trim()}'`
369+
: ""}
370+
{timespan
371+
? ` ${
372+
search.trim() ? "and" : "that"
373+
} were not sent in the past ${timespan}`
374+
: ""}
375+
.
376+
</b>
377+
<Button
378+
onClick={() => {
379+
actions.clearAllFilters();
380+
}}
381+
>
382+
<Icon name="close-circle-filled" style={{ color: "#888" }} /> Clear
383+
</Button>
384+
</div>
376385
}
377386
/>
378387
);

src/packages/frontend/chat/chatroom.tsx

Lines changed: 59 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Button, Divider, Input, Select, Tooltip } from "antd";
6+
import { Button, Divider, Input, Select, Space, Tooltip } from "antd";
77
import { debounce } from "lodash";
88
import { useDebounce } from "use-debounce";
99
import {
@@ -39,7 +39,14 @@ import { INPUT_HEIGHT, markChatAsReadIfUnseen } from "./utils";
3939
import VideoChatButton from "./video/launch-button";
4040
import Filter from "./filter";
4141

42-
const FILTER_RECENT_NONE = { value: 0, label: "All" } as const;
42+
const FILTER_RECENT_NONE = {
43+
value: 0,
44+
label: (
45+
<>
46+
<Icon name="clock" /> All
47+
</>
48+
),
49+
} as const;
4350

4451
const PREVIEW_STYLE: React.CSSProperties = {
4552
background: "#f5f5f5",
@@ -60,7 +67,6 @@ const GRID_STYLE: React.CSSProperties = {
6067
} as const;
6168

6269
const CHAT_LOG_STYLE: React.CSSProperties = {
63-
margin: "5px 0",
6470
padding: "0",
6571
background: "white",
6672
flex: "1 0 auto",
@@ -340,8 +346,8 @@ export const ChatRoom: React.FC<Props> = ({ project_id, path, is_visible }) => {
340346
<Tooltip
341347
title={
342348
value === 0
343-
? `All messages.`
344-
: `Only messages sent in the past ${label}.`
349+
? undefined
350+
: `Only threads with messages sent in the past ${label}.`
345351
}
346352
>
347353
{label}
@@ -390,69 +396,56 @@ export const ChatRoom: React.FC<Props> = ({ project_id, path, is_visible }) => {
390396

391397
function render_button_row() {
392398
return (
393-
<Row style={{ marginLeft: 0, marginRight: 0 }}>
394-
<Col xs={9} md={9} style={{ padding: "2px" }}>
395-
<ButtonGroup>
396-
{render_save_button()}
397-
{render_timetravel_button()}
398-
{render_compute_server_button()}
399-
</ButtonGroup>
400-
<ButtonGroup style={{ marginLeft: "5px" }}>
401-
{render_video_chat_button()}
402-
{render_bottom_button()}
403-
</ButtonGroup>
404-
<ButtonGroup style={{ marginLeft: "5px" }}>
405-
{render_decrease_font_size()}
406-
{render_increase_font_size()}
407-
</ButtonGroup>
408-
{render_export_button()}
409-
{actions.syncdb != null && (
410-
<VisibleMDLG>
411-
<ButtonGroup style={{ marginLeft: "5px" }}>
412-
<Button onClick={() => actions.syncdb?.undo()} title="Undo">
413-
<Icon name="undo" />
414-
</Button>
415-
<Button onClick={() => actions.syncdb?.redo()} title="Redo">
416-
<Icon name="redo" />
417-
</Button>
418-
</ButtonGroup>
419-
</VisibleMDLG>
420-
)}
421-
{actions.help != null && (
422-
<Button
423-
onClick={() => actions.help()}
424-
style={{ marginLeft: "5px" }}
425-
title="Documentation"
426-
>
427-
<Icon name="question-circle" />
428-
</Button>
429-
)}
430-
</Col>
431-
<Col
432-
xs={3}
433-
md={3}
399+
<Space style={{ width: "100%", marginTop: "3px" }} wrap>
400+
<ButtonGroup>
401+
{render_save_button()}
402+
{render_timetravel_button()}
403+
{render_compute_server_button()}
404+
</ButtonGroup>
405+
<ButtonGroup style={{ marginLeft: "5px" }}>
406+
{render_video_chat_button()}
407+
{render_bottom_button()}
408+
</ButtonGroup>
409+
<ButtonGroup style={{ marginLeft: "5px" }}>
410+
{render_decrease_font_size()}
411+
{render_increase_font_size()}
412+
</ButtonGroup>
413+
{render_export_button()}
414+
{actions.syncdb != null && (
415+
<VisibleMDLG>
416+
<ButtonGroup style={{ marginLeft: "5px" }}>
417+
<Button onClick={() => actions.syncdb?.undo()} title="Undo">
418+
<Icon name="undo" />
419+
</Button>
420+
<Button onClick={() => actions.syncdb?.redo()} title="Redo">
421+
<Icon name="redo" />
422+
</Button>
423+
</ButtonGroup>
424+
</VisibleMDLG>
425+
)}
426+
{actions.help != null && (
427+
<Button
428+
onClick={() => actions.help()}
429+
style={{ marginLeft: "5px" }}
430+
title="Documentation"
431+
>
432+
<Icon name="question-circle" />
433+
</Button>
434+
)}
435+
436+
<Filter
437+
actions={actions}
438+
search={search}
434439
style={{
435-
padding: "2px",
436-
display: "flex",
437-
verticalAlign: "center",
438-
gap: "5px",
440+
margin: 0,
441+
width: "100%",
442+
...(messages.size >= 2
443+
? undefined
444+
: { visibility: "hidden", height: 0 }),
439445
}}
440-
>
441-
{renderFilterRecent()}
442-
<Filter
443-
actions={actions}
444-
search={search}
445-
style={{
446-
margin: 0,
447-
width: "100%",
448-
marginBottom: "5px",
449-
...(messages.size >= 2
450-
? undefined
451-
: { visibility: "hidden", height: 0 }),
452-
}}
453-
/>
454-
</Col>
455-
</Row>
446+
/>
447+
{renderFilterRecent()}
448+
</Space>
456449
);
457450
}
458451

src/packages/frontend/chat/filter.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Filter({ actions, search, style }) {
2626
<Tooltip
2727
title={
2828
!value
29-
? "Show only message threads matching this search. Use /re/ for a regular expression, quotes and dash to negate."
29+
? "Show only threads containing at least one message that matches this search. Use /re/ for a regular expression, quotes, and dashes to negate."
3030
: undefined
3131
}
3232
>
@@ -51,4 +51,3 @@ export default function Filter({ actions, search, style }) {
5151
</Tooltip>
5252
);
5353
}
54-

0 commit comments

Comments
 (0)