-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution][Detections] - Auto refresh all rules/monitoring tables #82062
Changes from all commits
3416303
f44b9de
53cfe5f
9301afe
f79307f
dcbcbf9
d3c9833
35d33b8
c86d2fd
77e049c
d31c7b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The files under |
||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { I18nProvider } from '@kbn/i18n/react'; | ||
|
||
import { LastUpdatedAt } from './'; | ||
|
||
describe('LastUpdatedAt', () => { | ||
beforeEach(() => { | ||
Date.now = jest.fn().mockReturnValue(1603995369774); | ||
}); | ||
|
||
test('it renders correct relative time', () => { | ||
const wrapper = mount( | ||
<I18nProvider> | ||
<LastUpdatedAt updatedAt={1603995240115} /> | ||
</I18nProvider> | ||
); | ||
|
||
expect(wrapper.text()).toEqual(' Updated 2 minutes ago'); | ||
}); | ||
|
||
test('it only renders icon if "compact" is true', () => { | ||
const wrapper = mount( | ||
<I18nProvider> | ||
<LastUpdatedAt compact updatedAt={1603995240115} /> | ||
</I18nProvider> | ||
); | ||
|
||
expect(wrapper.text()).toEqual(''); | ||
expect(wrapper.find('[data-test-subj="last-updated-at-clock-icon"]').exists()).toBeTruthy(); | ||
}); | ||
|
||
test('it renders updating text if "showUpdating" is true', () => { | ||
const wrapper = mount( | ||
<I18nProvider> | ||
<LastUpdatedAt updatedAt={1603995240115} showUpdating /> | ||
</I18nProvider> | ||
); | ||
|
||
expect(wrapper.text()).toEqual(' Updating...'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EuiIcon, EuiText, EuiToolTip } from '@elastic/eui'; | ||
import { FormattedRelative } from '@kbn/i18n/react'; | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
|
||
import * as i18n from './translations'; | ||
|
||
interface LastUpdatedAtProps { | ||
compact?: boolean; | ||
updatedAt: number; | ||
showUpdating?: boolean; | ||
} | ||
|
||
export const Updated = React.memo<{ date: number; prefix: string; updatedAt: number }>( | ||
({ date, prefix, updatedAt }) => ( | ||
<> | ||
{prefix} | ||
{ | ||
<FormattedRelative | ||
data-test-subj="last-updated-at-date" | ||
key={`formatedRelative-${date}`} | ||
value={new Date(updatedAt)} | ||
/> | ||
} | ||
</> | ||
) | ||
); | ||
|
||
Updated.displayName = 'Updated'; | ||
|
||
const prefix = ` ${i18n.UPDATED} `; | ||
|
||
export const LastUpdatedAt = React.memo<LastUpdatedAtProps>( | ||
({ compact = false, updatedAt, showUpdating = false }) => { | ||
const [date, setDate] = useState(Date.now()); | ||
|
||
function tick() { | ||
setDate(Date.now()); | ||
} | ||
|
||
useEffect(() => { | ||
const timerID = setInterval(() => tick(), 10000); | ||
return () => { | ||
clearInterval(timerID); | ||
}; | ||
}, []); | ||
|
||
const updateText = useMemo(() => { | ||
if (showUpdating) { | ||
return <span> {i18n.UPDATING}</span>; | ||
} | ||
|
||
if (!compact) { | ||
return <Updated date={date} prefix={prefix} updatedAt={updatedAt} />; | ||
} | ||
|
||
return null; | ||
}, [compact, date, showUpdating, updatedAt]); | ||
|
||
return ( | ||
<EuiToolTip | ||
data-test-subj="timeline-stream-tool-tip" | ||
content={ | ||
<> | ||
<Updated date={date} prefix={prefix} updatedAt={updatedAt} /> | ||
</> | ||
} | ||
> | ||
<EuiText size="s"> | ||
<EuiIcon data-test-subj="last-updated-at-clock-icon" type="clock" /> | ||
{updateText} | ||
</EuiText> | ||
</EuiToolTip> | ||
); | ||
} | ||
); | ||
|
||
LastUpdatedAt.displayName = 'LastUpdatedAt'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const UPDATING = i18n.translate('xpack.securitySolution.lastUpdated.updating', { | ||
defaultMessage: 'Updating...', | ||
}); | ||
|
||
export const UPDATED = i18n.translate('xpack.securitySolution.lastUpdated.updated', { | ||
defaultMessage: 'Updated', | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ export const getColumns = ({ | |
getEmptyTagValue() | ||
) : ( | ||
<LocalizedDateTooltip fieldName={i18n.COLUMN_LAST_UPDATE} date={new Date(value)}> | ||
<FormattedRelative value={value} /> | ||
<FormattedDate value={value} fieldName={'last rule update date'} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this here because all the relative times (updated at, last run, last update, etc) felt overwhelming. @marrasherrier what do you think? |
||
</LocalizedDateTooltip> | ||
); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment still valid? Didn't see a cy.clock anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted in followup #83023