Skip to content

Commit c7314c0

Browse files
Loori-Rvalyala
andauthored
app/vmui: help button for shortcuts and controls (#839)
Co-authored-by: Aliaksandr Valialkin <[email protected]>
1 parent cc9f411 commit c7314c0

File tree

9 files changed

+37
-210
lines changed

9 files changed

+37
-210
lines changed

app/vmui/packages/vmui/src/components/Chart/BarHitsChart/BarHitsOptions/BarHitsOptions.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import "./style.scss";
55
import useStateSearchParams from "../../../../hooks/useStateSearchParams";
66
import { useSearchParams } from "react-router-dom";
77
import Button from "../../../Main/Button/Button";
8-
import { SettingsIcon, VisibilityIcon, VisibilityOffIcon } from "../../../Main/Icons";
8+
import { SettingsIcon, TipIcon, VisibilityIcon, VisibilityOffIcon } from "../../../Main/Icons";
99
import Tooltip from "../../../Main/Tooltip/Tooltip";
1010
import Popper from "../../../Main/Popper/Popper";
1111
import useBoolean from "../../../../hooks/useBoolean";
12+
import ShortcutKeys from "../../../Main/ShortcutKeys/ShortcutKeys";
1213

1314
interface Props {
1415
onChange: (options: GraphOptions) => void;
@@ -61,6 +62,13 @@ const BarHitsOptions: FC<Props> = ({ onChange }) => {
6162

6263
return (
6364
<div className="vm-bar-hits-options">
65+
<ShortcutKeys>
66+
<Button
67+
variant="text"
68+
color="gray"
69+
startIcon={<TipIcon/>}
70+
/>
71+
</ShortcutKeys>
6472
<div ref={optionsButtonRef}>
6573
<Tooltip title="Graph settings">
6674
<Button

app/vmui/packages/vmui/src/components/Chart/GraphTips/GraphTips.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

app/vmui/packages/vmui/src/components/Chart/GraphTips/constants/tips.tsx

Lines changed: 0 additions & 67 deletions
This file was deleted.

app/vmui/packages/vmui/src/components/Chart/GraphTips/style.scss

Lines changed: 0 additions & 49 deletions
This file was deleted.

app/vmui/packages/vmui/src/components/Main/ShortcutKeys/ShortcutKeys.tsx

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { FC, useCallback } from "preact/compat";
2-
import { getAppModeEnable } from "../../../utils/app-mode";
3-
import Button from "../Button/Button";
4-
import { KeyboardIcon } from "../Icons";
1+
import { FC, ReactNode, useCallback } from "preact/compat";
52
import Modal from "../Modal/Modal";
63
import "./style.scss";
74
import Tooltip from "../Tooltip/Tooltip";
@@ -14,8 +11,11 @@ const title = "Shortcut keys";
1411
const isMac = isMacOs();
1512
const keyOpenHelp = isMac ? "Cmd + /" : "F1";
1613

17-
const ShortcutKeys: FC<{ showTitle?: boolean }> = ({ showTitle }) => {
18-
const appModeEnable = getAppModeEnable();
14+
type Props = {
15+
children?: ReactNode
16+
}
17+
18+
const ShortcutKeys: FC<Props> = ({ children }) => {
1919

2020
const {
2121
value: openList,
@@ -35,20 +35,12 @@ const ShortcutKeys: FC<{ showTitle?: boolean }> = ({ showTitle }) => {
3535

3636
return <>
3737
<Tooltip
38-
open={showTitle === true ? false : undefined}
3938
title={`${title} (${keyOpenHelp})`}
4039
placement="bottom-center"
4140
>
42-
<Button
43-
className={appModeEnable ? "" : "vm-header-button"}
44-
variant="contained"
45-
color="primary"
46-
startIcon={<KeyboardIcon/>}
47-
onClick={handleOpen}
48-
ariaLabel={title}
49-
>
50-
{showTitle && title}
51-
</Button>
41+
<div onClick={handleOpen}>
42+
{children}
43+
</div>
5244
</Tooltip>
5345

5446
{openList && (
@@ -62,9 +54,6 @@ const ShortcutKeys: FC<{ showTitle?: boolean }> = ({ showTitle }) => {
6254
className="vm-shortcuts-section"
6355
key={section.title}
6456
>
65-
{section.readMore && (
66-
<div className="vm-shortcuts-section__read-more">{section.readMore}</div>
67-
)}
6857
<h3 className="vm-shortcuts-section__title">
6958
{section.title}
7059
</h3>

app/vmui/packages/vmui/src/components/Main/ShortcutKeys/constants/keyList.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { isMacOs } from "../../../../utils/detect-device";
2-
import { VisibilityIcon } from "../../Icons";
3-
import GraphTips from "../../../Chart/GraphTips/GraphTips";
42

53
const ctrlMeta = <code>{isMacOs() ? "Cmd" : "Ctrl"}</code>;
64

@@ -26,10 +24,6 @@ const keyList = [
2624
keys: <>{ctrlMeta} + <code>Arrow Down</code></>,
2725
description: "Next command from the Query history"
2826
},
29-
{
30-
keys: <>{ctrlMeta} + <code>click</code> by <VisibilityIcon/></>,
31-
description: "Toggle multiple queries"
32-
},
3327
{
3428
keys: AUTOCOMPLETE_QUICK_KEY,
3529
description: "Show quick autocomplete tips"
@@ -38,7 +32,6 @@ const keyList = [
3832
},
3933
{
4034
title: "Graph",
41-
readMore: <GraphTips/>,
4235
list: [
4336
{
4437
keys: <>{ctrlMeta} + <code>scroll Up</code> or <code>+</code></>,
@@ -53,12 +46,8 @@ const keyList = [
5346
description: "Move the graph left/right"
5447
},
5548
{
56-
keys: <><code>click</code></>,
57-
description: "Select the series in the legend"
58-
},
59-
{
60-
keys: <>{ctrlMeta} + <code>click</code></>,
61-
description: "Toggle multiple series in the legend"
49+
keys: <><code>click</code> on legend item</>,
50+
description: "Open the legend item menu"
6251
}
6352
]
6453
},

app/vmui/packages/vmui/src/components/Main/ShortcutKeys/style.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,10 @@
1515

1616
&__title {
1717
font-weight: bold;
18+
line-height: 24px;
1819
margin-bottom: $padding-global;
1920
}
2021

21-
&__read-more {
22-
position: absolute;
23-
top: -8px;
24-
right: 0;
25-
}
26-
2722
&-list {
2823
display: grid;
2924
gap: $padding-global;

app/vmui/packages/vmui/src/layouts/LogsLayout/ControlsLogsLayout.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import { ControlsProps } from "../Header/HeaderControls/HeaderControls";
55
import { TimeSelector } from "../../components/Configurators/TimeRangeSettings/TimeSelector/TimeSelector";
66
import TenantsFields from "../../components/Configurators/GlobalSettings/TenantsConfiguration/TenantsFields";
77
import { ExecutionControls } from "../../components/Configurators/TimeRangeSettings/ExecutionControls/ExecutionControls";
8+
import ShortcutKeys from "../../components/Main/ShortcutKeys/ShortcutKeys";
9+
import { getAppModeEnable } from "../../utils/app-mode";
10+
import Button from "../../components/Main/Button/Button";
11+
import { KeyboardIcon } from "../../components/Main/Icons";
812

913
const ControlsLogsLayout: FC<ControlsProps> = ({ isMobile, headerSetup }) => {
14+
const appModeEnable = getAppModeEnable();
1015
const settingsRef = useRef<GlobalSettingsHandle>(null);
1116

1217
return (
@@ -21,6 +26,16 @@ const ControlsLogsLayout: FC<ControlsProps> = ({ isMobile, headerSetup }) => {
2126
{headerSetup?.timeSelector && <TimeSelector onOpenSettings={settingsRef?.current?.open}/>}
2227
{headerSetup?.executionControls && <ExecutionControls/>}
2328
<GlobalSettings ref={settingsRef}/>
29+
{!isMobile && (
30+
<ShortcutKeys>
31+
<Button
32+
className={appModeEnable ? "" : "vm-header-button"}
33+
variant="contained"
34+
color="primary"
35+
startIcon={<KeyboardIcon/>}
36+
/>
37+
</ShortcutKeys>
38+
)}
2439
</div>
2540
);
2641
};

docs/victorialogs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ according to the follosing docs:
2222
## tip
2323

2424
* FEATURE: [syslog data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/syslog/): add support for automatic parsing of [`@cee` messages](http://cee.mitre.org/language/1.0-beta1/clt.html#syslog). Thanks to @exherb for the pull request [#842](https://github.com/VictoriaMetrics/VictoriaLogs/pull/842).
25+
* FEATURE: [web UI](https://docs.victoriametrics.com/victorialogs/querying/#web-ui): add the help button with shortcuts reference and controls for charts and query input. See [#77](https://github.com/VictoriaMetrics/VictoriaLogs/issues/77).
2526

2627
* BUGFIX: [delete API](https://docs.victoriametrics.com/victorialogs/#how-to-delete-logs): prevent from possible fatal error (panic) at `block_stream_merger.go:237` during the deletion of the logs. See [#825](https://github.com/VictoriaMetrics/VictoriaLogs/issues/825).
2728

0 commit comments

Comments
 (0)