Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/pages/Stream/Views/Explore/LogsViewConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ const ColumnsList = (props: { isLoading: boolean }) => {
setLogsStore((store) => setDisabledColumns(store, []));
}, [orderedHeaders]);

// const onToggleWordWrap = useCallback(() => {
// setLogsStore((store) => toggleWordWrap(store));
// }, []);

const handleOnlyClick = useCallback(
(column: string) => {
const filteredHeaders = orderedHeaders.filter((el) => el !== column);
Expand Down Expand Up @@ -245,15 +241,6 @@ const ColumnsList = (props: { isLoading: boolean }) => {

return (
<>
{/* <Stack style={{ alignItems: 'flex-end', padding: '0 0.5rem' }}>
<Switch
styles={{ label: { fontSize: '0.7rem' } }}
labelPosition="left"
label="Wrap Words"
checked={enableWordWrap}
onChange={onToggleWordWrap}
/>
</Stack> */}
<SearchBar
placeholder="Search Headers"
value={searchValue}
Expand Down
26 changes: 17 additions & 9 deletions src/pages/Stream/Views/Explore/StaticLogTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const makeColumnVisiblityOpts = (columns: string[]) => {
};

const Table = (props: { primaryHeaderHeight: number }) => {
const [{ orderedHeaders, disabledColumns, pinnedColumns, pageData, enableWordWrap }, setLogsStore] = useLogsStore(
const [{ orderedHeaders, disabledColumns, pinnedColumns, pageData, wrapDisabledColumns }, setLogsStore] = useLogsStore(
(store) => store.tableOpts,
);
const [isSecureHTTPContext] = useAppStore((store) => store.isSecureHTTPContext);
Expand All @@ -71,22 +71,30 @@ const Table = (props: { primaryHeaderHeight: number }) => {

setLogsStore((store) => setSelectedLog(store, log));
}, []);
return (
<MantineReactTable
enableBottomToolbar={false}
enableTopToolbar={false}
enableColumnResizing={true}
mantineTableBodyCellProps={{

const makeCellCustomStyles = useCallback(
(columnName: string) => {
return {
className: tableStyles.customCell,
style: {
padding: '0.5rem 1rem',
fontSize: '0.6rem',
overflow: 'hidden',
textOverflow: 'ellipsis',
display: 'table-cell',
...(enableWordWrap ? { whiteSpace: 'nowrap' } : {}),
...(!_.includes(wrapDisabledColumns, columnName) ? { whiteSpace: 'nowrap' as 'nowrap' } : {}),
},
}}
};
},
[wrapDisabledColumns],
);

return (
<MantineReactTable
enableBottomToolbar={false}
enableTopToolbar={false}
enableColumnResizing={true}
mantineTableBodyCellProps={({ column: { id } }) => makeCellCustomStyles(id)}
mantineTableHeadRowProps={{ style: { border: 'none' } }}
mantineTableHeadCellProps={{
style: {
Expand Down
80 changes: 49 additions & 31 deletions src/pages/Stream/components/Column.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Log } from '@/@types/parseable/api/query';
import { Box, Checkbox, Menu, ScrollArea, Stack, TextInput, Tooltip, px } from '@mantine/core';
import { Checkbox, Menu, ScrollArea, Stack, Switch, TextInput, Tooltip, px } from '@mantine/core';
import { type ChangeEvent, type FC, Fragment, useRef, useCallback, useState, useEffect } from 'react';
import { IconFilter, IconSearch } from '@tabler/icons-react';
import EmptyBox from '@/components/Empty';
Expand All @@ -9,7 +9,7 @@ import { Text } from '@mantine/core';
import { useLogsStore, logsStoreReducers } from '../providers/LogsProvider';
import _ from 'lodash';

const { getUniqueValues, setAndFilterData } = logsStoreReducers;
const { getUniqueValues, setAndFilterData, toggleWrapDisabledColumns } = logsStoreReducers;

type Column = {
columnName: string;
Expand All @@ -21,6 +21,7 @@ const Column: FC<Column> = (props) => {
const [filteredValues, setFilteredValues] = useState<string[]>([]);
const [selectedValues, setSelectedValues] = useState<string[]>([]);
const [rawData, setLogsStore] = useLogsStore((store) => store.data.rawData);
const [wrapDisabledColumns] = useLogsStore((store) => store.tableOpts.wrapDisabledColumns);
const inputValueRef = useRef('');

useEffect(() => {
Expand Down Expand Up @@ -53,38 +54,55 @@ const Column: FC<Column> = (props) => {

const checkboxList =
filteredValues.length === 0 ? (inputValueRef.current.length === 0 ? uniqueValues : []) : filteredValues;

const onToggleWrap = () => {
setLogsStore((store) => toggleWrapDisabledColumns(store, columnName));
};
const wordWrapEnabled = _.includes(wrapDisabledColumns, columnName);
return (
<div>
<Box style={{ width: '20rem', padding: '0.25rem 0.5rem 0.25rem 0.5rem' }}>
<Stack gap={8} my={16} style={{ flexDirection: 'row' }}>
<IconFilter stroke={1} size="1rem" />
<Text>Filter by values:</Text>
<Stack style={{ width: '20rem', padding: '0.8rem 1rem' }} gap={16}>
<Stack style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<Text style={{ fontSize: '0.7rem', fontWeight: 600 }}>Word Wrap</Text>
<Switch
styles={{ label: { fontSize: '0.7rem' } }}
labelPosition="left"
label={wordWrapEnabled ? 'Enabled' : 'Disabled'}
checked={wordWrapEnabled}
onChange={onToggleWrap}
/>
</Stack>
<Stack gap={4}>
<Stack gap={4} style={{ flexDirection: 'row', alignItems: 'center' }}>
<IconFilter stroke={1.4} size="0.8rem" />
<Text style={{ fontSize: '0.7rem', fontWeight: 600 }}>Filter by values:</Text>
</Stack>
<TextInput
className={searchInputStyle}
placeholder="Search"
leftSection={<IconSearch size={px('1rem')} />}
onChange={onSearch}
mt={8}
/>
{checkboxList.length ? (
<Fragment>
<CheckboxVirtualList
columnName={columnName}
list={checkboxList}
selectedFilters={selectedValues}
onSelect={onSelect}
/>
<Menu.Item>
<Button className={applyBtn} onClick={onApply} disabled={selectedValues.length === 0}>
Apply
</Button>
</Menu.Item>
</Fragment>
) : (
<EmptyBox mb="lg" />
)}
</Stack>
<TextInput
className={searchInputStyle}
placeholder="Search"
leftSection={<IconSearch size={px('1rem')} />}
onChange={onSearch}
mt={8}
/>
{checkboxList.length ? (
<Fragment>
<CheckboxVirtualList
columnName={columnName}
list={checkboxList}
selectedFilters={selectedValues}
onSelect={onSelect}
/>
<Menu.Item>
<Button className={applyBtn} onClick={onApply} disabled={selectedValues.length === 0}>
Apply
</Button>
</Menu.Item>
</Fragment>
) : (
<EmptyBox mb="lg" />
)}
</Box>
</Stack>
</div>
);
};
Expand Down
15 changes: 15 additions & 0 deletions src/pages/Stream/providers/LogsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ type LogsStore = {

tableOpts: {
disabledColumns: string[];
wrapDisabledColumns: string[];
pinnedColumns: string[];
pageData: Log[];
totalPages: number;
Expand Down Expand Up @@ -252,6 +253,7 @@ type LogsStoreReducers = {

// table opts reducers
toggleDisabledColumns: (store: LogsStore, columnName: string) => ReducerOutput;
toggleWrapDisabledColumns: (store: LogsStore, columnName: string) => ReducerOutput;
togglePinnedColumns: (store: LogsStore, columnName: string) => ReducerOutput;
setCurrentOffset: (store: LogsStore, offset: number) => ReducerOutput;
setPerPage: (store: LogsStore, perPage: number) => ReducerOutput;
Expand Down Expand Up @@ -309,6 +311,7 @@ const initialState: LogsStore = {

tableOpts: {
disabledColumns: [],
wrapDisabledColumns: [],
pinnedColumns: [],
pageData: [],
perPage: 50,
Expand Down Expand Up @@ -487,6 +490,16 @@ const toggleDisabledColumns = (store: LogsStore, columnName: string) => {
};
};

const toggleWrapDisabledColumns = (store: LogsStore, columnName: string) => {
const { tableOpts } = store;
return {
tableOpts: {
...tableOpts,
wrapDisabledColumns: addOrRemoveElement(tableOpts.wrapDisabledColumns, columnName),
},
};
};

const setDisabledColumns = (store: LogsStore, columns: string[]) => {
return {
tableOpts: {
Expand Down Expand Up @@ -688,6 +701,7 @@ const setCleanStoreForStreamChange = (store: LogsStore) => {
totalPages: 0,
orderedHeaders: [],
disabledColumns: [],
wrapDisabledColumns: [],
pinnedColumns: [],
filters: {},
},
Expand Down Expand Up @@ -981,6 +995,7 @@ const logsStoreReducers: LogsStoreReducers = {
setDisabledColumns,
setOrderedHeaders,
toggleWordWrap,
toggleWrapDisabledColumns
};

export { LogsProvider, useLogsStore, logsStoreReducers };
Loading