Skip to content

Commit 53ce20e

Browse files
authored
Merge pull request #2408 from RedisInsight/fe/bugfix/RI-4791
#RI-4791 - fix disabled state for clear all button
2 parents 2bedd97 + f22fe33 commit 53ce20e

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import styles from './styles.module.scss'
1818
export interface Props {
1919
items: CommandExecutionUI[]
2020
clearing: boolean
21+
processing: boolean
2122
activeMode: RunQueryMode
2223
activeResultsMode?: ResultsMode
2324
scrollDivRef: React.Ref<HTMLDivElement>
@@ -31,6 +32,7 @@ const WBResults = (props: Props) => {
3132
const {
3233
items = [],
3334
clearing,
35+
processing,
3436
activeMode,
3537
activeResultsMode,
3638
onQueryReRun,
@@ -81,6 +83,7 @@ const WBResults = (props: Props) => {
8183
iconSize="s"
8284
className={styles.clearAllBtn}
8385
onClick={() => onAllQueriesDelete?.()}
86+
disabled={clearing || processing}
8487
data-testid="clear-history-btn"
8588
>
8689
Clear Results

redisinsight/ui/src/pages/workbench/components/wb-results/WBResultsWrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import WBResults from './WBResults'
88
export interface Props {
99
items: CommandExecutionUI[]
1010
clearing: boolean
11+
processing: boolean
1112
activeMode: RunQueryMode
1213
activeResultsMode: ResultsMode
1314
scrollDivRef: React.Ref<HTMLDivElement>

redisinsight/ui/src/pages/workbench/components/wb-view/WBView/WBView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface Props {
3535
script: string
3636
items: CommandExecutionUI[]
3737
clearing: boolean
38+
processing: boolean
3839
setScript: (script: string) => void
3940
setScriptEl: Function
4041
scriptEl: Nullable<monacoEditor.editor.IStandaloneCodeEditor>
@@ -64,6 +65,7 @@ const WBView = (props: Props) => {
6465
script = '',
6566
items,
6667
clearing,
68+
processing,
6769
setScript,
6870
setScriptEl,
6971
scriptEl,
@@ -233,6 +235,7 @@ const WBView = (props: Props) => {
233235
<WBResultsWrapper
234236
items={items}
235237
clearing={clearing}
238+
processing={processing}
236239
activeMode={activeMode}
237240
activeResultsMode={resultsMode}
238241
scrollDivRef={scrollDivRef}

redisinsight/ui/src/pages/workbench/components/wb-view/WBViewWrapper.spec.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,18 @@ describe('WBViewWrapper', () => {
143143
expect(clearStoreActions(store.getActions().slice(-1))).toEqual(clearStoreActions([clearWbResults()]))
144144
})
145145

146+
it('should be disabled button when commands are processing', () => {
147+
(workbenchResultsSelector as jest.Mock).mockImplementation(() => ({
148+
items: [
149+
{ id: '1' },
150+
],
151+
processing: true
152+
}))
153+
render(<WBViewWrapper />)
154+
155+
expect(screen.getByTestId('clear-history-btn')).toBeDisabled()
156+
})
157+
146158
it('should not display clear results when with empty history', () => {
147159
(workbenchResultsSelector as jest.Mock).mockImplementation(() => ({
148160
items: [],

redisinsight/ui/src/pages/workbench/components/wb-view/WBViewWrapper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ let state: IState = {
7373
const WBViewWrapper = () => {
7474
const { instanceId } = useParams<{ instanceId: string }>()
7575

76-
const { loading, items, clearing } = useSelector(workbenchResultsSelector)
76+
const { loading, items, clearing, processing } = useSelector(workbenchResultsSelector)
7777
const { unsupportedCommands, blockingCommands } = useSelector(cliSettingsSelector)
7878
const { batchSize = PIPELINE_COUNT_DEFAULT } = useSelector(userSettingsConfigSelector) ?? {}
7979
const { cleanup: cleanupWB } = useSelector(userSettingsWBSelector)
@@ -298,6 +298,7 @@ const WBViewWrapper = () => {
298298
<WBView
299299
items={items}
300300
clearing={clearing}
301+
processing={processing}
301302
script={script}
302303
setScript={setScript}
303304
setScriptEl={setScriptEl}

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,23 @@
136136
background-color: transparent;
137137
transition: color ease 0.3s, background-color ease 0.3s;
138138

139-
.euiButtonEmpty__text,
140-
.euiText {
141-
transition: color ease 0.3s;
142-
color: var(--euiTextSubduedColor) !important;
143-
}
144-
145-
&:hover,
146-
&:focus {
147-
text-decoration: none !important;
148-
background-color: var(--hoverInListColorDarken);
149-
color: var(--htmlColor);
150-
139+
&:not([class*="isDisabled"]) {
151140
.euiButtonEmpty__text,
152141
.euiText {
153-
color: var(--htmlColor) !important;
142+
transition: color ease 0.3s;
143+
color: var(--euiTextSubduedColor) !important;
144+
}
145+
146+
&:hover,
147+
&:focus {
148+
text-decoration: none !important;
149+
background-color: var(--hoverInListColorDarken);
150+
color: var(--htmlColor);
151+
152+
.euiButtonEmpty__text,
153+
.euiText {
154+
color: var(--htmlColor) !important;
155+
}
154156
}
155157
}
156158
}

0 commit comments

Comments
 (0)