This repository was archived by the owner on Aug 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 816
Expand file tree
/
Copy pathToolbarQueryName.tsx
More file actions
52 lines (47 loc) · 1.41 KB
/
ToolbarQueryName.tsx
File metadata and controls
52 lines (47 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React from 'react';
import Button from '../common/Button';
import { toggleShowQueryModal } from '../stores/editor-actions';
import {
useSessionCanWrite,
useSessionQueryName,
useSessionQueryShared,
useSessionUnsavedChanges,
} from '../stores/editor-store';
import SharedIcon from 'mdi-react/AccountMultipleIcon';
import Tooltip from '../common/Tooltip';
// Shared icon is nudged a bit to align bottom of icon to text baseline
const sharedIconStyle = {
marginLeft: 8,
marginTop: 4,
};
function ToolbarQueryName() {
const queryName = useSessionQueryName();
const shared = useSessionQueryShared();
const unsavedChanges = useSessionUnsavedChanges();
const canWrite = useSessionCanWrite();
let tooltipLabel = 'View query info';
if (canWrite) {
if (unsavedChanges) {
tooltipLabel = `Edit and save query (unsaved changes)`;
} else {
tooltipLabel = `Edit and save query`;
}
}
return (
<Tooltip label={tooltipLabel}>
<Button
className="truncate"
variant="primary-ghost"
style={{ fontSize: 18 }}
onClick={toggleShowQueryModal}
>
<div className="truncate" style={{ maxWidth: 500 }}>
{queryName || 'New unsaved query'}
</div>
{unsavedChanges && canWrite && '*'}
{shared && <SharedIcon size={18} style={sharedIconStyle} />}
</Button>
</Tooltip>
);
}
export default React.memo(ToolbarQueryName);