Skip to content

Commit 4af9374

Browse files
committed
fix: JSON View scroll & currentstream changes
1 parent c287d0a commit 4af9374

File tree

4 files changed

+39
-24
lines changed

4 files changed

+39
-24
lines changed

src/layouts/MainLayout/providers/AppProvider.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { LogStreamData } from '@/@types/parseable/api/stream';
2-
import initContext from '@/utils/initContext';
1+
import { FIXED_DURATIONS, FixedDuration } from '@/constants/timeConstants';
2+
import dayjs, { Dayjs } from 'dayjs';
3+
34
import { AboutData } from '@/@types/parseable/api/about';
4-
import _ from 'lodash';
55
import { AxiosResponse } from 'axios';
6+
import { LogStreamData } from '@/@types/parseable/api/stream';
67
import { SavedFilterType } from '@/@types/parseable/api/savedFilters';
7-
import { FIXED_DURATIONS, FixedDuration } from '@/constants/timeConstants';
8-
import dayjs, { Dayjs } from 'dayjs';
8+
import _ from 'lodash';
9+
import initContext from '@/utils/initContext';
910
import timeRangeUtils from '@/utils/timeRangeUtils';
1011

1112
const { makeTimeRangeLabel } = timeRangeUtils;
@@ -57,6 +58,7 @@ type AppStore = {
5758
helpModalOpen: boolean;
5859
createStreamModalOpen: boolean;
5960
currentStream: null | string;
61+
streamForCorrelation: null | string;
6062
userRoles: UserRoles | null;
6163
userSpecificStreams: null | LogStreamData;
6264
userAccessMap: { [key: string]: boolean };
@@ -76,6 +78,7 @@ type AppStoreReducers = {
7678
toggleMaximize: (store: AppStore) => ReducerOutput;
7779
toggleHelpModal: (store: AppStore, val?: boolean) => ReducerOutput;
7880
changeStream: (store: AppStore, stream: string) => ReducerOutput;
81+
setStreamForCorrelation: (store: AppStore, stream: string) => ReducerOutput;
7982
setUserRoles: (store: AppStore, roles: UserRoles | null) => ReducerOutput;
8083
setshiftInterval: (store: AppStore, interval: number) => ReducerOutput;
8184
syncTimeRange: (store: AppStore) => ReducerOutput;
@@ -93,6 +96,7 @@ const initialState: AppStore = {
9396
maximized: false,
9497
helpModalOpen: false,
9598
currentStream: null,
99+
streamForCorrelation: null,
96100
userRoles: null,
97101
userSpecificStreams: null,
98102
userAccessMap: {},
@@ -208,6 +212,10 @@ const changeStream = (store: AppStore, stream: string) => {
208212
return { currentStream: stream, activeSavedFilters };
209213
};
210214

215+
const setStreamForCorrelation = (_store: AppStore, stream: string) => {
216+
return { streamForCorrelation: stream };
217+
};
218+
211219
const setUserRoles = (_store: AppStore, roles: UserRoles | null) => {
212220
return { userRoles: roles };
213221
};
@@ -240,6 +248,7 @@ const appStoreReducers: AppStoreReducers = {
240248
toggleMaximize,
241249
toggleHelpModal,
242250
changeStream,
251+
setStreamForCorrelation,
243252
setUserRoles,
244253
setUserSpecificStreams,
245254
setUserAccessMap,

src/pages/Correlation/Views/CorrelationJSONView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const CorrleationJSONView = (props: { errorMessage: string | null; hasNoData: bo
220220
className={classes.innerContainer}
221221
style={{ display: 'flex', flexDirection: 'row', maxHeight: `calc(100vh - ${primaryHeaderHeight}px )` }}>
222222
<Stack gap={0} style={{ width: '100%' }}>
223-
<Stack>
223+
<Stack style={{ overflowY: 'scroll' }}>
224224
<JsonRows isSearching={isSearching} setContextMenu={setContextMenu} />
225225
</Stack>
226226
</Stack>

src/pages/Correlation/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const Correlation = () => {
5252

5353
const { isStoreSynced } = useParamsController();
5454
const [timeRange] = useAppStore((store) => store.timeRange);
55-
const [currentStream, setAppStore] = useAppStore((store) => store.currentStream);
55+
const [streamForCorrelation, setAppStore] = useAppStore((store) => store.streamForCorrelation);
5656
const [maximized] = useAppStore((store) => store.maximized);
5757
const { isLoading: schemaLoading } = useGetStreamSchema({
58-
streamName: currentStream || '',
58+
streamName: streamForCorrelation || '',
5959
});
6060
const isSavedCorrelation = correlationId !== savedCorrelationId;
6161
const streamsToFetch =
@@ -148,10 +148,10 @@ const Correlation = () => {
148148
}, [correlationId, correlations]);
149149

150150
useEffect(() => {
151-
if (currentStream && streamNames.length > 0 && Object.keys(fields).includes(currentStream)) {
151+
if (streamForCorrelation && streamNames.length > 0 && Object.keys(fields).includes(streamForCorrelation)) {
152152
getFetchStreamData();
153153
}
154-
}, [currentStream, fields]);
154+
}, [streamForCorrelation, fields]);
155155

156156
useEffect(() => {
157157
if (isCorrelatedData) {
@@ -196,7 +196,7 @@ const Correlation = () => {
196196
}
197197
}, [loadingState, currentPage]);
198198

199-
if (isLoading) return;
199+
if (isLoading || !Object.keys(fields)) return;
200200

201201
return (
202202
<Box className={classes.correlationWrapper}>

src/pages/Stream/components/PrimaryToolbar.tsx

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import { Button, Stack, px, rem } from '@mantine/core';
2-
import IconButton from '@/components/Button/IconButton';
32
import { IconFilterHeart, IconMaximize, IconTable, IconTrash } from '@tabler/icons-react';
43
import { STREAM_PRIMARY_TOOLBAR_CONTAINER_HEIGHT, STREAM_PRIMARY_TOOLBAR_HEIGHT } from '@/constants/theme';
5-
import TimeRange from '@/components/Header/TimeRange';
6-
import RefreshInterval from '@/components/Header/RefreshInterval';
7-
import RefreshNow from '@/components/Header/RefreshNow';
8-
import Querier from './Querier';
94
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
5+
import { filterStoreReducers, useFilterStore } from '../providers/FilterProvider';
6+
import { logsStoreReducers, useLogsStore } from '../providers/LogsProvider';
107
import { useCallback, useEffect } from 'react';
11-
import StreamDropdown from '@/components/Header/StreamDropdown';
12-
import { notifications } from '@mantine/notifications';
138
import { useNavigate, useParams } from 'react-router-dom';
14-
import _ from 'lodash';
15-
import StreamingButton from '@/components/Header/StreamingButton';
9+
10+
import { CorrelationIcon } from '@/components/Navbar/components/CorrelationIcon';
11+
import IconButton from '@/components/Button/IconButton';
12+
import Querier from './Querier';
13+
import RefreshInterval from '@/components/Header/RefreshInterval';
14+
import RefreshNow from '@/components/Header/RefreshNow';
1615
import ShareButton from '@/components/Header/ShareButton';
17-
import { useLogsStore, logsStoreReducers } from '../providers/LogsProvider';
18-
import { filterStoreReducers, useFilterStore } from '../providers/FilterProvider';
16+
import StreamDropdown from '@/components/Header/StreamDropdown';
17+
import StreamingButton from '@/components/Header/StreamingButton';
18+
import TimeRange from '@/components/Header/TimeRange';
19+
import _ from 'lodash';
1920
import classes from './styles/PrimaryToolbar.module.css';
20-
import { CorrelationIcon } from '@/components/Navbar/components/CorrelationIcon';
21+
import { notifications } from '@mantine/notifications';
2122

2223
const { toggleDeleteModal, onToggleView } = logsStoreReducers;
2324
const { toggleSavedFiltersModal } = filterStoreReducers;
25+
const { setStreamForCorrelation } = appStoreReducers;
2426
const renderMaximizeIcon = () => <IconMaximize size={px('1rem')} stroke={1.5} />;
2527
const renderDeleteIcon = () => <IconTrash data-id="delete-stream-btn" size={px('1rem')} stroke={1.5} />;
2628

@@ -46,12 +48,16 @@ const SavedFiltersButton = () => {
4648

4749
const AddCorrelationButton = () => {
4850
const navigate = useNavigate();
51+
const [, setAppStore] = useAppStore(() => null);
4952

5053
return (
5154
<Button
5255
className={classes.savedFiltersBtn}
5356
h="100%"
54-
onClick={() => navigate('/correlation')}
57+
onClick={() => {
58+
setAppStore((store) => setStreamForCorrelation(store, store.currentStream || ''));
59+
navigate('/correlation');
60+
}}
5561
leftSection={<CorrelationIcon stroke={'#000000'} strokeWidth={1} />}>
5662
Correlate
5763
</Button>

0 commit comments

Comments
 (0)