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

[Endpoint] Adds take action dropdown and tests to alert details flyout #59242

Merged
merged 13 commits into from
Mar 17, 2020

Conversation

dplumlee
Copy link
Contributor

@dplumlee dplumlee commented Mar 3, 2020

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

Screen Shot 2020-03-11 at 5 43 27 PM

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@dplumlee dplumlee changed the title [Endpoint] Adds dropdown [Endpoint] Adds take action dropdown to alert details flyout Mar 3, 2020

export const TakeActionDropdown = styled(
memo(({ className }: { className?: string }) => {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

@peluja1012 peluja1012 added the Feature:Endpoint Elastic Endpoint feature label Mar 4, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-app-team (Feature:Endpoint)

@peluja1012 peluja1012 added the Team:Endpoint Response Endpoint Response Team label Mar 4, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-response (Team:Endpoint Response)

@dplumlee dplumlee force-pushed the alert-take-action-dropdown branch 2 times, most recently from 02b4f58 to aae466a Compare March 11, 2020 04:04
@dplumlee dplumlee added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0 labels Mar 11, 2020
@dplumlee dplumlee marked this pull request as ready for review March 11, 2020 21:46
@dplumlee dplumlee requested a review from a team as a code owner March 11, 2020 21:46
@dplumlee dplumlee force-pushed the alert-take-action-dropdown branch 3 times, most recently from 8a06655 to 41e05a8 Compare March 15, 2020 04:28
@dplumlee dplumlee changed the title [Endpoint] Adds take action dropdown to alert details flyout [Endpoint] Adds take action dropdown and tests to alert details flyout Mar 15, 2020
@dplumlee dplumlee force-pushed the alert-take-action-dropdown branch 4 times, most recently from 8718999 to 90a419d Compare March 16, 2020 03:35
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();
Copy link
Contributor

@peluja1012 peluja1012 Mar 16, 2020

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'));
Copy link
Contributor

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.

@@ -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',
Copy link
Contributor

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', () => {
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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(() => {
Copy link
Contributor

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.

Copy link
Contributor

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)}
Copy link
Contributor

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={() => {}}
Copy link
Contributor

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={() => {}}
Copy link
Contributor

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('');
Copy link
Contributor

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?

Copy link
Contributor Author

@dplumlee dplumlee Mar 16, 2020

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

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@peluja1012 peluja1012 merged commit 53d23fc into elastic:master Mar 17, 2020
@dplumlee dplumlee deleted the alert-take-action-dropdown branch March 17, 2020 15:47
cnasikas pushed a commit to cnasikas/kibana that referenced this pull request Mar 17, 2020
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 <robert.austin@elastic.co>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 17, 2020
* 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)
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 17, 2020
* 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)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 17, 2020
* 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)
  ...
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 18, 2020
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 59242 or prevent reminders by adding the backport:skip label.

peluja1012 pushed a commit to peluja1012/kibana that referenced this pull request Mar 19, 2020
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 <robert.austin@elastic.co>
@kibanamachine
Copy link
Contributor

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.

@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 19, 2020
peluja1012 added a commit that referenced this pull request Mar 19, 2020
#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 <robert.austin@elastic.co>

Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com>
Co-authored-by: oatkiller <robert.austin@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Endpoint Elastic Endpoint feature release_note:skip Skip the PR/issue when compiling release notes Team:Endpoint Response Endpoint Response Team v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants