Commit graph

98 commits

Author SHA1 Message Date
Sonja Krause-Harder
efcf7d1a25
[Fleet] Don't fail on errors in 'update' or 'reupdate' operation in /setup (#97404)
* Don't fail on, just report, update and reupdate errors.

* Show error toast on update and reupdate errors.

* Don't return empty error array.

* Adjust mock.

* Adjust test.
2021-04-19 16:01:10 +02:00
John Schulz
17ecb04dce
[Fleet] Filter hosted policies from menu (#97380)
## Summary

 * 4C & 7C from https://github.com/elastic/kibana/issues/91906 about hiding hosted agent policy from select menus
 * Also changed reassign agent to new policy UI from flyout to modal as requested
<details><summary>Screenshots</summary>

<h3>Current</h3>
<img width="1090" alt="Screen Shot 2021-04-16 at 1 37 02 PM" src="https://user-images.githubusercontent.com/57655/115075124-9d9ea600-9ec8-11eb-8e88-d8f14f62613f.png">


<h3>PR</h3>
<img width="1092" alt="Screen Shot 2021-04-16 at 1 43 51 PM" src="https://user-images.githubusercontent.com/57655/115075127-9d9ea600-9ec8-11eb-8c47-c3b1fbeb96eb.png">

<h3>current</h3>
<img width="1112" alt="Screen Shot 2021-04-16 at 1 44 41 PM" src="https://user-images.githubusercontent.com/57655/115075129-9e373c80-9ec8-11eb-9f93-cac511c9d53d.png">

<h3>PR</h3>
<img width="1106" alt="Screen Shot 2021-04-16 at 1 50 28 PM" src="https://user-images.githubusercontent.com/57655/115075130-9e373c80-9ec8-11eb-93fb-0adfa5ae81ba.png">


<h3>current</h3>
<img width="1106" alt="Screen Shot 2021-04-16 at 1 35 48 PM" src="https://user-images.githubusercontent.com/57655/115075121-9d9ea600-9ec8-11eb-8605-89336371938b.png">

<h3>PR</h3>
<img width="1106" alt="Screen Shot 2021-04-16 at 2 35 15 PM" src="https://user-images.githubusercontent.com/57655/115075133-9ecfd300-9ec8-11eb-9458-0b7f9cf76c10.png">

<img width="2136" alt="Screen Shot 2021-04-16 at 3 24 16 PM" src="https://user-images.githubusercontent.com/57655/115075141-a0010000-9ec8-11eb-896c-efc4be4be5ac.png">

</details>

### Checklist
- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-04-19 09:43:43 -04:00
John Schulz
2f4e9db7fc
Use <AgentPolicySummaryLine /> for consistent name+icon lockup (#97377)
## Summary

From design ticket https://github.com/elastic/observability-design/issues/32
> any ... place we display a link to the hosted agent policy, show an icon with hover tooltip:

This PR closes 1B + 1C from https://github.com/elastic/kibana/issues/91906 & two other places which followed the same pattern.

Factored out some repeated code at each call site into a `<AgentPolicySummaryLine />` component


<details><summary>Screenshots</summary>
<h3>Agent Policy List View</h3>
<img width="1103" alt="Screen Shot 2021-04-16 at 1 01 55 PM" src="https://user-images.githubusercontent.com/57655/115059112-18a99180-9eb4-11eb-9035-36a8e9db1f9d.png">

<h3>Agent List View</h3>
<img width="1185" alt="Screen Shot 2021-04-16 at 12 38 40 PM" src="https://user-images.githubusercontent.com/57655/115058885-bea8cc00-9eb3-11eb-8529-6f185fcac7d2.png">


<h3>Packaged Policy List View</h3>
<img width="1251" alt="Screen Shot 2021-04-16 at 10 23 49 AM" src="https://user-images.githubusercontent.com/57655/115058880-be103580-9eb3-11eb-8060-c501663af556.png">

<h3>Agent Policy Detail View</h3>
<img width="1145" alt="Screen Shot 2021-04-16 at 12 21 42 PM" src="https://user-images.githubusercontent.com/57655/115058883-bea8cc00-9eb3-11eb-9970-462ff4600fa4.png">



</details>

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-04-19 07:33:27 -04:00
John Schulz
6e5c9278ba
[Fleet] Use 'hosted agent policy' naming in UI & API messages (#97287)
## Summary

### What this PR _does_ change
 - [x] Replace all UI & API instances of "managed policy" with "hosted agent policy" #93504
 - [x] Replace all UI & API instances of "unmanaged policy" with "regular agent policy" #93504
 - [x] Update most variable names containing `managed` to `hosted`

<details><summary>screenshots</summary>

<img width="489" alt="Screen Shot 2021-04-15 at 10 54 01 AM" src="https://user-images.githubusercontent.com/57655/114898051-cac35980-9ddf-11eb-9c55-3fb5c0211c63.png">
<img width="339" alt="Screen Shot 2021-04-15 at 11 40 47 AM" src="https://user-images.githubusercontent.com/57655/114898053-cac35980-9ddf-11eb-8c60-3459aed3db6c.png">
<img width="714" alt="Screen Shot 2021-04-15 at 11 40 59 AM" src="https://user-images.githubusercontent.com/57655/114898054-cac35980-9ddf-11eb-912a-623eba9c3860.png">
</details>

### What this PR _does not_ change
  - [ ] The `is_managed` property of the agent policy saved object*
  - [ ] The updated error messages in https://github.com/elastic/kibana/issues/92591

<details><summary>*why not change the <code>is_managed</code> property?</summary>

<p>Changing the property will require a migration from 7.12. That's not a problem, but we haven't decided on <a href="https://github.com/elastic/kibana/issues/93504#issuecomment-790060997">a new name/approach</a> yet. Rather than update to <code>is_hosted: boolean</code> now and potentially something like <code>managed_by: enum</code> later, we'll update it when we have a decision.

<p><strong>TL;DR:</strong> It's a trivial update to make later and a minuscule amount of debt to pay until then. Less than cost of doing it twice.
 
</details>

### Checklist

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
2021-04-15 21:01:28 -04:00
Nicolas Chaulet
78937e3bb4
[Fleet] Remove fleet agent routes and related services (#97206) 2021-04-15 17:15:43 -04:00
Nicolas Chaulet
b96172e27c
[Fleet] Fleet server onboarding UI (#96867) 2021-04-15 01:22:32 -04:00
Zacqary Adam Xeper
deaa7794d5
[Fleet] Add ability to specify which integration variables should be configurable (#97163) 2021-04-14 17:00:18 -05:00
Greg Thompson
d679035664
Upgrade EUI to v32.0.4 (#96459)
* eui to 31.12.0

* type updates

* snapshot updates

* snapshot updates

* euiavatarprops

* eui to 32.0.3

* euicard updates

* update test
2021-04-14 11:27:36 -05:00
Zacqary Adam Xeper
7a070e893d
[Fleet] Add preconfiguration to kibana config (#96588) 2021-04-14 10:43:08 -05:00
John Schulz
c40121151f
[Fleet] UI changes on hosted policy detail view (#96337)
## Summary

Fixes several items from https://github.com/elastic/observability-design/issues/32

- Agent policy detail page
  - [x] Integrations tab: 1a) Show a lock icon with hover tooltip next to host policy name
  - [x] Integrations tab: 7a) hide the "Add integration" button
  - [x] Integrations tab: 7b) hide the "delete integration" action which appears in the [...] actions menu
  - [x] Settings tab: 5a) Do not show the “Delete policy” section for Hosted agent policies
  - [x] Settings tab: 5b) Disable the "name" and "description" inputs
 - Agents detail page
   - [x] 2b) remove the "actions" button in the page header (top right)

## Screenshots

<details><summary>Agent policy detail page - Integrations tab</summary>
<ul>
<li>1a) Show a lock icon with hover tooltip next to host policy name</li>
<li>7a) hide the "Add integration" button</li>
<li>7b) hide the "delete integration" action which appears in the [...] actions menu</li>
</ul>

<h3>Non-hosted policy</h3>
<img width="1186" alt="Screen Shot 2021-04-08 at 1 30 24 PM" src="https://user-images.githubusercontent.com/57655/114071393-0eade000-986f-11eb-847f-0c64c7d2aa5e.png">

<h3>Hosted policy</h3>
<img width="1184" alt="Screen Shot 2021-04-08 at 1 29 26 PM" src="https://user-images.githubusercontent.com/57655/114071389-0eade000-986f-11eb-9501-332509b0a85d.png">

</details>

<details><summary>Agent policy detail page - Settings tab</summary>

<ul>
<li>5a) Do not show the “Delete policy” section for Hosted agent policies</li>
<li>5b) Disable the "name" and "description" inputs</li>
</ul>

<h3>non-hosted policy: items available</h3>
<img width="1209" alt="Screen Shot 2021-04-07 at 1 24 39 PM" src="https://user-images.githubusercontent.com/57655/114069262-cdb4cc00-986c-11eb-84c8-926c98a75d47.png">

<h3>Hosted policy: items hidden / disabled</h3>
<img width="1228" alt="Screen Shot 2021-04-07 at 1 24 23 PM" src="https://user-images.githubusercontent.com/57655/114069259-cdb4cc00-986c-11eb-82fc-39509c6ef9fe.png">

</details>

<details><summary>Agents detail page: 2b) remove the "actions" button in the page header (top right)</summary>

<h4>shown on non-hosted policy</h4>
<img width="1408" alt="Screen Shot 2021-04-08 at 9 55 06 AM" src="https://user-images.githubusercontent.com/57655/114068747-38193c80-986c-11eb-9fb6-b8f9eb77a1d6.png">

<h4>hidden on hosted policy</h4>
<img width="1345" alt="Screen Shot 2021-04-08 at 9 55 31 AM" src="https://user-images.githubusercontent.com/57655/114068748-38b1d300-986c-11eb-9eee-ee15f8acd718.png">

</details>

### Checklist
- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)


Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-04-12 09:43:06 -04:00
Ross Wolf
93965343e5
[Fleet] Install security_rule assets as saved objects (#95885)
* [Fleet] Install security_rule assets as saved objects

* Add security-rule to update_assets.ts

* Update UUIDs for security_rule asset

* Change .type to match the saved object type not the asset type

* Add saved object mapping for security-rule

* Make SO non-hidden

* Fix SO mapping for security-rule

* Make security-rule a non-hidden asset
2021-04-08 00:52:10 -04:00
John Schulz
2adc060044
[Fleet] Hide many actions for hosted agent policies (#96160)
## Summary

Fixes items 2a, 4a, 5c2, and 6 from https://github.com/elastic/kibana/issues/91906

### 2a - On the agents table, remove all actions except for "View agent"

[code commit](a93dd8cc7b) 

<img width="1090" alt="Screen Shot 2021-04-02 at 2 00 34 PM" src="https://user-images.githubusercontent.com/57655/113446102-1b40bd00-93c5-11eb-804b-2afec37a176b.png">
<img width="1100" alt="Screen Shot 2021-04-02 at 2 00 41 PM" src="https://user-images.githubusercontent.com/57655/113446103-1b40bd00-93c5-11eb-8aba-daa1aa539955.png">

### 4a & 5c2 On the agent policy list page, remove the "add agent" & "copy policy" actions which appears in the [...] actions menu
[code commit](f0c267f717)
<img width="1067" alt="Screen Shot 2021-04-02 at 2 36 57 PM" src="https://user-images.githubusercontent.com/57655/113446281-7b376380-93c5-11eb-9f82-03e957e6656c.png">
<img width="1104" alt="Screen Shot 2021-04-02 at 2 37 02 PM" src="https://user-images.githubusercontent.com/57655/113446282-7bcffa00-93c5-11eb-942c-1a98ebbab385.png">


### 6 - Do not show the the "revoke token" trash icon

[code commit](cd05cd0f97)
<img width="1088" alt="Screen Shot 2021-04-02 at 2 15 54 PM" src="https://user-images.githubusercontent.com/57655/113446176-4a572e80-93c5-11eb-9740-9723c1cb9f50.png">

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-04-06 11:00:30 -04:00
John Schulz
357c4a5457
[Fleet] Can't select managed agent. Bulk upgrade agent UI changes (#96087)
## Summary

This PR implements several items from point 8 in https://github.com/elastic/observability-design/issues/32 

The changes to modal titles and success/error behavior are only for bulk upgrade in this PR. Once we confirm the pattern, I'll apply it to unenroll and reassign in a follow up PR.

- [x] Disable the checkbox for agents enrolled in a hosted agent policy. We don't need to provide a tooltip description since the Agent policy "lock" icon appears in the table row.
- [x] If a user selects the top-left checkbox to select all agents on the page, and then clicks "select everything on all pages", we don't need to provide a count for total number of agents selected. The bulk actions button can say "all agents selected" (as discussed, calculating the total number of agents is problematic and can be tough on performance). Choosing a bulk action should filter out / not include any agents that are enrolled in a hosted agent policy.
- [x] Related to calculating total number of agents, we previously showed a count in the action modal's title. In the case where users have selected everything on all pages, the title can just say "all selected agents" -> i.e. "upgrade all selected agents"
- [x] If the result of a bulk action has mixed results, as in some percentage of agents are successful but others fail, show a warning toast that indicates how many succeeded and how many failed. See screenshot below.
- [x] Change the "experimental" badge for the upgrade agent action modal to be an icon only badge. You can use the `beaker` icon. The badge should use the same tooltip description that we use today indicating that this action is experimental.

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)
- [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios

## Per feature details & screenshots
<details>
  <summary>Disable the checkbox for agents enrolled in a hosted agent policy.</summary>
<img width="1016" alt="Screen Shot 2021-04-02 at 10 35 38 AM" src="https://user-images.githubusercontent.com/57655/113425437-d9e9e680-939f-11eb-9b1b-423d78dbc8fc.png">
<blockquote>We don't need to provide a tooltip description since the Agent policy "lock" icon appears in the table row.</blockquote>
I left the description in until we implement the "lock" icon.
</details>

<details>
  <summary>If a user selects the top-left checkbox to select all agents on the page, and then clicks "select everything on all pages", ... the bulk actions button can say "all agents selected" </summary>
<img width="998" alt="Screen Shot 2021-04-02 at 9 20 28 AM" src="https://user-images.githubusercontent.com/57655/113426911-1d455480-93a2-11eb-98e2-5a328ebd9d97.png">
<img width="1010" alt="Screen Shot 2021-04-02 at 9 20 45 AM" src="https://user-images.githubusercontent.com/57655/113426912-1d455480-93a2-11eb-92f3-7036d9e95f0c.png">

<blockquote>Choosing a bulk action should filter out / not include any agents that are enrolled in a hosted agent policy.</blockquote>
<img width="529" alt="Screen Shot 2021-04-02 at 10 58 43 AM" src="https://user-images.githubusercontent.com/57655/113427313-cb50fe80-93a2-11eb-948a-68dc165e567b.png">
<img width="593" alt="Screen Shot 2021-04-02 at 11 00 44 AM" src="https://user-images.githubusercontent.com/57655/113427317-cbe99500-93a2-11eb-9701-48a598350d4b.png">
<img width="1021" alt="Screen Shot 2021-04-02 at 10 59 27 AM" src="https://user-images.githubusercontent.com/57655/113427315-cb50fe80-93a2-11eb-8af3-822a23b91940.png">
<em>There are 7 rows, but only 6 were attempted because 1 is managed</em>
</details>

<details>
  <summary>When users have selected everything on all pages, the title can just say "all selected agents" -> i.e. "upgrade all selected agents"</summary>
<img width="843" alt="Screen Shot 2021-04-01 at 11 35 06 AM" src="https://user-images.githubusercontent.com/57655/113344391-04379780-92ff-11eb-86f8-62cdc0cde69d.png">
<em>the text inside the modal was also updated per the screenshots</em>

<h4>Single agent case</h4>
<img width="796" alt="Screen Shot 2021-04-01 at 11 35 18 AM" src="https://user-images.githubusercontent.com/57655/113344393-04d02e00-92ff-11eb-8b7e-1992a1ac695e.png">

<h4>Multiple items but not "all"</h4>
<img width="786" alt="Screen Shot 2021-04-01 at 11 35 33 AM" src="https://user-images.githubusercontent.com/57655/113344394-04d02e00-92ff-11eb-8f67-2f03fe8014c3.png">

</details>


<details>
  <summary>If the result of a bulk action has mixed results, as in some percentage of agents are successful but others fail, show a warning toast that indicates how many succeeded and how many failed</summary>

<h4>Mixed success & failure: show warning</h4>

<img width="1021" alt="Screen Shot 2021-04-02 at 10 59 27 AM" src="https://user-images.githubusercontent.com/57655/113427315-cb50fe80-93a2-11eb-8af3-822a23b91940.png">

<h4>All succeed. Variants for multiple vs all selected</h4>

<img width="376" alt="Screen Shot 2021-04-02 at 11 26 46 AM" src="https://user-images.githubusercontent.com/57655/113432299-2129a480-93ab-11eb-93f1-9a3edf2f1a2d.png">
<img width="342" alt="Screen Shot 2021-04-02 at 11 59 44 AM" src="https://user-images.githubusercontent.com/57655/113432300-21c23b00-93ab-11eb-85a8-222cef29a941.png">

<h4>All fail. Variants for multiple vs all selected</h4>

<img width="381" alt="Screen Shot 2021-04-02 at 11 14 48 AM" src="https://user-images.githubusercontent.com/57655/113428661-2daafe80-93a5-11eb-86b4-1993ebf9d2fa.png">

<img width="351" alt="Screen Shot 2021-04-02 at 11 19 17 AM" src="https://user-images.githubusercontent.com/57655/113428746-592de900-93a5-11eb-9cc0-5d919afd6d59.png">

</details>
<details>
  <summary>Change the "experimental" badge for the upgrade agent action modal to be an icon only badge. You can use the `beaker` icon. The badge should use the same tooltip description that we use today indicating that this action is experimental.</summary>
<img width="843" alt="Screen Shot 2021-04-01 at 11 35 06 AM" src="https://user-images.githubusercontent.com/57655/113344391-04379780-92ff-11eb-86f8-62cdc0cde69d.png">

</details>


Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-04-06 10:20:43 -04:00
James Gowdy
478ad3bad5
[Fleet] Adding ML module asset type (#94950)
* [Fleet] Adding ML module asset type

* adding test

* guessing asset ids

* better guess at IDs

* renaming asset ids

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-29 16:21:49 +01:00
Nicolas Chaulet
db7da2238e
[Fleet] add support for fleet server urls (#94364) 2021-03-26 14:53:35 -04:00
Paul Tavares
8933037bd0
[Fleet] Add fleetServerEnabled config setting and use it in SO migration for Endpoint Policies (#95204)
* Add `agents.fleetServerEnabled` to plugin configuration
* Use feature flag in Endpoint package policy SO migration
2021-03-23 15:24:24 -04:00
Nicolas Chaulet
11f02f78c6
[Fleet] Remove unused Fleet settings package|agent auto upgrade (#94805) 2021-03-18 09:08:35 -04:00
Nicolas Chaulet
85d5f40d0c
[Fleet] Fix version on agent details screen (#94867) 2021-03-17 23:50:08 -04:00
Jen Huang
2374af3011
Remove string as a valid registry var type value (#94174)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-16 12:32:02 -07:00
Zacqary Adam Xeper
cda2fb3d5a
[Data UI] [Fleet] Add submitOnBlur functionality to QueryStringInput (#93819)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-15 14:33:49 -04:00
John Schulz
a4fa4a62cb
Use consistent-type-imports lint rule to autofix type-only imports (#94464)
## Summary

Use the [`consistent-type-imports` lint rule ](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-imports.md) to use `import type ...` where possible

Code-only changes like this were recently added in https://github.com/elastic/kibana/pull/92979, but it was a more manual process.  This PR adds an autofixable lint rule which will keep the changes up-to-date and Just Work ™️
2021-03-15 13:58:50 +01:00
Jen Huang
394593ae94
Use password field for password vars (#94166) 2021-03-09 15:30:26 -05:00
Jen Huang
b8df640c95
[Fleet] Surface package version used in a package policy in UI (#93712)
* Surface package version used in a package policy in UI

* Fix i18n
2021-03-08 12:07:27 -05:00
Nicolas Chaulet
f4caf8727d
[Fleet] Remove fleetServerEnabled feature flag and use fleet system indices (#92422) 2021-03-08 07:40:09 -05:00
Jen Huang
b310138717
Don't truncate package name in package details page title (#93716) 2021-03-05 08:14:50 -08:00
Sonja Krause-Harder
3cd0d455c6
[Fleet] Don't add extra quotes to YAML strings from manifest files (#93585)
* Add UI validation for string YAML values in policies.

* Do not quote YAML strings containing special characters.

* Add test case for wildcards in the middle of strings.

* Add multiline test case.

* Polish test case.

* Update API docs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-05 15:00:31 +01:00
Alejandro Fernández Gómez
a050b7af79
[Fleet] Correctly track install status of an integration (#93464) 2021-03-04 11:01:23 +01:00
Nicolas Chaulet
a61e1dd9fa
[Fleet] Fix package version comparaison in the UI (#93498) 2021-03-03 17:04:52 -05:00
John Schulz
b5522ed30c
[Fleet] Add lint rule/fix for import order groups (#93300)
## Problem
Blocks of 10-15 `import`s are common in the plugin and there a few places which have ~50 lines of `import`s. It makes it more difficult to understand the where/why of what's being imported.

We've had instances while files import from the same module in different lines. i.e.

```ts
import { a } from './file';
... 5-10 lines later
import { b } from './file';
```

## Proposed solution
Add a lint rule to enforce a convention on the module `import` order. This can help in the same way Prettier & ESLint help to format type signatures or other code. It makes it easier to understand or notice any changes in the code. It's also able to be fixed automatically (`node scripts/eslint.js --fix` or any existing "format on save" in an editor).

## This PR
replaces #92980 (based on https://github.com/elastic/kibana/pull/92980#pullrequestreview-601070556)

### Lint rule
f9be98d Add eslint rule to enforce/autofix import group order. Use the same rule as a few other plugins. Groups `import` statements by type as shown in the [lint rule docs](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order
). The order is:

  1. node "builtin" modules
  2. "external" modules
  3. "internal" modules
  4. modules from a "parent" directory
  5. "sibling" modules from the same or a sibling's directory, "index" of the current directory, everything else

e.g.

```typescript
import fs from 'fs';
import path from 'path';

import _ from 'lodash';
import chalk from 'chalk';

import foo from 'src/foo';

import foo from '../foo';
import qux from '../../foo/qux';

import bar from './bar';
import baz from './bar/baz';
import main from './';
```
The [lint rule](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#importorder-enforce-a-convention-in-module-import-order) is relatively light handed. It only ensures  the `imports` are groups together in the given order. It doesn't alphabetize or otherwise sort the order of the files.


e.g. imports aren't rewritten to be in alphabetical order. This is fine

```ts
import from './c';
import from './a';
import from './b';
```

The [docs show other options](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#options) and 2831f02bc7/.eslintrc.js (L1138-L1168) uses many of them

### Newlines option
The newlines settings means a change from something like

```typescript
import fs from 'fs';
import path from 'path';
import _ from 'lodash';
import chalk from 'chalk';
import foo from 'src/foo';
import foo from '../foo';
import qux from '../../foo/qux';
import bar from './bar';
import baz from './bar/baz';
import main from './';
```

to 

```typescript
import fs from 'fs';
import path from 'path';

import _ from 'lodash';
import chalk from 'chalk';

import foo from 'src/foo';

import foo from '../foo';
import qux from '../../foo/qux';

import bar from './bar';
import baz from './bar/baz';
import main from './';
```



Added it as a separate commit 2831f02 in case we want to avoid it, but I believe it's an improvement overall. Especially on the files with 25+ lines of imports. Even the "worst case" of something like this isn't bad (IMO). Especially since it's an automatic reformat like anything else in prettier


```typescript
import fs from 'fs';

import _ from 'lodash';

import foo from '../foo';

import main from './';
```
2021-03-03 13:58:20 -05:00
Zacqary Adam Xeper
1b8d20c1c1
[Fleet] Fix default integration name when adding 10+ names (#93278) 2021-03-02 15:08:03 -05:00
John Schulz
1702cf98f0
[Fleet] Use type-only imports where possible (#92979)
## Summary

Use [type-only `import`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export) to differentiate between runtime values and (erasable) TS types.

<img width="1499" alt="Screen Shot 2021-02-27 at 6 34 46 PM" src="https://user-images.githubusercontent.com/57655/109403323-84e32c80-792a-11eb-94b7-854d0e5c3e99.png">

Allows Babel and `tsc` to make some optimizations since it can be sure what can be erased.

It can also be helpful in situations like below which highlights that even though `KibanaAssetType` and `KibanaSavedObjectType` are named a certain way and from `common/types`, they are JS values _not_ TS types. They are `enum`s which means they are JS objects at runtime; not eliminated at runtime.

d92a1a08d8/x-pack/plugins/fleet/common/types/models/epm.ts (L41-L63)
2021-03-02 12:10:39 -05:00
Jen Huang
10b1fddf35
[Fleet] Handle long text in agent details page (#91776)
* Fix #85521

* Set a minimum height for agent logs component #89831

* Truncate long integration names nicely #85404
2021-02-19 08:49:48 -08:00
Zacqary Adam Xeper
0760bfb870
[Fleet] Bootstrap functional test suite (#91898) 2021-02-18 16:34:50 -05:00
Greg Thompson
8126488021
Upgrade EUI to v31.7.0 (#91210)
* eui to 31.6.0

* flyout, collapsible snapshot updates

* initial overlaymask removal

* undo jest

* overlaymask src snapshot updates

* more overlaymask removals

* overlaymask removal xpack test updates

* saved objects modal form

* eui to 31.7.0

* code, codeblock types

* snapshot update

* tooltip

* remove ownFocus from ConfirmModal

* remove fragments
2021-02-16 14:06:25 -06:00
Mikhail Shustov
a1490d46f4
TS config cleanup (#90492)
* exclude all the plugins from src/plugins

* move all the used fixtures to discover

* remove src/fixtures alias

* remove unused fixtures

* cleanup x-pack/tsconfig.json

* dont compile apm/scripts

* fix tests

* dont include infra in xpack/tsconfig.json

* update list of includes
2021-02-11 12:34:25 -05:00
Jen Huang
c2b41c484b
[Fleet] Revamp integration detail page (#90887)
* Extract integration detail page changes from POC

* Remove unneccessary link wrappers

* Remove unused import

* Fix method name

* Fix linting
2021-02-10 12:03:34 -08:00
Nicolas Chaulet
f95bfe83b7
[Fleet] Use Fleet Server indices in the search bar (#90835) 2021-02-10 08:28:22 -05:00
Sonja Krause-Harder
4ee9603801
Use new shortcut links to Fleet discuss forums. (#90786)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-02-10 11:33:17 +01:00
Pierre Gayvallet
3b3327dbc3
Migrate most plugins to synchronous lifecycle (#89562)
* first pass

* migrate more plugins

* migrate yet more plugins

* more oss plugins

* fix test file

* change Plugin signature on the client-side too

* fix test types

* migrate OSS client-side plugins

* migrate OSS client-side test plugins

* migrate xpack client-side plugins

* revert fix attempt on fleet plugin

* fix presentation start signature

* fix yet another signature

* add warnings for server-side async plugins in dev mode

* remove unused import

* fix isPromise

* Add client-side deprecations

* update migration examples

* update generated doc

* fix xpack unit tests

* nit

* (will be reverted) explicitly await for license to be ready in the auth hook

* Revert "(will be reverted) explicitly await for license to be ready in the auth hook"

This reverts commit fdf73feb

* restore await on on promise contracts

* Revert "(will be reverted) explicitly await for license to be ready in the auth hook"

This reverts commit fdf73feb

* Revert "restore await on on promise contracts"

This reverts commit c5f2fe51

* add delay before starting tests in FTR

* update deprecation ts doc

* add explicit contract for monitoring setup

* migrate monitoring plugin to sync

* change plugin timeout to 10sec

* use delay instead of silence
2021-02-08 10:19:54 +01:00
Jen Huang
be53a06925
Fix state sharing between home integration components, prevent full page reload when clicking Fleet link (#90334)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-02-05 09:56:32 -08:00
John Schulz
9e7e1e1708
[Fleet] Managed Agent Policy (#88688)
## Summary
Introduces the concept of a managed agent policy. Resolves most of the acceptance criteria from #76843. Remaining to be done in follow up PRs

- [x] Define hosted Agent Policy concept in Fleet.
    - [x] Flag in policy? **_yes, added `is_managed: boolean`_ in agent policy SO**
    - [x] Should not built only for cloud, an admin should be able to set theses restrictions.
    - [x] We should have an API to configure it _**Can `POST` and `PUT` to  `/api/fleet/agent_policies/{policy_id}`**_
    - [x] Integration should be editable, we expect integration author to do the right thing and limit what can be edited.
- [x] Research if we can ensure the right behavior of Hosted Agent policy and restrict the super user.
- [ ] Capabilities restrictions
  - [ ] An Agent enrolled in an Hosted Agent policy should not be able to be upgraded.
  - [x] An Agent enrolled in an Hosted Agent policy should not be able to be unenrolled.
  - [ ] No Agents cannot be enrolled into this policy by the user.
      - Hide the enrollment key?
      - Need to figure out the workflow.
  - [x] An Agent enrolled in an Hosted Agent policy should not be able to be reassigned to a different configuration.
- [x] As a user I should be prevented to do theses action. _**No user-level checks. Only Agent Policy. No UI changes, but API errors are shown for failed actions like reassigning**_
- [x] As an API user I should receive error messages.
- [x] If making a single "flag" is easier/faster let's do it.  _**Currently single `is_managed` property on agent policy SO.**_

Checks are implemented in service layer (is agent enrolled in a managed policy?)

No UI-specific changes added but UI is affected because HTTP requests (like `api/fleet/agents/{agentId}/reassign`) can fail. See screenshots below.

Tests at service (`yarn test:jest`) and http (`yarn test ftr`) layers for each of create policy, update policy, unenroll agent, and reassign agent

Bulk actions currently filter out restricted items. A follow-up PR will change them to throw an error and cause the request to fail.


## Managed Policy
Can create (`POST`) and update (`PUT`) an agent policy with an `is_managed` property. Each new saved object will have an `is_managed` property (default `false`)

<details><summary>HTTP commands</summary>

#### Create (`is_managed: false` by default)
```
 curl --user elastic:changeme -X POST localhost:5601/api/fleet/agent_policies -H 'Content-Type: application/json' -d'{ "name": "User created policy", "namespace": "default"}' -H 'kbn-xsrf: true'
{"item":{"id":"edc236a0-5cbb-11eb-ab2c-0134aecb4ce8","name":"User created policy","namespace":"default","is_managed":false,"revision":1,"updated_at":"2021-01-22T14:12:58.250Z","updated_by":"elastic"}}
```

#### Create with `is_managed: true`
```
 curl --user elastic:changeme -X POST localhost:5601/api/fleet/agent_policies -H 'Content-Type: application/json' -d'{ "name": "User created policy", "namespace": "default"}' -H 'kbn-xsrf: true'
{"item":{"id":"67c785b0-662e-11eb-bf6b-4790dc0178c0","name":"User created policy","namespace":"default","is_managed":false,"revision":1,"updated_at":"2021-02-03T14:45:06.059Z","updated_by":"elastic"}}
```

#### Update with `is_managed: true`
```
 curl --user elastic:changeme -X PUT  -H 'Content-Type: application/json' -H 'kbn-xsrf: 1234' localhost:5601/api/fleet/agent_policies/67c785b0-662e-11eb-bf6b-4790dc0178c0 -d '{ "name":"User created policy","namespace":"default","is_managed":true }'
{"item":{"id":"67c785b0-662e-11eb-bf6b-4790dc0178c0","name":"User created policy","namespace":"default","is_managed":true,"revision":2,"updated_at":"2021-02-03T14:47:28.471Z","updated_by":"elastic","package_policies":[]}}
```
</details>

## Enroll behavior
is not changed/addressed in this PR. Agents can still be enrolled in managed policies

## Unenroll Agent from managed policy behavior
#### Enrolled in managed agent policy, cannot be unenrolled
```
curl --user elastic:changeme -X POST http://localhost:5601/api/fleet/agents/441d4a40-6710-11eb-8f57-db14e8e41cff/unenroll -H 'kbn-xsrf: 1234' | jq
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Cannot unenroll 441d4a40-6710-11eb-8f57-db14e8e41cff from a managed agent policy af9b4970-6701-11eb-b55a-899b78cb64da"
}
```

<details><summary>Screenshots for managed & unmanaged policies</summary>

#### Enrolled in managed agent policy, cannot be unenrolled
<img width="1931" alt="Screen Shot 2021-01-19 at 1 22 53 PM" src="https://user-images.githubusercontent.com/57655/105081614-67d05980-5a60-11eb-8faa-07e4e722a5b5.png">
<img width="1199" alt="Screen Shot 2021-01-19 at 1 30 26 PM" src="https://user-images.githubusercontent.com/57655/105081617-67d05980-5a60-11eb-9099-832dc6e04eca.png">
<img width="1971" alt="Screen Shot 2021-01-19 at 1 30 42 PM" src="https://user-images.githubusercontent.com/57655/105081618-67d05980-5a60-11eb-9a84-b80b6295ba19.png">

#### Enrolled agent policy is not managed, agent can be unenrolled<img width="1917" alt="Screen Shot 2021-01-19 at 1 44 12 PM" src="https://user-images.githubusercontent.com/57655/105081951-e3caa180-5a60-11eb-9308-7741b8986e8e.png">
<img width="2183" alt="Screen Shot 2021-01-19 at 1 44 19 PM" src="https://user-images.githubusercontent.com/57655/105081952-e3caa180-5a60-11eb-9833-1c721be0a107.png">

</details>


## Reassign agent 
#### No agent can be reassigned to a managed policy
```
 curl --user elastic:changeme -X 'PUT'  'http://localhost:5601/api/fleet/agents/482760d0-6710-11eb-8f57-db14e8e41cff/reassign' -H 'kbn-xsrf: xxx' -H 'Content-Type: application/json' -d '{"policy_id":"af9b4970-6701-11eb-b55a-899b78cb64da"}' 
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Cannot reassign an agent to managed agent policy 94129590-6707-11eb-b55a-899b78cb64da"
}
```
<details><summary>Screenshots</summary>

<img width="1350" alt="Screen Shot 2021-02-04 at 2 14 51 PM" src="https://user-images.githubusercontent.com/57655/106943490-8044a300-66f3-11eb-9d2c-4b1ceef2e783.png">

</details>

#### Enrolled in managed agent policy, cannot be reassigned
```
 curl --user elastic:changeme -X 'PUT'  'http://localhost:5601/api/fleet/agents/482760d0-6710-11eb-8f57-db14e8e41cff/reassign' -H 'kbn-xsrf: xxx' -H 'Content-Type: application/json' -d '{"policy_id":"af9b4970-6701-11eb-b55a-899b78cb64da"}' 
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Cannot reassign an agent from managed agent policy 94129590-6707-11eb-b55a-899b78cb64da"
}
```

<details><summary>Screenshots</summary>
<img width="1364" alt="Screen Shot 2021-01-19 at 2 58 38 PM" src="https://user-images.githubusercontent.com/57655/105086737-72dab800-5a67-11eb-8f5e-93cd7768b914.png">
<img width="1367" alt="Screen Shot 2021-01-19 at 2 58 44 PM" src="https://user-images.githubusercontent.com/57655/105086740-73734e80-5a67-11eb-8ef9-9c7005a0a4ea.png">
<img width="623" alt="Screen Shot 2021-01-19 at 2 59 27 PM" src="https://user-images.githubusercontent.com/57655/105086741-740be500-5a67-11eb-8fc2-721f8b5d178a.png">
</details>

#### Enrolled agent policy is unmanaged, agent can be reassigned to another unmanaged policy

<details><summary>Screenshots</summary>
<img width="1368" alt="Screen Shot 2021-01-19 at 3 00 01 PM" src="https://user-images.githubusercontent.com/57655/105086754-78d09900-5a67-11eb-86a5-9e3ac02d6e1f.png">
<img width="1363" alt="Screen Shot 2021-01-19 at 3 00 08 PM" src="https://user-images.githubusercontent.com/57655/105086761-7a01c600-5a67-11eb-991d-acf994e2a393.png">
<img width="625" alt="Screen Shot 2021-01-19 at 3 00 46 PM" src="https://user-images.githubusercontent.com/57655/105086764-7a9a5c80-5a67-11eb-8290-e79648d01579.png">
</details>

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)
- [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials
- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
2021-02-04 15:16:45 -05:00
Brandon Kobel
4584a8b570
Elastic License 2.0 (#90099)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:12:39 -08:00
Jen Huang
19effe2157
[Fleet] Fix duplicate data streams being shown in UI (#89812)
* Add API integration tests for data streams list, including one that is expected to fail due to reliance on number of backing indices

* Use ES data streams API as source of truth for list of data streams, and only query against backing indices afterwards

* Get package name from data stream meta info

* Increate retry timeout

* Move initial info requests inside Promise.all

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-02-02 10:11:15 -08:00
Nathan L Smith
e5588a129b
Move EUI styled components integration to kibana_react (#86065)
...from xpack_legacy.

Remove the duplicated typings from the observability plugin and only use the ones from kibana_react.

Fixes #78248.
2021-01-25 13:48:35 -06:00
Thom Heymann
aeb6df30d5
Update user management page (#87133)
* Update user management page

* Fixed i18n errors

* Fix linting errors

* Add ids required for accessability

* Added suggestions from code review

* Fix test errors

* Fix types in fleet

* fix translations

* Fix i18n

* Added suggestions from code review

* Fix i18n errors

* Fix linting errors

* Update messaging

* Updated unit tests

* Updated functional tests

* Fixed functional tests

* Fix linting errors

* Fix React warnings

* Added suggestions from code review

* Added tests and renamed routes

* Fix functional tests

* Simplified API integration tests

* Updated copy based on writing suggestions

* Fixed unit tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-01-25 13:51:57 +00:00
Nicolas Chaulet
3b728b73cf
[Fleet] Use fleet server indices for enrollment keys and to list agents with a feature flag (#86179) 2021-01-20 19:29:04 -05:00
John Schulz
11d4457d97
Don't retry if icon isn't in initial response (#88403) 2021-01-15 09:33:19 -05:00
Jen Huang
d8678ded03
[Fleet] Prevent long names from breaking agent details page (#88383)
* Fix long policy name breaking agent details page

* Fix long agent host name breaking agent details page
2021-01-14 13:39:05 -08:00
Sonja Krause-Harder
d37852a343
[EPM] Install Lens assets from packages if present. (#88189)
* Install Lens assets from packages if present.

* Add integration tests for Lens assets.
2021-01-14 18:01:00 +01:00
John Schulz
ca87bc495d
Fix broken icon key for Maps (#88093)
## PR Summary
Show [`emsApp` icon from EUI](https://eui.elastic.co/#/display/icons#apps) if integration includes map assets.

<img width="229" alt="Screen Shot 2021-01-12 at 3 14 14 PM" src="https://user-images.githubusercontent.com/57655/104367878-65628280-54e9-11eb-8d9c-fa838e2c15ae.png">

Looking at https://github.com/elastic/kibana/pull/62059#discussion_r401211966, I believe it landed with the incorrect key at a time when that part of the page wasn't visible. When we enabled that section, we likely didn't notice the missing key since most integrations don't have Maps assets

## Bug: `master` doesn't have an icon for Map assets
 1. Visit an integration with map assets, like AWS http://localhost:5601/app/fleet#/integrations/detail/aws-0.3.16
 2. Observe missing icon for Map in right column summary & HTTP request for `/app/mapApp`
    <img width="1013" alt="Screen Shot 2021-01-12 at 3 10 44 PM" src="https://user-images.githubusercontent.com/57655/104367875-64c9ec00-54e9-11eb-81d8-982bec862f5f.png">

## This PR adds one
 1. Visit an integration with map assets, like AWS http://localhost:5601/app/fleet#/integrations/detail/aws-0.3.16
 2. Observe EMS icon is present in right column summary
    <img width="1087" alt="Screen Shot 2021-01-12 at 3 11 39 PM" src="https://user-images.githubusercontent.com/57655/104367877-65628280-54e9-11eb-91da-578fec6ff769.png">
2021-01-14 08:53:16 -05:00