Skip to content

Commit c89c24a

Browse files
authored
minor feedbacks fixes for the release (#208)
1 parent 3bf47a8 commit c89c24a

File tree

6 files changed

+95
-76
lines changed

6 files changed

+95
-76
lines changed

src/hooks/useAlertsEditor.tsx

+16-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ import { notifyError, notifySuccess } from '@/utils/notification';
44
import { AxiosError, isAxiosError } from 'axios';
55

66
export const useAlertsEditor = (streamName: string) => {
7-
const { mutate: updateLogStreamAlerts } = useMutation((data: any) => putLogStreamAlerts(streamName, data), {
8-
onSuccess: () => notifySuccess({ message: 'Updated Successfully' }),
9-
onError: (data: AxiosError) => {
10-
if (isAxiosError(data) && data.response) {
11-
const error = data.response?.data as string;
12-
typeof error === 'string' && notifyError({ message: error });
13-
} else if (data.message && typeof data.message === 'string') {
14-
notifyError({ message: data.message });
15-
}
7+
const { mutate: updateLogStreamAlerts } = useMutation(
8+
(data: { config: any; onSuccess?: () => void }) => putLogStreamAlerts(streamName, data.config),
9+
{
10+
onSuccess: (_data, variables) => {
11+
variables.onSuccess && variables.onSuccess();
12+
notifySuccess({ message: 'Updated Successfully' });
13+
},
14+
onError: (data: AxiosError) => {
15+
if (isAxiosError(data) && data.response) {
16+
const error = data.response?.data as string;
17+
typeof error === 'string' && notifyError({ message: error });
18+
} else if (data.message && typeof data.message === 'string') {
19+
notifyError({ message: data.message });
20+
}
21+
},
1622
},
17-
});
23+
);
1824

1925
return {
2026
updateLogStreamAlerts,

src/hooks/useRetentionEditor.tsx

+16-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ import { notifyError, notifySuccess } from '@/utils/notification';
44
import { AxiosError, isAxiosError } from 'axios';
55

66
export const useRetentionEditor = (streamName: string) => {
7-
const { mutate: updateLogStreamRetention } = useMutation((data: any) => putLogStreamRetention(streamName, data), {
8-
onSuccess: () => notifySuccess({ message: 'Updated Successfully' }),
9-
onError: (data: AxiosError) => {
10-
if (isAxiosError(data) && data.response) {
11-
const error = data.response?.data as string;
12-
typeof error === 'string' && notifyError({ message: error });
13-
} else if (data.message && typeof data.message === 'string') {
14-
notifyError({ message: data.message });
15-
}
7+
const { mutate: updateLogStreamRetention } = useMutation(
8+
(data: { config: any; onSuccess?: () => void }) => putLogStreamRetention(streamName, data.config),
9+
{
10+
onSuccess: (_data, variables) => {
11+
notifySuccess({ message: 'Updated Successfully' });
12+
variables.onSuccess && variables.onSuccess();
13+
},
14+
onError: (data: AxiosError) => {
15+
if (isAxiosError(data) && data.response) {
16+
const error = data.response?.data as string;
17+
typeof error === 'string' && notifyError({ message: error });
18+
} else if (data.message && typeof data.message === 'string') {
19+
notifyError({ message: data.message });
20+
}
21+
},
1622
},
17-
});
23+
);
1824

1925
return {
2026
updateLogStreamRetention,

src/pages/Logs/AlertsModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const AlertsModal = () => {
2929
} catch (e) {
3030
return notifyError({ message: 'Unable to parse config' });
3131
}
32-
updateLogStreamAlerts(parsedConfig);
32+
updateLogStreamAlerts({config: parsedConfig, onSuccess: closeAlertsModal});
3333
} else {
3434
return notifyError({ message: 'Unable to parse config' });
3535
}

src/pages/Logs/LogTable.tsx

+59-52
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const TotalLogsCount = (props: TotalLogsCountProps) => {
7373

7474
const renderTotalCount = useCallback(() => (<Tooltip label={totalCount}><Text>{HumanizeNumber(totalCount)}</Text></Tooltip>), [totalCount]);
7575
return (
76-
<Stack style={{ alignItems: 'center', justifyContent: 'center', flexDirection: 'row' }} gap={6}>
76+
<Stack style={{ alignItems: 'center', justifyContent: 'center', flexDirection: 'row'}} gap={6}>
7777
<Text>{`Showing ${loadedCount < LOAD_LIMIT ? loadedCount : LOAD_LIMIT} out of`}</Text>
7878
{renderTotalCount()}
7979
</Stack>
@@ -498,57 +498,64 @@ const LogTable: FC = () => {
498498
</Center>
499499
)}
500500
<Box className={tableStyles.footerContainer}>
501-
<TotalLogsCount totalCount={totalCount} loadedCount={loadedCount} />
502-
{!loading && !logsLoading ? (
503-
<Pagination.Root
504-
total={pageLogData?.totalPages || 1}
505-
value={pageLogData?.page || 1}
506-
onChange={(page) => {
507-
goToPage(page, pageLogData?.limit || 1);
508-
pagination.setPage(page);
509-
}}>
510-
<Group gap={5} justify="center">
511-
<Pagination.First
512-
onClick={() => {
513-
if (pageOffset !== 0) setPageOffset((value) => value - loadLimit);
514-
}}
515-
disabled={pageOffset === 0}
516-
/>
517-
<Pagination.Previous />
518-
{pagination.range.map((page) => {
519-
if (page === 'dots') {
520-
return <Pagination.Dots key={page} />;
521-
} else {
522-
return (
523-
<Pagination.Control
524-
value={page}
525-
key={page}
526-
active={pageLogData?.page === page}
527-
onClick={() => {
528-
goToPage(page);
529-
pagination.setPage(page);
530-
}}>
531-
{pageLogData?.limit ? page + pageOffset / pageLogData?.limit ?? 1 : page}
532-
</Pagination.Control>
533-
);
534-
}
535-
})}
536-
537-
<Pagination.Next />
538-
<Pagination.Last
539-
onClick={() => {
540-
setPageOffset((value) => {
541-
return value + loadLimit;
542-
});
543-
}}
544-
disabled={false}
545-
/>
546-
</Group>
547-
</Pagination.Root>
548-
) : (
549-
<Loader variant="dots" />
550-
)}
551-
<LimitControl value={pageLogData?.limit || 0} onChange={setPageLimit} />
501+
<Stack w="100%" justify="center" align="flex-start">
502+
<TotalLogsCount totalCount={totalCount} loadedCount={loadedCount} />
503+
</Stack>
504+
<Stack w="100%" justify="center">
505+
{!loading && !logsLoading ? (
506+
<Pagination.Root
507+
total={pageLogData?.totalPages || 1}
508+
value={pageLogData?.page || 1}
509+
onChange={(page) => {
510+
goToPage(page, pageLogData?.limit || 1);
511+
pagination.setPage(page);
512+
}}>
513+
<Group gap={5} justify="center">
514+
<Pagination.First
515+
onClick={() => {
516+
if (pageOffset !== 0) setPageOffset((value) => value - loadLimit);
517+
}}
518+
disabled={pageOffset === 0}
519+
/>
520+
<Pagination.Previous />
521+
{pagination.range.map((page) => {
522+
if (page === 'dots') {
523+
return <Pagination.Dots key={page} />;
524+
} else {
525+
return (
526+
<Pagination.Control
527+
value={page}
528+
key={page}
529+
active={pageLogData?.page === page}
530+
onClick={() => {
531+
goToPage(page);
532+
pagination.setPage(page);
533+
}}>
534+
{pageLogData?.limit ? page + pageOffset / pageLogData?.limit ?? 1 : page}
535+
</Pagination.Control>
536+
);
537+
}
538+
})}
539+
<Pagination.Next />
540+
<Pagination.Last
541+
onClick={() => {
542+
setPageOffset((value) => {
543+
return value + loadLimit;
544+
});
545+
}}
546+
disabled={false}
547+
/>
548+
</Group>
549+
</Pagination.Root>
550+
) : (
551+
<Stack w="100%" align="center">
552+
<Loader variant="dots" />
553+
</Stack>
554+
)}
555+
</Stack>
556+
<Stack w="100%" align="flex-end">
557+
<LimitControl value={pageLogData?.limit || 0} onChange={setPageLimit} />
558+
</Stack>
552559
</Box>
553560
</Box>
554561
);

src/pages/Logs/QueryCodeEditor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const QueryCodeEditor: FC = () => {
156156
</Stack>
157157
</ScrollArea>
158158
<Stack className={queryCodeStyles.footer} style={{ alignItems: 'center' }}>
159-
<Button onClick={resetQuerySearch} disabled={!isSqlSearchActive}>
159+
<Button onClick={resetQuerySearch} disabled={!isSqlSearchActive} variant='outline'>
160160
Clear
161161
</Button>
162162
<Button onClick={() => runQuery(query)}>Apply</Button>

src/pages/Logs/RetentionModal.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const RententionModal = () => {
2121
const { handleCacheToggle, isCacheEnabled } = useCacheToggle(currentStream);
2222

2323
const { getLogRetentionData } = useGetRetention(currentStream);
24-
const {updateLogStreamRetention} = useRetentionEditor(currentStream);
24+
const { updateLogStreamRetention } = useRetentionEditor(currentStream);
2525

2626
const switchStyles = {
2727
track: isCacheEnabled ? classes.trackStyle : {},
@@ -35,7 +35,7 @@ const RententionModal = () => {
3535
} catch (e) {
3636
return notifyError({ message: 'Unable to parse config' });
3737
}
38-
updateLogStreamRetention(parsedConfig);
38+
updateLogStreamRetention({ config: parsedConfig, onSuccess: closeRetentionModal });
3939
} else {
4040
return notifyError({ message: 'Unable to parse config' });
4141
}

0 commit comments

Comments
 (0)