Skip to content

Commit b0aa5ba

Browse files
committed
RI-7595: refactor and fix QueryActions
1 parent 05335fc commit b0aa5ba

File tree

7 files changed

+58
-133
lines changed

7 files changed

+58
-133
lines changed

redisinsight/ui/src/assets/img/workbench/execution_time.svg

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

redisinsight/ui/src/components/base/forms/buttons/EmptyButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const EmptyButton = ({
2222
...rest
2323
}: ButtonProps) => (
2424
<TextButton {...rest}>
25-
<Row justify={justify} gap="s" align="center">
25+
<Row justify={justify} gap="m" align="center">
2626
<ButtonIcon
2727
buttonSide="left"
2828
icon={icon}

redisinsight/ui/src/components/base/icons/iconRegistry.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import CopilotSvg from 'uiSrc/assets/img/icons/copilot.svg?react'
1212
import DefaultPluginDarkSvg from 'uiSrc/assets/img/workbench/default_view_dark.svg?react'
1313
import DefaultPluginLightSvg from 'uiSrc/assets/img/workbench/default_view_light.svg?react'
1414
import DislikeSvg from 'uiSrc/assets/img/icons/dislike.svg?react'
15-
import ExecutionTimeSvg from 'uiSrc/assets/img/workbench/execution_time.svg?react'
1615
import ExtendSvg from 'uiSrc/assets/img/icons/extend.svg?react'
1716
import GithubHelpCenterSVG from 'uiSrc/assets/img/github.svg?react'
1817
import GroupModeSvg from 'uiSrc/assets/img/icons/group_mode.svg?react'
@@ -170,7 +169,6 @@ export const CopilotIcon = createIconComponent(CopilotSvg)
170169
export const DefaultPluginDarkIcon = createIconComponent(DefaultPluginDarkSvg)
171170
export const DefaultPluginLightIcon = createIconComponent(DefaultPluginLightSvg)
172171
export const DislikeIcon = createIconComponent(DislikeSvg)
173-
export const ExecutionTimeIcon = createIconComponent(ExecutionTimeSvg)
174172
export const ExtendIcon = createIconComponent(ExtendSvg)
175173
export const GithubHelpCenterIcon = createIconComponent(GithubHelpCenterSVG)
176174
export const GroupModeIcon = createIconComponent(GroupModeSvg)

redisinsight/ui/src/components/query/components/RunButton.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@ import { PlayFilledIcon } from 'uiSrc/components/base/icons'
44
import { EmptyButton } from 'uiSrc/components/base/forms/buttons'
55

66
const StyledEmptyButton = styled(EmptyButton)`
7-
height: 24px !important;
8-
min-width: auto !important;
9-
min-height: auto !important;
10-
border-radius: 4px !important;
11-
background: transparent !important;
12-
box-shadow: none !important;
13-
margin-left: 8px;
14-
15-
border: 1px solid transparent !important;
16-
17-
& .RI-flex-row {
18-
padding: 0 6px;
19-
}
20-
217
&:focus,
228
&:active {
23-
outline: 0 !important;
9+
outline: 0;
2410
}
2511
2612
svg {
2713
margin-top: 1px;
2814
width: 14px;
2915
height: 14px;
30-
color: var(--rsSubmitBtn) !important;
16+
color: var(--rsSubmitBtn);
3117
}
3218
`
3319

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import styled from 'styled-components'
2+
import { EmptyButton } from 'uiSrc/components/base/forms/buttons'
3+
import Divider from 'uiSrc/components/divider/Divider'
4+
export const QADivider = styled(Divider)`
5+
height: 20px;
6+
`
7+
export const QABtn = styled(EmptyButton)<{ $active: boolean }>`
8+
height: 24px;
9+
min-width: auto;
10+
min-height: auto;
11+
border-radius: 4px;
12+
background: ${({ $active }) =>
13+
$active ? 'var(--browserComponentActive)' : 'transparent'};
14+
box-shadow: none;
15+
16+
border: 1px solid
17+
${({ $active }) => ($active ? 'var(--euiColorPrimary)' : 'transparent')};
18+
19+
:global(.RI-flex-row) {
20+
padding: 0 6px;
21+
font:
22+
normal normal 400 14px/17px Graphik,
23+
sans-serif;
24+
}
25+
26+
&:focus,
27+
&:active {
28+
outline: 0;
29+
}
30+
31+
svg {
32+
margin-top: 1px;
33+
width: 14px;
34+
height: 14px;
35+
}
36+
37+
svg path {
38+
fill: var(--euiTextSubduedColor);
39+
}
40+
`

redisinsight/ui/src/components/query/query-actions/QueryActions.tsx

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import React from 'react'
22

3-
import cx from 'classnames'
43
import { ResultsMode, RunQueryMode } from 'uiSrc/slices/interfaces'
54
import { KEYBOARD_SHORTCUTS } from 'uiSrc/constants'
65
import { KeyboardShortcut, RiTooltip } from 'uiSrc/components'
76
import { isGroupMode } from 'uiSrc/utils'
87

98
import { GroupModeIcon, RawModeIcon } from 'uiSrc/components/base/icons'
109

11-
import Divider from 'uiSrc/components/divider/Divider'
1210
import { Spacer } from 'uiSrc/components/base/layout/spacer'
13-
import { EmptyButton } from 'uiSrc/components/base/forms/buttons'
1411
import { Text } from 'uiSrc/components/base/text'
15-
import styles from './styles.module.scss'
1612
import RunButton from 'uiSrc/components/query/components/RunButton'
13+
import { Row } from 'uiSrc/components/base/layout/flex'
14+
import {
15+
QABtn,
16+
QADivider,
17+
} from 'uiSrc/components/query/query-actions/QueryActions.styles'
1718

1819
export interface Props {
1920
onChangeMode?: () => void
@@ -22,13 +23,11 @@ export interface Props {
2223
activeMode: RunQueryMode
2324
resultsMode?: ResultsMode
2425
isLoading?: boolean
25-
isDisabled?: boolean
2626
}
2727

2828
const QueryActions = (props: Props) => {
2929
const {
3030
isLoading,
31-
isDisabled,
3231
activeMode,
3332
resultsMode,
3433
onChangeMode,
@@ -37,39 +36,32 @@ const QueryActions = (props: Props) => {
3736
} = props
3837
const KeyBoardTooltipContent = KEYBOARD_SHORTCUTS?.workbench?.runQuery && (
3938
<>
40-
<Text className={styles.tooltipText} size="s">
41-
{KEYBOARD_SHORTCUTS.workbench.runQuery?.label}:
42-
</Text>
39+
<Text size="s">{KEYBOARD_SHORTCUTS.workbench.runQuery?.label}:</Text>
4340
<Spacer size="s" />
4441
<KeyboardShortcut
45-
badgeTextClassName={styles.tooltipText}
4642
separator={KEYBOARD_SHORTCUTS?._separator}
4743
items={KEYBOARD_SHORTCUTS.workbench.runQuery.keys}
4844
/>
4945
</>
5046
)
5147

5248
return (
53-
<div
54-
className={cx(styles.actions, { [styles.disabledActions]: isDisabled })}
55-
>
49+
<Row align="center" justify="between" gap="l" grow={false}>
5650
{onChangeMode && (
5751
<RiTooltip
5852
position="left"
5953
content="Enables the raw output mode"
6054
data-testid="change-mode-tooltip"
6155
>
62-
<EmptyButton
56+
<QABtn
6357
onClick={() => onChangeMode()}
6458
icon={RawModeIcon}
6559
disabled={isLoading}
66-
className={cx(styles.btn, styles.textBtn, {
67-
[styles.activeBtn]: activeMode === RunQueryMode.Raw,
68-
})}
60+
$active={activeMode === RunQueryMode.Raw}
6961
data-testid="btn-change-mode"
7062
>
7163
Raw mode
72-
</EmptyButton>
64+
</QABtn>
7365
</RiTooltip>
7466
)}
7567
{onChangeGroupMode && (
@@ -85,24 +77,18 @@ const QueryActions = (props: Props) => {
8577
}
8678
data-testid="group-results-tooltip"
8779
>
88-
<EmptyButton
80+
<QABtn
8981
onClick={() => onChangeGroupMode()}
9082
disabled={isLoading}
9183
icon={GroupModeIcon}
92-
className={cx(styles.btn, styles.textBtn, {
93-
[styles.activeBtn]: isGroupMode(resultsMode),
94-
})}
84+
$active={isGroupMode(resultsMode)}
9585
data-testid="btn-change-group-mode"
9686
>
9787
Group results
98-
</EmptyButton>
88+
</QABtn>
9989
</RiTooltip>
10090
)}
101-
<Divider
102-
orientation="vertical"
103-
colorVariable="separatorColor"
104-
className={styles.divider}
105-
/>
91+
<QADivider orientation="vertical" colorVariable="separatorColor" />
10692
<RiTooltip
10793
position="left"
10894
content={
@@ -114,7 +100,7 @@ const QueryActions = (props: Props) => {
114100
>
115101
<RunButton isLoading={isLoading} onSubmit={onSubmit} />
116102
</RiTooltip>
117-
</div>
103+
</Row>
118104
)
119105
}
120106

redisinsight/ui/src/components/query/query-actions/styles.module.scss

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

0 commit comments

Comments
 (0)