clusters"s table styles was fixed, added hyphens to breadcrumbs, URP … (#1384)

* clusters"s table styles was fixed, added hyphens to breadcrumbs, URP is not abbreviated and ISR is abbreviated already and "f0" was changed to 0

* styled component name for cluster table was changed

* adding tests for clusterwidget cells, adding title for ISR and bringing back changes in breadcrumb regarding hyphens

* fixing clusterWidget test

* fixing double scroll issue inside Topics > Messages > Content for large message content

* bring back last changes

* changing styles for scrollbar

* added required changes from reviewers and removed enzyme from clusterWidgets test
This commit is contained in:
NelyDavtyan 2022-01-19 16:14:47 +04:00 committed by GitHub
parent 8c99cdfb50
commit 3291b85838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 57 additions and 28 deletions

View file

@ -37,7 +37,7 @@ const Overview: React.FC<OverviewProps> = ({
{runningTasksCount} {runningTasksCount}
</Metrics.Indicator> </Metrics.Indicator>
<Metrics.Indicator label="Tasks Failed" isAlert> <Metrics.Indicator label="Tasks Failed" isAlert>
f{failedTasksCount} {failedTasksCount}
</Metrics.Indicator> </Metrics.Indicator>
</Metrics.Section> </Metrics.Section>
</Metrics.Wrapper> </Metrics.Wrapper>

View file

@ -226,7 +226,6 @@ exports[`Overview view matches snapshot 1`] = `
</svg> </svg>
</div> </div>
<span> <span>
f
2 2
</span> </span>
</div> </div>

View file

@ -1,5 +1,15 @@
import styled from 'styled-components'; import styled from 'styled-components';
interface TableCellProps {
maxWidth?: string;
}
export const SwitchWrapper = styled.div` export const SwitchWrapper = styled.div`
padding: 16px; padding: 16px;
`; `;
export const TableCell = styled.td.attrs({ role: 'cells' })<TableCellProps>`
padding: 16px;
word-break: break-word;
max-width: ${(props) => props.maxWidth};
`;

View file

@ -84,24 +84,26 @@ const ClustersWidget: React.FC<Props> = ({
<tbody> <tbody>
{chunkItem.data.map((cluster) => ( {chunkItem.data.map((cluster) => (
<tr key={cluster.name}> <tr key={cluster.name}>
<td> <S.TableCell maxWidth="99px">
{cluster.readOnly && <Tag color="blue">readonly</Tag>}{' '} {cluster.readOnly && <Tag color="blue">readonly</Tag>}{' '}
{cluster.name} {cluster.name}
</td> </S.TableCell>
<td>{cluster.version}</td> <S.TableCell maxWidth="99px">{cluster.version}</S.TableCell>
<td>{cluster.brokerCount}</td> <S.TableCell maxWidth="99px">{cluster.brokerCount}</S.TableCell>
<td>{cluster.onlinePartitionCount}</td> <S.TableCell maxWidth="78px">
<td> {cluster.onlinePartitionCount}
</S.TableCell>
<S.TableCell maxWidth="60px">
<NavLink to={clusterTopicsPath(cluster.name)}> <NavLink to={clusterTopicsPath(cluster.name)}>
{cluster.topicCount} {cluster.topicCount}
</NavLink> </NavLink>
</td> </S.TableCell>
<td> <S.TableCell maxWidth="85px">
<BytesFormatted value={cluster.bytesInPerSec} /> <BytesFormatted value={cluster.bytesInPerSec} />
</td> </S.TableCell>
<td> <S.TableCell maxWidth="85px">
<BytesFormatted value={cluster.bytesOutPerSec} /> <BytesFormatted value={cluster.bytesOutPerSec} />
</td> </S.TableCell>
</tr> </tr>
))} ))}
</tbody> </tbody>

View file

@ -31,4 +31,10 @@ describe('ClustersWidget', () => {
it('when cluster is read-only', () => { it('when cluster is read-only', () => {
expect(screen.getByText('readonly')).toBeInTheDocument(); expect(screen.getByText('readonly')).toBeInTheDocument();
}); });
it('render clusterWidget cells', () => {
const cells = screen.getAllByRole('cells');
expect(cells.length).toBe(14);
expect(cells[0]).toHaveStyle('max-width: 99px');
});
}); });

View file

@ -17,7 +17,7 @@ const LatestVersionItem: React.FC<LatestVersionProps> = ({
<LatestVersionWrapper> <LatestVersionWrapper>
<div> <div>
<h1>Relevant version</h1> <h1>Relevant version</h1>
<JSONViewer data={schema} /> <JSONViewer data={schema} maxLines={28} />
</div> </div>
<div data-testid="meta-data"> <div data-testid="meta-data">
<div> <div>

View file

@ -8,6 +8,7 @@ exports[`LatestVersionItem matches snapshot 1`] = `
</h1> </h1>
<JSONViewer <JSONViewer
data="{\\"type\\":\\"record\\",\\"name\\":\\"MyRecord1\\",\\"namespace\\":\\"com.mycompany\\",\\"fields\\":[{\\"name\\":\\"id\\",\\"type\\":\\"long\\"}]}" data="{\\"type\\":\\"record\\",\\"name\\":\\"MyRecord1\\",\\"namespace\\":\\"com.mycompany\\",\\"fields\\":[{\\"name\\":\\"id\\",\\"type\\":\\"long\\"}]}"
maxLines={28}
/> />
</div> </div>
<div <div

View file

@ -57,7 +57,8 @@ const Overview: React.FC<Props> = ({
<Metrics.RedText>{underReplicatedPartitions}</Metrics.RedText> <Metrics.RedText>{underReplicatedPartitions}</Metrics.RedText>
</Metrics.Indicator> </Metrics.Indicator>
<Metrics.Indicator <Metrics.Indicator
label="In Sync Replicas" label="ISR"
title="In Sync Replicas"
isAlert isAlert
alertType={inSyncReplicas === replicas ? 'success' : 'error'} alertType={inSyncReplicas === replicas ? 'success' : 'error'}
> >

View file

@ -3,11 +3,12 @@ import JSONEditor from 'components/common/JSONEditor/JSONEditor';
import { StyledWrapper } from './StyledWrapper.styled'; import { StyledWrapper } from './StyledWrapper.styled';
interface FullMessageProps { export interface FullMessageProps {
data: string; data: string;
maxLines?: number;
} }
const JSONViewer: React.FC<FullMessageProps> = ({ data }) => { const JSONViewer: React.FC<FullMessageProps> = ({ data, maxLines }) => {
try { try {
if (data.trim().startsWith('{')) { if (data.trim().startsWith('{')) {
return ( return (
@ -18,7 +19,7 @@ const JSONViewer: React.FC<FullMessageProps> = ({ data }) => {
value={JSON.stringify(JSON.parse(data), null, '\t')} value={JSON.stringify(JSON.parse(data), null, '\t')}
setOptions={{ setOptions={{
showLineNumbers: false, showLineNumbers: false,
maxLines: 40, maxLines,
showGutter: false, showGutter: false,
}} }}
readOnly readOnly

View file

@ -3,7 +3,4 @@ import styled from 'styled-components';
export const StyledWrapper = styled.div` export const StyledWrapper = styled.div`
background-color: #f9fafa; background-color: #f9fafa;
padding: 8px 16px; padding: 8px 16px;
max-height: 516px;
overflow-y: scroll;
overflow-wrap: anywhere;
`; `;

View file

@ -1,18 +1,30 @@
import { shallow } from 'enzyme';
import React from 'react'; import React from 'react';
import JSONViewer from 'components/common/JSONViewer/JSONViewer'; import JSONViewer, {
FullMessageProps,
} from 'components/common/JSONViewer/JSONViewer';
import { render } from 'lib/testHelpers';
import { screen } from '@testing-library/react';
const data = { a: 1 }; const data = { a: 1 };
const maxLines = 28;
describe('JSONViewer component', () => { describe('JSONViewer component', () => {
const setupComponent = (props: FullMessageProps) =>
render(<JSONViewer {...props} />);
it('renders JSONTree', () => { it('renders JSONTree', () => {
const component = shallow(<JSONViewer data={JSON.stringify(data)} />); setupComponent({
expect(component.exists('Styled(JSONEditor)')).toBeTruthy(); data: JSON.stringify(data),
maxLines,
});
expect(screen.getByRole('textbox')).toBeInTheDocument();
}); });
it('matches the snapshot with fixed height with no value', () => { it('matches the snapshot with fixed height with no value', () => {
const component = shallow(<JSONViewer data={data as unknown as string} />); setupComponent({
expect(component.exists('JSONEditor')).toBeFalsy(); data: '',
expect(component.exists('p')).toBeTruthy(); maxLines,
});
expect(screen.getByText(JSON.stringify(''))).toBeInTheDocument();
}); });
}); });