Skip to content

Conversation

GnaneshKunal
Copy link
Contributor

No description provided.

import Chart from './components/Chart/Chart'
import ChartResultView from './components/Chart/ChartResultView'

import { TimeSeries, YAxisConfig, ChartConfig, AxisScale, GraphMode } from './components/Chart/interfaces'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move interface after imports.

/* eslint-disable react/jsx-filename-extension */
import React, {useState} from 'react'


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove one empty line

const App = (props: Props) => {
const { command = '', result: [{ response = '', status = '' } = {}] = [] } = props

const data= response1.result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add space after data

* chartConfig={chartConfig}
* data={data as any}
* />
* ) */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove comment blocks

* }

* return <TableResult query={command} result={result} /> */
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same.
Also will be good to handle fail status

import ChartConfigForm from './ChartConfigForm'
import { TimeSeries, YAxisConfig, ChartConfig, AxisScale, GraphMode } from './interfaces'
import Chart from './Chart'
import { EuiSpacer } from '@elastic/eui'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, sort imports

</div>
)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please refactor this component to function component

export const TIMESERIES_HISTORY_CONTAINER_NAME = 'REDIS_TIMESERIES'

export const AUTO_UPDATE_TIMER_DEFAULT_VALUE = 5000 // time in milliseconds
export const AUTO_UPDATE_NUM_SAMPLES_DEFAULT_VALUE = 50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import these constants from './constants'

check: EuiIconCheck,
})

import { EuiProvider } from '@elastic/eui';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, sort imports

import { icon as EuiIconArrowRight } from '@elastic/eui/es/components/icon/assets/arrow_right';
import { icon as EuiIconArrowDown } from '@elastic/eui/es/components/icon/assets/arrow_down';
import { icon as EuiIconCross } from '@elastic/eui/es/components/icon/assets/cross';
import { icon as EuiIconCheck } from '@elastic/eui/es/components/icon/assets/check';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, remove semicolons

Copy link
Contributor

@rsergeenko rsergeenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could you please, check the plugin for responsive design?

import React, { useRef, useEffect } from 'react'
import Plotly, { Layout } from 'plotly.js-dist-min'
import { Legend, LayoutAxis, PlotData } from 'plotly.js'
import moment from 'moment'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moment.js is depricated
Could you replace it to date-fns?


const isDarkTheme = document.body.classList.contains('theme_DARK')

export default function Chart(props: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an interface for props?

{ displayModeBar: false, autosizable: true, responsive: true, setBackground: () => 'transparent', },
)
chartContainer.current.on('plotly_hover', function (eventdata) {
var points = eventdata.points[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change var to const
and at the line below

})),
Object.keys((chartContainer.current)._fullLayout._plots))
})
chartContainer.current.on('plotly_relayout', function (eventdata) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add an interface for eventdata?
And for others chartContainer.current handlers

})),
Object.keys((chartContainer.current)._fullLayout._plots))
})
chartContainer.current.on('plotly_relayout', function (eventdata) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move 'plotly_relayout', 'plotly_hover' and 'plotly_doubleclick' to enum

chartState: LAYOUT_STATE
}

export default class ChartResultView extends React.Component<ChartResultViewProps, ChartResultViewState> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite React.Component to Functional Component

@@ -0,0 +1,264 @@
export const WATERMARK_OPTIONS = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move all constants from this file to constants.ts file

}

function getMimeTypeOfDataURI(uri: DataURI) {
return uri.split(/[:;,]/g)[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move RegExp to constants?
and please add Optional chaining operator before [1], this is not safety
uri.split(...).?[1]

}
}

export function hexToRGBA(hex: string, opacity: number): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite this function. It's hard to read

const { command = '', data: result = [] } = props
render(
<App command={command} result={result} />,
document.getElementById('app'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move second round bracket to the next line

@egor-zalenski
Copy link
Contributor

Also could you add Unit tests for utils?
The better way is like in this test.
Create an array with input and output, and then compare them

https://github.com/RedisInsight/RedisInsight/blob/main/redisinsight/ui/src/utils/tests/formatTypes.spec.ts

@egor-zalenski
Copy link
Contributor

@GnaneshKunal
We have to merge this pr to main without fix pr comments for release.
Please fix all comments in the nearest feature

# Conflicts:
#	scripts/build-statics.cmd
#	scripts/build-statics.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants