Skip to content

Commit b5ccb09

Browse files
#3977 - demo comments resolve
1 parent 9cd2006 commit b5ccb09

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

redisinsight/api/src/modules/database-analysis/models/recommendation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Recommendation {
1919

2020
@ApiPropertyOptional({
2121
description: 'User vote',
22-
example: 'Amazing',
22+
example: 'useful',
2323
})
2424
@Expose()
2525
vote?: string;

redisinsight/api/src/modules/database-analysis/providers/database-analysis.provider.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ const mockDatabaseAnalysis = {
152152

153153
const mockDatabaseAnalysisWithVote = {
154154
...mockDatabaseAnalysis,
155-
recommendations: [{ name: 'luaScript', vote: 'amazing' }],
155+
recommendations: [{ name: 'luaScript', vote: 'useful' }],
156156
} as DatabaseAnalysis;
157157

158158
const mockRecommendationVoteDto: RecommendationVoteDto = {
159159
name: 'luaScript',
160-
vote: 'amazing',
160+
vote: 'useful',
161161
};
162162

163163
describe('DatabaseAnalysisProvider', () => {

redisinsight/api/test/api/database-analysis/PATCH-databases-id-analysis.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('PATCH /databases/:instanceId/analysis/:id', () => {
5353
name: 'Should add vote for RTS recommendation',
5454
data: {
5555
name: 'luaScript',
56-
vote: 'amazing',
56+
vote: 'useful',
5757
},
5858
statusCode: 200,
5959
responseSchema,

redisinsight/api/test/helpers/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ export const constants = {
516516

517517
TEST_LUA_SCRIPT_VOTE_RECOMMENDATION: {
518518
name: RECOMMENDATION_NAMES.LUA_SCRIPT,
519-
vote: 'amazing',
519+
vote: 'useful',
520520
},
521521
// etc...
522522
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export enum Vote {
2-
DoubleLike = 'amazing',
2+
DoubleLike = 'very useful',
33
Like = 'useful',
44
Dislike = 'not useful'
55
}

redisinsight/ui/src/pages/databaseAnalysis/components/recommendation-voting/RecommendationVoting.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ describe('RecommendationVoting', () => {
3939
expect(render(<RecommendationVoting {...instance(mockedProps)} />)).toBeTruthy()
4040
})
4141

42-
it('should call "setRecommendationVote" action be called after click "amazing-vote-btn"', () => {
42+
it('should call "setRecommendationVote" action be called after click "very-useful-vote-btn"', () => {
4343
render(<RecommendationVoting {...instance(mockedProps)} />)
44-
fireEvent.click(screen.getByTestId('amazing-vote-btn'))
44+
fireEvent.click(screen.getByTestId('very-useful-vote-btn'))
4545

4646
const expectedActions = [setRecommendationVote()]
4747
expect(store.getActions()).toEqual(expectedActions)
@@ -75,9 +75,9 @@ describe('RecommendationVoting', () => {
7575
})
7676

7777
it('should render component where all buttons are disabled"', async () => {
78-
render(<RecommendationVoting {...instance(mockedProps)} vote="amazing" />)
78+
render(<RecommendationVoting {...instance(mockedProps)} vote="useful" />)
7979

80-
expect(screen.getByTestId('amazing-vote-btn')).toBeDisabled()
80+
expect(screen.getByTestId('very-useful-vote-btn')).toBeDisabled()
8181
expect(screen.getByTestId('useful-vote-btn')).toBeDisabled()
8282
expect(screen.getByTestId('not-useful-vote-btn')).toBeDisabled()
8383
})

redisinsight/ui/src/pages/databaseAnalysis/components/recommendation-voting/RecommendationVoting.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react'
2-
import { useDispatch } from 'react-redux'
2+
import { useDispatch, useSelector } from 'react-redux'
33
import cx from 'classnames'
44
import {
55
EuiButton,
@@ -11,6 +11,7 @@ import {
1111
EuiIcon,
1212
EuiLink,
1313
} from '@elastic/eui'
14+
import { userSettingsConfigSelector } from 'uiSrc/slices/user/user-settings'
1415
import { putRecommendationVote } from 'uiSrc/slices/analytics/dbAnalysis'
1516
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1617
import { EXTERNAL_LINKS } from 'uiSrc/constants/links'
@@ -25,6 +26,7 @@ import styles from './styles.module.scss'
2526
export interface Props { vote?: Vote, name: string }
2627

2728
const RecommendationVoting = ({ vote, name }: Props) => {
29+
const config = useSelector(userSettingsConfigSelector)
2830
const [isPopoverOpen, setIsPopoverOpen] = useState(false)
2931
const dispatch = useDispatch()
3032

@@ -46,29 +48,33 @@ const RecommendationVoting = ({ vote, name }: Props) => {
4648
dispatch(putRecommendationVote(name, vote, onSuccessVoted))
4749
}
4850

51+
const getTooltipContent = (content: string) => (config?.agreements?.analytics
52+
? content
53+
: 'Enable Analytics on the Settings page to vote for a recommendation')
54+
4955
return (
5056
<EuiFlexGroup alignItems="center" className={styles.votingContainer}>
5157
<EuiText size="m">Rate Recommendation</EuiText>
5258
<div className={styles.vote}>
5359
<EuiToolTip
54-
content="Amazing"
60+
content={getTooltipContent('Very Useful')}
5561
position="bottom"
5662
>
5763
<EuiButtonIcon
58-
disabled={!!vote}
64+
disabled={!!vote || !config?.agreements?.analytics}
5965
iconType={DoubleLikeIcon}
6066
className={cx(styles.voteBtn, { [styles.selected]: vote === Vote.DoubleLike })}
61-
aria-label="vote amazing"
62-
data-testid="amazing-vote-btn"
67+
aria-label="vote very useful"
68+
data-testid="very-useful-vote-btn"
6369
onClick={() => handleClick(name, Vote.DoubleLike)}
6470
/>
6571
</EuiToolTip>
6672
<EuiToolTip
67-
content="Useful"
73+
content={getTooltipContent('Useful')}
6874
position="bottom"
6975
>
7076
<EuiButtonIcon
71-
disabled={!!vote}
77+
disabled={!!vote || !config?.agreements?.analytics}
7278
iconType={LikeIcon}
7379
className={cx(styles.voteBtn, { [styles.selected]: vote === Vote.Like })}
7480
aria-label="vote useful"
@@ -77,7 +83,7 @@ const RecommendationVoting = ({ vote, name }: Props) => {
7783
/>
7884
</EuiToolTip>
7985
<EuiToolTip
80-
content="Not Useful"
86+
content={getTooltipContent('Not Useful')}
8187
position="bottom"
8288
>
8389
<EuiPopover
@@ -89,7 +95,7 @@ const RecommendationVoting = ({ vote, name }: Props) => {
8995
panelClassName={cx('euiToolTip', 'popoverLikeTooltip', styles.popover)}
9096
button={(
9197
<EuiButtonIcon
92-
disabled={!!vote}
98+
disabled={!!vote || !config?.agreements?.analytics}
9399
iconType={DislikeIcon}
94100
className={cx(styles.voteBtn, { [styles.selected]: vote === Vote.Dislike })}
95101
aria-label="vote not useful"

0 commit comments

Comments
 (0)