Commit graph

44 commits

Author SHA1 Message Date
Spencer f466ebf1a3
[esArchiver] drop support for --dir, use repo-relative paths instead (#101345)
Co-authored-by: spalger <spalger@users.noreply.github.com>
2021-06-08 17:37:42 -04:00
Spencer 808b44f2c1
[kbn/test] move types/ftr into src (#99555)
* [kbn/test] move types/ftr into src

* Apply eslint updates

* fix import of Lifecycle type

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-05-17 09:51:53 -07:00
Alejandro Fernández Haro 6bd0a7fcc5
[Plugins Discovery] Enforce camelCase plugin IDs (#90752)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-02-11 14:36:17 +00: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
Larry Gregory bf0f8bbb42
Cleanup feature registration (#80909) 2020-10-20 12:53:43 -04:00
Larry Gregory 9f3992f6c2
Grouped features for space management (#74151)
* Grouped features for space management

* Apply suggestions from code review

Co-authored-by: Joe Portner <5295965+jportner@users.noreply.github.com>

* Address PR Feedback

* docs changes

* updating types/docs

* update APM feature name

* Reintroduce extraAction following EUI update

* change ordering of infra features, and render callout for management category

Co-authored-by: Joe Portner <5295965+jportner@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-18 12:30:59 -04:00
Larry Gregory 613509d81a
Improve home screen for limited-access users (#77665) 2020-09-18 08:54:08 -04:00
Larry Gregory 2e34eb239f
Hide management sections based on cluster/index privileges (#67791)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-09-14 09:30:47 -04: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
Pierre Gayvallet e70ef657d4
Delete src/legacy/ui/public folder (#76085)
* delete src/legacy/ui/public folder

* remove jest.mock('ui/XXX'); from tests

* adapt stubbedLogstashIndexPatternService

* remove delete keys from translation files

* fix types import with Capabilities

* remove legacy test utils

* remove dead file referencing ui/newPlatform

* move saved-object-finder styles to timelion plugin
2020-09-01 09:23:22 +02:00
Catherine Liu 532f2d70e8
[Home] Elastic home page redesign (#70571)
Co-authored-by: Catherine Liu <catherine.liu@elastic.co>
Co-authored-by: Ryan Keairns <contactryank@gmail.com>
Co-authored-by: Catherine Liu <catherineqliu@outlook.com>
Co-authored-by: Michael Marcialis <michael.marcialis@elastic.co>
2020-08-26 13:00:00 -07:00
Mikhail Shustov 88c0631344
Update @typescript-eslint to ensure compatibility with TypeScript v3.9 (#74091)
* bump @typescript-eslint deps

* update rules

* fix errors in pacakges

* fix src/

* fix x-pack

* fix test

* fix typings

* fix examples

* allow _ as prefix and suffix

* roll back prefix and suffix changes

* add eslint-plugin-eslint-comments

* report unused rules

* remove unused eslint comments from tests

* remove unused eslint comments 2nd pass

* remove unused eslint comments from src/

* remove unused comments in x-pack

* use no-script-url and no-unsanitized/property for ts files

* remove unused eslint comments

* eui/href-or-on-click removed when not complained

* no import/* rules for ts files

* cleanup

* remove the unused eslint-disable

* rollback unnecessary changes

* allow underscore prefix & sufix in type name

* update docs

* fix type error in enterprise search plugin mocks

* rename platform hack __coreProvider --> _coreProvider

* rollback space removal in src/core/public/legacy/legacy_service.test.ts

* fix naming convention in APM
2020-08-05 17:32:19 +02:00
Larry Gregory 09b11b61f0
Introduce reserved ml privilege for the apm_user role (#72266)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-07-28 07:44:37 -04: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
restrry bf04235dae apply prettier styles 2020-05-22 09:08:58 +02:00
Mikhail Shustov 4912153ce6
don't register any features in LP. (#65611)
* don't register any features in LP. breaks features value reading in KP

* move test plugin to NP

* fix mappings

* update docs

* migrate another test

* use contstants file for BWC with original code

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-05-11 18:43:45 +02:00
Larry Gregory b82cc6ed4a
Support for sub-feature privileges (#60563)
* initial server-side support for sub-feature privileges (#57507)

* initial server-side support for sub-feature privileges

* start addressing PR feedback

* renaming interfaces

* move privilege id collision check to security plugin

* additional testing

* change featurePrivilegeIterator import location

* fix link assertions following rebase from master

* Initial UI support for sub-feature privileges (#59198)

* Initial UI support for sub-feature privileges

* Address PR feedback

* display deleted spaces correctly in the privilege summary

* additional testing

* update snapshot

* Enables sub-feature privileges for gold+ licenses (#59750)

* enables sub-feature privileges for gold+ licenses

* Address PR feedback

* address platform review feedback
2020-03-24 11:12:49 -04:00
Brandon Kobel 02f309c206
Specifying valid licenses for the Graph feature (#55911)
* Specifying valid licenses for the Graph feature

* Adding option to /api/features to ignore valid licenses

This allow us to take advantage of the /api/featues endpoint within our
tests to disable all features, including those which are disabled by the
current license. The ui capabilities don't take into considerating the
license at the moment, so they're separate entirely separeate mechanisms
at this point in time.

* Addressing PR comments

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-02-07 10:27:55 -08:00
Michail Yasonik da54657b91
Grouped Kibana nav (#53545)
Adds concept of `category` to nav links, grouping them by this in the side nav
2020-01-21 12:48:07 -05:00
spalger 8e9a8a84dc autofix all violations 2019-12-13 23:17:13 -07:00
Spencer b66415e416
[xpack/ftr/common] follow service provider conventions (#52236)
* [xpack/ftr/common] follow conventions, expose a config file

In order to make xpack/test/common ftr config easier to work with, this updates it to follow the conventions established by most other configs of exposing all services from the services module as an object that can be easily merges into local services modules.

* common config file and FtrProviderConfig are unused and unnecessary

* turns out FtrProviderContext was used...
2019-12-05 10:16:17 -07:00
Pierre Gayvallet 99c6396fd5
Migrate Capabilities to new platform (#51438)
* create service skeleton

* move registerCapabilitiesModifier to capabilities service and rename to registerCapabilitiesSwitcher

* starts to move capabilities logic to CapabilitiesService

* move capabilities route to service

* add initial integration test for capabilities route

* capabilitiesMixin now delegates to capability service

* use server-side Capabilities import in server code

* update generated doc

* remove capabilities from injectedMetadatas

* use applications sent from client instead of server-registered navLinks

* disable authRequired for capabilities route

* (temp) exposes two endpoints for capabilities

* Add fetch-mock on capabilities call for karma tests

* adapt xpack Capabilities test - first attempt

* adapt x-pack ui_capabilities test

* add '/status' to the list of anonymous pages

* Add documentation on Capabilities APIs

* move Capabilities to core/types

* update generated docs

* add service tests

* protecting resolveCapabilities against added/removed capabilities

* update generated docs

* adapt mocks due to rebase

* add forgotten exports

* improve capabilities routes registering

* name capabilities registering methods

* resolve conflicts due to merge

* address review issues

* add comment about reason for exposing two routes

* extract createHttpServer test helper

* fix merge conflicts

* improve documentation

* remove `/status` anon registration as now done in NP status plugin

* fix merge conflicts
2019-12-03 09:34:49 +01:00
Aleh Zasypkin ad356f5c11
Migrate authorization subsystem to the new platform. (#46145) 2019-11-12 11:31:46 +01:00
Brian Seeders cafc857aba Re-split ciGroups after pipeline rollout (#46375)
* Re-split ciGroups after pipeline rollout

Revert "Revert "Revert "Revert "Revert "[ci] compress jobs for CI stab… (#45454)"

This reverts commit 9a109f2170.

Revert "set IS_PIPELINE_JOB in intake jobs (#45850)"

This reverts commit b1a01effa8.

* Split one of the slow test suites up to try to make overall CI faster

* Disable visualRegression groups, they are being handled in other work

* Revert "Split one of the slow test suites up to try to make overall CI faster"

This reverts commit 1213239545.

* Move some different xpack ciGroup8 suites around
2019-09-25 15:18:37 -07:00
Larry Gregory 15e52f2e5e
Spaces NP Migration - Moving server to the LegacyAPI model (#45382) 2019-09-18 12:57:05 -04:00
Spencer 9a109f2170
Revert "Revert "Revert "Revert "[ci] compress jobs for CI stab… (#45454)
* Revert "Revert "Revert "Revert "[ci] compress jobs for CI stability" (#44584)"""

This reverts commit 148b8c0f90.

* sync changes with Jenkinsfile
2019-09-11 15:27:43 -07:00
Brian Seeders 27d23c4184 Jenkins pipeline with parallel cigroups (#45285)
* Pipeline

* WIP some work for parallelization with ciGroups

* Fix xpack kibana install dir, and add some debugging

* Attempt to quick fix a few tests

* Revert "Revert "Revert "[ci] compress jobs for CI stability" (#44584)""

This reverts commit 078ac2897f.

* Recombine test groups, and try runbld again

* Mostly cleanup, and fix failed_tests reporting to hopefully work for both pipeline and non-pipeline

* Fix typo in shell script

* Remove some debug code

* Add support for changing es transport.port during testing via TEST_ES_TRANSPORT_PORT

* Fix test that uses hard-coded es transport port and add it back in to parallel groups

* Disable checks reporter again for now

* Set env var for TEST_ES_TRANSPORT_PORT in pipeline

* Update Jenkinsfile for shorter testrunner labels

* Fix another hard-coded transport port

* Fix a new test with hard-coded URLs

* Jenkinsfile cleanup and fix one of the groups

* Fix double slash

* Testing vault credentials on jenkins server

* Add a non-existent credential

* Revert "Add a non-existent credential"

This reverts commit 0dc234c465a5483b1a994cb510a182fef766e9cc.

* Try github-checks-reporter again

* github-checks-reporter should only run for elastic/kibana, forks won't work

* Clean up some debug code

* Changing names around to try to make BlueOcean UI a little better

* Add more stages

* Make some changes to stage structure to mirror a nested example from CloudBees

* Handle TODOs, and some cleanup in Jenkinsfile

* Pass GIT_BRANCH when started without GHPRB, fix branch check

* Fix mailer problem and add code that ensures all tests are in cigroups back in

* Test adding worker/job name to junit report paths

* Remove some duplication from ci_setup scripts

* Fix unit test that uses junit path

* Don't reinstall node every time setup_env is run

* Fix yarn install logic

* Fix another unit test that uses junit output dir

* Download latest ES snapshot after kibana builds

* Make sure junit reports are always processed

* Add two failing tests for testing purposes

* Add support to Jenkinsfile for kibana build e-mails

* Remove some debug code for email sending

* Change JOB env handling in junit paths and move it to a sub-directory

* Revert "Add two failing tests for testing purposes"

This reverts commit 5715203e26922a93483feb0ebb8bb3fdcc3daf8c.

* Fix junit report path in test

* Don't send kibana emails on build abort

* Address PR feedback, formatting and use built-in url formatting library

* Fix path formatting for functional test

* Add email sending back in to Jenkinsfile

* Fix another unit test with path problem
2019-09-11 11:58:28 -07:00
spalger 078ac2897f Revert "Revert "[ci] compress jobs for CI stability" (#44584)"
This reverts commit 50355d08f2.
2019-09-10 09:03:23 -07:00
Aleh Zasypkin 9d69b72a5f
Move base feature controls functionality from XPack Main plugin to a dedicated XPack Features plugin (#44664) 2019-09-09 19:15:58 +02:00
Spencer 50355d08f2
Revert "[ci] compress jobs for CI stability" (#44584)
This reverts commit debf8c62b4.
2019-09-03 08:36:47 -07:00
spalger debf8c62b4 [ci] compress jobs for CI stability 2019-08-28 22:31:40 -07:00
Mike Côté bb6aa330e8
Disable security plugin in spaces only test suite (#43608) 2019-08-20 17:00:31 -04:00
Spencer d66b3c74eb
[x-pack/ftr] refactor types to be more accurate/consistent wit… (#42407) 2019-08-02 15:43:05 -07:00
Spencer 415e3bca27
[ts] upgrade to 3.5.3 (#40228)
* [ts] upgrade to 3.5.2

* [ts] run from cwd so that relative paths are correct

* move eslint-disable-line comment into jsx attribute

* autofix eslint violations

* avoid generic type, it's not necessary and problematic

* make elasticsearch.cluster optional, many instances don't have them

* remove invalid prop

* expand AllowUnknownProperties to cleanly handle arrays

* esfilter values can sometimes be an array of strings

* allow exception objects to have unknown properties

* define accumulator as a boolean

* fix return type

* return a 404 if beat isn't found after update

* use Object.values for better types

* define return type of get() call

* define value type for Set

* define return value of get()

* define State property type

* use less get(), so ts can infer types

* define Set item type

* map state type

* make default_operator optional, since it's not always defined

* remove seemingly unused prop

* define return type of get() fn

* define inner type for state

* don't define base types are objects with index signatues

* regenerate public api docs

* make indices privileges optional too

* remove unnecessary index-signature from Exception interface

* use variadic _arg instead

* [core/plugin] use Record<string, any> rather than {}

* replace a couple more instances of {}

* revert some unnecessary changes

* remove unused types

* [reporting] output, payload, and meta are required properties

* bump to latest patch version
2019-07-10 12:26:23 -07:00
Larry Gregory ee27bc4083
Feature Controls - Simplify Saved Objects Management UI Capabilities (#38461)
* start simplifying saved objects management UI Capabilities

* update tests

* simplify UI

* address PR feedback

* remove savedObjectsManagement UI Capabilities tests
2019-06-10 18:08:59 -04:00
Lee Drengenberg 67dc8a45aa
Split ciGroup3 and ciGroup5 (#36928)
* split large x-pack ciGroup5 into 3 groups

* split large x-pack ciGroup3 into 2 groups

* Add groups to the jenkins xpack ci group file

* Re-level some more work

* move es_search_source test to new describe block

* move es_search_source to first in ciGroup7
2019-05-24 14:20:43 -05:00
Xavier Mouligneau 9a01a0d69d
[SIEM] Persistence of a Timeline (#36662)
* persistence of a timeline

s Please enter the commit message for your changes. Lines starting

* fix unit testing + add functionality in the setting of timeline

* fix ciGroup5

* fix duplicate timeline

* fix merge issue

* fix test

* review I

* cleanup merge

* add kql from savedObject to kql bar

* add operator from Dataprovider to saveObject
2019-05-22 01:15:15 -04:00
Josh Dover d9c34caf95
Load Capabilities from InjectedMetadata (#36710) 2019-05-21 13:58:07 -05:00
Larry Gregory f37e04484a
Feature Controls - Add saved objects management feature (#35982)
* adds saved objects management feature

* document TODO

* testing UI Capbilities

* update SOM functional tests

* fixing privilege action mapping from merge

* remove describe.only

* add new feature to expected feature list

* prettier

* adds simple unit tests for OSS feature registration

* fix tests following merge
2019-05-07 12:45:38 -04:00
Josh Dover 8fe1eb2086
[new-platform] Introduce ApplicationService scaffolding and capabilities loading (#35545) 2019-05-06 22:08:25 -05:00
Catherine Liu 53ad55cf6f
[Canvas]Feat: Custom Elements (#34140)
* Added custom element routes

    Added context menu to sidebar header

    Added custom element modal

    Added tabs to element_types

    Added handlers for retrieving custom elements

    sidebar header tweaks

    Added edit and delete element controls

    Added a selector for transient.selectedToplevelNodes

    Refactored element event handlers

    Added additional sidebar views

    Fixed adding custom element to workpad

    Converted element_controls to tsx

    Disabled group/ungroup buttons sidebar

    Disabled layer controls in multi_element_settings

    Cleaned up props for element_types

    Added story for element_controls

    Added stories for global_config, group_settings, and multi_element_config

    TSified element_handler_creators

    fixed ts errors

    more tsifying

    Added decorator to element_controls

    Updated stories for custom_element_modal

    Disabled global_config, group_settings, and multi_element_settings stories

    TSified sidebar

    disable layer controls in group_settings

    Removed save element shortcut

    added public/private keywords

    Converted sidebar_header to ts and added stories

Refactored sidebar_header

fix file extension

design cleanup

fix image in edit modal

Fixed ts errors

Update x-pack/plugins/canvas/server/routes/custom_elements.js

Co-Authored-By: cqliu1 <catherineqliu@outlook.com>

Update x-pack/plugins/canvas/server/routes/workpad.js

Co-Authored-By: cqliu1 <catherineqliu@outlook.com>

Reordered args for insertNodes and removeNodes to match corresponding redux actions

Extracted PositionedElement interface

Fixed TS issues

Adjust title and desc lengths

Added comments to props interface

Refactored onClick handlers

more ts

Added types for ast

Switched common/lib/constants back to JS

Added comments

Updated more comments

Removed unused import

Added snapshots

Typed custom_element_service

Fixed ts errors

* Added comments to @ts-ignore's

* Removed custom_element_modal stories

* Added a few more comments

* Update security tests with new canvas-element saved object

* Updated privileges test

* Updated ui_capabilities security_only saved_objects_management test

* Added state interface for CustomElementTypes

* Added state interfaces

* fixed comment

* Removed unnecessary exports
2019-05-02 16:38:46 -05:00
Larry Gregory e18bfc1497
Feature Controls - Allow telemetry to be toggled with advancedSettings feature privilege (#35250)
* Allow telemetry to be toggled with feature privileges
2019-04-25 11:43:42 -04:00
Brandon Kobel 80aae6bba8
Feature Controls (#31652)
* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Introducing uiCapabilities, removing config providers & user profile (#25387)

## Summary
Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions.

* GAP - Actions Restructured and Extensible (#25347)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing saved object capability checking

* Beginning to restructure actions to be used for all action building

* Using actions to build ui capabilities

* dropping /read from client-side userprovide ui capabilities

* Adding some actions

* Using different syntax which will hopefully help with allowing apps to
specify the privileges themselves

* Exposing all saved object operations in the capabilities

* Using actions in security's onPostAuth

* Only loading the default index pattern when it's required

* Only using the navlinks for the "ui capabilities"

* Redirecting from the discover application if the user can't access
kibana:discover

* Redirecting from dashboard if they're hidden

* Features register their privileges now

* Introducing a FeaturesPrivilegesBuilder

* REmoving app from the feature definition

* Adding navlink specific ations

* Beginning to break out the serializer

* Exposing privileges from the authorization service

* Restructuring the privilege/resource serialization to support features

* Adding actions unit tests

* Adding features privileges builders tests

* Adding PrivilegeSerializer tests

* Renaming missed usages

* Adding tests for the privileges serializer

* Adding privileges tests

* Adding registerPrivilegesWithCluster tests

* Better tests

* Fixing authorization service tests

* Adding ResourceSerializer tests

* Fixing Privileges tests

* Some PUT role tests

* Fixing read ui/api actions

* Exposing features from xpackMainPlugin

* Adding navlink:* to the "reserved privileges"

* navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink ->
navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link

* Automatically determining navlink based ui capabilities

* Backing out changes that got left behind

* Using ui actions for navlinks

* Adding TODOs

* Ui -> UI

* Deleting unused file

* Removing api: [] as it's not necessary anymore

* Fixing graph saved object privileges

* Privileges are now async

* Pushing the asycnchronicity to the privileges "service"

* Adding TODO

* Providing initial value for reduce

* adds uiCapabilities to test_entry_template

* Adding config to APM/ML feature privileges

* Commenting out obviously failing test so we can get CI greeenn

* Fixing browser tests

* Goodbyyeee

* Adding app actions to the reserved privileges

* update snapshot

* UI/API changes to facilitate disabling features within spaces (#24235)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Introducing uiCapabilities, removing config providers & user profile (#25387)

## Summary
Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions.

* GAP - Actions Restructured and Extensible (#25347)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing saved object capability checking

* Beginning to restructure actions to be used for all action building

* Using actions to build ui capabilities

* dropping /read from client-side userprovide ui capabilities

* Adding some actions

* Using different syntax which will hopefully help with allowing apps to
specify the privileges themselves

* Exposing all saved object operations in the capabilities

* Using actions in security's onPostAuth

* Only loading the default index pattern when it's required

* Only using the navlinks for the "ui capabilities"

* Redirecting from the discover application if the user can't access
kibana:discover

* Redirecting from dashboard if they're hidden

* Features register their privileges now

* Introducing a FeaturesPrivilegesBuilder

* REmoving app from the feature definition

* Adding navlink specific ations

* Beginning to break out the serializer

* Exposing privileges from the authorization service

* Restructuring the privilege/resource serialization to support features

* Adding actions unit tests

* Adding features privileges builders tests

* Adding PrivilegeSerializer tests

* Renaming missed usages

* Adding tests for the privileges serializer

* Adding privileges tests

* Adding registerPrivilegesWithCluster tests

* Better tests

* Fixing authorization service tests

* Adding ResourceSerializer tests

* Fixing Privileges tests

* Some PUT role tests

* Fixing read ui/api actions

* Exposing features from xpackMainPlugin

* Adding navlink:* to the "reserved privileges"

* navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink ->
navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link

* Automatically determining navlink based ui capabilities

* Backing out changes that got left behind

* Using ui actions for navlinks

* Adding TODOs

* Ui -> UI

* Deleting unused file

* Removing api: [] as it's not necessary anymore

* Fixing graph saved object privileges

* Privileges are now async

* Pushing the asycnchronicity to the privileges "service"

* Adding TODO

* Providing initial value for reduce

* adds uiCapabilities to test_entry_template

* Adding config to APM/ML feature privileges

* Commenting out obviously failing test so we can get CI greeenn

* Fixing browser tests

* Goodbyyeee

* Adding app actions to the reserved privileges

* Begin to allow features to be disabled within spaces

typescript fixes

additional cleanup

attempt to resolve build error

fix tests

more ts updates

fix typedefs on manage_spaces_button

more import fixes

test fixes

move user profile into xpack common

Restructure space management screen

fix SASS references

design edits

remove Yes/No language from feature toggles

fix casing

removed unused imports

update snapshot

fix sass reference for collapsible panel

Fix sass reference, take 2

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* extract migration logic into testable unit

* Introducing uiCapabilities, removing config providers & user profile (#25387)

## Summary
Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions.

* Design edits (#12)

enables customize avatar popover

update tests, and simplify editing space identifier

remove references to user profile

remove unused test suite

remove unnecessary sass import

removes security's capability_decorator

* fix i18n

* updates toggleUiCapabilities to use new feature definitions

* cleanup and testing

* remove references to old feature interface

* readd lost spacer

* adds feature route testing

* additional i18n

* snapshot update

* copy edits

* fix ml app icon

* add missing export

* remove unnecessary sass import

* attempt to fix build

* fix spaces api tests

* esArchiver mapping updates

* rename toggleUiCapabilities -> toggleUICapabilities

* removes shared collapsible_panel component in favor of plugin-specific components

* some copy and style adjustments

* fix test following rebase

* add lost types file

* design edits

* remove stale export

* feature feedback; fixes cached disabled features

* GAP: Security disables UI capabilities (#25809)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing saved object capability checking

* Beginning to restructure actions to be used for all action building

* Using actions to build ui capabilities

* dropping /read from client-side userprovide ui capabilities

* Adding some actions

* Using different syntax which will hopefully help with allowing apps to
specify the privileges themselves

* Exposing all saved object operations in the capabilities

* Using actions in security's onPostAuth

* Only loading the default index pattern when it's required

* Only using the navlinks for the "ui capabilities"

* Redirecting from the discover application if the user can't access
kibana:discover

* Redirecting from dashboard if they're hidden

* Features register their privileges now

* Introducing a FeaturesPrivilegesBuilder

* REmoving app from the feature definition

* Adding navlink specific ations

* Beginning to break out the serializer

* Exposing privileges from the authorization service

* Restructuring the privilege/resource serialization to support features

* Adding actions unit tests

* Adding features privileges builders tests

* Adding PrivilegeSerializer tests

* Renaming missed usages

* Adding tests for the privileges serializer

* Adding privileges tests

* Adding registerPrivilegesWithCluster tests

* Better tests

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing authorization service tests

* Adding ResourceSerializer tests

* Fixing Privileges tests

* Some PUT role tests

* Fixing read ui/api actions

* Introducing uiCapabilities, removing config providers & user profile (#25387)

## Summary
Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions.

* Exposing features from xpackMainPlugin

* Adding navlink:* to the "reserved privileges"

* navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink ->
navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link

* Automatically determining navlink based ui capabilities

* Backing out changes that got left behind

* Using ui actions for navlinks

* Adding TODOs

* Ui -> UI

* Deleting unused file

* Removing api: [] as it's not necessary anymore

* Fixing graph saved object privileges

* Privileges are now async

* Pushing the asycnchronicity to the privileges "service"

* Adding TODO

* Providing initial value for reduce

* adds uiCapabilities to test_entry_template

* Adding config to APM/ML feature privileges

* Commenting out obviously failing test so we can get CI greeenn

* Fixing browser tests

* First, very crappy implementation

* Adding tests for disabling ui capabilities

* All being set to false no longer requires a clone

* Using _.mapValues makes this a lot more readable

* Checking those privileges dynamically

* Fixing some broken stuff when i introduced checkPrivilegesDynamically

* Adding conditional plugin tests

* Renaming conditional plugin to optional plugin

* Fixing type errors

* GAP - Actions Restructured and Extensible (#25347)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing saved object capability checking

* Beginning to restructure actions to be used for all action building

* Using actions to build ui capabilities

* dropping /read from client-side userprovide ui capabilities

* Adding some actions

* Using different syntax which will hopefully help with allowing apps to
specify the privileges themselves

* Exposing all saved object operations in the capabilities

* Using actions in security's onPostAuth

* Only loading the default index pattern when it's required

* Only using the navlinks for the "ui capabilities"

* Redirecting from the discover application if the user can't access
kibana:discover

* Redirecting from dashboard if they're hidden

* Features register their privileges now

* Introducing a FeaturesPrivilegesBuilder

* REmoving app from the feature definition

* Adding navlink specific ations

* Beginning to break out the serializer

* Exposing privileges from the authorization service

* Restructuring the privilege/resource serialization to support features

* Adding actions unit tests

* Adding features privileges builders tests

* Adding PrivilegeSerializer tests

* Renaming missed usages

* Adding tests for the privileges serializer

* Adding privileges tests

* Adding registerPrivilegesWithCluster tests

* Better tests

* Fixing authorization service tests

* Adding ResourceSerializer tests

* Fixing Privileges tests

* Some PUT role tests

* Fixing read ui/api actions

* Exposing features from xpackMainPlugin

* Adding navlink:* to the "reserved privileges"

* navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink ->
navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link

* Automatically determining navlink based ui capabilities

* Backing out changes that got left behind

* Using ui actions for navlinks

* Adding TODOs

* Ui -> UI

* Deleting unused file

* Removing api: [] as it's not necessary anymore

* Fixing graph saved object privileges

* Privileges are now async

* Pushing the asycnchronicity to the privileges "service"

* Adding TODO

* Providing initial value for reduce

* adds uiCapabilities to test_entry_template

* Adding config to APM/ML feature privileges

* Commenting out obviously failing test so we can get CI greeenn

* Fixing browser tests

* Goodbyyeee

* Adding app actions to the reserved privileges

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Introducing uiCapabilities, removing config providers & user profile (#25387)

## Summary
Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions.

* GAP - Actions Restructured and Extensible (#25347)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing saved object capability checking

* Beginning to restructure actions to be used for all action building

* Using actions to build ui capabilities

* dropping /read from client-side userprovide ui capabilities

* Adding some actions

* Using different syntax which will hopefully help with allowing apps to
specify the privileges themselves

* Exposing all saved object operations in the capabilities

* Using actions in security's onPostAuth

* Only loading the default index pattern when it's required

* Only using the navlinks for the "ui capabilities"

* Redirecting from the discover application if the user can't access
kibana:discover

* Redirecting from dashboard if they're hidden

* Features register their privileges now

* Introducing a FeaturesPrivilegesBuilder

* REmoving app from the feature definition

* Adding navlink specific ations

* Beginning to break out the serializer

* Exposing privileges from the authorization service

* Restructuring the privilege/resource serialization to support features

* Adding actions unit tests

* Adding features privileges builders tests

* Adding PrivilegeSerializer tests

* Renaming missed usages

* Adding tests for the privileges serializer

* Adding privileges tests

* Adding registerPrivilegesWithCluster tests

* Better tests

* Fixing authorization service tests

* Adding ResourceSerializer tests

* Fixing Privileges tests

* Some PUT role tests

* Fixing read ui/api actions

* Exposing features from xpackMainPlugin

* Adding navlink:* to the "reserved privileges"

* navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink ->
navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link

* Automatically determining navlink based ui capabilities

* Backing out changes that got left behind

* Using ui actions for navlinks

* Adding TODOs

* Ui -> UI

* Deleting unused file

* Removing api: [] as it's not necessary anymore

* Fixing graph saved object privileges

* Privileges are now async

* Pushing the asycnchronicity to the privileges "service"

* Adding TODO

* Providing initial value for reduce

* adds uiCapabilities to test_entry_template

* Adding config to APM/ML feature privileges

* Commenting out obviously failing test so we can get CI greeenn

* Fixing browser tests

* Goodbyyeee

* Adding app actions to the reserved privileges

* Update x-pack/plugins/security/server/lib/authorization/disable_ui_capabilities.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/plugins/security/server/lib/authorization/check_privileges_dynamically.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Disabling all ui capabilities if route is anonymous

* More typescript

* Even more typescript

* Updating snapshot

* Less any

* More safer

* Another one

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Introducing uiCapabilities, removing config providers & user profile (#25387)

## Summary
Introduces the concept of "UI Capabilities", which allows Kibana applications to declare capabilities via the `uiCapabilities` injected var, and then use them client-side via the `ui/capabilities` module to inform their rendering decisions.

* GAP - Actions Restructured and Extensible (#25347)

* Restructure user profile for granular app privs (#23750)

merging to feature branch for further development

* Fixing saved object capability checking

* Beginning to restructure actions to be used for all action building

* Using actions to build ui capabilities

* dropping /read from client-side userprovide ui capabilities

* Adding some actions

* Using different syntax which will hopefully help with allowing apps to
specify the privileges themselves

* Exposing all saved object operations in the capabilities

* Using actions in security's onPostAuth

* Only loading the default index pattern when it's required

* Only using the navlinks for the "ui capabilities"

* Redirecting from the discover application if the user can't access
kibana:discover

* Redirecting from dashboard if they're hidden

* Features register their privileges now

* Introducing a FeaturesPrivilegesBuilder

* REmoving app from the feature definition

* Adding navlink specific ations

* Beginning to break out the serializer

* Exposing privileges from the authorization service

* Restructuring the privilege/resource serialization to support features

* Adding actions unit tests

* Adding features privileges builders tests

* Adding PrivilegeSerializer tests

* Renaming missed usages

* Adding tests for the privileges serializer

* Adding privileges tests

* Adding registerPrivilegesWithCluster tests

* Better tests

* Fixing authorization service tests

* Adding ResourceSerializer tests

* Fixing Privileges tests

* Some PUT role tests

* Fixing read ui/api actions

* Exposing features from xpackMainPlugin

* Adding navlink:* to the "reserved privileges"

* navlink -> navLink | nav_linknavlink -> navLink | nav_linknavlink ->
navLink | nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink |
nav_linknavlink -> navLink | nav_linknavlink -> navLink | nav_link

* Automatically determining navlink based ui capabilities

* Backing out changes that got left behind

* Using ui actions for navlinks

* Adding TODOs

* Ui -> UI

* Deleting unused file

* Removing api: [] as it's not necessary anymore

* Fixing graph saved object privileges

* Privileges are now async

* Pushing the asycnchronicity to the privileges "service"

* Adding TODO

* Providing initial value for reduce

* adds uiCapabilities to test_entry_template

* Adding config to APM/ML feature privileges

* Commenting out obviously failing test so we can get CI greeenn

* Fixing browser tests

* Goodbyyeee

* Adding app actions to the reserved privileges

* update snapshot

* Update x-pack/plugins/security/server/lib/authorization/check_privileges.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/plugins/security/server/lib/authorization/check_privileges.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Fixing type errors

* Only disabling navLinks if a feature is registered for them

* Adding non i18n'ed tooltip

* Making metadata and tooltip optional

* i18n'ing tooltips

* Responding to peer review comments

* GAP - Role API Structure (#26740)

* Updated the role api PUT structure

* Minimum is an array now

* Updating get route to naively support the new structure

* Renaming and removing some serialized methods

* Updating Role PUT api tests

* Fixing PUT jest tests

* Fixing GET tests

* Updating PrivilegeSerializer tests

* Renaming features to feature for the GET, so we're consistent

* Validating features and feature privileges

* Update x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/plugins/security/server/lib/authorization/privilege_serializer.test.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Renaming some variables/members of the PrivilegesSerializer

* Fixing privileges serializer tests

* Fixing register privileges with cluster tests

* Fixing the role creation for the api integration tests

* Generalizing regex within the feature registry

* update tests

* [GAP] - Support infra features (#26955)

## Summary
This PR adds the `Infrastructure` and `Logs` apps as toggle-able features via Granular Application Privileges.

* [GAP] - Enables xpack_main to populate UI Capabilities (#27031)

## Summary

Currently, plugins that register features via `xpackMainPlugin.registerFeature({...})` also have to specify their own `uiCapabilities` via `injectDefaultVars`, which is counter-intuitive and cumbersome. We've accepted this complexity for OSS plugins, but x-pack and third-party plugins should not have to concern themselves with such implementation details.

This PR removes that requirement for x-pack and third-party plugins, so all they have to do is register features, and ensure that their feature privileges contain the appropriate UI Capabilities in the `ui` property.

### Notes
This implementation intentionally does not alter UI Capabilities that come in via OSS Kibana. The capabilities defined there should be the source of truth, regardless of which distribution is used.


### Example
<pre>
xpackMainPlugin.registerFeature({
  id: 'graph',
  name: 'Graph',
  icon: 'graphApp',
  <b>navLinkId: 'graph',</b>
  privileges: {
    all: {
      app: [],
      savedObject: { ... },
      <b>ui: ['showWriteControls'],</b>
    },
    read: {
      app: [],
      savedObject: { ... },
      <b>ui: ['someOtherCapability],</b>
    }
  }
});
</pre>

Will be translated to the following UI Capabilities:
```
uiCapabilities: {
  navLinks: {
    graph: true
  },
  graph: {
    showWriteControls: true,
    someOtherCapability: true, 
  }
}
```


xpack_main is **not responsible** for disabling UI capabilities, so this will initialize all capabilities with a value of `true`.

* Hide write controls for the visualization application (#26536)

* Hide write controls for the timelion application (#26537)

* blacklist feature ids (#27493)

* [GAP] - Support management links (#27055)

## Summary

This enables management links to be toggled via UI Capabilities.

## TODO
- [x] Implement spaces controls
- [x] Implement security controls
- [x] Testing
- [ ] (optional) - dedicated display for managing management links?

* Enables the feature catalogue registry to be controlled via uiCapabil… (#27945)

* Enables the feature catalogue registry to be controlled via uiCapabilities

* update snapshot

* xpack_main populates uiCapabilities with the full list of catalogue entries

* builds application privileges using catalogue actions

* prevent 'catalogue' from being registered as a feature id

* fix mocha tests

* fix merge

* update snapshots

* GAP - Discover and NavLinks Functional Testing (#27414)

* Adding very basic Discover tests

* Ensuring discover is visible in both spaces

* Parsing the DOM to determine the uiCapabilities

* Making this.wreck `any` because the type definitions suck

* Specifying auth when requesting ui capabilities

* Beginning architecture to support permutation testing

* Adding documentation of the different configurations we'd like to test

* Fixing type errors

* Beginning to work on the framework to test the combinations

* Adding some factories

* Pushing forward, not a huge fan of what I have right now

* The new-new

* Less weird types

* Revising some things after talking with Larry

* Switching from wreck to axios

* Restructuring some files

* Changing to a space with all features, and a space with no features

* Beginning to add the security only tests

* Adding a navLinksBuilder

* Adding spaces only tests

* Not disabling ui capabilities, or authing app/api access when we
shouldn't be

* Can't get rid of management

* Adding more user types

* More users, this is starting to really suck

* Renaming some things...

* Revising which users we'll test in which ui capabilities "test suite"

* Adding some more user scenarios for the security_only configuration

* Adding security_only user scenarios

* Adding space scenarios

* Fixing type errors

* Udpating the readme for the spaces we're testing with

* Adding global read discover security ui functional tests

* Adding tests to make sure save buttons are shown/hidden

The actual implementation is broken somewhere

* Fixing tests after GIS is added and conflicts happened for infra

* Adding discover ui capability tests

* Fixing navlinks tests

* Adding discover view tests

* Adding UI tests for spaces being disabled

* Fixing tests

* Removing wreck dependency, it's garbage

* Fixing typo

* Updating ui capabilities README.md and adding another user for the
security and spaces ui capability tests

* Updating yarn lock file

* Consolidation some types

* Adding VisualizeDisabledSpace to the scenarios.

* Fixing esArchives with .kibana_2

* Disable features optional again

* Adding ensureCurrentUrl: false

* Fixing space selector tests

* Fixing gis privileges, they use saved objects

* Fixing find's element staleness checks

* Update x-pack/test/functional/es_archives/spaces/disabled_features/data.json

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Generalizing logic to get appNavLinksText

* Removing duplicate license header

* Adding GIS mappingst

* Fixing readme

* We love our future selfs

* Adding GisRead scenario

* Whoops

* Adding note about funky syntax for use with exhaustive switches

* Using a centralized list of features

* Give it some time

* Even more time?

* Space Management - accessibility & i18n improvements (#28195)

## Summary

1) Improves the accessibility for the spaces management screen:
    - Customize Space Avatar popover now receives focus when toggled
    - Labels are more descriptive, providing context
    - Delete Space modal correctly focuses

2) Improves i18n support
    - fixed a couple hard-coded strings

3) Adds a "Features" column to the spaces grid page, which shows a brief summary of the number of features enabled for each space:

![image](https://user-images.githubusercontent.com/3493255/50785093-93b78280-127d-11e9-975e-7209d35211ff.png)



Related: https://github.com/elastic/kibana/issues/28184

* Feature Controls - spaces - functional tests (#28213)

* adds tests for /api/features/v1 endpoint

* update failing management test

* Fc/run ui capability tests (#28362)

* Running the UI Capability Tests as part of the normal CI runs

* Adding uptime feature to get these tests passing

* Adding features and sorting

* Adding uptime security_only uiCapability tests, and fixing devTools

* Fixing the docs

* Fixing section panel i18n issue

* Removing unused import

* Updating snapshots

* Feature Controls - The new new role API (#28441)

These changes allow us to build the most recent UI where spaces can be "grouped" and edited at once. This changes the kibana section of the role definition to the following:

```
{
  kibana: [
    {
        base: ['read'],
        feature: {
          discover: ['all'],
          dashboard: ['all']
        },
        spaces: ['*']
    },
    {
        base: ['read'],
        feature: {
          discover: ['all'],
          dashboard: ['all']
        },
        spaces: ['marketing', 'sales']
    }
  ]
}
```

If the `spaces` property isn't provided (for example if the user isn't using Spaces) then it'll default to `['*']`. 

There are a few other stipulations that we're implementing with this approach. 

1. Each "item" can be for 1 to many spaces OR globally. We can't specify both space privileges and global privileges in the same "item" because for Spaces we translate `all` to `space_all`, etc. so we can give them different privileges, and this becomes problematic when trying to serialize/deserialize to ES.
2. Additionally, each space can only appear once. The ES model would allow this, but the role management UI becomes more complicated if we were to allow this when calculating effective privileges.

* Feature Controls - Discover Save Button Test #28500 (#28501)

* Adding some debug logs

* Setting ui settings using the functional services

* Doing the same for the spaces disabled features

* Removing console.log debug statements

* Using save instead of showWriteControls

* Reload when adjusting visible features within the users active space (#28409)

## Summary

Changes to the visible features within a space are not visible until the page is refreshed. Because of this, when a user is editing their active space, their changes are not immediately visible.

This updates the space management screen to force a refresh when updating the visible features inside the active space. It also introduces a modal warning that this will happen:

![image](https://user-images.githubusercontent.com/3493255/50923423-ebd7bb80-141a-11e9-92bd-2779020578a4.png)

* Throwing error if we register a feature after getAll is called (#29030)

* Throwing error if we register a feature after getAll is called

* Fixing some tests

* Fixing feature route tests

* Removing unused imports

* Fixing merge conflict

* Feature Controls - Fixing fallout of removing the legacy fallback (#29141)

* Fixing use of mode.useRbacFoRequest to mode.useRbac

* Fixing ui capability tests

* [Feature Controls] - Fix a11y for customize feature section (#29174)

## Summary

Fixes the displayed and announced text for the "show"/"hide" button of the Customize Visible Features section of the spaces management page.

This was inadvertently broken following a merge from master at some point.

* Feature Controls: Fixing k7's new "nav links" (#29198)

* Fixing k7's new applist for feature controls

* Renaming appSwitcher to appsMenu

* Feature Controls - Dashboard (#29139)

* Using addRouteSetupWork to implement the redirect

* Using centralized addSetupWork

* Fixing dashboard functional feature privileges tests

* Ensuring landing page and create dashboard redirect to the home-page

* Adding more tests to ensure the redirects work properly

* Adding disabled space feature tests for Dashboards

* Update src/ui/public/capabilities/route_setup.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update test/functional/page_objects/common_page.js

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Fixing ui capability tests after adding createNew

* Removing unnecessary `return undefined`

* requireUICapabilities -> requireUICapability

* Updating dashboard ui capability tests

* Fixing issue with the selection column appearing on Dashboards

* Fixing ui capability dashboard space only tests

* [FC] - Move management and catalogue entries out of privilege definition (#28354)

* Moves catalogue and management entries from privilege defintion to base feature definition

* Update new management menu to respect items disabled via UI Capabilities

* add test

* re-add index pattern entries

* re-add advanced settings icon

* fix tests

* remove management and catalogue entries from read-only users

* bring it back now y'all

* catalogue updates for xpack plugins

* Introduces 'grantWithBaseRead' flag

* update privileges from all -> read where necessary

* rename feature builder functions

* catalogue and management items should cascade to privileges when not specified

* add catalogue entry for uptime app

* Simplify feature registrations using inherited catalogue/management entries

* consolidate and fix privilege building logic

* rename variables

* remove debug code

* remove duplicate lodash import

* Update x-pack/plugins/xpack_main/server/lib/feature_registry/feature_registry.ts

Co-Authored-By: legrego <lgregorydev@gmail.com>

* [GAP] - Role Management UI (#26840)

 
![image](https://user-images.githubusercontent.com/3493255/51063094-72310080-15c7-11e9-9274-debf0e9b84f1.png)

![image](https://user-images.githubusercontent.com/3493255/51063108-8aa11b00-15c7-11e9-92fc-31c922086e05.png)


![image](https://user-images.githubusercontent.com/3493255/51063165-cb992f80-15c7-11e9-894d-630c109211d3.png)






---------
Edge-case scenarios:
  1) [x] '*' and spaces in the same "entry"
Handled via `_transform_errors` at the API level. Renders a partial read-only view in the UI.
  2) [x] same space appearing in multiple "entries"
Handled via `_transform_errors` at the API level. Renders a partial read-only view in the UI.
  3) [x] base and feature privileges being set on the same "entry"
UI does not allow this to be set, but UI is smart enough to display the correct effective privilege in this case.
  4) [x] multiple base privileges set in the same "entry"
UI does not allow this to be set, but UI is smart enough to apply the most permissive base privilege when displaying and performing privilege calculations.
  5) [x] multiple feature privileges for the same "entry" (ml_all and ml_read)
UI does not allow for this to be set, but UI is smart enough to apply the most permissive base privilege when displaying and performing privilege calculations.


--------

## Summary
This updates the role management UI to allow application privileges to be customized globally and per-space.

## TODO:
- [x] [First Design review](https://github.com/legrego/kibana/pull/13)
- [ ] Second Design review
- [ ] Copy review
- [x] i18n
- [x] Handle deleted/unknown features
- [x] Handle deleted/unknown spaces
- [x] Cleanup & refactoring
- [x] Testing

* [Feature Controls, Spaces] - Don't load bundles for hidden apps (#29617)

## Summary
This enables the spaces plugin to issue a 404 if the requested application is disabled within the users active space.

To enable this functionality, the `app` property was moved to the root feature level, with the option to override at the privilege level. This follows the same logic as `catalogue` and `management` sections.

This will enable automatic app "protections" for those which only specify a single UI application, including:

1) Timelion
2) Canvas
3) Monitoring
4) APM
5) Code (when it merges)
6) GIS
7) Graph
8) ML

* [Feature Controls] - Copy Edits (#29651)

## Summary
Copy edits from today's session

* [Feature Controls] - Rename-a-thon (#29709)

* post-merge cleanup

* [Feature Controls] - fixes from recent merge from master (#29826)

## Summary

this pr will contain any required changes to fix CI from the recent merge from master, which includes the new k7 redesign design and dark mode

* Feature Controls: Adding privileges tooltip for Dev Tools (#30008)

* Adding privileges tooltip for Dev Tools

* appeasing the linter

* [Feature Controls] - Fix displayed space base privilege (#30133)

## Summary
This fixes the displayed space base privilege when a global base privilege is influencing the dropdown control:

1) Add global 'read' privilege
2) Configure space privilege -- note default base privilege of 'read'
3) Change space base privilege to 'custom'

Prior to this fix, the dropdown would not honor the change; it would keep 'read' as the selected option.

* Feature Controls: Adding read privileges for advanced settings and index patterns (#30106)

* Adding read privileges for advanced settings and index patterns

* Fixing the tests and the actual code itself

* Feature Controls - spaces not a security mechanism warning (#29853)

* Changing copy for the spaces not a security mechanism warning

* Using Gail's wording

* [Feature Controls] - Fixes from merging from master (8.0) (#30267)

* improve typings

* fix xpack_main type definitions

* test updates

* Fc/functional test move (#29835)

* Moving dashboard feature control tests to the dashboard application

* Moving more tests around

* Fixing some tests, no longer using uiSettings service, doesn't play
nicely with spaces

* Fixing esarchived issue

* Renaming some files

* [Feature Controls] - Readonly view for Advanced Settings using UICapabilities (#30243)

## Summary
This builds on the work done in https://github.com/elastic/kibana/pull/30106 to enable a read-only mode for the Advanced Settings screen:

- Input fields are disabled
- Save options are not displayed
- "Reset to default" options are not displayed

* Feature Controls: No Wildcards (#30169)

* A poorly named abstraction enters the room

* No more wildcards, starting to move some stuff around

* Splitting out the feature privilege builders

* Using actions instead of relying on their implementation

* We don't need the saved object types any longer

* Explicitly specifying some actions that used to rely on wildcards

* Fixing api integration test for privileges

* Test fixture plugin which adds the globaltype now specifies a feature

* Unauthorized to find unknown types now

* Adding tests for features with no privileges

* Update x-pack/test/saved_object_api_integration/security_and_spaces/apis/find.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Adding back accidentally deleted test

* Using the shared XPackMainPlugin definition

* Fixing privileges

* [Feature Controls] - Readonly mode for Canvas using UICapabilities (#29264)

## Summary

Updates Canvas to respect UICapabilities when determining if a user has read or read/write access to the application:

1) Adds a `showWriteControls` UI Capability to the Canvas's `all` privilege.
2) Removes the `setCanUserWrite` Redux action
3) Sets the initial (and only) state for `state.transient.canUserWrite` based on the UI Capability.

Closes https://github.com/elastic/kibana/issues/27695

* [Feature Controls] - Readonly mode for Maps using UICapabilities (#30437)

## Summary

This updates the maps application to support a read-only mode:

1) Removes selection/delete from Maps listing page
2) Removes "save" option

## TODO:
- [x] Functional UI Tests

* Add typings for x-pack/test to support .html imports (#30570)

We're importing `ui/capabilities` from the x-pack/test project, which
implicitly traverses into typings which are potentially importing .html
files, so we have to teach TypeScript about it.

* [Feature Controls] - Readonly mode for Timelion using UICapabilities (#30128)

## Summary

Updates Timelion to respect UICapabilities when determining if a user has read or read/write access to the application.

A previous PR was responsible for hiding the save controls, but this PR adds testing and the appropriate UICapabilities to the registered privilege definition.

* remove stray debug code

* [Feature Controls] - Updates from src/ui move to src/legacy/ui (#30678)

* dummy commit

* fix import path

* update message identifier

* fix snapshot

* remove unused translations

* Feature Controls: Adding read/write privileges for all applications (#30732)

* Adding read/write privileges for all applications

* Using default for advanced settings, canvas, maps and timelion

* Update x-pack/test/ui_capabilities/security_only/tests/canvas.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_only/tests/canvas.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_only/tests/maps.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_only/tests/maps.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_only/tests/timelion.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* [Feature Controls] - Readonly mode for Visualize using UICapabilities (#29714)

* enable read-only view, and enable app redirection for visualize app

* Hide 'Edit Visualization' dashboard context menu item if visualizations are not editable

* Hide 'Add new visualization' button if action is not available

* show 'Visualize' button on discover view only if viz app is available

* update tests

* allow visualizations to be created, but not saved for read-only users

* adds functional tests for visualize

* add tests for showing/hiding the visualize button in the discover app

* fix visualize tests following merge from master

* tests for edit viz feature from dashboards

* cleanup

* remove unnecessary call to set ui settings

* remove unused variables

* reduce flakyness of tsvb tests

* renames visualize.showWriteControls => visualize.save

* fix ui capability tests

* fix tests

* fix references to timePicker page object

* fix ts errors

* adds 'editable' property to embeddable metadata instead of hardcoded capability checks

* Remove unnecessary read-only considerations

* revert unnecessary mock changes

* [Feature Controls] - Adds missing uptime icon (#30716)

## Summary
Adds missing feature icon for Uptime application.

Needs https://github.com/elastic/kibana/pull/30678 to merge before this will go green.

* Feature Controls - Fix branch (#31135)

* Updating snapshot

* Switching visualize to use the default branch of the switch

* Fixing esarchive

* Feature Controls - Graph (#30762)

* Adding graph functional tests

* Fixing Privilieges API test

* Adding graph ui capability tests

* Update x-pack/test/ui_capabilities/security_only/tests/graph.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_only/tests/graph.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_and_spaces/tests/graph.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/security_only/tests/graph.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Update x-pack/test/ui_capabilities/spaces_only/tests/graph.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Apply suggestions from code review

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Removing hard-coded constants

* Adding Graph delete button

* Fixing ui capability tests

* [Feature Controls] - Fixes page width for spaces management screen (#30723)

## Summary

Fixes the skinny spaces management screen following the redesign of the overall management area.

Needs https://github.com/elastic/kibana/pull/30678 to merge before this will go green.

* Feature Controls - Dev Tools (#30712)

* Adding functional tests

* Addingn Dev_Tools ui capability tests

* Adding some api tests for console's API

* Apply suggestions from code review

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Moving uiCapability definition

* Giving user_1 dashboard access to space_2

* Using the default in the switch for devtools/visualize

* Using forceLogout, maps are leaving us on a 404 page

* Fixing privileges API tests

* Feature Controls- Fix Merge Conflicts (#31651)

* Removing duplicated and outdated tests

* Updating snapshot

* Fixing type script errors

* Getting rid of some double quotes

* Adding saved_object:url access to discover temporarily to fix tests

* Fixing dashboard tests, updating snapshots

* Fixing security only find tests

* Removing reduntant test

* Trying to give it more time

* Fixing it 20 seconds to redirect away from the create new dashboard

* Feature Controls - No more route defaults for dashboards (#31767)

* No more route defaults for dashboards

* Verbose logging...

* Changing some ciGroups to try to narrow down the problem

* Revert "Verbose logging..."

This reverts commit 3198e73b61.

* Revert "No more route defaults for dashboards"

This reverts commit 525cd94dc5.

* Chaning the method in which we do the redirect

* Fixing type issue

* Update index.ts

* Update index.ts

* Feature Controls - Only allowing features to register all and read privileges (#31526)

* Only allowing features to register all and read privileges

* Making all and read optional properties required some existence checks

* Using Aleh's superior solution!

* No more unnecessary `as any`

* Feature Controls - Saved Object Management (#31332)

* Adding savedObject uiCapabilities that mirror the savedobject actions

* Using uiCapabilities to limit which types to search for

* Restricting which saved objects can be deleted based on type

* Hiding "view in app" button when we aren't allowed to

* Filtering the saved objects relationships based on the valid saved
object types

* Using dedicated savedObjectsManagement ui capabilities

* Adding readonly mode of viewing an object

* Displaying View In App if you can actually do so

* No more operations

* Moving saved objects ui capability population to kibana plugin

* Updating x-pack jest tests

* Adding security only saved objects management ui capability tests

* Adding security and spaces tests

* Adding spaces only saved objects managment ui capability tests

* Adding saved object management listing page functional tests

* Adding functional tests for edit visualization

* Consolidating canViewInApp and getInAppUrl into the same file

* Fixing imports

* One more stray import/export

* Adding back esFrom source

* Revert "Adding back esFrom source"

This reverts commit dfb626ace3.

* Updating jest snapshots

* Updating privileges

* Adding some logging

* Back to 10 seconds

* Trying to get more logs...

* Back to normal logging levels

* Fixing ui capability tests

* Putting timeouts back.

* Feature Controls - UI capability API integration tests with fixture plugins (#32086)

* Only testing the foo plugin for security and spaces

* Using the foo plugin with the security_only tests

* Changing spaces only tests to use the foo plugin

* Using list of features from api, and fixing bug with the spaces
interceptor

* Adding catalogue tests, which are alluding to another bug

* saved_objects catalogue aren't driven by ui capabilites presently

* Expanding the coverage for the spaces only catalogue tests

* Fixing some catalogue asserts

* Fixing catalogue tests for spaces_only, I had it backwards

* Adjusting Readme, adding "global read" scenario for security only tests

* Responding to PR feedback

* Adding back saved objects tests I accidentally deleted

* Fixing typescript issues, we can't import EUI on the server

* Fixing eslint error

* Updating Jest snapshots, fixing chrome mock

* Fixing dashboard listing test

* Adding missing await and forcing logout for graph functional tests

* Putting i18n string back

* Fixing type script issue

* Fixing canvas assert because of merge

* Fixing saved object api error assertations

* user-action is now a saved object type

* Fixing typescript error

* Fixing saved object actions as a result of the merge

* Feature Controls - Infrastructure and Logging (#31843)

* hide infra/logs apps if disabled via UICapabilities

* adds tests

* adds UICapability tests for infra and log apps

* update expected privilege/action mapping

* adds feature controls security tests for infraHome

* adds infra spaces feature control tests

* remove debug code

* a sample readonly implementation, ignoring 'logs' privileges

* ts fixes

* fix capability expectations

* Removing RequiresUICapability component, since there are no usages

* Driving the source configuration seperately for logs/infrastructure

* Adding infrastructure feature controls security functional tests

* Adding spaces infrastructure tests

* Adding logs functional tests

* Reworking the ui capability tests to be more consistent

* Fixing privileges API

* Forcing logout

* Fixing comma issue introduced by merge

* Fix merge conflicts and loading/unloading esarchives more consistently

* Removing unnecessary !!

* Fixing saved object management tests

* Fixing more tests

* Using the new context APIs

* Revert "Using the new context APIs"

This reverts commit 4776f1fc86.

* Adding future version of ui capabilities react provider

* Switching the order of the HOC's for infra and making the future the
default

* Applying Felix's PR feedback

* Protecting Infra's GraphQL APIs

* Updating privileges list

* Using the introspection query

* No longer using apollo context library, rephrasing test descriptions

* Fixing issue introduced by merge conflict, I forgot a }

* Putting back missplaced data test subj

* Updating jest snapshots

* Feature Controls - Short URLs (#32418)

* Discover is showing creating short urls properly

* Adding Discover functional tests

* When dashboards show the share menu you can always create short urls

* Visualize now displays the short urls link appropriately

* Dashboard all gets access to saved objects and updating privileges api
test

* Updating and adding short url test to url panel content

* Fixing misspelling

* Updating jest snapshot

* Adding comment why allowShortUrl is always true for Dashboards

* Updating snapshots

* Fixing snapshots, mocking chrome.getInjected

* Feature Controls - Uptime (#32577)

* Adding uptime functional tests

* Enabling feature controls for uptime

* Updating the privileges API's actions

* Using a single access tag for limiting API access

* Revising the behavior of maps read-only mode (#33338)

* Feature Controls - APIs (#32915)

* Using HapiJS's scopes to perform authorization on api endpoints

* Revert "Using HapiJS's scopes to perform authorization on api endpoints"

This reverts commit f73810c22d.

* Switching the syntax of the api tags

* Fixing privileges API

* Typescriptifying some dependencies of the api authorization extensions

* Using dedicated typescript file for api post auth filtering

* Adding tests and restructuring the flow of the api authorization

* Adjusting uptime's usage of privileges and the privileges test

* Integrating PR feedback

* Fixing graph test subject, thanks Joe!

* Consolidating hideWriteControls dashboard listing test

* Reusing maps constants

* Adding type to saved object management ui capability tests

* Feature Controls - Index Pattern Management (#33314)

* Enabling feature controls for index patterns

* Updating privileges API tests

* Fixing saved object management's view index patterns in app logic

* Fixing forgotten canViewInApp tests

* Fixing maps spaces functional tests

* Feature Controls - Differentiating the privileges with the same actions (#32266)

* Differentiating the privileges with the same actions

* The types for the lodash.uniqwith packare aren't right, and we need to
customize the isEqual also, so we're gonna do it ourselves

* Fixing dev tools ui capability

* Removing are equivalent privileges prevention, it's not what we really
need

* Requiring all to be more permissive than read on startup

* Transparently differentiating "all" from "read" feature privileges

* Fixing jest tests

* Adding the allHack: action to the space and global base privileges

* Changing actions to be readonly

* Adding JSDoc's for the Actions class and specifically the `allHack`
action

* Making the import of xpack_main types consistent

* Feature Controls: APM (#32812)

* Adding APM read privilege and adding functional UI tests

* Beginning to validate the APM routes are protected properly

* Protecting APM's APIs

* Specifying CI group

* Fixing privileges

* Adding forgotten apm show ui capability

* Fixing apm's privileges

* Fixing merge-conflict with privileges allHack: and APM

* address canvas feedback (#34269)

* [Feature Controls] - Plugin postInit (#29172)

## Summary

Throwing this up as a straw ~man~ person. If we like it, I can split it out and point the OSS changes against master if we'd prefer.

Introduces a `postInit` plugin hook that is called after all plugins have gone through their `preInit` and `init` phases, which allows the security plugin to call `registerPrivilegesWithCluster` after all plugins have had an opportunity to register their features.

* Feature Controls - Adds bulk toggle for showing/hiding features within a space (#34288)

## Summary

Adds a "Change all" option to the spaces management screen to allow all features to be shown/hidden:

![image](https://user-images.githubusercontent.com/3493255/55344105-85db5d00-547a-11e9-9325-136d1c13f40e.png)


Closes #34184

* Feature Controls - Unregistered Applications Authorization (#34122)

* Converting the app authorization to use typescript

* Adding jest tests

* Only authorizing app routes that are registered for features

* Using ProtectedApplications to lazily get feature applications

* Removing unneeded mocked headers as part of the authorization

* Adding some logging for the app authorization

* Fixing imports, thanks tslint --fix!

* Updating snapshots

* Feature Controls - Disable privilege form until spaces are selected (#34386)

## Summary
This disables the privilege selection until one or more spaces are selected in the role management form:

![image](https://user-images.githubusercontent.com/3493255/55432524-1724ff00-5561-11e9-86f6-1589ba3fa701.png)

* Feature Controls - Visualize read-only create new (#34209)

* Allowing users to create new visualizations, even if they can't be saved

* Fixing privileges and tests

* Updating snapshot

* Removing visualize edit ui capability

* Feature Controls - Actions Version Prefix (#34405)

* Prefixing actions with version

* Updating privileges api integration test

* Update x-pack/plugins/security/server/lib/authorization/actions/saved_object.ts

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Requiring version to be a not empty string

* Updating jest snapshots

* Changing the 403 messages for the saved object client

* Fixing ui/chrome mock

* Feature Controls - Displaying share menu on dashboards when in read-only mode (#34207)

* Displaying share menu on dashboards when in read-only mode

* Fixing test description, thanks Luke!

* Fixing dashboard view mode tests because the share menu is now visible

* migrate from tslint to eslint

* Feature Controls - Reserved Role Apps (#30525)

* Removing feature privileges from ml/monitoring/apm

* Adding monitoring/ml/apm as hard-coded global privileges

* A poorly named abstraction enters the room

* No more wildcards, starting to move some stuff around

* Splitting out the feature privilege builders

* Using actions instead of relying on their implementation

* We don't need the saved object types any longer

* Explicitly specifying some actions that used to rely on wildcards

* Fixing api integration test for privileges

* Test fixture plugin which adds the globaltype now specifies a feature

* Unauthorized to find unknown types now

* Adding reserved privileges tests

* Adding reserved privileges in a designated reserved bucket

* Fixing ui capability tests

* Adding spaces api tests for apm/ml/monitoring users

* Adding more roles to the security only ui capability tests

* You can put a role with reserved privileges using the API

* Adding support to get roles with _reserved privileges

* Adding APM functional tests

* Adding monitoring functional tests

* Fixing typo

* Ensuring apm_user, monitoring_user alone don't authorize you

* Adding ml functional tests

* Fixing test

* Fixing some type errors

* Updating snapshots

* Fixing privileges tests

* Trying to force this to run from source

* Fixing TS errors

* Being a less noisy neighbor

* Forcing logout for apm/dashboard feature controls security tests

* Fixing the security only ui capability tests

* Removing test that monitoring now tests itself

* Fixing some ui capability tests

* Cleaning up the error page services

* Fixing misspelling in comment

* Using forceLogout for monitoring

* Removing code that never should have been there, sorry Larry

* Less leniency with the get roles

* Barely alphabetical for a bit

* Apply suggestions from code review

Co-Authored-By: kobelb <brandon.kobel@gmail.com>

* Removing errant timeout

* No more hard coded esFrom source

* More nits

* Adding back esFrom source

* APM no longer uses reserved privileges, reserved privileges are
pluggable

* Fixing typescript errors

* Fixing ui capability test themselves

* Displaying reserved privileges for the space aware and simple forms

* Removing ability to PUT roles with _reserved privileges.
Removing ability to GET roles that have entries with both reserved and
feature/base privileges.

* Updating jest snapshots

* Changing the interface for a feature to register a reserved privilege to
include a description as well

* Displaying features with reserved privileges in the feature table

* Adjusting the reserved role privileges unit tests

* Changing usages of expect.js to @kbn/expect

* Changing the CalculatedPrivilege's _reserved property to reserved

* Allowing reserved privileges to be assigned at kibana-*

* Updating forgotten snapshot

* Validating reserved privileges

* Updating imports

* Removing --esFrom flag, we don't need it anymore

* Switching from tslint's ignore to eslint's ignore

* Feature Controls - Adds feature registration to plugin generator (#34537)

## Summary

This updates the plugin generator to allow plugin authors to automatically register their feature with the Feature Registry, for control via Spaces/Security.

Running:
```
elastic-mbp:kibana larry$ node scripts/generate_plugin.js test-plugin
? Provide a short description An awesome Kibana plugin
? What Kibana version are you targeting? master
? Should an app component be generated? Yes
? Should translation files be generated? Yes
? Should a hack component be generated? Yes
? Should a server API be generated? Yes
? Should SCSS be used? Yes
```

Generates the following:
```js
import { resolve } from 'path';
import { existsSync } from 'fs';


import { i18n } from '@kbn/i18n';

import exampleRoute from './server/routes/example';

export default function (kibana) {
  return new kibana.Plugin({
    require: ['elasticsearch'],
    name: 'test_plugin',
    uiExports: {
      app: {
        title: 'Test Plugin',
        description: 'An awesome Kibana plugin',
        main: 'plugins/test_plugin/app',
      },
      hacks: [
        'plugins/test_plugin/hack'
      ],
      styleSheetPaths: [resolve(__dirname, 'public/app.scss'), resolve(__dirname, 'public/app.css')].find(p => existsSync(p)),
    },

    config(Joi) {
      return Joi.object({
        enabled: Joi.boolean().default(true),
      }).default();
    },

    init(server, options) { // eslint-disable-line no-unused-vars
        const xpackMainPlugin = server.plugins.xpack_main;
        if (xpackMainPlugin) {
          const featureId = 'test_plugin';

          xpackMainPlugin.registerFeature({
            id: featureId,
            name: i18n.translate('testPlugin.featureRegistry.featureName', {
              defaultMessage: 'test-plugin',
            }),
            navLinkId: featureId,
            icon: 'discoverApp',
            app: [featureId, 'kibana'],
            catalogue: [],
            privileges: {
              all: {
                api: [],
                savedObject: {
                  all: [],
                  read: ['config'],
                },
                ui: ['show'],
              },
              read: {
                api: [],
                savedObject: {
                  all: [],
                  read: ['config'],
                },
                ui: ['show'],
              },
            },
          });
        }
      // Add server routes and initialize the plugin here
      exampleRoute(server);
    }
  });
}

```

* Updating core system docs

* Fixing infra's dates with data for the functional tests

* [Feature Controls] - Move UICapabilities to the new platform (#30585)

## Summary

This moves the UI Capabilities service into the new platform, shimming into the old platform in a way that is consistent with the `i18n` service.

* Fixing uptime functional api tests

* Removing .only...
2019-04-12 09:16:13 -07:00