Skip to content

Commit b95ce45

Browse files
committed
#RI-3096 - Total keys are not formatted
#RI-3071 - Internal links for Monitor and PSubscribe
1 parent 77ab5f9 commit b95ce45

File tree

7 files changed

+66
-80
lines changed

7 files changed

+66
-80
lines changed

redisinsight/ui/src/components/cli/components/cli-body/CliBodyWrapper.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ import {
1717
sendCliClusterCommandAction,
1818
processUnsupportedCommand,
1919
processUnrepeatableNumber,
20-
processMonitorCommand,
21-
processPSubscribeCommand,
2220
} from 'uiSrc/slices/cli/cli-output'
23-
import { CommandMonitor, CommandPSubscribe } from 'uiSrc/constants'
21+
import { CommandMonitor, CommandPSubscribe, Pages } from 'uiSrc/constants'
2422
import { getCommandRepeat, isRepeatCountCorrect } from 'uiSrc/utils'
2523
import { ConnectionType } from 'uiSrc/slices/interfaces'
2624
import { ClusterNodeRole } from 'uiSrc/slices/interfaces/cli'
2725
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
2826
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
2927
import { checkUnsupportedCommand, clearOutput, cliCommandOutput } from 'uiSrc/utils/cliHelper'
28+
import { cliTexts } from 'uiSrc/constants/cliOutput'
29+
import { showMonitor } from 'uiSrc/slices/cli/monitor'
3030
import { SendClusterCommandDto } from 'apiSrc/modules/cli/dto/cli.dto'
3131

3232
import CliBody from './CliBody'
@@ -81,15 +81,15 @@ const CliBodyWrapper = () => {
8181

8282
// Flow if MONITOR command was executed
8383
if (checkUnsupportedCommand([CommandMonitor.toLowerCase()], commandLine)) {
84-
dispatch(processMonitorCommand(commandLine, resetCommand))
84+
dispatch(concatToOutput(cliTexts.MONITOR_COMMAND_CLI(() => { dispatch(showMonitor()) })))
85+
resetCommand()
8586
return
8687
}
8788

8889
// Flow if PSUBSCRIBE command was executed
8990
if (checkUnsupportedCommand([CommandPSubscribe.toLowerCase()], commandLine)) {
90-
dispatch(processPSubscribeCommand(commandLine, () => {
91-
resetCommand()
92-
}))
91+
dispatch(concatToOutput(cliTexts.PSUBSCRIBE_COMMAND_CLI(Pages.pubSub(instanceId))))
92+
resetCommand()
9393
return
9494
}
9595

redisinsight/ui/src/components/database-overview/components/OverviewMetrics/OverviewMetrics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export const getOverviewMetrics = ({ theme, items, db = 0 }: Props): Array<IMetr
238238
title: 'Total Keys',
239239
content: (<b>{numberWithSpaces(totalKeys || 0)}</b>),
240240
},
241-
content: truncateNumberToRange(totalKeys || 0),
241+
content: (<b>{numberWithSpaces(totalKeys || 0)}</b>),
242242
},
243243
{
244244
id: 'overview-db-total-keys',

redisinsight/ui/src/components/query-card/QueryCardCommonResult/components/CommonErrorResponse/CommonErrorResponse.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { useSelector } from 'react-redux'
2+
import { useDispatch, useSelector } from 'react-redux'
33
import { useParams } from 'react-router-dom'
44
import {
55
checkUnsupportedCommand,
@@ -18,32 +18,23 @@ import { RSNotLoadedContent } from 'uiSrc/pages/workbench/constants'
1818
import { cliSettingsSelector } from 'uiSrc/slices/cli/cli-settings'
1919
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
2020
import ModuleNotLoaded from 'uiSrc/pages/workbench/components/module-not-loaded'
21+
import { showMonitor } from 'uiSrc/slices/cli/monitor'
2122

2223
const CommonErrorResponse = (command = '', result?: any) => {
2324
const { instanceId = '' } = useParams<{ instanceId: string }>()
2425
const { unsupportedCommands: cliUnsupportedCommands, blockingCommands } = useSelector(cliSettingsSelector)
2526
const { modules } = useSelector(connectedInstanceSelector)
27+
const dispatch = useDispatch()
2628
const unsupportedCommands = [SelectCommand.toLowerCase(), ...cliUnsupportedCommands, ...blockingCommands]
2729
const [commandLine, countRepeat] = getCommandRepeat(command)
2830

2931
// Flow if MONITOR command was executed
3032
if (checkUnsupportedCommand([CommandMonitor.toLowerCase()], commandLine)) {
31-
return cliParseTextResponse(
32-
cliTexts.MONITOR_COMMAND,
33-
commandLine,
34-
CommandExecutionStatus.Fail,
35-
CliPrefix.QueryCard,
36-
)
33+
return cliTexts.MONITOR_COMMAND(() => { dispatch(showMonitor()) })
3734
}
3835
// Flow if PSUBSCRIBE command was executed
3936
if (checkUnsupportedCommand([CommandPSubscribe.toLowerCase()], commandLine)) {
40-
return cliParseTextResponse(
41-
cliTexts.PSUBSCRIBE_COMMAND(Pages.pubSub(instanceId)),
42-
commandLine,
43-
CommandExecutionStatus.Fail,
44-
CliPrefix.QueryCard,
45-
true,
46-
)
37+
return cliTexts.PSUBSCRIBE_COMMAND(Pages.pubSub(instanceId))
4738
}
4839

4940
const unsupportedCommand = checkUnsupportedCommand(unsupportedCommands, commandLine)

redisinsight/ui/src/constants/cliOutput.tsx

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { EuiTextColor } from '@elastic/eui'
1+
import { EuiLink, EuiTextColor } from '@elastic/eui'
22
import React from 'react'
3+
import { getRouterLinkProps } from 'uiSrc/services'
34

45
export const ClearCommand = 'clear'
56
export const SelectCommand = 'select'
@@ -36,14 +37,41 @@ export const cliTexts = {
3637
commandLine + unsupportedCommandTextWorkbench + commands,
3738
REPEAT_COUNT_INVALID: 'Invalid repeat command option value',
3839
CONNECTION_CLOSED: 'Client connection previously closed. Run the command after the connection is re-created.',
39-
MONITOR_COMMAND: 'Use the "Profiler" tool to see all the requests processed by the server.',
40-
PSUBSCRIBE_COMMAND: (href: string = '') =>
41-
'Use Pub/Sub to see the messages published to all channels in your database.',
4240
UNABLE_TO_DECRYPT: 'Unable to decrypt. Check the system keychain or re-run the command.',
41+
PSUBSCRIBE_COMMAND: (path: string = '') => (
42+
<EuiTextColor color="danger" key={Date.now()}>
43+
{'Use '}
44+
<EuiLink {...getRouterLinkProps(path)} color="text" data-test-subj="pubsub-page-btn">
45+
Pub/Sub
46+
</EuiLink>
47+
{' to see the messages published to all channels in your database.'}
48+
</EuiTextColor>
49+
),
50+
PSUBSCRIBE_COMMAND_CLI: (path: string = '') => (
51+
[
52+
cliTexts.PSUBSCRIBE_COMMAND(path),
53+
'\n',
54+
]
55+
),
56+
MONITOR_COMMAND: (onClick: () => void) => (
57+
<EuiTextColor color="danger" key={Date.now()}>
58+
{'Use '}
59+
<EuiLink onClick={onClick} className="btnLikeLink" color="text" data-test-subj="monitor-btn">
60+
Profiler
61+
</EuiLink>
62+
{' tool to see all the requests processed by the server.'}
63+
</EuiTextColor>
64+
),
65+
MONITOR_COMMAND_CLI: (onClick: () => void) => (
66+
[
67+
cliTexts.MONITOR_COMMAND(onClick),
68+
'\n',
69+
]
70+
),
4371
CLI_ERROR_MESSAGE: (message: string) => (
4472
[
4573
'\n',
46-
<EuiTextColor color="warning" key={Date.now()}>
74+
<EuiTextColor color="danger" key={Date.now()}>
4775
{message}
4876
</EuiTextColor>,
4977
'\n\n',

redisinsight/ui/src/slices/cli/cli-output.ts

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import { createSlice } from '@reduxjs/toolkit'
22

33
import { CliOutputFormatterType, cliTexts, ConnectionSuccessOutputText, SelectCommand } from 'uiSrc/constants/cliOutput'
44
import { apiService, localStorageService } from 'uiSrc/services'
5-
import { ApiEndpoints, BrowserStorageItem, CommandMonitor } from 'uiSrc/constants'
5+
import { ApiEndpoints, BrowserStorageItem, CommandMonitor, } from 'uiSrc/constants'
66
import {
77
cliParseTextResponseWithOffset,
8-
cliParseTextResponseWithRedirect, getDbIndexFromSelectQuery,
8+
cliParseTextResponseWithRedirect,
9+
getDbIndexFromSelectQuery,
910
} from 'uiSrc/utils/cliHelper'
1011
import { getApiErrorMessage, getApiErrorName, getUrl, isStatusSuccessful } from 'uiSrc/utils'
1112
import { cliUnsupportedCommandsSelector, updateCliClientAction } from 'uiSrc/slices/cli/cli-settings'
1213
import ApiErrors from 'uiSrc/constants/apiErrors'
1314

1415
import { SendClusterCommandDto, SendClusterCommandResponse, SendCommandResponse, } from 'apiSrc/modules/cli/dto/cli.dto'
1516

16-
import { showMonitor } from './monitor'
1717
import { AppDispatch, RootState } from '../store'
1818
import { CommandExecutionStatus, StateCliOutput } from '../interfaces/cli'
1919

@@ -262,46 +262,6 @@ export function processUnrepeatableNumber(
262262
}
263263
}
264264

265-
export function processMonitorCommand(
266-
command: string = '',
267-
onSuccessAction?: () => void
268-
) {
269-
return async (dispatch: AppDispatch) => {
270-
dispatch(showMonitor())
271-
272-
dispatch(
273-
concatToOutput(
274-
cliParseTextResponseWithOffset(
275-
cliTexts.MONITOR_COMMAND,
276-
command,
277-
CommandExecutionStatus.Fail
278-
)
279-
)
280-
)
281-
282-
onSuccessAction?.()
283-
}
284-
}
285-
286-
export function processPSubscribeCommand(
287-
command: string = '',
288-
onSuccessAction?: () => void
289-
) {
290-
return async (dispatch: AppDispatch) => {
291-
dispatch(
292-
concatToOutput(
293-
cliParseTextResponseWithOffset(
294-
cliTexts.PSUBSCRIBE_COMMAND(),
295-
command,
296-
CommandExecutionStatus.Fail
297-
)
298-
)
299-
)
300-
301-
onSuccessAction?.()
302-
}
303-
}
304-
305265
function handleRecreateClient(dispatch: AppDispatch, stateInit: () => RootState, command = ''): void {
306266
const state = stateInit()
307267
const { cliClientUuid } = state.cli.settings

redisinsight/ui/src/styles/components/_buttons.scss

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import '../../../../../node_modules/@elastic/eui/src/global_styling/index';
1+
@import "../../../../../node_modules/@elastic/eui/src/global_styling/index";
22

33
.euiButton {
44
text-decoration: none !important;
@@ -11,7 +11,7 @@
1111
&.euiButton--secondary {
1212
color: var(--buttonSecondaryTextColor) !important;
1313
border-color: var(--euiColorSecondary);
14-
&:not([class*='isDisabled']) {
14+
&:not([class*="isDisabled"]) {
1515
&:hover {
1616
background-color: var(--buttonSecondaryHoverColor);
1717
border-color: var(--buttonSecondaryHoverColor);
@@ -27,7 +27,7 @@
2727
}
2828
}
2929
&.euiButton--primary {
30-
&:not([class*='isDisabled']) {
30+
&:not([class*="isDisabled"]) {
3131
box-shadow: none;
3232
}
3333
}
@@ -47,15 +47,15 @@
4747
border-color: var(--euiColorSecondary);
4848
background-color: var(--euiColorSecondary);
4949

50-
&:not([class*='isDisabled']) {
50+
&:not([class*="isDisabled"]) {
5151
&:hover {
5252
background-color: var(--buttonSecondaryHoverColor);
5353
border-color: var(--buttonSecondaryHoverColor);
5454
}
5555
&:focus:not(:hover),
5656
&:focus-within:not(:hover) {
5757
border: 2px solid var(--euiColorPrimary);
58-
}
58+
}
5959
}
6060
}
6161
}
@@ -109,7 +109,7 @@
109109
}
110110

111111
.euiButton {
112-
&.euiButton--warning.euiButton--fill:not([class*='isDisabled']) {
112+
&.euiButton--warning.euiButton--fill:not([class*="isDisabled"]) {
113113
background-color: var(--buttonWarningColor);
114114
border-color: var(--buttonWarningColor);
115115

@@ -128,18 +128,25 @@
128128
background-color: transparent;
129129
transition: color ease 0.3s, background-color ease 0.3s;
130130

131-
.euiButtonEmpty__text, .euiText {
131+
.euiButtonEmpty__text,
132+
.euiText {
132133
transition: color ease 0.3s;
133134
color: var(--euiTextSubduedColor) !important;
134135
}
135136

136-
&:hover, &:focus {
137+
&:hover,
138+
&:focus {
137139
text-decoration: none !important;
138140
background-color: var(--hoverInListColorDarken);
139141
color: var(--htmlColor);
140142

141-
.euiButtonEmpty__text, .euiText {
143+
.euiButtonEmpty__text,
144+
.euiText {
142145
color: var(--htmlColor) !important;
143146
}
144147
}
145148
}
149+
150+
.btnLikeLink {
151+
font: inherit !important;
152+
}

redisinsight/ui/src/utils/cliHelper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const cliParseTextResponseWithOffset = (
4040
) => [cliParseTextResponse(text, command, status), '\n']
4141

4242
const cliParseTextResponse = (
43-
text: string = '',
43+
text: string | JSX.Element = '',
4444
command: string = '',
4545
status: CommandExecutionStatus = CommandExecutionStatus.Success,
4646
prefix: CliPrefix = CliPrefix.Cli,

0 commit comments

Comments
 (0)