Skip to content

Commit ebe550a

Browse files
authored
Merge branch 'master' into opensearch/update-to-2.19.4
2 parents d11e918 + a0670a9 commit ebe550a

File tree

6 files changed

+25
-76
lines changed

6 files changed

+25
-76
lines changed

graylog2-web-interface/src/components/common/EntityDataTable/Table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const StyledTable = styled(BaseTable)(
3737
({ theme }) => css`
3838
table-layout: fixed;
3939
margin-bottom: 0;
40+
height: 100%; // required to be able to use height: 100% in td
4041
4142
thead > tr > th,
4243
tbody > tr > td {
@@ -65,7 +66,7 @@ const Td = styled.td<{
6566
opacity: var(${columnOpacityVar($colId)}, 1);
6667
transform: var(${columnTransformVar($colId)}, none);
6768
transition: var(${columnTransition()}, none);
68-
height: 0; // required to be able to use height: 100% in child elements
69+
height: 100%; // required to be able to use height: 100% in child elements
6970
${$pinningPosition
7071
? css`
7172
position: sticky;

graylog2-web-interface/src/components/common/EntityDataTable/TableHead.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const Th = styled.th<{
4848
transform: var(${columnTransformVar($colId)}, translate3d(0, 0, 0));
4949
background-color: ${theme.colors.table.head.background};
5050
transition: var(${columnTransition()}, none);
51-
height: 0; // required to be able to use height: 100% in child elements
51+
height: 100%; // required to be able to use height: 100% in child elements
5252
${$pinningPosition
5353
? css`
5454
position: sticky;

graylog2-web-interface/src/components/common/EntityDataTable/hooks/useActionsColumnWidth.ts

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,45 @@
1515
* <http://www.mongodb.com/licensing/server-side-public-license>.
1616
*/
1717

18-
import { useCallback, useEffect, useMemo, useState } from 'react';
18+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1919

2020
import { CELL_PADDING } from 'components/common/EntityDataTable/Constants';
2121

2222
import type { EntityBase } from '../types';
2323

2424
const useActionsColumnWidth = <Entity extends EntityBase>(entities: ReadonlyArray<Entity>, hasRowActions: boolean) => {
2525
const [rowWidths, setRowWidths] = useState<{ [rowId: string]: number }>({});
26-
const visibleRowIdsSet = useMemo(() => new Set(entities.map(({ id }) => id)), [entities]);
26+
const visibleRowIds = useMemo(() => new Set(entities.map(({ id }) => id)), [entities]);
27+
const visibleRowIdsRef = useRef<Set<string>>(visibleRowIds);
2728

2829
useEffect(() => {
29-
// eslint-disable-next-line react-hooks/set-state-in-effect
30-
setRowWidths((cur) => {
31-
const curEntries = Object.entries(cur);
32-
const filteredEntries = curEntries.filter(([rowId]) => visibleRowIdsSet.has(rowId));
30+
visibleRowIdsRef.current = visibleRowIds;
31+
}, [visibleRowIds]);
3332

34-
if (filteredEntries.length === curEntries.length) {
35-
return cur;
36-
}
33+
const handleWidthChange = useCallback((rowId: string, width: number) => {
34+
const rounded = Math.round(width);
3735

38-
return Object.fromEntries(filteredEntries);
39-
});
40-
}, [visibleRowIdsSet]);
41-
42-
const handleWidthChange = useCallback(
43-
(rowId: string, width: number) => {
44-
const rounded = Math.round(width);
45-
46-
if (rounded <= 0 || !visibleRowIdsSet.has(rowId)) {
47-
return;
48-
}
36+
if (rounded <= 0 || !visibleRowIdsRef.current.has(rowId)) {
37+
return;
38+
}
4939

50-
setRowWidths((cur) => (cur[rowId] === rounded ? cur : { ...cur, [rowId]: rounded }));
51-
},
52-
[visibleRowIdsSet],
53-
);
40+
setRowWidths((cur) => (cur[rowId] === rounded ? cur : { ...cur, [rowId]: rounded }));
41+
}, []);
5442

5543
const colMinWidth = useMemo(() => {
56-
if (!visibleRowIdsSet.size) {
44+
if (!visibleRowIds.size) {
5745
return CELL_PADDING * 2;
5846
}
5947

6048
const maxWidth = Math.max(
6149
0,
62-
...Array.from(visibleRowIdsSet)
50+
...Array.from(visibleRowIds)
6351
.map((rowId) => rowWidths[rowId])
6452
.filter((width) => !!width),
6553
);
6654

6755
return hasRowActions ? maxWidth + CELL_PADDING * 2 : 0;
68-
}, [hasRowActions, rowWidths, visibleRowIdsSet]);
56+
}, [hasRowActions, rowWidths, visibleRowIds]);
6957

7058
return { colMinWidth, handleWidthChange };
7159
};

graylog2-web-interface/src/components/inputs/InputsOveriew/ColumnRenderers.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ import type { ColumnRenderers } from 'components/common/EntityDataTable';
2020
import type { InputSummary } from 'hooks/usePaginatedInputs';
2121
import type { InputTypesSummary } from 'hooks/useInputTypes';
2222
import type { InputStates } from 'hooks/useInputsStates';
23-
import {
24-
TitleCell,
25-
TypeCell,
26-
NodeCell,
27-
ThroughputCell,
28-
ExpandedSectionToggleWrapper,
29-
} from 'components/inputs/InputsOveriew';
23+
import { TypeCell, NodeCell, ThroughputCell, ExpandedSectionToggleWrapper } from 'components/inputs/InputsOveriew';
3024
import { InputStateBadge } from 'components/inputs';
25+
import Routes from 'routing/Routes';
26+
import { Link } from 'components/common/router';
3127

3228
type Props = {
3329
inputTypes: InputTypesSummary;
@@ -39,7 +35,9 @@ const customColumnRenderers = ({ inputTypes, inputStates }: Props): ColumnRender
3935
title: {
4036
renderCell: (_title: string, input: InputSummary) => (
4137
<ExpandedSectionToggleWrapper id={input.id}>
42-
<TitleCell input={input} />
38+
<Link to={Routes.SYSTEM.INPUT_DIAGNOSIS(input.id)} title={`show input diagnosis for ${input.title}`}>
39+
{input.title}
40+
</Link>
4341
</ExpandedSectionToggleWrapper>
4442
),
4543
width: 0.5,
@@ -82,13 +80,12 @@ const customColumnRenderers = ({ inputTypes, inputStates }: Props): ColumnRender
8280
{input.attributes?.bind_address || 'N/A'}
8381
</ExpandedSectionToggleWrapper>
8482
),
85-
staticWidth: 100,
83+
staticWidth: 125,
8684
},
8785
port: {
8886
renderCell: (_port: string, input: InputSummary) => (
8987
<ExpandedSectionToggleWrapper id={input.id}>{input.attributes?.port || 'N/A'}</ExpandedSectionToggleWrapper>
9088
),
91-
staticWidth: 100,
9289
},
9390
},
9491
});

graylog2-web-interface/src/components/inputs/InputsOveriew/cells/TitleCell.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

graylog2-web-interface/src/components/inputs/InputsOveriew/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export { default as ColumnRenderers } from './ColumnRenderers';
1818
export { default as Constants } from './Constants';
1919
export { default as InputsOverview } from './InputsOverview';
2020
export { default as InputsActions } from './InputsActions';
21-
export { default as TitleCell } from './cells/TitleCell';
2221
export { default as TypeCell } from './cells/TypeCell';
2322
export { default as NodeCell } from './cells/NodeCell';
2423
export { default as ThroughputCell } from './cells/ThroughputCell';

0 commit comments

Comments
 (0)