-
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
[Endpoint] Adds take action dropdown and tests to alert details flyout #59242
[Endpoint] Adds take action dropdown and tests to alert details flyout #59242
Conversation
|
||
export const TakeActionDropdown = styled( | ||
memo(({ className }: { className?: string }) => { | ||
const [isDropdownOpen, setIsDropdownOpen] = useState(false); |
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.
@oatkiller @paul-tavares @dplumlee Wanted to get your thoughts on local component state. Here Davis is using local component state to keep track of whether the dropdown is open or closed. In the past, we have leaned towards keeping all application state, including local component state, in the redux store. It's a bit different now because we have been using EUI components heavily and they use local component state internally. So currently we don't store all application state in the redux store.
My main question for you is: For reusable components that we create, do we want to we want to store the state in the redux store or use local state?
If we wanted to store reusable component state in the redux store, we could create new versions of helpers like tacotruck activatable.
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.
question. can the popover et al work without any external state?
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.
👍 I agree that for re-usable components, local state (or props) should be used to drive the component's functionality and for them to not have state stored in Redux (especially if there is a chance of these reusable components to be present on a view multiple times).
💭 That being said - this is a fuzzy boundary (IMO). Normally (I think) redux/store is helpful when wanting to share state across the entire application, but the way we are using it is more as a global place to store state that applies only to the given view. One could also argue that we could use local state in that case as well (especially around Views, which act more like Container Components). I can tell you that as I work more with the Ingest code base, which is all built around local state and the use of hooks, the dev. mental model is allot simpler.
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.
I think this is fine. if some other component needs to know about the state then we should reconsider at that point.
In this case, it's not much different than having a native <select />
maintain its own open/closed state.
.../endpoint/public/applications/endpoint/view/alerts/details/overview/take_action_dropdown.tsx
Outdated
Show resolved
Hide resolved
.../endpoint/public/applications/endpoint/view/alerts/details/overview/take_action_dropdown.tsx
Outdated
Show resolved
Hide resolved
.../endpoint/public/applications/endpoint/view/alerts/details/overview/take_action_dropdown.tsx
Outdated
Show resolved
Hide resolved
Pinging @elastic/endpoint-app-team (Feature:Endpoint) |
Pinging @elastic/endpoint-response (Team:Endpoint Response) |
.../endpoint/public/applications/endpoint/view/alerts/details/overview/take_action_dropdown.tsx
Outdated
Show resolved
Hide resolved
02b4f58
to
aae466a
Compare
8a06655
to
41e05a8
Compare
8718999
to
90a419d
Compare
await pageObjects.endpointAlerts.submitSearchBarFilter(); | ||
const currentUrl = await browser.getCurrentUrl(); | ||
expect(currentUrl).to.contain('query='); | ||
expect(currentUrl).to.contain('date_range='); | ||
await pageObjects.endpointAlerts.enterSearchBarQuery(''); | ||
await pageObjects.endpointAlerts.submitSearchBarFilter(); |
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.
We should put these in an after
block. I suggest doing something like:
describe('when submitting a new bar query', () => {
before(async () => {
await pageObjects.endpointAlerts.enterSearchBarQuery('test query');
await pageObjects.endpointAlerts.submitSearchBarFilter();
});
it('should update the url correctly', () => {});
after(async () => {
await pageObjects.endpointAlerts.enterSearchBarQuery('');
await pageObjects.endpointAlerts.submitSearchBarFilter();
});
});
@@ -15,6 +15,6 @@ export default function({ loadTestFile }: FtrProviderContext) { | |||
loadTestFile(require.resolve('./management')); | |||
loadTestFile(require.resolve('./policy_list')); | |||
loadTestFile(require.resolve('./policy_details')); | |||
loadTestFile(require.resolve('./alert_list')); | |||
loadTestFile(require.resolve('./alert')); |
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.
We should rename this file to alerts.ts
instead of alert.ts
.
90a419d
to
840e94a
Compare
x-pack/test/functional/config.js
Outdated
@@ -88,6 +88,7 @@ export default async function({ readConfigFile }) { | |||
'--telemetry.banner=false', | |||
'--timelion.ui.enabled=true', | |||
'--xpack.endpoint.enabled=true', | |||
'--xpack.endpoint.alertResultListDefaultDateRange.from=2018-01-10T00:00:00.000Z', |
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.
oh no
import { mockAlertResultList } from '../../store/alerts/mock_alert_result_list'; | ||
import { DepsStartMock, depsStartMock } from '../../mocks'; | ||
|
||
describe('when the alert details flyout is open', () => { |
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.
This description doesn't match the setup logic. Also, it seems very close to what is here:
https://github.com/elastic/kibana/blob/master/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.test.tsx#L23
I think these specs should be parts of that. The setup logic can be reused that way. Also, the tests are about the same feature set.
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.
abstracted the building render logic out into its own function
beforeEach(() => { | ||
reactTestingLibrary.act(() => { | ||
history.push({ | ||
...history.location, |
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 line necessary?
export const TakeActionDropdown = memo(() => { | ||
const [isDropdownOpen, setIsDropdownOpen] = useState(false); | ||
|
||
const TakeActionButton = useMemo(() => { |
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.
Creating a new component in the render method of another component is a bit nonstandard. The component itself will be redefined when isDropdownOpen
is changed. For consistency with the recommended react patterns, consider defining this component once.
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.
Here's a commit with the changes I'd recommend: oatkiller@98bca4a
button={TakeActionButton} | ||
isOpen={isDropdownOpen} | ||
anchorPosition="downRight" | ||
closePopover={() => setIsDropdownOpen(false)} |
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.
please use useCallback
here to prevent EuiPopover
from rendering too often
<EuiButtonEmpty | ||
data-test-subj="alertDetailTakeActionCloseAlertButton" | ||
color="text" | ||
onClick={() => {}} |
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.
Can you remove this function? It shouldn't do anything, and having a new function reference on each render will force EuiButtonEmpty
to rerender each time
<EuiButtonEmpty | ||
data-test-subj="alertDetailTakeActionWhitelistButton" | ||
color="text" | ||
onClick={() => {}} |
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.
Can you remove this?
expect(currentUrl).to.contain('date_range='); | ||
}); | ||
after(async () => { | ||
await pageObjects.endpointAlerts.enterSearchBarQuery(''); |
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.
Why do you need this? is the page not being reloaded after each test?
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.
it's not being reloaded after each test, seemingly only for each file, so this just clears out the state so as to not impede further tests in this file with narrowed filter conditions
4ecb496
to
bbfd954
Compare
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* master: [SIEM] Adds 'Closes one signal when more than one opened signals are selected' test again (elastic#60380) [SIEM][Detections Engine] - Add rule markdown field to rule create, detail, and edit flows (elastic#60108) [Fleet] Add config revision to fleet agents (elastic#60292) Allow kbn-config-schema to ignore unknown keys (elastic#59560) [ML] Functional tests - disable df analytics clone tests skip flaky suite (elastic#58643) (elastic#58991) [FTR] Add support for --include and --exclude files via tags (elastic#60123) [SIEM] Fix link on overview page (elastic#60348) skip flaky test (elastic#60369) [Endpoint] Adds take action dropdown and tests to alert details flyout (elastic#59242) [Lens] Simplify state management from visualization (elastic#58279) Changing default type to start and allowing it to be configured by the event category (elastic#60323) [ML] Adds the class_assignment_objective to classification (elastic#60358)
* master: (51 commits) do not update cell background if is label cell (elastic#60308) FTR configurable test users (elastic#52431) [Reporting] Wholesale moves client to newest-platform (elastic#58945) [Ingest] Support `show_user` package registry flag (elastic#60338) [SIEM] Adds 'Closes one signal when more than one opened signals are selected' test again (elastic#60380) [SIEM][Detections Engine] - Add rule markdown field to rule create, detail, and edit flows (elastic#60108) [Fleet] Add config revision to fleet agents (elastic#60292) Allow kbn-config-schema to ignore unknown keys (elastic#59560) [ML] Functional tests - disable df analytics clone tests skip flaky suite (elastic#58643) (elastic#58991) [FTR] Add support for --include and --exclude files via tags (elastic#60123) [SIEM] Fix link on overview page (elastic#60348) skip flaky test (elastic#60369) [Endpoint] Adds take action dropdown and tests to alert details flyout (elastic#59242) [Lens] Simplify state management from visualization (elastic#58279) Changing default type to start and allowing it to be configured by the event category (elastic#60323) [ML] Adds the class_assignment_objective to classification (elastic#60358) [TSVB] fix text color when using custom background color (elastic#60261) Fix import to timefilter from in TSVB (elastic#60296) [NP] Get rid of usage redirectWhenMissing service (elastic#59777) ...
* alerting/view-in-app: (53 commits) fixed typo handle optional alerting plugin do not update cell background if is label cell (elastic#60308) FTR configurable test users (elastic#52431) [Reporting] Wholesale moves client to newest-platform (elastic#58945) [Ingest] Support `show_user` package registry flag (elastic#60338) [SIEM] Adds 'Closes one signal when more than one opened signals are selected' test again (elastic#60380) [SIEM][Detections Engine] - Add rule markdown field to rule create, detail, and edit flows (elastic#60108) [Fleet] Add config revision to fleet agents (elastic#60292) Allow kbn-config-schema to ignore unknown keys (elastic#59560) [ML] Functional tests - disable df analytics clone tests skip flaky suite (elastic#58643) (elastic#58991) [FTR] Add support for --include and --exclude files via tags (elastic#60123) [SIEM] Fix link on overview page (elastic#60348) skip flaky test (elastic#60369) [Endpoint] Adds take action dropdown and tests to alert details flyout (elastic#59242) [Lens] Simplify state management from visualization (elastic#58279) Changing default type to start and allowing it to be configured by the event category (elastic#60323) [ML] Adds the class_assignment_objective to classification (elastic#60358) [TSVB] fix text color when using custom background color (elastic#60261) ...
Friendly reminder: Looks like this PR hasn’t been backported yet. |
elastic#59242) * adds dropdown * changes i18n fields * switches to buttons * adds tests for alert details flyout * updates es archiver data * finishes functional and react tests * cleanup tests for alerts * updates alert esarchive data * replaces es archives and fixes tests * rebase * fixes functional tests * suggested changes to take action button * addresses comments Co-authored-by: oatkiller <[email protected]>
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
#59242) (#60598) * adds dropdown * changes i18n fields * switches to buttons * adds tests for alert details flyout * updates es archiver data * finishes functional and react tests * cleanup tests for alerts * updates alert esarchive data * replaces es archives and fixes tests * rebase * fixes functional tests * suggested changes to take action button * addresses comments Co-authored-by: oatkiller <[email protected]> Co-authored-by: Davis Plumlee <[email protected]> Co-authored-by: oatkiller <[email protected]>
Summary
Adds a take action dropdown to the alert details flyout as a base for the close alert and whitlelisting actions to be created on. Also fleshes out the alert detail flyout jest and functional tests. It also recreates the es-archive files for endpoint management and alerts to match the new sample data generator and updates the functional/api integration tests accordingly
Checklist
Delete any items that are not applicable to this PR.
For maintainers