Skip to content

Commit 365acc3

Browse files
Merge pull request #2510 from RedisInsight/fe/feature/RI-4888_cloud-link
#RI-4888 - add link to cloud console
2 parents 455dad2 + 6892d65 commit 365acc3

File tree

6 files changed

+68
-8
lines changed

6 files changed

+68
-8
lines changed
Lines changed: 4 additions & 0 deletions
Loading

redisinsight/ui/src/constants/links.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export const EXTERNAL_LINKS = {
66
recommendationFeedback: 'https://github.com/RedisInsight/RedisInsight/issues/new/choose',
77
guidesRepo: 'https://github.com/RedisInsight/Tutorials',
88
redisStack: 'https://redis.io/docs/about/about-stack/',
9+
cloudConsole: 'https://app.redislabs.com/#/databases'
910
}

redisinsight/ui/src/pages/home/components/DatabasesListComponent/DatabasesListWrapper.spec.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const mockInstances = [
6363
caCertId: '70b95d32-c19d-4311-bb24-e684af12cf15',
6464
clientCertPairId: '70b95d32-c19d-4311-b23b24-e684af12cf15',
6565
},
66+
cloudDetails: {}
6667
},
6768
]
6869

@@ -163,5 +164,29 @@ describe('DatabasesListWrapper', () => {
163164
numberOfDatabases: 1
164165
}
165166
})
167+
168+
sendEventTelemetry.mockRestore()
169+
})
170+
171+
it('should show link to cloud console', () => {
172+
render(<DatabasesListWrapper {...instance(mockedProps)} />)
173+
174+
expect(screen.queryByTestId(`cloud-link-${mockInstances[0].id}`)).not.toBeInTheDocument()
175+
expect(screen.getByTestId(`cloud-link-${mockInstances[1].id}`)).toBeInTheDocument()
176+
})
177+
178+
it('should call proper telemetry on click cloud console ling', () => {
179+
const sendEventTelemetryMock = jest.fn()
180+
181+
sendEventTelemetry.mockImplementation(() => sendEventTelemetryMock)
182+
render(<DatabasesListWrapper {...instance(mockedProps)} />)
183+
184+
fireEvent.click(screen.getByTestId(`cloud-link-${mockInstances[1].id}`))
185+
186+
expect(sendEventTelemetry).toBeCalledWith({
187+
event: TelemetryEvent.CLOUD_LINK_CLICKED,
188+
})
189+
190+
sendEventTelemetry.mockRestore()
166191
})
167192
})

redisinsight/ui/src/pages/home/components/DatabasesListComponent/DatabasesListWrapper.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
EuiButtonIcon,
33
EuiIcon,
4+
EuiLink,
45
EuiTableFieldDataColumnType,
56
EuiText,
67
EuiTextColor,
@@ -16,19 +17,16 @@ import AutoSizer from 'react-virtualized-auto-sizer'
1617
import { saveAs } from 'file-saver'
1718
import {
1819
checkConnectToInstanceAction,
19-
deleteInstancesAction, exportInstancesAction,
20+
deleteInstancesAction,
21+
exportInstancesAction,
2022
instancesSelector,
2123
setConnectedInstanceId,
2224
} from 'uiSrc/slices/instances/instances'
23-
import {
24-
CONNECTION_TYPE_DISPLAY,
25-
ConnectionType,
26-
Instance,
27-
} from 'uiSrc/slices/interfaces'
25+
import { CONNECTION_TYPE_DISPLAY, ConnectionType, Instance, } from 'uiSrc/slices/interfaces'
2826
import { resetKeys } from 'uiSrc/slices/browser/keys'
2927
import { resetRedisearchKeysData } from 'uiSrc/slices/browser/redisearch'
3028
import { PageNames, Pages, Theme } from 'uiSrc/constants'
31-
import { sendEventTelemetry, TelemetryEvent, getRedisModulesSummary } from 'uiSrc/telemetry'
29+
import { getRedisModulesSummary, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
3230
import { ThemeContext } from 'uiSrc/contexts/themeContext'
3331
import { ShowChildByCondition } from 'uiSrc/components'
3432
import { formatLongName, getDbIndex, lastConnectionFormat, Nullable, replaceSpaces } from 'uiSrc/utils'
@@ -40,6 +38,8 @@ import RediStackDarkMin from 'uiSrc/assets/img/modules/redistack/RediStackDark-m
4038
import RediStackLightMin from 'uiSrc/assets/img/modules/redistack/RediStackLight-min.svg'
4139
import RediStackLightLogo from 'uiSrc/assets/img/modules/redistack/RedisStackLogoLight.svg'
4240
import RediStackDarkLogo from 'uiSrc/assets/img/modules/redistack/RedisStackLogoDark.svg'
41+
import { ReactComponent as CloudLinkIcon } from 'uiSrc/assets/img/oauth/cloud_link.svg'
42+
import { EXTERNAL_LINKS } from 'uiSrc/constants/links'
4343
import DatabasesList from './DatabasesList/DatabasesList'
4444

4545
import styles from './styles.module.scss'
@@ -201,6 +201,12 @@ const DatabasesListWrapper = ({
201201
))
202202
}
203203

204+
const handleClickGoToCloud = () => {
205+
sendEventTelemetry({
206+
event: TelemetryEvent.CLOUD_LINK_CLICKED,
207+
})
208+
}
209+
204210
const columnsFull: EuiTableFieldDataColumnType<Instance>[] = [
205211
{
206212
field: 'name',
@@ -350,11 +356,26 @@ const DatabasesListWrapper = ({
350356
{
351357
field: 'controls',
352358
className: 'column_controls',
353-
width: '100px',
359+
width: '120px',
354360
name: '',
355361
render: function Actions(_act: any, instance: Instance) {
356362
return (
357363
<>
364+
{instance.cloudDetails && (
365+
<EuiToolTip
366+
content="Go to Redis Enterprise Cloud"
367+
>
368+
<EuiLink
369+
target="_blank"
370+
external={false}
371+
href={EXTERNAL_LINKS.cloudConsole}
372+
onClick={handleClickGoToCloud}
373+
data-testid={`cloud-link-${instance.id}`}
374+
>
375+
<EuiIcon type={CloudLinkIcon} className={styles.cloudIcon} />
376+
</EuiLink>
377+
</EuiToolTip>
378+
)}
358379
<EuiButtonIcon
359380
iconType="pencil"
360381
className="editInstanceBtn"

redisinsight/ui/src/pages/home/components/DatabasesListComponent/styles.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,11 @@ $breakpoint-l: 1400px;
110110
padding-left: 5px !important;
111111
}
112112
}
113+
114+
.cloudIcon {
115+
:global {
116+
path {
117+
fill: var(--euiTextSubduedColor);
118+
}
119+
}
120+
}

redisinsight/ui/src/telemetry/events.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export enum TelemetryEvent {
258258
CLOUD_SIGN_IN_PROVIDER_FORM_CLOSED = 'CLOUD_SIGN_IN_PROVIDER_FORM_CLOSED',
259259
CLOUD_IMPORT_DATABASES_CLICKED = 'CLOUD_IMPORT_DATABASES_CLICKED',
260260
CLOUD_API_KEY_REMOVED = 'CLOUD_API_KEY_REMOVED',
261+
CLOUD_LINK_CLICKED = 'CLOUD_LINK_CLICKED',
261262

262263
TRIGGERS_AND_FUNCTIONS_LIBRARIES_SORTED = 'TRIGGERS_AND_FUNCTIONS_LIBRARIES_SORTED',
263264
TRIGGERS_AND_FUNCTIONS_LIBRARY_LIST_REFRESH_CLICKED = 'TRIGGERS_AND_FUNCTIONS_LIBRARY_LIST_REFRESH_CLICKED',

0 commit comments

Comments
 (0)