Skip to content

Commit d97b9f2

Browse files
authored
Merge pull request #3387 from RedisInsight/fe/bugfix/RI-5402-ai-assistant
#RI-5739 - change behaviour to unblock chatbot input
2 parents 41ca2e3 + 9862c3e commit d97b9f2

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

redisinsight/ui/src/components/oauth/oauth-jobs/OAuthJobs.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { RootState } from 'uiSrc/slices/store'
1010
import { loadInstances } from 'uiSrc/slices/instances/instances'
1111
import { INFINITE_MESSAGES, InfiniteMessagesIds } from 'uiSrc/components/notifications/components'
1212
import { CustomErrorCodes } from 'uiSrc/constants'
13+
import { setSSOFlow } from 'uiSrc/slices/instances/cloud'
1314
import OAuthJobs from './OAuthJobs'
1415

1516
jest.mock('react-redux', () => ({
@@ -130,6 +131,7 @@ describe('OAuthJobs', () => {
130131

131132
const expectedActions = [
132133
addErrorNotification({ response: { data: error } } as AxiosError),
134+
setSSOFlow(),
133135
removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress),
134136
]
135137
expect(clearStoreActions(store.getActions())).toEqual(
@@ -160,6 +162,7 @@ describe('OAuthJobs', () => {
160162

161163
const expectedActions = [
162164
addInfiniteNotification(INFINITE_MESSAGES.DATABASE_EXISTS()),
165+
setSSOFlow(),
163166
removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress),
164167
]
165168
expect(clearStoreActions(store.getActions())).toEqual(
@@ -190,6 +193,7 @@ describe('OAuthJobs', () => {
190193

191194
const expectedActions = [
192195
addInfiniteNotification(INFINITE_MESSAGES.DATABASE_EXISTS()),
196+
setSSOFlow(),
193197
removeInfiniteNotification(InfiniteMessagesIds.oAuthProgress),
194198
]
195199
expect(clearStoreActions(store.getActions())).toEqual(

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/assistance-chat/AssistanceChat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ const AssistanceChat = () => {
201201
onAgreementsDisplayed={handleAgreementsDisplay}
202202
agreements={!agreements ? ASSISTANCE_CHAT_AGREEMENTS : undefined}
203203
placeholder="Ask me about Redis"
204-
isDisabled={!!inProgressMessage}
204+
isDisabled={inProgressMessage?.content === ''}
205205
onSubmit={handleSubmit}
206206
/>
207207
</div>

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/expert-chat/ExpertChat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const ExpertChat = () => {
226226
<ChatForm
227227
onAgreementsDisplayed={handleAgreementsDisplay}
228228
agreements={!isAgreementsAccepted ? EXPERT_CHAT_AGREEMENTS : undefined}
229-
isDisabled={!instanceId || !!inProgressMessage}
229+
isDisabled={!instanceId || inProgressMessage?.content === ''}
230230
validation={getValidationMessage()}
231231
placeholder="Ask me to query your data (e.g. How many road bikes?)"
232232
onSubmit={handleSubmit}

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/welcome-ai-assistant/WelcomeAiAssistant.spec.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { cleanup, fireEvent, mockedStore, render, screen, act } from 'uiSrc/util
55
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
66
import { setSSOFlow } from 'uiSrc/slices/instances/cloud'
77
import { OAuthSocialAction, OAuthSocialSource } from 'uiSrc/slices/interfaces'
8-
import { signIn } from 'uiSrc/slices/oauth/cloud'
8+
import { setOAuthCloudSource, signIn } from 'uiSrc/slices/oauth/cloud'
99
import WelcomeAiAssistant from './WelcomeAiAssistant'
1010

1111
jest.mock('uiSrc/telemetry', () => ({
@@ -49,7 +49,11 @@ describe('WelcomeAiAssistant', () => {
4949
fireEvent.click(screen.getByTestId('google-oauth'))
5050
})
5151

52-
expect(store.getActions()).toEqual([signIn(), setSSOFlow(OAuthSocialAction.SignIn)])
52+
expect(store.getActions()).toEqual([
53+
signIn(),
54+
setSSOFlow(OAuthSocialAction.SignIn),
55+
setOAuthCloudSource(OAuthSocialSource.AiChat)
56+
])
5357

5458
expect(sendEventTelemetry).toBeCalledWith({
5559
event: TelemetryEvent.CLOUD_SIGN_IN_SOCIAL_ACCOUNT_SELECTED,

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/welcome-ai-assistant/WelcomeAiAssistant.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { OAuthAgreement, OAuthSocialButtons } from 'uiSrc/components/oauth/share
66
import { OAuthSocialAction, OAuthSocialSource } from 'uiSrc/slices/interfaces'
77
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
88
import { setSSOFlow } from 'uiSrc/slices/instances/cloud'
9-
import { setSocialDialogState } from 'uiSrc/slices/oauth/cloud'
9+
import { setOAuthCloudSource } from 'uiSrc/slices/oauth/cloud'
1010
import styles from './styles.module.scss'
1111

1212
const WelcomeAiAssistant = () => {
1313
const dispatch = useDispatch()
1414

1515
const handleSsoClick = (accountOption: string) => {
1616
dispatch(setSSOFlow(OAuthSocialAction.SignIn))
17-
dispatch(setSocialDialogState(OAuthSocialSource.AiChat))
17+
dispatch(setOAuthCloudSource(OAuthSocialSource.AiChat))
1818

1919
sendEventTelemetry({
2020
event: TelemetryEvent.CLOUD_SIGN_IN_SOCIAL_ACCOUNT_SELECTED,

redisinsight/ui/src/electron/components/ConfigOAuth/ConfigOAuth.spec.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ describe('ConfigOAuth', () => {
4949
})
5050

5151
it('should call proper actions on success', () => {
52+
(cloudSelector as jest.Mock).mockReturnValue({
53+
ssoFlow: 'signIn'
54+
})
55+
5256
window.app?.cloudOauthCallback.mockImplementation((cb: any) => cb(undefined, { status: CloudAuthStatus.Succeed }))
5357
render(<ConfigOAuth />)
5458

@@ -63,6 +67,10 @@ describe('ConfigOAuth', () => {
6367
})
6468

6569
it('should call proper actions on failed', () => {
70+
(cloudSelector as jest.Mock).mockReturnValue({
71+
ssoFlow: 'signIn'
72+
})
73+
6674
window.app?.cloudOauthCallback.mockImplementation((cb: any) =>
6775
cb(
6876
undefined, {
@@ -88,7 +96,11 @@ describe('ConfigOAuth', () => {
8896
expect(store.getActions()).toEqual(expectedActions)
8997
})
9098

91-
it('should fetch plans by default', () => {
99+
it('should fetch plans with create flow', () => {
100+
(cloudSelector as jest.Mock).mockReturnValue({
101+
ssoFlow: 'create'
102+
})
103+
92104
const fetchUserInfoMock = jest.fn().mockImplementation((onSuccessAction: () => void) => () => onSuccessAction());
93105
(fetchUserInfo as jest.Mock).mockImplementation(fetchUserInfoMock)
94106

@@ -136,7 +148,8 @@ describe('ConfigOAuth', () => {
136148

137149
it('should call create free job after success with recommended settings', () => {
138150
(cloudSelector as jest.Mock).mockReturnValue({
139-
isRecommendedSettings: true
151+
isRecommendedSettings: true,
152+
ssoFlow: 'create'
140153
})
141154

142155
const fetchUserInfoMock = jest.fn().mockImplementation((onSuccessAction: () => void) => () => onSuccessAction());

redisinsight/ui/src/electron/components/ConfigOAuth/ConfigOAuth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ConfigOAuth = () => {
2626

2727
const ssoFlowRef = useRef(ssoFlow)
2828
const isRecommendedSettingsRef = useRef(isRecommendedSettings)
29-
const isFlowStarted = useRef(false)
29+
const isFlowStarted = useRef(!!ssoFlow)
3030

3131
const history = useHistory()
3232
const dispatch = useDispatch()

0 commit comments

Comments
 (0)