Skip to content

Commit 025d5ff

Browse files
authored
feat(TopicData): add topic message details in Drawer (#2266)
1 parent 2664ec7 commit 025d5ff

35 files changed

+1093
-280
lines changed

src/components/EnableFullscreenButton/EnableFullscreenButton.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
import {SquareDashed} from '@gravity-ui/icons';
2+
import type {ButtonView} from '@gravity-ui/uikit';
23
import {Button, Icon} from '@gravity-ui/uikit';
34

45
import {enableFullscreen} from '../../store/reducers/fullscreen';
56
import {useTypedDispatch} from '../../utils/hooks';
67

78
interface EnableFullscreenButtonProps {
89
disabled?: boolean;
10+
view?: ButtonView;
911
}
1012

11-
function EnableFullscreenButton({disabled}: EnableFullscreenButtonProps) {
13+
function EnableFullscreenButton({disabled, view = 'flat-secondary'}: EnableFullscreenButtonProps) {
1214
const dispatch = useTypedDispatch();
1315
const onEnableFullscreen = () => {
1416
dispatch(enableFullscreen());
1517
};
1618
return (
17-
<Button
18-
onClick={onEnableFullscreen}
19-
view="flat-secondary"
20-
disabled={disabled}
21-
title="Fullscreen"
22-
>
19+
<Button onClick={onEnableFullscreen} view={view} disabled={disabled} title="Fullscreen">
2320
<Icon data={SquareDashed} />
2421
</Button>
2522
);

src/components/EntityStatus/EntityStatus.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const b = cn('entity-status');
1616
interface EntityStatusProps {
1717
status?: EFlag;
1818
name?: string;
19+
renderName?: (name?: string) => React.ReactNode;
1920
label?: string;
2021
path?: string;
2122
iconPath?: string;
@@ -34,9 +35,14 @@ interface EntityStatusProps {
3435
className?: string;
3536
}
3637

38+
function defaultRenderName(name?: string) {
39+
return name ?? '';
40+
}
41+
3742
export function EntityStatus({
3843
status = EFlag.Grey,
3944
name = '',
45+
renderName = defaultRenderName,
4046
label,
4147
path,
4248
iconPath,
@@ -75,14 +81,14 @@ export function EntityStatus({
7581
if (externalLink) {
7682
return (
7783
<UIKitLink className={b('name')} href={path}>
78-
{name}
84+
{renderName(name)}
7985
</UIKitLink>
8086
);
8187
}
8288

8389
return (
8490
<InternalLink className={b('name')} to={path}>
85-
{name}
91+
{renderName(name)}
8692
</InternalLink>
8793
);
8894
}

src/components/JsonViewer/JsonViewer.scss

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
--data-table-row-height: 20px;
55
--toolbar-background-color: var(--g-color-base-background);
66

7+
width: max-content;
8+
79
&__toolbar {
810
position: sticky;
911
z-index: 2;

src/components/JsonViewer/JsonViewer.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ interface JsonViewerCommonProps {
3333
tableSettings?: DT100.Settings;
3434
search?: boolean;
3535
collapsedInitially?: boolean;
36+
maxValueWidth?: number;
37+
toolbarClassName?: string;
3638
}
3739

3840
interface JsonViewerProps extends JsonViewerCommonProps {
@@ -60,7 +62,7 @@ const SETTINGS: DT100.Settings = {
6062
displayIndices: false,
6163
dynamicRender: true,
6264
sortable: false,
63-
dynamicRenderMinSize: 100,
65+
dynamicRenderMinSize: 50,
6466
};
6567

6668
function getCollapsedState(value: UnipikaValue) {
@@ -114,6 +116,8 @@ function JsonViewerComponent({
114116
search = true,
115117
extraTools,
116118
collapsedInitially,
119+
maxValueWidth = 100,
120+
toolbarClassName,
117121
}: JsonViewerComponentProps) {
118122
const [caseSensitiveSearch, setCaseSensitiveSearch] = useSetting(
119123
CASE_SENSITIVE_JSON_SEARCH,
@@ -162,6 +166,7 @@ function JsonViewerComponent({
162166
filter={filter}
163167
showFullText={onShowFullText}
164168
index={index}
169+
maxValueWidth={maxValueWidth}
165170
/>
166171
);
167172
};
@@ -295,7 +300,7 @@ function JsonViewerComponent({
295300

296301
const renderToolbar = () => {
297302
return (
298-
<Flex gap={2} wrap="nowrap" className={block('toolbar')}>
303+
<Flex gap={2} wrap="nowrap" className={block('toolbar', toolbarClassName)}>
299304
<Flex gap={1} wrap="nowrap">
300305
<ActionTooltip title={i18n('action_expand-all')}>
301306
<Button onClick={onExpandAll} view="flat-secondary">

src/components/JsonViewer/components/Cell.tsx

+16-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface CellProps {
2323
filter?: string;
2424
index: number;
2525
showFullText: (index: number) => void;
26+
maxValueWidth?: number;
2627
}
2728

2829
export function Cell(props: CellProps) {
@@ -69,6 +70,7 @@ export function Cell(props: CellProps) {
6970
matched={matched?.valueMatch}
7071
filter={filter}
7172
showFullText={handleShowFullText}
73+
maxValueWidth={props.maxValueWidth}
7274
/>
7375
)}
7476
{collapsed && depth === undefined && <span className={'unipika'}>...</span>}
@@ -97,6 +99,7 @@ function Key(props: KeyProps) {
9799

98100
interface ValueProps extends KeyProps {
99101
showFullText?: () => void;
102+
maxValueWidth?: number;
100103
}
101104

102105
function Value(props: ValueProps) {
@@ -109,16 +112,24 @@ function Value(props: ValueProps) {
109112

110113
function renderValueWithFilter(props: ValueProps, className: string) {
111114
if ('string' === props.text?.$type) {
112-
return renderStringWithFilter(props, className, 100);
115+
return renderStringWithFilter(props, className);
113116
}
114117
return renderWithFilter(props, block('value'));
115118
}
116119

117-
function renderStringWithFilter(props: ValueProps, className: string, maxWidth = Infinity) {
118-
const {text, settings = defaultUnipikaSettings, matched = [], filter, showFullText} = props;
119-
const tmp = unipika.format(text, {...settings, asHTML: false});
120+
function renderStringWithFilter(props: ValueProps, className: string) {
121+
const {
122+
text,
123+
settings = defaultUnipikaSettings,
124+
matched = [],
125+
filter,
126+
showFullText,
127+
maxValueWidth = Infinity,
128+
} = props;
129+
130+
const tmp = unipika.format(text, {...settings, maxStringSize: 10, asHTML: false});
120131
const length = tmp.length;
121-
const visible = tmp.substring(1, Math.min(length - 1, maxWidth + 1));
132+
const visible = tmp.substring(1, Math.min(length - 1, maxValueWidth + 1));
122133
const truncated = visible.length < tmp.length - 2;
123134
let hasHiddenMatch = false;
124135
if (truncated) {

src/components/JsonViewer/components/FullValueDialog.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ interface FullValueDialogProps {
1414
}
1515

1616
export function FullValueDialog({onClose, text, starts, length}: FullValueDialogProps) {
17+
//if dialog opens from Drawer, outside click should not close Drawer
18+
const handleClickOutside = (e: MouseEvent) => {
19+
e.stopPropagation();
20+
};
1721
return (
18-
<Dialog open={true} onClose={onClose}>
22+
<Dialog open={true} onClose={onClose} onOutsideClick={handleClickOutside}>
1923
<Dialog.Header caption={i18n('description_full-value')} />
2024
<Dialog.Divider />
2125
<Dialog.Body>

src/components/ShortyString/ShortyString.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.kv-shorty-string {
22
&__toggle {
3-
margin-left: 2em;
3+
margin-left: 1em;
44

55
font-size: 0.85em;
66
}

src/containers/Tenant/Diagnostics/Partitions/PartitionsControls/PartitionsControls.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const PartitionsControls = ({
5656
connectionHost,
5757
} = partition;
5858

59-
const isPartitionIdMatch = partitionIdRe.test(partitionId);
59+
const isPartitionIdMatch = partitionIdRe.test(String(partitionId));
6060

6161
const otherValues = [
6262
readerName,

src/containers/Tenant/Diagnostics/Partitions/columns/columns.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const allColumns: Column<PreparedPartitionDataWithHosts>[] = [
4545
),
4646
sortAccessor: (row) => isNumeric(row.partitionId) && Number(row.partitionId),
4747
align: DataTable.LEFT,
48-
render: ({row}) => <PartitionId id={row.partitionId} />,
48+
render: ({row}) => <PartitionId id={String(row.partitionId)} />,
4949
},
5050
{
5151
name: PARTITIONS_COLUMNS_IDS.STORE_SIZE,

src/containers/Tenant/Diagnostics/TopicData/TopicData.scss

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
&__date-picker {
1313
min-width: 265px;
1414
}
15-
&__column-setup {
16-
margin-left: auto;
15+
&__offset-input {
16+
width: max-content;
1717
}
1818

1919
&__row {
@@ -24,5 +24,11 @@
2424
background: var(--g-color-base-selection-hover) !important;
2525
}
2626
}
27+
&_removed {
28+
color: var(--g-color-text-secondary);
29+
}
30+
}
31+
&__scroll-button {
32+
margin-right: var(--g-spacing-half);
2733
}
2834
}

0 commit comments

Comments
 (0)