Skip to content

Commit 857fa51

Browse files
committed
Merge branch 'main' into feature/RI-4186-Upload_custom_tutorials
# Conflicts: # redisinsight/ui/src/components/upload-file/UploadFile.tsx
2 parents f381d33 + 9eb38af commit 857fa51

File tree

75 files changed

+1417
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1417
-73
lines changed

configs/webpack.config.web.prod.babel.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ export default merge(commonConfig, {
2525
target: 'web',
2626
entry: ['regenerator-runtime/runtime', './index.tsx'],
2727
output: {
28-
filename: 'js/bundle.[fullhash].min.js',
28+
filename: 'js/bundle.[name].min.js',
2929
path: resolve(__dirname, '../redisinsight/ui/dist'),
3030
publicPath: '/',
31+
chunkFilename: '[id].[chunkhash].js'
3132
},
3233
optimization: {
3334
minimize: true,
@@ -37,6 +38,34 @@ export default merge(commonConfig, {
3738
}),
3839
new CssMinimizerPlugin(),
3940
],
41+
runtimeChunk: 'single',
42+
splitChunks: {
43+
chunks: 'all',
44+
maxInitialRequests: Infinity,
45+
minSize: 0,
46+
cacheGroups: {
47+
reactVendor: {
48+
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
49+
name: "reactVendor"
50+
},
51+
elasticVendor: {
52+
test: /[\\/]node_modules[\\/](@elastic)[\\/]/,
53+
name: "elasticVendor"
54+
},
55+
monacoVendor: {
56+
test: /[\\/]node_modules[\\/](monaco-editor)[\\/]/,
57+
name: "monacoVendor"
58+
},
59+
utilityVendor: {
60+
test: /[\\/]node_modules[\\/](lodash)[\\/]/,
61+
name: "utilityVendor"
62+
},
63+
vendor: {
64+
test: /[\\/]node_modules[\\/](!@elastic)(!monaco-editor)(!lodash)[\\/]/,
65+
name: "vendor"
66+
},
67+
},
68+
},
4069
},
4170
plugins: [
4271
new MiniCssExtractPlugin({

redisinsight/about-panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ICON_PATH = app.isPackaged
77

88
export default {
99
applicationName: 'RedisInsight-v2',
10-
applicationVersion: app.getVersion() || '2.2.0',
10+
applicationVersion: app.getVersion() || '2.20.0',
1111
copyright: `Copyright © ${new Date().getFullYear()} Redis Ltd.`,
1212
iconPath: ICON_PATH,
1313
};

redisinsight/api/config/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default {
5656
tlsKey: process.env.SERVER_TLS_KEY,
5757
staticContent: !!process.env.SERVER_STATIC_CONTENT || false,
5858
buildType: process.env.BUILD_TYPE || 'ELECTRON',
59-
appVersion: process.env.APP_VERSION || '2.0.0',
59+
appVersion: process.env.APP_VERSION || '2.20.0',
6060
requestTimeout: parseInt(process.env.REQUEST_TIMEOUT, 10) || 25000,
6161
excludeRoutes: [],
6262
excludeAuthRoutes: [],

redisinsight/api/config/swagger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const SWAGGER_CONFIG: Omit<OpenAPIObject, 'paths'> = {
55
info: {
66
title: 'RedisInsight Backend API',
77
description: 'RedisInsight Backend API',
8-
version: '2.0.0',
8+
version: '2.20.0',
99
},
1010
tags: [],
1111
};

redisinsight/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "redisinsight",
33
"productName": "RedisInsight",
44
"private": true,
5-
"version": "2.18.0",
5+
"version": "2.20.0",
66
"description": "RedisInsight",
77
"main": "./main.prod.js",
88
"author": {

redisinsight/ui/src/components/analytics-tabs/constants.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ export const analyticsViewTabs: AnalyticsTabs[] = [
1414
{
1515
id: AnalyticsViewTab.ClusterDetails,
1616
label: 'Overview',
17-
onboard: ONBOARDING_FEATURES.ANALYTICS_OVERVIEW
17+
onboard: ONBOARDING_FEATURES?.ANALYTICS_OVERVIEW
1818
},
1919
{
2020
id: AnalyticsViewTab.DatabaseAnalysis,
2121
label: 'Database Analysis',
22-
onboard: ONBOARDING_FEATURES.ANALYTICS_DATABASE_ANALYSIS
22+
onboard: ONBOARDING_FEATURES?.ANALYTICS_DATABASE_ANALYSIS
2323
},
2424
{
2525
id: AnalyticsViewTab.SlowLog,
2626
label: 'Slow Log',
27-
onboard: ONBOARDING_FEATURES.ANALYTICS_SLOW_LOG
27+
onboard: ONBOARDING_FEATURES?.ANALYTICS_SLOW_LOG
2828
},
2929
]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react'
2+
import { render, screen, fireEvent } from 'uiSrc/utils/test-utils'
3+
4+
import CodeBlock from './CodeBlock'
5+
6+
const originalClipboard = { ...global.navigator.clipboard }
7+
describe('CodeBlock', () => {
8+
beforeEach(() => {
9+
// @ts-ignore
10+
global.navigator.clipboard = {
11+
writeText: jest.fn(),
12+
}
13+
})
14+
15+
afterEach(() => {
16+
jest.resetAllMocks()
17+
// @ts-ignore
18+
global.navigator.clipboard = originalClipboard
19+
})
20+
21+
it('should render', () => {
22+
expect(render(<CodeBlock>text</CodeBlock>)).toBeTruthy()
23+
})
24+
25+
it('should render proper content', () => {
26+
render(<CodeBlock data-testid="code">text</CodeBlock>)
27+
expect(screen.getByTestId('code')).toHaveTextContent('text')
28+
})
29+
30+
it('should not render copy button by default', () => {
31+
render(<CodeBlock data-testid="code">text</CodeBlock>)
32+
expect(screen.queryByTestId('copy-code-btn')).not.toBeInTheDocument()
33+
})
34+
35+
it('should copy proper text', () => {
36+
render(<CodeBlock data-testid="code" isCopyable>text</CodeBlock>)
37+
fireEvent.click(screen.getByTestId('copy-code-btn'))
38+
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('text')
39+
})
40+
41+
it('should copy proper text when children is ReactNode', () => {
42+
render(<CodeBlock data-testid="code" isCopyable><span>text2</span></CodeBlock>)
43+
fireEvent.click(screen.getByTestId('copy-code-btn'))
44+
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('text2')
45+
})
46+
})
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React, { HTMLAttributes, useMemo } from 'react'
2+
import cx from 'classnames'
3+
import { EuiButtonIcon, useInnerText } from '@elastic/eui'
4+
5+
import styles from './styles.module.scss'
6+
7+
export interface Props extends HTMLAttributes<HTMLPreElement> {
8+
children: React.ReactNode
9+
className?: string
10+
isCopyable?: boolean
11+
}
12+
13+
const CodeBlock = (props: Props) => {
14+
const { isCopyable, className, children, ...rest } = props
15+
const [innerTextRef, innerTextString] = useInnerText('')
16+
17+
const innerText = useMemo(
18+
() => innerTextString?.replace(/[\r\n?]{2}|\n\n/g, '\n') || '',
19+
[innerTextString]
20+
)
21+
22+
const handleCopyClick = () => {
23+
navigator?.clipboard?.writeText(innerText)
24+
}
25+
26+
return (
27+
<div className={cx(styles.wrapper, { [styles.isCopyable]: isCopyable })}>
28+
<pre className={cx(styles.pre, className)} ref={innerTextRef} {...rest}>{children}</pre>
29+
{isCopyable && (
30+
<EuiButtonIcon
31+
onClick={handleCopyClick}
32+
className={styles.copyBtn}
33+
iconType="copy"
34+
data-testid="copy-code-btn"
35+
aria-label="copy code"
36+
/>
37+
)}
38+
</div>
39+
)
40+
}
41+
42+
export default CodeBlock
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import CodeBlock from './CodeBlock'
2+
3+
export default CodeBlock
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.wrapper {
2+
position: relative;
3+
4+
&.isCopyable {
5+
.pre {
6+
padding: 8px 30px 8px 16px !important;
7+
}
8+
}
9+
10+
.pre {
11+
padding: 8px 16px !important;
12+
}
13+
14+
.copyBtn {
15+
position: absolute;
16+
top: 4px;
17+
right: 4px;
18+
}
19+
}

0 commit comments

Comments
 (0)