Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport main] Fix events home table and toast life time #1174

Merged
merged 1 commit into from
Oct 24, 2023
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
4 changes: 2 additions & 2 deletions public/components/event_analytics/explorer/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ export const Explorer = ({
setLiveTailName(name);
setLiveTailTabId((curSelectedTabId.current as unknown) as string);
setIsLiveTailOn(true);
setToast('Live tail On', 'success');
setToast('Live tail On', 'success', '', 'right', 2000);
setIsLiveTailPopoverOpen(false);
setLiveTimestamp(
dateMath.parse(endingTime, { roundUp: true })?.utc().format(DATE_PICKER_FORMAT) || ''
Expand All @@ -819,7 +819,7 @@ export const Explorer = ({
setIsLiveTailOn(false);
setLiveHits(0);
setIsLiveTailPopoverOpen(false);
if (isLiveTailOnRef.current) setToast('Live tail Off', 'danger');
if (isLiveTailOnRef.current) setToast('Live tail Off', 'danger', '', 'right', 2000);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
"filters": Array [
Object {
"field": "type",
"multiSelect": false,
"multiSelect": "or",
"name": "Type",
"options": Array [
Object {
Expand Down Expand Up @@ -186,7 +186,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
Array [
Object {
"field": "type",
"multiSelect": false,
"multiSelect": "or",
"name": "Type",
"options": Array [
Object {
Expand Down Expand Up @@ -334,7 +334,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
Array [
Object {
"field": "type",
"multiSelect": false,
"multiSelect": "or",
"name": "Type",
"options": Array [
Object {
Expand Down Expand Up @@ -386,7 +386,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
config={
Object {
"field": "type",
"multiSelect": false,
"multiSelect": "or",
"name": "Type",
"options": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function SavedQueryTable({
type: 'field_value_selection',
field: 'type',
name: 'Type',
multiSelect: false,
multiSelect: 'or',
options: FILTER_OPTIONS.map((i) => ({
value: i,
name: i,
Expand Down
12 changes: 10 additions & 2 deletions public/components/event_analytics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ export const EventAnalytics = ({
...props
}: EventAnalyticsProps) => {
const [toasts, setToasts] = useState<Toast[]>([]);
const [toastLifeTime, setToastLifeTime] = useState(6000);

const eventAnalyticsBreadcrumb = {
text: 'Logs',
href: '#/',
};

const setToast = (title: string, color = 'success', text?: ReactChild, side?: string) => {
const setToast = (
title: string,
color = 'success',
text?: ReactChild,
side?: string,
toastLifeTimeMs?: number
) => {
if (!text) text = '';
setToasts([...toasts, { id: new Date().toISOString(), title, text, color } as Toast]);
if (toastLifeTimeMs) setToastLifeTime(toastLifeTimeMs);
};

return (
Expand All @@ -49,7 +57,7 @@ export const EventAnalytics = ({
dismissToast={(removedToast) => {
setToasts(toasts.filter((toast) => toast.id !== removedToast.id));
}}
toastLifeTimeMs={6000}
toastLifeTimeMs={toastLifeTime}
/>
<HashRouter>
<Switch>
Expand Down
Loading