Skip to content

Commit 7c0f409

Browse files
Merge pull request #3073 from RedisInsight/fe/feature/RI-5445
#RI-5445 - do not display run commands confirmation for free databases
2 parents 26f81dd + bef02e9 commit 7c0f409

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/Code/Code.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface Props {
1919
}
2020

2121
const Code = ({ children, params = '', label, path, ...rest }: Props) => {
22-
const { provider, modules = [] } = useSelector(connectedInstanceSelector)
22+
const { provider, modules = [], isFreeDb } = useSelector(connectedInstanceSelector)
2323

2424
const { search } = useLocation()
2525
const { setScript } = useContext(EnablementAreaContext)
@@ -82,6 +82,7 @@ const Code = ({ children, params = '', label, path, ...rest }: Props) => {
8282
modules={modules}
8383
label={label}
8484
params={parsedParams}
85+
isShowConfirmation={!isFreeDb}
8586
{...rest}
8687
/>
8788
)

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/CodeButtonBlock/CodeButtonBlock.spec.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ describe('CodeButtonBlock', () => {
8989
expect(screen.queryByTestId(`run-btn-${label}`)).not.toBeInTheDocument()
9090
})
9191

92+
it('should not show confirmation popover with option', async () => {
93+
render(
94+
<CodeButtonBlock
95+
{...instance(mockedProps)}
96+
label={label}
97+
onApply={jest.fn}
98+
params={{ run_confirmation: 'true' }}
99+
content={simpleContent}
100+
isShowConfirmation={false}
101+
/>
102+
)
103+
await act(() => {
104+
fireEvent.click(screen.getByTestId(`run-btn-${label}`))
105+
})
106+
107+
expect(screen.queryByTestId('tutorial-popover-apply-run')).not.toBeInTheDocument()
108+
})
109+
92110
it('should go to home page after click on change db', async () => {
93111
const pushMock = jest.fn()
94112
reactRouterDom.useHistory = jest.fn().mockReturnValue({ push: pushMock })

redisinsight/ui/src/components/database-side-panels/panels/enablement-area/EnablementArea/components/CodeButtonBlock/CodeButtonBlock.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface Props {
2828
isLoading?: boolean
2929
className?: string
3030
params?: CodeButtonParams
31+
isShowConfirmation?: boolean
3132
}
3233

3334
const FINISHED_COMMAND_INDICATOR_TIME_MS = 5_000
@@ -41,6 +42,7 @@ const CodeButtonBlock = (props: Props) => {
4142
content,
4243
onCopy,
4344
modules = [],
45+
isShowConfirmation = true,
4446
...rest
4547
} = props
4648

@@ -51,10 +53,6 @@ const CodeButtonBlock = (props: Props) => {
5153

5254
const { instanceId } = useParams<{ instanceId: string }>()
5355

54-
const isNotShowConfirmation = getDBConfigStorageField(
55-
instanceId,
56-
ConfigDBStorageItem.notShowConfirmationRunTutorial
57-
)
5856
const isButtonHasConfirmation = params?.run_confirmation === BooleanParams.true
5957
const isRunButtonHidden = params?.executable === BooleanParams.false
6058
const [notLoadedModule] = getUnsupportedModulesFromQuery(modules, content)
@@ -66,6 +64,11 @@ const CodeButtonBlock = (props: Props) => {
6664
})
6765
}, [])
6866

67+
const getIsShowConfirmation = () => isShowConfirmation && !getDBConfigStorageField(
68+
instanceId,
69+
ConfigDBStorageItem.notShowConfirmationRunTutorial
70+
)
71+
6972
const handleCopy = () => {
7073
const query = getCommandsForExecution(content)?.join('\n') || ''
7174
navigator?.clipboard?.writeText(query)
@@ -82,7 +85,10 @@ const CodeButtonBlock = (props: Props) => {
8285
}
8386

8487
const handleRunClicked = () => {
85-
if (!instanceId || notLoadedModule || (!isNotShowConfirmation && isButtonHasConfirmation)) {
88+
if (!instanceId
89+
|| notLoadedModule
90+
|| (getIsShowConfirmation() && isButtonHasConfirmation)
91+
) {
8692
setIsPopoverOpen((v) => !v)
8793
return
8894
}

redisinsight/ui/src/slices/instances/instances.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ const instancesSlice = createSlice({
190190
state.connectedInstance = payload
191191
state.connectedInstance.loading = false
192192
state.connectedInstance.isRediStack = isRediStack || false
193+
state.connectedInstance.isFreeDb = payload.cloudDetails?.free || false
193194
state.connectedInstance.db = sessionStorageService.get(`${BrowserStorageItem.dbIndex}${payload.id}`) ?? payload.db
194195
},
195196

0 commit comments

Comments
 (0)