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] Can delete policies #68567

Merged
merged 18 commits into from
Jun 12, 2020
Merged

Conversation

kevinlog
Copy link
Contributor

@kevinlog kevinlog commented Jun 8, 2020

Summary

Adds ability to delete Policies from the Endpoint management pages.

image

image

image

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@kevinlog
Copy link
Contributor Author

kevinlog commented Jun 9, 2020

@elasticmachine merge upstream

@kevinlog kevinlog marked this pull request as ready for review June 9, 2020 22:46
@kevinlog kevinlog requested review from a team as code owners June 9, 2020 22:46
@kevinlog kevinlog changed the title Can delete policies [Endpoint] Can delete policies Jun 9, 2020
@kevinlog kevinlog added release_note:skip Skip the PR/issue when compiling release notes v7.9.0 v8.0.0 Feature:Endpoint Elastic Endpoint feature labels Jun 9, 2020
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

Pinging @elastic/endpoint-management (Team:Endpoint Management)

@@ -24,7 +24,7 @@ import { EuiTabProps } from '@elastic/eui/src/components/tabs/tab';

const StyledEuiPage = styled(EuiPage)`
&.endpoint--isListView {
padding: 0;
padding: 0 70px 0 24px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated for 2 reasons, to be more uniform with the rest of the security app and to allow functional tests to execute properly as the overlap with the timeline was blocking click events

@@ -79,12 +79,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
expect(relativeDate).to.match(RELATIVE_DATE_FORMAT);
});
});
it('should show policy name as link', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed since I check the link is formed correctly in a unit test now


const StyledEuiPage = styled(EuiPage)`
&.endpoint--isListView {
padding: 0;
padding: 0 ${gutterTimeline} 0 ${(props) => props.theme.eui.euiSizeL};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated for 2 reasons, to be more uniform with the rest of the security app and to allow functional tests to execute properly as the overlap with the timeline was blocking click events.

We'll be looking to remove the timeline flyout, so we could remove the functional test and add it back in afterwards, but wouldn't we want the tables to look uniform with the rest of the app regardless?

Thoughts @paul-tavares @bfishel

Here's what it looks like
image

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 ok for now. In the future we will likely move way from <PageView> and use SIEMs page and header components -- and/or -- as you said, remove/hide the timeline

expect(policyDeleteButton).not.toBeNull();
});
});
it('should display agent config action as link', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be good to put spaces between the ITs

@kevinlog
Copy link
Contributor Author

@elasticmachine merge upstream

@kevinlog
Copy link
Contributor Author

@elasticmachine merge upstream

body: DeleteDatasourcesRequest,
options?: HttpFetchOptions
) => {
return http.post<DeleteDatasourcesResponse>(`${INGEST_API_DELETE_DATASOURCE}`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optinal:

Suggested change
return http.post<DeleteDatasourcesResponse>(`${INGEST_API_DELETE_DATASOURCE}`, {
return http.post<DeleteDatasourcesResponse>(INGEST_API_DELETE_DATASOURCE, {

@@ -47,6 +58,45 @@ export const policyListMiddlewareFactory: ImmutableMiddlewareFactory<PolicyListS
total: response ? response.total : initialPolicyListState().total,
},
});
} else if (action.type === 'userClickedPolicyListDeleteButton') {
const { policyId } = action.payload;
const datasourceIds: string[] = [policyId];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use the DeleteDatatsourceRequest['body']['datasourceIds'] here case the interface is ever changed?

expect(policyActionsButton).not.toBeNull();

reactTestingLibrary.fireEvent.click(policyActionsButton);
renderResult.findByTestId('agentConfigLink').then((agentConfigLink) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and similar lines below that are using then() I think are causing the it() test to exit before running the expect. I would one of two things: either use a variable assignment along with await or create a Promise.all() and return that so that the test knows to wait.

await actionsButton.click();
const deleteAction = await testSubjects.find('policyDeleteButton');
await deleteAction.click();
return await testSubjects.find('policyListDeleteModal');
Copy link
Contributor

@paul-tavares paul-tavares Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - thre are a few modal page objects in common that might do some of this here. Example: below, I use pageObjects.common.clickConfirmOnModal() to click on the modal's confirm button

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually am using that function in one of the tests itself - https://github.com/elastic/kibana/pull/68567/files#diff-c48c00cc17b949e71b8732594dc70734R98

This is more to go through the motions of actually launching the delete modal through the policy actions

@paul-tavares
Copy link
Contributor

paul-tavares commented Jun 10, 2020

This looks great @kevinlog . I checked out the branch and ran through 🌞 day scenario and 👍 .
Left a few comment - only the Jest UT comment seems to me to be the most important

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@@ -6,6 +6,7 @@

import { PolicyData } from '../../../../../../common/endpoint/types';
import { ServerApiError } from '../../../../../common/types';
import { GetAgentStatusResponse } from '../../../../../../../ingest_manager/common/types/rest_spec';
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 exposed at top level /common? if so, use that path instead.
You can do this in a subsequent PR 😃

await (await pageObjects.policy.findFirstActionsButton()).click();
});

it('should delete a policy', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@@ -33,6 +33,16 @@ export function EndpointPageProvider({ getService, getPageObjects }: FtrProvider
});
},

async waitForTableToNotHaveData(dataTestSubj: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice one and I can see us moving this to a page_utils page object in the future as a common way to wait for a table to empty out 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment: we should add JSDocs to this method. I think normally, the page objects can be reused by other tests (even outside of Endpoint) to integrate/interact with endpoint functionality

/**
* ensures that the Policy Page is the currently display view
*/
async ensureIsOnPolicyPage() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename suggestion: ensureIsOnPolicyListPage()?

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not run locally again, but changes look good. Left some minor comments that are optional and can be incorporated in future PRs.

Great job on this 👍
🚀

@kevinlog kevinlog merged commit ccf8def into elastic:master Jun 12, 2020
@kevinlog kevinlog deleted the task/add-delete-action branch June 12, 2020 15:28
kevinlog added a commit to kevinlog/kibana that referenced this pull request Jun 12, 2020
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 v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants