Commit graph

31 commits

Author SHA1 Message Date
Constance bc4928fd0b
[Enterprise Search] Create reusable EntSearchLogStream component (#105804)
* Set up Kibana dependencies required by LogStream component

- notably, `infra` and `data` - @see https://github.com/elastic/kibana/blob/master/x-pack/plugins/infra/public/components/log_stream/log_stream.stories.mdx#prerequisites

- tsconfig.json note - I believe I missed kibana_react from when we previously started requiring it for KibanaPageTemplate. Because LogStream requires it for KibanaContextProvider anyway I decided to add as a reference just in case

* Set up log source configuration for ent search logs

@see https://github.com/elastic/kibana/blob/master/x-pack/plugins/infra/public/components/log_stream/log_stream.stories.mdx#with-a-source-configuration

or, monitoring plugin also has example usage

* Set up providers required by the LogStream component

@see https://github.com/elastic/kibana/blob/master/x-pack/plugins/infra/public/components/log_stream/log_stream.stories.mdx#prerequisites

Note: there's some overlap in KibanaContextProvider with KibanaLogic that may be worth investigating/DRYing out in the future

* Create reusable EntSearchLogStream component

- light wrapper over LogStream with certain prepopulated defaults

+ Update LogStreamProps from infra team to be exported publicly for reuse (eslint will error otherwise)

* Fix bad type export

- thanks @afgomez!!

* Fix failing security_only nav_links test

- which was caused by `spaces` being required by infra but optional for our plugin. I moved `spaces` to required by `enterprise_search for clarity.

- I'm still not sure I actually fixed the nav_links test correctly. I have almost no memory of adding those lines 12 months ago 🙈

* Fix spaces typing

- remove `?` notation now that it's a required and non-optional plugin
+ reorder required plugins slightly

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-07-20 13:58:57 -04:00
Constance 6feea1a506
[Enterprise Search] Distinguish between error connecting vs. 5xx responses from Enterprise Search in UI (#103555)
* Update Enterprise Search request handler to send back an error connecting header

- vs only distinguishing error connecting issues by 502 status

+ clarify comment where this.handleConnectionError is called - for the most part, auth issues should already be caught by 401s in logic above

* Update HttpLogic to set errorConnecting state based on header

+ update tests etc to match read-only-mode state

* [Tech debt] Gracefully handle invalid HTTP responses

I've noticed this error a few times after Kibana gets shut down (http.response is undefined) so figured I would catch it here

* Fix missing try/catch/flashAPIErrors on engines overview

- This is the only http call I found missing a try/catch across our codebase, so we should be set for all views correctly flashing an API error that receive a 5xx response from ent-search

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-06-28 18:56:03 -04:00
James Rucker b6fb390ea9
[Workplace Search] OAuth flows for Custom Search and Default Search (#101996)
* Add OAuth authorize endpoint support for custom search experiences

* Add support for default search experience authentication

Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
2021-06-28 18:27:49 -04:00
Scotty Bollinger 0857e620c7
[Workplace Search] Remove isFederatedAuth checks to expose user features (#103278)
* Remove isFederated from main app and routes

* Expose all overview cards that were hidden for federated auth

* Expose all user features that were hidden for groups

* Remove remaining isFederatedAuth references

* Lint fixes

* Add modified test back for Workplace Search

* Remove extraCell

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Remove brackets

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Update test name

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

Co-authored-by: Constance <constancecchen@users.noreply.github.com>
2021-06-24 15:59:10 -04:00
James Rucker add02f13e8
[Workplace Search] Persist OAuth token package during OAuth connect flow (#93210)
* Store session data sent from Enterprise Search server

This modifies the EnterpriseSearchRequestHandler to remove any data in a
response under the _sessionData key and instead persist it on the server
side.

Ultimately, this data will be persisted in the login session, but for
now we'll just store it in a cookie. https://github.com/elastic/kibana/issues/92558

Also uses this functionality to persist Workplace Search's OAuth token
package.

* Only return a modified response body if _sessionData was found

The destructuring I'm doing to remove _sessionData from the response is
breaking routes that currently expect an empty response body. This
change just leaves those response bodies alone.

* Refactor from initial feedback & add tests

* Decrease levity

* Changes from PR feedback

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-08 16:17:35 -08:00
Constance fd3b3eb8cd
[App Search] Refactor AppLogic to initialize data via props rather than action (#92841)
* [Misc cleanup] Move Access type to common

- it was being duplicated in server/check_access and InitialAppData

+ add mock access data to DEFAULT_INITIAL_APP_DATA
+ update server/ tests to account for access in DEFAULT_INITIAL_APP_DATA

* Update AppSearchConfigured to pass props to AppLogic vs calling initializeAppData

+ update tests to rerender a wrapper rather than doing {...DEFAULT_INITIAL_APP_DATA} repeatedly

* Update AppLogic to set values from props rather than a listener

- main goal of this PR is to prevent the flash of state between mount and initializeX being called

- note: I recommend turning off whitespace changes in the test file

* Update AppLogic typing so that app data is always expected

- which it should be in any case in a production environment

- note: I could have changed InitialAppData to remove the ? optional notation, but decided on this route instead since InitialAppData affects more than just App Search (e.g. server, WS), and I didn't want this to have potential far-reaching side effects

* Update type scenarios where AppLogic values were previously thought potentially undefined

- which is mostly just configuredLimits it looks like

* [PR feedback] Type name
2021-03-02 11:25:01 -08:00
Constance 301df28a66
[App Search] Standardize table pagination logic/UX (#92293)
* Create table pagination helpers

* Update Curations table to use new pagination helpers

* Update Credentials table to use new helpers

+ update to use DEFAULT_META and pass page[size] customization
+ update useEffect to manually call fetchCredentials on current page change
+ update table to pass empty prompt within table (rather than instead of), and add a loading indicator
- update deleteApiKey to re-fetch credentials from API rather than modify the in-memory array (which more correctly handles pagination)

* Update Engines table to use new helpers

Server:
+ update server route to take page[current] (consistent w/ other routes) and page[size]
- remove custom param translation (passing as-is)
- remove ENGINES_PAGE_SIZE constant, basically stored within DEFAULT_META now and page size is passed from client-side
- remove misc header cruft from engines table

EnginesLogic:
- Update http calls to send page[current] & page[size] (same as other files)
- Change individual *Total/*Page vars to store the meta obj coming back from the API (same as other logic files)
- Change on*Load actions to simply pass the API response (update typing to clarify)
- Add new individual enginesLoading/metaEnginesLoading vars so that tables can show individual loading indicators between pagination
- Change dataLoading to a selector (should only show on initial page load, and should use table loading indicators after)

EnginesTable:
- Update props to more closely match EuiBasicTable (items, onChange, add loading) so users can do a simple pass-through
- Reorganize tests so that language block doesn't need its own custom wrapper vars
- Remove empty data test (no longer really testing anything meaningful) and add loading test

EnginesOverview:
- Update to use new helpers, values, props, etc.
- Add new test for onPaginate handlers
2021-02-23 10:41:35 -08: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
Scotty Bollinger 67014a7970
[Enterprise Search] Update apps to use a service for docs links (#89425)
* Create DocLinksService

* Set docLinks on app start

* Update routes modules to use service

* Update component and test to use service

* Remove legacy files

* Add comment

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Add new line

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Refactor test

* Rename class and remove extra route segments

* Update test names

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
2021-01-28 18:14:04 -06:00
John Schulz 380fa5b3f6
[bundle optimization] Update to semver 7.x to get tree-shaking (#83020)
## What's changed in this PR
### Update to latest available `semver`: `7.3.2`
 * `semver` 5.x pulls in the entire library in one large file (~38k uncompressed / ~9k gz), when we might only use 1-2K.
 * `semver` 7.0+ supports tree-shaking: https://github.com/npm/node-semver/blob/master/CHANGELOG.md#700

### Update paths to only import individual function(s) used instead of the entire library
  * Getting the smaller bundle requires a different import style [as shown in the docs](https://github.com/npm/node-semver#usage)
  * Only changed code in `public` & `common` folders; not `server`. We could also update `server` as well for consistency, but I skipped because the new import style is more verbose and the filesize didn't seem as important on the server

### Results
The build stats show a 10K+ improvement for initial page bundles https://github.com/elastic/kibana/pull/83020#issuecomment-724724432

| id | [before](c6afc47f32) | [after](213bb52a8c) | diff |
| --- | --- | --- | --- |
| `ingestManager` | 386.2KB | 373.9KB | -12.3KB |
| `telemetry` | 63.5KB | 50.1KB | -13.5KB |
| `upgradeAssistant` | 74.5KB | 60.5KB | -14.0KB |
| total |  |  | -39.7KB |

### The import paths look odd. Are they required?
I agree and, no, they're not strictly required. If you'd like me to revert to the prior style just drop a comment and I'll undo them.

The caveat is that the current style (in `master` & this PR) pulls in the entire `semver` library. In 7.x that added ~15K to the initial size. Some more details in the comments: https://github.com/elastic/kibana/pull/83020#issuecomment-724859130

### Possible issues
Moving 2 major versions. We're currently on 5.7 and the latest available is 7.3. 
  * changelog says 5.x (our current) to 6.0 should be safe: https://github.com/npm/node-semver/blob/master/CHANGELOG.md#60
  * There 6.x & 7.x changes all appear to be new features or bugfixes around the `includePrerelease` flag added in 5.6, but I'm not sure if those "fixes" will break existing code
    * https://github.com/npm/node-semver/blob/master/CHANGELOG.md#613
    * https://github.com/npm/node-semver/blob/master/CHANGELOG.md#722

### Stats / screenshots
generated with `node scripts/build_kibana_platform_plugins.js --profile --focus=ingestManager`
<details><summary><b>Ingest Manager in `master`</b>: imports entire `semver` lib, totals 40k+, only 1 large file (orange arc below)</summary>

<img width="972" alt="Screen Shot 2020-11-09 at 6 50 23 PM" src="https://user-images.githubusercontent.com/57655/98666188-a50ac380-231a-11eb-9b8a-6ca784752714.png">
</details>

<details><summary><b>Ingest Manager in PR after upgrade to 7</b>: still imports entire lib. file size *increased* to ~60k, but now individual files are imported (orange arcs below)</summary>
<img width="825" alt="Screen Shot 2020-11-09 at 5 46 30 PM" src="https://user-images.githubusercontent.com/57655/98666355-e602d800-231a-11eb-803f-bc04beb4eaf1.png">
<img width="963" alt="Screen Shot 2020-11-09 at 5 47 06 PM" src="https://user-images.githubusercontent.com/57655/98666357-e69b6e80-231a-11eb-92d3-c66904f92c30.png">
</details>

<details><summary><b>Ingest Manager in PR after changing `import`s:</b> total imported size down to ~20k. Can see individual imported files</summary>
<img width="926" alt="Screen Shot 2020-11-10 at 6 10 23 AM" src="https://user-images.githubusercontent.com/57655/98667058-e64fa300-231b-11eb-9690-5e36ed6475e0.png">
<img width="895" alt="Screen Shot 2020-11-10 at 6 10 53 AM" src="https://user-images.githubusercontent.com/57655/98667059-e780d000-231b-11eb-8abf-98d8bdbcf061.png">
</details>

### Checklist

- [ ] [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
2020-11-14 07:32:02 -05:00
Constance bd99b19bd8
[App Search] Version documentation links (#83245)
* Fix CURRENT_MAJOR_VERSION for use in Elastic docs links

- Was previously just sending (e.g.) "7". instead of "7.9"

* Add App Search DOCS_PREFIX constant

- follow WS's example

* Update all App Search doc links to use prefixed URLs

- except for Enterprise Search setup guide, which should be updated to use a shared URL at some point in any case
2020-11-12 07:42:41 -08:00
Constance 2d5de2b3bd
[Enterprise Search] Tech debt/cleanup: remove I/E/T Typescript prefixes (#83099)
* [All] Remove prefixes on simple self-contained type defs

- Types should not be exported
- Types should not be used outside each affected file

* [All][kea] Remove ts prefixes and unnecessary exports

Kea now takes care of type checking for us, so there should virtually never be a need to export our values and actions interfaces going forward

* [shared] Remove createHref type prefixes

* [shared] Remove breadcrumb prefixes

* [shared] Remove telemetry prefixes

* [shared] remove types.ts

Opionionated change: it was only being used for IFlashMessage, and at this point I think it's more useful to go in one level deeper to grab the type you need

* [server] remove route dependencies prefixes

* [server] Various type cleanups

- plugin.ts - remove unnecessary export
- MockRouter - remove prefix for request type, change IMockRouter to match Kibana's IRouter
- check_access - remove prefixes
- callEnterpriseSearchConfigAPI - remove prefixes
- EnterpriseSearchRequestHandler - remove prefixes

* [common] Remove InitialAppData prefix

+ remove unnecessary export from public/plugin.ts

* [common] Remove Meta prefixes

* [common] Remove configured limits prefixes

* [AS] Remove Account and Role prefixes

* [AS] Remove Engine prefixes

* [AS] Remove credentials prefixes

* [AS] Remove log settings prefixes

* [WS] Remove account/organization/initial data prefixes

* [WS] Remove group(s), user, & content source prefixes

+ GroupLogic and GroupsLogic refactor - remove unnecessary defs in actions, it's already defined in the Actions interface above and in some cases (e.g. old History param) is causing out of date issues

* [WS] Misc type fixes

- TSpacerSize -> SpaceSizeTypes
- SourcePriority - remove prefixes
- IComponentLoader - this isn't used anywhere else and appears to be component props so it probably should live only within component_loader.tsx
- Remove recent feed activity prefix

* [WS][Opinionated] Move interfaces not used in server/ out of common/ and to public/

* Fix recently rebased types
2020-11-10 14:00:53 -08:00
Tyler Smalley f8d74e240b Revert "[Enterprise Search] Tech debt/cleanup: remove I/E/T Typescript prefixes (#83027)"
This reverts commit c7f085ff0b.
2020-11-10 11:24:02 -08:00
Constance c7f085ff0b
[Enterprise Search] Tech debt/cleanup: remove I/E/T Typescript prefixes (#83027)
* [All] Remove prefixes on simple self-contained type defs

- Types should not be exported
- Types should not be used outside each affected file

* [All][kea] Remove ts prefixes and unnecessary exports

Kea now takes care of type checking for us, so there should virtually never be a need to export our values and actions interfaces going forward

* [shared] Remove createHref type prefixes

* [shared] Remove breadcrumb prefixes

* [shared] Remove telemetry prefixes

* [shared] remove types.ts

Opionionated change: it was only being used for IFlashMessage, and at this point I think it's more useful to go in one level deeper to grab the type you need

* [server] remove route dependencies prefixes

* [server] Various type cleanups

- plugin.ts - remove unnecessary export
- MockRouter - remove prefix for request type, change IMockRouter to match Kibana's IRouter
- check_access - remove prefixes
- callEnterpriseSearchConfigAPI - remove prefixes
- EnterpriseSearchRequestHandler - remove prefixes

* [common] Remove InitialAppData prefix

+ remove unnecessary export from public/plugin.ts

* [common] Remove Meta prefixes

* [common] Remove configured limits prefixes

* [AS] Remove Account and Role prefixes

* [AS] Remove Engine prefixes

* [AS] Remove credentials prefixes

* [AS] Remove log settings prefixes

* [WS] Remove account/organization/initial data prefixes

* [WS] Remove group(s), user, & content source prefixes

+ GroupLogic and GroupsLogic refactor - remove unnecessary defs in actions, it's already defined in the Actions interface above and in some cases (e.g. old History param) is causing out of date issues

* [WS] Misc type fixes

- TSpacerSize -> SpaceSizeTypes
- SourcePriority - remove prefixes
- IComponentLoader - this isn't used anywhere else and appears to be component props so it probably should live only within component_loader.tsx
- Remove recent feed activity prefix

* [WS][Opinionated] Move interfaces not used in server/ out of common/ and to public/
2020-11-10 10:52:20 -08:00
Catherine Liu 63b76f2cd5
[Core UI] Kibana Overview Page (#75827)
* Added kibana landing page

Created kivana_overview plugin

Removed test from home plugin

Added CSS

Fixed page header links

Added news feed

Fixed spacers between news items

[Core UI] Kibana Overview Page Style Tweaks (#76712)

Fixed link to index management

Added solution cards to kibana landing page

Added solution links

Fixed ts errors

Using publishReplay() to support multiple consumers in newsfeed plugin

Added createNewsFeed$ to newsfeed plugin start

Added tests

Removed unnecessary export

Hides overview link when other Kibana apps are not available

Added icon to overview plugin

Removed question mark from news feed title

Updated plugin-list

Fixed i18n errors

Revert snapshot

Updated getting started page copy

Hide news feed when no news feed results

Disables Kibana overview page when kibana apps are unavailable

Updated snapshots

Refactor to use KibanaContextProvider

Fixed security tests

Fixed newsfeed api test

Moved overview_footer and overview_header to kibana-react plugin

[Core UI] Kibana Overview Page Style Fixes (#78677)

* Fixed a11y issues

* Made newsfeed optional dep of kibana overview plugin

* Removed duplicate license copy

* Fixed management security test

* Added toast to change default route button

* Updated snapshots

* Simplified toast notification

* Fixed i18n error

* Assigned kibana_overview plugin to Core UI in CODEOWNERS

* Updated snapshots

* Fix import

* [Core UI] Kibana Overview Page Style Fixes, Part 3 (#78970)

* fix overview cards not stretching height equally

* change var name for better specificity

* [Core UI] Kibana Overview Page Style Fixes, Part 4 (#79136)

* Adds support for all newsfeed plugin config settings in createNewsFeed$

* Fixed type

* Updated kibana overview page route

* Fixed imports in page_footer and page_header

* Update Kibana overview graphics (#79534)

* Updated snapshots

* Updated snapshots

* Changes newsfeed endpoint to kibana analytics in kibana_overview plugin

* Renamed components

* Fixed overview page footer and header component class names

* Removed extraneous files

* Fixed import

* Replaced SVGs with optimized SVGs

* Fixed header and footer in home and kibana overview pages

* Updated snapshots

* Changed url_forwarding plugin appRoute

* Fixed aria-labelledby value

* Updated snapshots

* Added base paths

Co-authored-by: Michael Marcialis <michael.marcialis@elastic.co>
Co-authored-by: Ryan Keairns <contactryank@gmail.com>
2020-10-06 09:13:31 -07:00
Scotty Bollinger 197510a737
[Enterprise Search][Workplace Search] Migrate Groups to Kibana (#78679)
* Initial copying of Groups component tree

This commit moves the base component tree from ent-search with the following changes to satisfy pre-commit hooks

- All file names changed to camel_case
- Copyright comment added to the top of each file
- Semicolons and formatting to match Kibana
- Default exports removed from components
- Placeholder keyboard listener functions added to non-interactive elements with click handlers

* Update paths, remove kea typecasting

This commit does the following:

- Updates the paths of the imports
- Removed the need to typecast logic i.e. "as IGroupsLogic" after the Kea hooks
- Fixed a few TypeScript errors with events and return values on functions

- Finally, this commit does away with the ConfirmModal component (was never copied over), as it only wraps 2 EUI components and we decided it was not needed

* Add constants and image

* Update types

- Adds new types
- Moves types needed by server and app to common

* Refactor ContentSection and ViewContentHeader

With the groups components, we needed to add a header action that was right-aligned to ContentSection.

After building what was needed, I realized that the header in the ContentSection was basically a ViewContentHeader with a different sized heading. I refactored ViewContentHeader to have variable sizes and for ContentSection to use that instead.

Also added styles from ent-search

* Add group routes

This is both the server routes and the frontend paths. After conversation with Jonas, we decided to not use the `/org` prefix. Will clean up the other routes as we build out the rest the migration

* Update logic files

This commit converts the logic files for use in Kibana. This includes:

- Using the new Kea 2.2 syntax that uses MakeLogicType to provide types
- Uses the Kibana HttpLogic instead of the rails routes/http
- Adds return types to Actions interfaces
- Adds `path` key to help with debuggin in dev tools
- Removes FashMessages in lieu of separate logic. Because of this, we have to manually clear the flash mesages with listeners where reducers used to do it when the messages were local to the logic file
- Preplaces promises with async/await & try/catch

- Also, in GroupsLogic’s getSearchResults method, we used Kea’s breakpoint functionality and replaced the useDebouce Hook that was used in the component (future commit)
- Uses global lodash per Kibana’s new directive

* Update routers an indexes

This PR configures the routers to work with Kibana

- Updates paths to imports
- Adds top-level styles

For GroupRouter
- Removes AppView
- Use global flash messages
- Remove sidebar and breadcrumbs

* Update GroupOverview

Adds some changes to facilitate the new design for Kibana

- Copy changes
- Layout changes to have buttons inline and not conditionally shown

* Various updates to components

Adds some changes to facilitate the new design for Kibana.

- Remove unnecessary TableHeader
- Adds pencil in lieu of manage button per design

* Update main groups component

A previous commit did this for the components, as the intention was to do this for components in one PR and the others an a separate PR. Unfortunately the build does not pass with all the missing imports.

This commit does the following:
- Updates the paths of the imports
- Removed the need to typecast logic i.e. "as IGroupsLogic" after the Kea hooks
- Fixed a few TypeScript errors with events and return values on functions
- Use global flash messages
- Remove debounces filderValue, as it’s now debounces in logic file
- Remove legacy isCurated props
- Remove legact AppView

* Add sub navigation to main nav

Also removes redundant search link in sidebar

* Update logic file to reset flashmessages correctly

Because we have separated concerns with global flash message state, we now have to manually trigger resets of flash messages with listeners in Kea where we used to be able to use a reducer to listen to changes and reset flash messages.

* Use navigateToUrl for navigation over history.push

Thanks to work by @constance, we can now use the KibanaLogic’s navigateToUrl value to change routes directly from logic files

* Fix failing test

A previous commit removed the redundant Search link from the sidebar nav because of the one in the header. This commit fixes a filing test and now assets on the number of items as the link addresses will be changing as we migrate more components over

* Convert React Router links to our wrappers

* Replace anchors with EuiButtonEmpty

The original pre-commit hooks failed because the anchors didn’t have key handlers. Pleaceholders were added with TODOs and these have been replaced with EuiButtonEmpty, which satisifies the UI needs and passes linting

* Fix a bug where header actions disappearing

There was a bug where changing routes would cause the header action, in the case of Workplace Search the “Go to search application” link, to disappear on route changes.

Turns out that we didn’t need it in the useEffect and that moving it out keeps the unmount from removing the link from the header.

* i18n top-level component and logic files

* i18n for components

* Fix failing test

This was from 3254c6277e

* Fix broken i18n

Had duplicate ids and misnamed value

* Fix a bug where manage group not in Flash message

There is a button that appears in the Flash Message when a new group is added so that the user can navigate to manage the group and, because the order of setting the new group was before the instantiation of the global flashmessages, the button was not appearing. This commit moves the action after the flash message is set.

* Refactor typings

* Refactor ContentSection spacing

The css was not being used and the bottom padding of 44px (xxl + xs spacer) was being generated with spacers. This has been changed to use only CSS

* Remove canCreateInvitations

* Remove hasMessages check rendering FlashMessages

* snake_case telemetry and path

Will convert other paths in a separate PR

* Fix failing tests

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-10-05 13:33:58 -05:00
Constance 5812217631
[Enterprise Search] Update chrome/breadcrumbs to support dynamic/nested breadcrumbs (#79231)
* [Setup] Add new stripLeadingSlash util

- will be used by upcoming breadcrumb/path logic
- rename folder + update references
+ clean up tests

* Update breadcrumb helpers with new useGenerateBreadcrumbs
- responsible for generating an array of IBreadcrumb objs with correct react router paths, given an array of breadcrumb text

+ rename previous generic useBreadcrumbs helper to a more specific useEuiBreadcrumbs (indicates the type of transforming happening)

+ misc typing updates/improvements

* Update SetChrome helpers
- to use new useGenerateBreadcrumbs() helper

+ simplify props - remove `isRoot` and `text` (now just accepts a single `trail` array - an empty trail creates the same effect as isRoot
+ simplify/improve typing as a result (yay!)
- improve docs

+ useEffect update - update breadcrumbs/titles if `trail` ever changes. This will primarily be most helpful for pages that fetch dynamic data on page load (e.g. a dynamic engineName, groupName, etc.)
- note that in the above case trail arrays should probably be wrapped in useMemo() to reduce unnecessary rerenders

* Update all instances of SetPageChrome to new props

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2020-10-05 10:08:13 -07:00
Jason Stoltzfus 378b8c80ea
[Enterprise Search] Added Logic for the Credentials View (#77626) 2020-09-28 09:39:46 -04:00
Constance 034d76ef1e
[App Search] Hydrate AppLogic with more initial data, + set up role abilities & wrap routes/navigation in checks (#77693)
* [Setup] Fix onboarding var name

- I camelCased too hard 🤦‍♀️ should be just onboardingComplete per ent-search code

* [Cleanup] Remove role.ability.destroy array

- This was only being used for 'session'/canDestroySession, which no longer applies in a Kibana world
- The destroy property still remains in the API endpoint, but will be ignored/unused by our front-end (similar to the defunct `roles: {}` obj)

* Hydrate AppLogic with more app-wide data

- namely: account, myRole, configuredLimits, and ilmEnabled
- also port over setOnboardingComplete action because it's fairly small and will be used

- role/myRole changes:
  - This is a fairly opinionated change - open to thoughts!
  - Ditch the Role()/Ability() classes and useAbilities() hook in favor of just storing that data from the get-go in myRole
  - Remove unused fns from myRole (mostly those around the role obj, which is now always empty in SMAS)

- Type updates:
  - Move IRole to client-side only, and to describe the myRole value
  - IAccount.role should now only describe role data coming from the server-side

* Wrap App Search routes/navigation in ability checks

* Fix merged test

* PR feedback: Move myRole transformation to its own file

- Turns out Kea may or may not have been squashing some type errors! Moving to a separate file helped catch some type issues

* [Opinion] Move role-related types to role file

- Open to debate on this one, but it feels like it makes sense to keep all role related types in the same area.

+ keep export in main ./types file for convenience

* Product feedback: Remove canViewEngines

- there shouldn't be a scenario where a user isn't able to access any engines but can access the rest of the product

* Misc PR feedback

* Typescript feedback: use partials to account for default state

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-21 10:40:16 -07:00
Constance 03e3c85228
[Enterprise Search] Add read-only mode interceptor and error handler (#77569)
* Add readOnlyMode prop + callout to Layout component

* Update HttpLogic to initialize readOnlyMode from config_data

+ update App Search & Workplace Search layout to pass readOnlyMode state
- update passed props test to not refer to readOnlyMode, so as not to confuse distinction between props.readOnlyMode (passed on init, can grow stale) and HttpLogic.values.readOnlyMode (will update on every http call)

- DRY out HttpLogic initializeHttp type defs

* Update enterpriseSearchRequestHandler to pass read-only mode header

+ add a custom 503 API response for read-only mode errors that come back from API endpoints (e.g. when attempting to create/edit a document) - this is so we correctly display a flash message error instead of the generic "Error Connecting" state

+ note that we still need to send back read only mode on ALL headers, not just on handleReadOnlyModeError however - this is so that the read-only mode state can updates dynamically on all API polls (e.g. on a 200 GET)

* Add HttpLogic read-only mode interceptor

- which should now dynamically listen / update state every time an Enterprise Search API call is made

+ DRY out isEnterpriseSearchApi helper and making wrapping/branching clearer

* PR feedback: Copy
2020-09-17 08:43:40 -07:00
Michail Yasonik 61c4e6fd8d
Stacked headers and navigational search (#72331)
Co-authored-by: Poff Poffenberger <poffdeluxe@gmail.com>
Co-authored-by: Ryan Keairns <contactryank@gmail.com>
Co-authored-by: pgayvallet <pierre.gayvallet@elastic.co>
Co-authored-by: cchaos <caroline.horn@elastic.co>
2020-09-14 14:32:30 -05:00
Constance f56fcb3055
[Enterprise Search] Update shared API request handler (#77112)
* Add user auth check for /ent/select redirects

- Recent Enterprise Search CSRF changes have made it so redirects can occur to /ent/select and not just /login

* Fix request.query typing

- API endpoints passing in custom request.query params were seeing {} type errors - this change works around them

* Add Accept and Content-Type JSON headers to Enterprise Search requests

- Without the Accept header, Enterprise Search APIs will kick back a CSRF error
- Without the Content-Type header, APIs will not load JSON bodies as parameters per Ruby on Rails docs
2020-09-09 20:20:20 -07:00
Constance d67a421e68
[Enterprise Search] Add Overview landing page/plugin (#76734)
* [public] Register Enterprise search plugin

+ move new Home strings to constants

* [server] Register plugin access/visibility

* Set up Enterprise Search Kibana Chrome

- Add SetEnterpriseSearchChrome
- Update Enterprise Search breadcrumbs to link to new overview plugin (+ update overview plugin URL per team discussion)
  - Add ability to break out of React Router basename by not using history.createhref
  - Update createHref mock to more closely match Kibana urls (adding /app prefix)
- Minor documentation fix

* Set up Enterprise Search plugin telemetry

- client-side: SendEnterpriseSearchTelemetry
- server-side: register saved objects, usage collector, etc.

* Enterprise search overview views (#23)

* Add formatTestSubj util

This allows us to correctly format strings into our casing for data-test-subj attrs

* Add images and stylesheet

* Add product card component

* Add index component

* Remove unused styles

* Fix inter-plugin links
- by add shouldNotCreateHref prop to RR helpers
- similiar to breadcrumb change

* Fix/clean up CSS

- Prefer EUI components over bespoke CSS (e.g. EuiCard)
- Remove unused or unspecific CSS
- Pull out product card CSS to its component
- Fix kebab-cased CSS classes to camelCased

* Clean up ProductCard props

- Prefer passing in our plugin consts instead of separate props
- Move productCardDescription to constants
- Update tests

* Add telemetry clicked actions to product buttons

+ revert data-test-subj strings to previous implementation
+ prune format_test_subj helper by using lodash util directly

* [PR feedback] Add new plugin to applicationUsageSchema per telemetry team request

* Fix failing functional navLinks test

* Fix telemetry schema test

* [Perf] Optimize assets size by switching from 300kb SVG to 25kb PNG

* Only show product cards if the user has access to that product

- adds access checks
- fixes flex/CSS to show one card at a time

Co-authored-by: Scotty Bollinger <scotty.bollinger@elastic.co>
2020-09-09 12:53:51 -07:00
Constance a0defb8196
[Enterprise Search] Update config data endpoint to v2 (#76970)
* Update our internal config/app data to v2 specs

- Update endpoint to v2
- Update data accordingly to new API structures
- Update types accordingly

* Fix failing type check for other endpoints that use IAccount

* Update role type casing

- ent search was fixed from camel to snake
2020-09-09 10:01:28 -07:00
Constance 3466436031
[Enterprise Search] Add 404 pages (#76404)
* Add new 404 NotFound shared view

* Add new telemetry ui_error.not_found metric

* Add check for licensed users who should be sent to support.elastic.co
2020-09-02 08:53:23 -07:00
Scotty Bollinger 35b8d50ccd
[Enterprise Search] Adds app logic file to Workplace Search (#76009)
* Add new Workplace Search initial data properties

* Add app logic

* Refactor index to match App Search

Adds the easier-to-read ComponentConfigured and ComponentUnconfigured FCs with a ternary in the root compoenent

* Remove ‘Logic’ from interface names

* Extract initial data from WS into interface

This allows for breaking apart the app-specific data and also having an interface to extend in the app_logic file

* Destructuring FTW
2020-08-26 16:21:11 -05:00
Constance 172c464b14
[Enterprise Search] Convert our public_url route to config_data and collect initialAppData (#75616)
* [Setup] DRY out stripTrailingSlash helper

- DRYs out repeated code
- This will be used by an upcoming server/ endpoint change, hence why it's in common

* [Setup] DRY out initial app data types to common/types

- In preparation for upcoming server logic that will need to reuse these types
+ DRY out and clean up workplace_search types
  - remove unused supportEligible
  - remove currentUser - unneeded in Kibana

* Update callEnterpriseSearchConfigAPI to parse and fetch new expected data

* Remove /public_url API for /config_data

* Remove getPublicUrl in favor of directly calling the new /config_data API from public/plugin

+ set returned initialData in this.data

* Set up product apps to be passed initial data as props

* Fix for Kea/redux state not resetting between AS<->WS nav

- resetContext at the top level only gets called once total on first plugin load and never after, causing navigating between WS and AS to crash when both have Kea - this fixes the issue

- moves redux Provider to top level app as well

* Add very basic Kea logic file to App Search

* Finish AppSearchConfigured tests & set up kea+useEffect mocks

* [Cleanup] DRY out repeated mock initialAppData to a reusable defaults constant
2020-08-21 09:02:15 -07:00
Scotty Bollinger ac04e0546a
[Enterprise Search] Add Workplace Search side navigation (#74894)
* Add routes

* Add version for use in doc link

* Set up basic router layout + WorkplaceSearchNav

* Update views to account for Layout

* Move version to common folder

* Fix version path

* Remove product button

No longer needed since we have all top-level app links in Kibana as a part of this PR

* You know, for search

* Remove comment

* Remove unused i18n properties from JSON

Tests were failing after removing component:
https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/67797/execution/node/382/log/

* Revert button and i18n copy  removal

This reverts commit ba0535187e.

* Move Overview out of layout to hide nav

For now, the route for groups was added to avoid having comment out the code. Will add the groups component in a future PR

* Revert layout changes to Overview

Since there is no nav, the padding was missing and the view looked off. Reverting to the 7.9, centered column view

* Remove extra Overview component

Was causing tests to fail

* Revert error state to use EuiPage

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-08-14 15:28:34 -05:00
Constance 47b9aba3bf
[Enterprise Search] Fix/DRY out plugin i18n strings (#74323)
* i18n refactor

- DRY out plugin details to constants and correctly i18n-ize front-end-facing strings

* DRY out new i18n constants

- refactor instances of i18n.translate to use new constants

* Fix non-i18n'd breadcrumb strings

* PR feedback: swap out more plugin ID strings for constants
2020-08-05 10:12:25 -07:00
Scotty Bollinger 41c4f18b89
Workplace Search in Kibana MVP (#70979)
* Add Workplace Search plugin to app

- Adds telemetry for Workplace Search
- Adds routing for telemetry and overview
- Registers plugin

* Add breadcrumbs for Workplace Search

* Add Workplace Search index

* Add route paths, types and shared assets

* Add shared Workplace Search components

* Add setup guide to Workplace Search

* Add error state to Workplace Search

* Add Workplace Search overview

This is the functional MVP for Workplace Search

* Update telemetry per recent changes

- Remove saved objects indexing
- add schema definition
- remove no_ws_account
- minor cleanup

* Fix pluralization syntax

- Still not working but fixed the syntax nonetheless

* Change pluralization method

- Was unable to get the `FormattedMessage` to work using the syntax in the docs. Always added ‘more’, even when there were zero (or one for users). This commit uses an alternative approach that works

* Update readme

* Fix duplicate i18n label

* Fix failing test from previous commit

🤦

* Update link for image in Setup Guide

* Remove need for hash in routes

Because of a change in the Workplace Search rails code, we can now use non-hash routes that will be redirected by rails so that we don’t have users stuck on the overview page in Workplace Search when logging in

* Directly link to source details from activity feed

Previously the dashboard in legacy Workplace Search linked to the sources page and this was replicated in the Kibana MVP. This PR aligns with the legacy dashboard directly linking to the source details

https://github.com/elastic/ent-search/pull/1688

* Add warn logging to Workplace Search telemetry collector

* Change casing to camel to match App Search

* Misc security feedback for Workplace Search

* Update licence mocks to match App Search

* PR feedback from App Search PR

* REmove duplicate code from merge conflict

* Fix tests

* Move varible declaration inside map for TypeScript

There was no other way 🤦

* Refactor last commit

* Add punctuation

Smallest commit ever.

* Fix actionPath type errors

* Update rebase feedback

* Fix failing test

* Update telemetry test after AS PR feedback

* DRY out error state prompt copy

* DRY out telemetry endpoint into a single route + DRY out

DRY out endpoint
- Instead of /api/app_search/telemetry & /api/workplace_search/telemetry, just have a single /api/enterprise_search/telemetry endpoint that takes a product param
- Update public/send_telemetry accordingly (+ write tests for SendWorkplaceSearchTelemetry)

DRY out helpers
- Pull out certain reusable helper functions into a shared lib/ folder and have them take the repo id/name as a param
- Move tests over
- Remove misplaced comment block

+BONUS
- pull out content type header that's been giving us grief in Chrome into a constant

* Remove unused telemetry type

* Minor server cleanup - DRY out mockLogger

* Setup Guide cleanup

* Clean up Loading component

- use EUI vars per feedback
- remove unnecessary wrapper
- adjust vh for Kibana layout
- Actually apply loadingSpinner styles

* Misc i18n fixes

+ minor newline reduction, because prettier lets me

* Refactor Recent Activity component/styles

- Remove table markup/styles - not semantically correct or accessible in this case - replace w flex
- Fix link colors not inheriting
- Add EuiPanel, error colors looked odd against page background
- Fix prop/type definition
- CSS cleanup - EUI vars, correct BEM, don't target generic selectors

* [Opinionated] Refactor RecentActivity component

- Pull out iterated activity items into a child subcomponent
- Move constants/strings closer to where they're being used, instead of having to jump around the file
- Move IActivityFeed definition to this file, since that's primarily where it's used

@scottybollinger - if you're not a fan of this commit no worries, just let me know and we can discuss/roll back as needed

* Refactor ViewContentHeader

- remove unused CSS
- fallback cleanup
- refactor tests

* Refactor ContentSection

- Remove unused CSS classes
- Refactor tests to include all props/more specific assertions

* Refactor StatisticCard

- Prefer using EuiTextColor to spans / custom classes
- Prefer using EuiCard's native `href` behavior over using our own wrapping link/--isClickablec class
- Note that when we port the link/destination over to React Router, we should instead opt to use React Router history, which will involve creating a EuiCard helper
- Make test a bit more specific

* Minor OrganizationStats cleanup

- Use EuiFlexGrid

* Refactor OnboardingSteps

- i18n
    - Compact i18n newlines (nit)
    - Convert FormattedMessage to i18n.translate for easier test assertions
- Org Name CTA
    - Move to separate child subcomponent to make it easier to quickly skim the parent container
    - Remove unused CSS class
    - Fix/add responsive behavior

- Tests refactor
    - Use describe() blocks to break up tests by card/section
    - Make sure each card has tests for each state - zero, some/complete, and disabled/no access
    - Assert by plain text now that we're using i18n.translate()
    - Remove ContentSection/EuiPanel assertions - they're not terribly useful, and we have more specific elements to check
    - Add accounts={0} test to satisfy yellow branch line

* Clean up OnboardingCard

- Remove unused CSS class
- Remove unnecessary template literal

Tests
- Swap out check for EuiFlexItem - it's not really the content we're concerned about displaying, EuiEmptyPrompt is the primary component
- Remove need for mount() by dive()ing into EuiEmptyPrompt (this also removes the need to specify a[data-test-subj] instead of just [data-test-subj])
- Simplify empty button test - previous test has already checked for href/telemetry
- Cover uncovered actionPath branch line

* Minor Overview cleanup

- Remove unused telemetry type
- Remove unused CSS class
- finally
- Remove unused license context from tests

* Feedback: UI fixes

- Fix setup guide CSS class casing
- Remove border transparent (UX > UI)

* Fix Workplace Search not being hidden on feature control

- Whoops, totally missed this 🤦

* Add very basic functional Workplace Search test

- Has to be without_host_configured, since with host requires Enterprise Search
- Just checks for basic Setup Guide redirect for now
- TODO: Add more in-depth feature/privilege functional tests for both plugins at later date

* Pay down test render/loading tech debt

- Turns out you don't need render(), shallow() skips useEffect already 🤦
- Fix outdated comment import example

* DRY out repeated mountWithApiMock into mountWithAsyncContext

+ Minor engines_overview test refactors:
    - Prefer to define `const wrapper` at the start of each test rather than a `let wrapper` - this better for sandboxing / not leaking state between tests
    - Move Platinum license tests above pagination, so the contrast between the two tests are easier to grok

* Design feedback

- README copy tweak + linting
- Remove unused euiCard classes from onboarding card

Co-authored-by: Constance Chen <constance.chen.3@gmail.com>
2020-07-13 13:10:35 -05:00
Constance f7b5144e1d
New Enterprise Search Kibana plugin (#66922)
* Initial App Search in Kibana plugin work

- Initializes a new platform plugin that ships out of the box w/ x-pack
- Contains a very basic front-end that shows AS engines, error states, or a Setup Guide
- Contains a very basic server that remotely calls the AS internal engines API and returns results

* Update URL casing to match Kibana best practices

- URL casing appears to be snake_casing, but kibana.json casing appears to be camelCase

* Register App Search plugin in Home Feature Catalogue

* Add custom App Search in Kibana logo

- I haven't had much success in surfacing a SVG file via a server-side endpoint/URL, but then I realized EuiIcon supports passing in a ReactElement directly. Woo!

* Fix appSearch.host config setting to be optional

- instead of crashing folks on load

* Rename plugin to Enterprise Search

- per product decision, URL should be enterprise_search/app_search and Workplace Search should also eventually live here
- reorganize folder structure in anticipation for another workplace_search plugin/codebase living alongside app_search
- rename app.tsx/main.tsx to a standard top-level index.tsx (which will contain top-level routes/state)
- rename AS->ES files/vars where applicable
- TODO: React Router

* Set up React Router URL structure

* Convert showSetupGuide action/flag to a React Router link

- remove showSetupGuide flag
- add a new shared helper component for combining EuiButton/EuiLink with React Router behavior (https://github.com/elastic/eui/blob/master/wiki/react-router.md#react-router-51)

* Implement Kibana Chrome breadcrumbs

- create shared helper (WS will presumably also want this) for generating EUI breadcrumb objects with React Router links+click behavior
- create React component that calls chrome.setBreadcrumbs on page mount
- clean up type definitions - move app-wide props to IAppSearchProps and update most pages/views to simply import it instead of calling their own definitions

* Added server unit tests (#2)

* Added unit test for server

* PR Feedback

* Refactor top-level Kibana props to a global context state

- rather them passing them around verbosely as props, the components that need them should be able to call the useContext hook

+ Remove IAppSearchProps in favor of IKibanaContext

+ Also rename `appSearchUrl` to `enterpriseSearchUrl`, since this context will contained shared/Kibana-wide values/actions useful to both AS and WS

* Added unit tests for public (#4)

* application.test.ts

* Added Unit Test for EngineOverviewHeader

* Added Unit Test for generate_breadcrumbs

* Added Unit Test for set_breadcrumb.tsx

* Added a unit test for link_events

- Also changed link_events.tsx to link_events.ts since it's just TS, no
React
- Modified letBrowserHandleEvent so it will still return a false
boolean when target is blank

* Betterize these tests

Co-Authored-By: Constance <constancecchen@users.noreply.github.com>

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Add UI telemetry tracking to AS in Kibana (#5)

* Set up Telemetry usageCollection, savedObjects, route, & shared helper

- The Kibana UsageCollection plugin handles collecting our telemetry UI data (views, clicks, errors, etc.) and pushing it to elastic's telemetry servers
- That data is stored in incremented in Kibana's savedObjects lib/plugin (as well as mapped)
- When an end-user hits a certain view or action, the shared helper will ping the app search telemetry route which increments the savedObject store

* Update client-side views/links to new shared telemetry helper

* Write tests for new telemetry files

* Implement remaining unit tests (#7)

* Write tests for React Router+EUI helper components

* Update generate_breadcrumbs test

- add test suite for generateBreadcrumb() itself (in order to cover a missing branch)
- minor lint fixes
- remove unnecessary import from set_breadcrumbs test

* Write test for get_username util

+ update test to return a more consistent falsey value (null)

* Add test for SetupGuide

* [Refactor] Pull out various Kibana context mocks into separate files

- I'm creating a reusable useContext mock for shallow()ed enzyme components
+ add more documentation comments + examples

* Write tests for empty state components

+ test new usecontext shallow mock

* Empty state components: Add extra getUserName branch test

* Write test for app search index/routes

* Write tests for engine overview table

+ fix bonus bug

* Write Engine Overview tests

+ Update EngineOverview logic to account for issues found during tests :)
  - Move http to async/await syntax instead of promise syntax (works better with existing HttpServiceMock jest.fn()s)
  - hasValidData wasn't strict enough in type checking/object nest checking and was causing the app itself to crash (no bueno)

* Refactor EngineOverviewHeader test to use shallow + to full coverage

- missed adding this test during telemetry work
- switching to shallow and beforeAll reduces the test time from 5s to 4s!

* [Refactor] Pull out React Router history mocks into a test util helper

+ minor refactors/updates

* Add small tests to increase branch coverage

- mostly testing fallbacks or removing fallbacks in favor of strict type interface
- these are slightly obsessive so I'd also be fine ditching them if they aren't terribly valuable

* Address larger tech debt/TODOs (#8)

* Fix optional chaining TODO

- turns out my local Prettier wasn't up to date, completely my bad

* Fix constants TODO

- adds a common folder/architecture for others to use in the future

* Remove TODO for eslint-disable-line and specify lint rule being skipped

- hopefully that's OK for review, I can't think of any other way to sanely do this without re-architecting the entire file or DDoSing our API

* Add server-side logging to route dependencies

+ add basic example of error catching/logging to Telemetry route
+ [extra] refactor mockResponseFactory name to something slightly easier to read

* Move more Engines Overview API logic/logging to server-side

- handle data validation in the server-side
- wrap server-side API in a try/catch to account for fetch issues
- more correctly return 2xx/4xx statuses and more correctly deal with those responses in the front-end
- Add server info/error/debug logs (addresses TODO)
- Update tests + minor refactors/cleanup
    - remove expectResponseToBe200With helper (since we're now returning multiple response types) and instead make mockResponse var name more readable
    - one-line header auth
    - update tests with example error logs
    - update schema validation for `type` to be an enum of `indexed`/`meta` (more accurately reflecting API)

* Per telemetry team feedback, rename usageCollection telemetry mapping name to simpler 'app_search'

- since their mapping already nests under 'kibana.plugins'
- note: I left the savedObjects name with the '_telemetry' suffix, as there very well may be a use case for top-level generic 'app_search' saved objects

* Update Setup Guide installation instructions (#9)

Co-authored-by: Chris Cressman <chris@chriscressman.com>

* [Refactor] DRY out route test helper

* [Refactor] Rename public/test_utils to public/__mocks__

- to better follow/use jest setups and for .mock.ts suffixes

* Add platinum licensing check to Meta Engines table/call (#11)

* Licensing plugin setup

* Add LicensingContext setup

* Update EngineOverview to not hit meta engines API on platinum license

* Add Jest test helpers for future shallow/context use

* Update plugin to use new Kibana nav + URL update (#12)

* Update new nav categories to add Enterprise Search + update plugin to use new category

- per @johnbarrierwilson and Matt Riley, Enterprise Search should be under Kibana and above Observability
- Run `node scripts/check_published_api_changes.js --accept` since this new category affects public API

* [URL UPDATE] Change '/app/enterprise_search/app_search' to '/app/app_search'

- This needs to be done because App Search and Workplace search *have* to be registered as separate plugins to have 2 distinct nav links
- Currently Kibana doesn't support nested app names (see: https://github.com/elastic/kibana/issues/59190) but potentially will in the future

- To support this change, we need to update applications/index.tsx to NOT handle '/app/enterprise_search' level routing, but instead accept an async imported app component (e.g. AppSearch, WorkplaceSearch).
- AppSearch should now treat its router as root '/' instead of '/app_search'

- (Addl) Per Josh Dover's recommendation, switch to `<Router history={params.history}>` from `<BrowserRouter basename={params.appBasePath}>` since they're deprecating appBasePath

* Update breadcrumbs helper to account for new URLs

- Remove path for Enterprise Search breadcrumb, since '/app/enterprise_search' will not link anywhere meaningful for the foreseeable future, so the Enterprise Search root should not go anywhere
- Update App Search helper to go to root path, per new React Router setup

Test changes:
- Mock custom basepath for App Search tests
- Swap enterpriseSearchBreadcrumbs and appSearchBreadcrumbs test order (since the latter overrides the default mock)

* Add create_first_engine_button telemetry tracking to EmptyState

* Switch plugin URLs back to /app/enterprise_search/app_search

Now that https://github.com/elastic/kibana/pull/66455 has been merged in 🎉

* Add i18n formatted messages / translations (#13)

* Add i18n provider and formatted/i18n translated messages

* Update tests to account for new I18nProvider context + FormattedMessage components

- Add new mountWithContext helper that provides all contexts+providers used in top-level app
- Add new shallowWithIntl helper for shallow() components that dive into FormattedMessage

* Format i18n dates and numbers

+ update some mock tests to not throw react-intl invalid date messages

* Update EngineOverviewHeader to disable button on prop

* Address review feedback (#14)

* Fix Prettier linting issues

* Escape App Search API endpoint URLs

- per PR feedback
- querystring should automatically encodeURIComponent / escape query param strings

* Update server plugin.ts to use getStartServices() rather than storing local references from start()

- Per feedback: https://github.com/elastic/kibana/blob/master/src/core/CONVENTIONS.md#applications

- Note: savedObjects.registerType needs to be outside of getStartServices, or an error is thrown

- Side update to registerTelemetryUsageCollector to simplify args

- Update/fix tests to account for changes

* E2E testing (#6)

* Wired up basics for E2E testing

* Added version with App Search

* Updated naming

* Switched configuration around

* Added concept of 'fixtures'

* Figured out how to log in as the enterprise_search user

* Refactored to use an App Search service

* Added some real tests

* Added a README

* Cleanup

* More cleanup

* Error handling + README updatre

* Removed unnecessary files

* Apply suggestions from code review

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Update x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/engine_table.tsx

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* PR feedback - updated README

* Additional lint fixes

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* Add README and CODEOWNERS (#15)

* Add plugin README and CODEOWNERS

* Fix Typescript errors (#16)

* Fix public mocks

* Fix empty states types

* Fix engine table component errors

* Fix engine overview component errors

* Fix setup guide component errors

- SetBreadcrumbs will be fixed in a separate commit

* Fix App Search index errors

* Fix engine overview header component errors

* Fix applications context index errors

* Fix kibana breadcrumb helper errors

* Fix license helper errors

*  Refactor React Router EUI link/button helpers
- in order to fix typescript errors

- this changes the component logic significantly to a react render prop, so that the Link and Button components can have different types - however, end behavior should still remain the same

* Fix telemetry helper errors

* Minor unused var cleanup in plugin files

* Fix telemetry collector/savedobjects errors

* Fix MockRouter type errors and add IRouteDependencies export

- routes will use IRouteDependencies in the next few commits

* Fix engines route errors

* Fix telemetry route errors

* Remove any type from source code

- thanks to Scotty for the inspiration

* Add eslint rules for Enterprise Search plugin

- Add checks for type any, but only on non-test files
- Disable react-hooks/exhaustive-deps, since we're already disabling it in a few files and other plugins also have it turned off

* Cover uncovered lines in engines_table and telemetry tests

* Fixed TS warnings in E2E tests (#17)

* Feedback: Convert static CSS values to EUI variables where possible

* Feedback: Flatten nested CSS where possible

- Prefer setting CSS class overrides on individual EUI components, not on a top-level page

+ Change CSS class casing from kebab-case to camelCase to better match EUI/Kibana

+ Remove unnecessary .euiPageContentHeader margin-bottom override by changing the panelPaddingSize of euiPageContent

+ Decrease engine overview table padding on mobile

* Refactor out components shared with Workplace Search (#18)

* Move getUserName helper to shared

- in preparation for Workplace Search plugin also using this helper

* Move Setup Guide layout to a shared component

* Setup Guide: add extra props for standard/native auth links

Note: It's possible this commit may be unnecessary if we can publish shared Enterprise Search security mode docs

* Update copy per feedback from copy team

* Address various telemetry issues

- saved objects: removing indexing per #43673
- add schema and generate json per #64942
- move definitions over to collectors since saved objects is mostly empty at this point, and schema throws an error when it imports an obj instead of being defined inline
- istanbul ignore saved_objects file since it doesn't have anything meaningful to test but was affecting code coverage

* Disable plugin access if a normal user does not have access to App Search (#19)

* Set up new server security dependency and configs

* Set up access capabilities

* Set up checkAccess helper/caller

* Remove NoUserState component from the public UI

- Since this is now being handled by checkAccess / normal users should never see the plugin at all if they don't have an account/access, the component is no longer needed

* Update server routes to account for new changes

- Remove login redirect catch from routes, since the access helper should now handle that for most users by disabling the plugin (superusers will see a generic cannot connect/error screen)
- Refactor out new config values to a shared mock

* Refactor Enterprise Search http call to hit/return new internal API endpoint

+ pull out the http call to a separate library for upcoming public URL work (so that other files can call it directly as well)

* [Discussion] Increase timeout but add another warning timeout for slow servers

- per recommendation/convo with Brandon

* Register feature control

* Remove no_as_account from UI telemetry

- since we're no longer tracking that in the UI

* Address PR feedback - isSuperUser check

* Public URL support for Elastic Cloud (#21)

* Add server-side public URL route

- Per feedback from Kibana platform team, it's not possible to pass info from server/ to public/ without a HTTP call :[

* Update MockRouter for routes without any payload/params

* Add client-side helper for calling the new public URL API

+ API seems to return a URL a trailing slash, which we need to omit

* Update public/plugin.ts to check and set a public URL

- relies on this.hasCheckedPublicUrl to only make the call once per page load instead of on every page nav

* Fix failing feature control tests

- Split up scenario cases as needed
- Add plugin as an exception alongside ML & Monitoring

* Address PR feedback

- version: kibana
- copy edits
- Sass vars
- code cleanup

* Casing feedback: change all plugin registration IDs from snake_case to camelCase

- note: current remainng snake_case exceptions are telemetry keys
- file names and api endpoints are snake_case per conventions

* Misc security feedback

- remove set
- remove unnecessary capabilities registration
- telemetry namespace agnostic

* Security feedback: add warn logging to telemetry collector

see https://github.com/elastic/kibana/pull/66922#discussion_r451215760
- add if statement
- pass log dependency around (this is kinda medium, should maybe refactor)
- update tests
- move test file comment to the right file (was meant for telemetry route file)

* Address feedback from Pierre

- Remove unnecessary ServerConfigType
- Remove unnecessary uiCapabilities
- Move registerTelemetryRoute / SavedObjectsServiceStart workaround
- Remove unnecessary license optional chaining

* PR feedback

Address type/typos

* Fix telemetry API call returning 415 on Chrome

- I can't even?? I swear charset=utf-8 fixed the same error a few weeks ago

* Fix failing tests

* Update Enterprise Search functional tests (without host) to run on CI

- Fix incorrect navigateToApp slug (hadn't realized this was a URL, not an ID)
- Update without_host_configured tests to run without API key
- Update README

* Address PR feedback from Pierre

- remove unnecessary authz?
- remove unnecessary content-type json headers
- add loggingSystemMock.collect(mockLogger).error assertion
- reconstrcut new MockRouter on beforeEach for better sandboxing
- fix incorrect describe()s -should be it()
- pull out reusable mockDependencies helper (renamed/extended from mockConfig) for tests that don't particularly use config/log but still want to pass type definitions
- Fix comment copy

Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Chris Cressman <chris@chriscressman.com>
Co-authored-by: scottybollinger <scotty.bollinger@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-09 13:10:31 -07:00