mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* 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:  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:  * 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)    --------- 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 commit3198e73b61
. * Revert "No more route defaults for dashboards" This reverts commit525cd94dc5
. * 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 commitdfb626ace3
. * 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 commit4776f1fc86
. * 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 commitf73810c22d
. * 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:  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:  * 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...
This commit is contained in:
parent
4907541c3b
commit
438bfa49ae
735 changed files with 44824 additions and 9736 deletions
|
@ -0,0 +1,11 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [Capabilities](./kibana-plugin-public.capabilities.md) > [catalogue](./kibana-plugin-public.capabilities.catalogue.md)
|
||||
|
||||
## Capabilities.catalogue property
|
||||
|
||||
Catalogue capabilities. Catalogue entries drive the visibility of the Kibana homepage options.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
catalogue: Record<string, boolean>;
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [Capabilities](./kibana-plugin-public.capabilities.md) > [management](./kibana-plugin-public.capabilities.management.md)
|
||||
|
||||
## Capabilities.management property
|
||||
|
||||
Management section capabilities.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
management: {
|
||||
[sectionId: string]: Record<string, boolean>;
|
||||
};
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [Capabilities](./kibana-plugin-public.capabilities.md)
|
||||
|
||||
## Capabilities interface
|
||||
|
||||
The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface Capabilities
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [catalogue](./kibana-plugin-public.capabilities.catalogue.md) | <code>Record<string, boolean></code> | Catalogue capabilities. Catalogue entries drive the visibility of the Kibana homepage options. |
|
||||
| [management](./kibana-plugin-public.capabilities.management.md) | <code>{`<p/>` [sectionId: string]: Record<string, boolean>;`<p/>` }</code> | Management section capabilities. |
|
||||
| [navLinks](./kibana-plugin-public.capabilities.navlinks.md) | <code>Record<string, boolean></code> | Navigation link capabilities. |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [Capabilities](./kibana-plugin-public.capabilities.md) > [navLinks](./kibana-plugin-public.capabilities.navlinks.md)
|
||||
|
||||
## Capabilities.navLinks property
|
||||
|
||||
Navigation link capabilities.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
navLinks: Record<string, boolean>;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [CapabilitiesSetup](./kibana-plugin-public.capabilitiessetup.md) > [getCapabilities](./kibana-plugin-public.capabilitiessetup.getcapabilities.md)
|
||||
|
||||
## CapabilitiesSetup.getCapabilities property
|
||||
|
||||
Gets the read-only capabilities.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getCapabilities: () => Capabilities;
|
||||
```
|
|
@ -0,0 +1,18 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [CapabilitiesSetup](./kibana-plugin-public.capabilitiessetup.md)
|
||||
|
||||
## CapabilitiesSetup interface
|
||||
|
||||
Capabilities Setup.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface CapabilitiesSetup
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [getCapabilities](./kibana-plugin-public.capabilitiessetup.getcapabilities.md) | <code>() => Capabilities</code> | Gets the read-only capabilities. |
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[Home](./index) > [kibana-plugin-public](./kibana-plugin-public.md) > [CoreSetup](./kibana-plugin-public.coresetup.md) > [capabilities](./kibana-plugin-public.coresetup.capabilities.md)
|
||||
|
||||
## CoreSetup.capabilities property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
capabilities: CapabilitiesSetup;
|
||||
```
|
|
@ -15,6 +15,7 @@ export interface CoreSetup
|
|||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [basePath](./kibana-plugin-public.coresetup.basepath.md) | <code>BasePathSetup</code> | |
|
||||
| [capabilities](./kibana-plugin-public.coresetup.capabilities.md) | <code>CapabilitiesSetup</code> | |
|
||||
| [chrome](./kibana-plugin-public.coresetup.chrome.md) | <code>ChromeSetup</code> | |
|
||||
| [fatalErrors](./kibana-plugin-public.coresetup.fatalerrors.md) | <code>FatalErrorsSetup</code> | |
|
||||
| [http](./kibana-plugin-public.coresetup.http.md) | <code>HttpSetup</code> | |
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
| Interface | Description |
|
||||
| --- | --- |
|
||||
| [Capabilities](./kibana-plugin-public.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
|
||||
| [CapabilitiesSetup](./kibana-plugin-public.capabilitiessetup.md) | Capabilities Setup. |
|
||||
| [ChromeBrand](./kibana-plugin-public.chromebrand.md) | |
|
||||
| [ChromeBreadcrumb](./kibana-plugin-public.chromebreadcrumb.md) | |
|
||||
| [CoreSetup](./kibana-plugin-public.coresetup.md) | Core services exposed to the start lifecycle |
|
||||
|
|
|
@ -32,9 +32,9 @@ Authorization: Basic kibana changeme
|
|||
"actions":[
|
||||
"version:7.0.0-alpha1-SNAPSHOT",
|
||||
"action:login",
|
||||
"action:saved_objects/dashboard/get",
|
||||
"action:saved_objects/dashboard/bulk_get",
|
||||
"action:saved_objects/dashboard/find",
|
||||
"saved_object:dashboard/get",
|
||||
"saved_object:dashboard/bulk_get",
|
||||
"saved_object:dashboard/find",
|
||||
...
|
||||
],"metadata":{}}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ Authorization: Basic foo_read_only_user password
|
|||
"application":"kibana-.kibana",
|
||||
"resources":["*"],
|
||||
"privileges":[
|
||||
"action:saved_objects/dashboard/save",
|
||||
"saved_object:dashboard/save",
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -120,7 +120,7 @@ Authorization: Basic foo_legacy_user password
|
|||
"application":"kibana-.kibana",
|
||||
"resources":["*"],
|
||||
"privileges":[
|
||||
"action:saved_objects/dashboard/save"
|
||||
"saved_object:dashboard/save"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -152,7 +152,7 @@ Here is an example response if the user does not have application privileges, bu
|
|||
"application": {
|
||||
"kibana-.kibana": {
|
||||
"*": {
|
||||
"action:saved_objects/dashboard/save": false
|
||||
"saved_object:dashboard/save": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ describe('plugin generator sao integration', () => {
|
|||
expect(uiExports).not.toContain('app:');
|
||||
expect(uiExports).not.toContain('hacks:');
|
||||
expect(uiExports).not.toContain('init(server, options)');
|
||||
expect(uiExports).not.toContain('registerFeature(');
|
||||
});
|
||||
|
||||
it('includes app when answering yes', async () => {
|
||||
|
@ -73,8 +74,9 @@ describe('plugin generator sao integration', () => {
|
|||
|
||||
const uiExports = getConfig(res.files['index.js']);
|
||||
expect(uiExports).toContain('app:');
|
||||
expect(uiExports).toContain('init(server, options)');
|
||||
expect(uiExports).toContain('registerFeature(');
|
||||
expect(uiExports).not.toContain('hacks:');
|
||||
expect(uiExports).not.toContain('init(server, options)');
|
||||
});
|
||||
|
||||
it('includes hack when answering yes', async () => {
|
||||
|
@ -94,7 +96,8 @@ describe('plugin generator sao integration', () => {
|
|||
const uiExports = getConfig(res.files['index.js']);
|
||||
expect(uiExports).toContain('app:');
|
||||
expect(uiExports).toContain('hacks:');
|
||||
expect(uiExports).not.toContain('init(server, options)');
|
||||
expect(uiExports).toContain('init(server, options)');
|
||||
expect(uiExports).toContain('registerFeature(');
|
||||
});
|
||||
|
||||
it('includes server api when answering yes', async () => {
|
||||
|
@ -115,6 +118,7 @@ describe('plugin generator sao integration', () => {
|
|||
expect(uiExports).toContain('app:');
|
||||
expect(uiExports).toContain('hacks:');
|
||||
expect(uiExports).toContain('init(server, options)');
|
||||
expect(uiExports).toContain('registerFeature(');
|
||||
});
|
||||
|
||||
it('plugin config has correct name and main path', async () => {
|
||||
|
|
|
@ -3,6 +3,11 @@ import { resolve } from 'path';
|
|||
import { existsSync } from 'fs';
|
||||
|
||||
<% } -%>
|
||||
|
||||
<% if (generateApp) { -%>
|
||||
import { i18n } from '@kbn/i18n';
|
||||
<% } -%>
|
||||
|
||||
<% if (generateApi) { -%>
|
||||
import exampleRoute from './server/routes/example';
|
||||
|
||||
|
@ -34,11 +39,49 @@ export default function (kibana) {
|
|||
enabled: Joi.boolean().default(true),
|
||||
}).default();
|
||||
},
|
||||
<%_ if (generateApi) { -%>
|
||||
<%_ if (generateApi || generateApp) { -%>
|
||||
|
||||
init(server, options) { // eslint-disable-line no-unused-vars
|
||||
<%_ if (generateApp) { -%>
|
||||
const xpackMainPlugin = server.plugins.xpack_main;
|
||||
if (xpackMainPlugin) {
|
||||
const featureId = '<%= snakeCase(name) %>';
|
||||
|
||||
xpackMainPlugin.registerFeature({
|
||||
id: featureId,
|
||||
name: i18n.translate('<%= camelCase(name) %>.featureRegistry.featureName', {
|
||||
defaultMessage: '<%= name %>',
|
||||
}),
|
||||
navLinkId: featureId,
|
||||
icon: 'questionInCircle',
|
||||
app: [featureId, 'kibana'],
|
||||
catalogue: [],
|
||||
privileges: {
|
||||
all: {
|
||||
api: [],
|
||||
savedObject: {
|
||||
all: [],
|
||||
read: ['config'],
|
||||
},
|
||||
ui: ['show'],
|
||||
},
|
||||
read: {
|
||||
api: [],
|
||||
savedObject: {
|
||||
all: [],
|
||||
read: ['config'],
|
||||
},
|
||||
ui: ['show'],
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
<%_ } -%>
|
||||
|
||||
<%_ if (generateApi) { -%>
|
||||
// Add server routes and initialize the plugin here
|
||||
exampleRoute(server);
|
||||
<%_ } -%>
|
||||
}
|
||||
<%_ } -%>
|
||||
});
|
||||
|
|
|
@ -47,6 +47,7 @@ export function KuiListingTable({
|
|||
toolBarActions,
|
||||
onFilter,
|
||||
onItemSelectionChanged,
|
||||
enableSelection,
|
||||
selectedRowIds,
|
||||
filter,
|
||||
prompt,
|
||||
|
@ -76,11 +77,12 @@ export function KuiListingTable({
|
|||
}
|
||||
}
|
||||
|
||||
function renderTableRows() {
|
||||
function renderTableRows(enableSelection) {
|
||||
return rows.map((row, rowIndex) => {
|
||||
return (
|
||||
<KuiListingTableRow
|
||||
key={rowIndex}
|
||||
enableSelection={enableSelection}
|
||||
isSelected={selectedRowIds.indexOf(row.id) >= 0}
|
||||
onSelectionChanged={toggleRow}
|
||||
row={row}
|
||||
|
@ -111,15 +113,17 @@ export function KuiListingTable({
|
|||
return (
|
||||
<KuiTable>
|
||||
<KuiTableHeader>
|
||||
<KuiTableHeaderCheckBoxCell
|
||||
isChecked={areAllRowsSelected()}
|
||||
onChange={toggleAll}
|
||||
/>
|
||||
{enableSelection &&
|
||||
<KuiTableHeaderCheckBoxCell
|
||||
isChecked={areAllRowsSelected()}
|
||||
onChange={toggleAll}
|
||||
/>
|
||||
}
|
||||
{renderHeader()}
|
||||
</KuiTableHeader>
|
||||
|
||||
<KuiTableBody>
|
||||
{renderTableRows()}
|
||||
{renderTableRows(enableSelection)}
|
||||
</KuiTableBody>
|
||||
</KuiTable>
|
||||
);
|
||||
|
@ -171,6 +175,7 @@ KuiListingTable.propTypes = {
|
|||
})),
|
||||
pager: PropTypes.node,
|
||||
onItemSelectionChanged: PropTypes.func.isRequired,
|
||||
enableSelection: PropTypes.bool,
|
||||
selectedRowIds: PropTypes.array,
|
||||
prompt: PropTypes.node, // If given, will be shown instead of a table with rows.
|
||||
onFilter: PropTypes.func,
|
||||
|
@ -181,4 +186,5 @@ KuiListingTable.propTypes = {
|
|||
KuiListingTable.defaultProps = {
|
||||
rows: [],
|
||||
selectedRowIds: [],
|
||||
enableSelection: true,
|
||||
};
|
||||
|
|
|
@ -57,13 +57,15 @@ export class KuiListingTableRow extends React.PureComponent {
|
|||
}
|
||||
|
||||
render() {
|
||||
const { isSelected } = this.props;
|
||||
const { enableSelection, isSelected } = this.props;
|
||||
return (
|
||||
<KuiTableRow>
|
||||
<KuiTableRowCheckBoxCell
|
||||
isChecked={isSelected}
|
||||
onChange={this.onSelectionChanged}
|
||||
/>
|
||||
{enableSelection &&
|
||||
<KuiTableRowCheckBoxCell
|
||||
isChecked={isSelected}
|
||||
onChange={this.onSelectionChanged}
|
||||
/>
|
||||
}
|
||||
{this.renderCells()}
|
||||
</KuiTableRow>
|
||||
);
|
||||
|
@ -83,6 +85,11 @@ KuiListingTableRow.propTypes = {
|
|||
],
|
||||
)),
|
||||
}).isRequired,
|
||||
enableSelection: PropTypes.bool,
|
||||
onSelectionChanged: PropTypes.func.isRequired,
|
||||
isSelected: PropTypes.bool,
|
||||
};
|
||||
|
||||
KuiListingTableRow.defaultProps = {
|
||||
enableSelection: true,
|
||||
};
|
||||
|
|
45
src/core/public/capabilities/capabilities_service.mock.ts
Normal file
45
src/core/public/capabilities/capabilities_service.mock.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { Capabilities, CapabilitiesService, CapabilitiesSetup } from './capabilities_service';
|
||||
|
||||
const createSetupContractMock = () => {
|
||||
const setupContract: jest.Mocked<CapabilitiesSetup> = {
|
||||
getCapabilities: jest.fn(),
|
||||
};
|
||||
setupContract.getCapabilities.mockReturnValue({
|
||||
catalogue: {},
|
||||
management: {},
|
||||
navLinks: {},
|
||||
} as Capabilities);
|
||||
return setupContract;
|
||||
};
|
||||
|
||||
type CapabilitiesServiceContract = PublicMethodsOf<CapabilitiesService>;
|
||||
const createMock = () => {
|
||||
const mocked: jest.Mocked<CapabilitiesServiceContract> = {
|
||||
setup: jest.fn(),
|
||||
};
|
||||
mocked.setup.mockReturnValue(createSetupContractMock());
|
||||
return mocked;
|
||||
};
|
||||
|
||||
export const capabilitiesServiceMock = {
|
||||
create: createMock,
|
||||
createSetupContract: createSetupContractMock,
|
||||
};
|
60
src/core/public/capabilities/capabilities_service.test.ts
Normal file
60
src/core/public/capabilities/capabilities_service.test.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { InjectedMetadataService } from '../injected_metadata';
|
||||
import { CapabilitiesService } from './capabilities_service';
|
||||
|
||||
describe('#start', () => {
|
||||
it('returns a service with getCapabilities', () => {
|
||||
const injectedMetadata = new InjectedMetadataService({
|
||||
injectedMetadata: {
|
||||
vars: {
|
||||
uiCapabilities: {
|
||||
foo: 'bar',
|
||||
bar: 'baz',
|
||||
},
|
||||
},
|
||||
} as any,
|
||||
});
|
||||
const service = new CapabilitiesService();
|
||||
const startContract = service.setup({ injectedMetadata: injectedMetadata.setup() });
|
||||
expect(startContract.getCapabilities()).toEqual({
|
||||
foo: 'bar',
|
||||
bar: 'baz',
|
||||
});
|
||||
});
|
||||
|
||||
it(`does not allow Capabilities to be modified`, () => {
|
||||
const injectedMetadata = new InjectedMetadataService({
|
||||
injectedMetadata: {
|
||||
vars: {
|
||||
uiCapabilities: {
|
||||
foo: 'bar',
|
||||
bar: 'baz',
|
||||
},
|
||||
},
|
||||
} as any,
|
||||
});
|
||||
const service = new CapabilitiesService();
|
||||
const startContract = service.setup({ injectedMetadata: injectedMetadata.setup() });
|
||||
const capabilities = startContract.getCapabilities();
|
||||
|
||||
// @ts-ignore TypeScript knows this shouldn't be possible
|
||||
expect(() => (capabilities.foo = 'foo')).toThrowError();
|
||||
});
|
||||
});
|
72
src/core/public/capabilities/capabilities_service.tsx
Normal file
72
src/core/public/capabilities/capabilities_service.tsx
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { InjectedMetadataSetup } from '../injected_metadata';
|
||||
import { deepFreeze } from '../utils/deep_freeze';
|
||||
|
||||
interface StartDeps {
|
||||
injectedMetadata: InjectedMetadataSetup;
|
||||
}
|
||||
|
||||
/**
|
||||
* The read-only set of capabilities available for the current UI session.
|
||||
* Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID,
|
||||
* and the boolean is a flag indicating if the capability is enabled or disabled.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface Capabilities {
|
||||
/** Navigation link capabilities. */
|
||||
navLinks: Record<string, boolean>;
|
||||
|
||||
/** Management section capabilities. */
|
||||
management: {
|
||||
[sectionId: string]: Record<string, boolean>;
|
||||
};
|
||||
|
||||
/** Catalogue capabilities. Catalogue entries drive the visibility of the Kibana homepage options. */
|
||||
catalogue: Record<string, boolean>;
|
||||
|
||||
/** Custom capabilities, registered by plugins. */
|
||||
[key: string]: Record<string, boolean | Record<string, boolean>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Capabilities Setup.
|
||||
* @public
|
||||
*/
|
||||
export interface CapabilitiesSetup {
|
||||
/**
|
||||
* Gets the read-only capabilities.
|
||||
*/
|
||||
getCapabilities: () => Capabilities;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
/**
|
||||
* Service that is responsible for UI Capabilities.
|
||||
*/
|
||||
export class CapabilitiesService {
|
||||
public setup({ injectedMetadata }: StartDeps): CapabilitiesSetup {
|
||||
return {
|
||||
getCapabilities: () =>
|
||||
deepFreeze<Capabilities>(injectedMetadata.getInjectedVar('uiCapabilities') as Capabilities),
|
||||
};
|
||||
}
|
||||
}
|
20
src/core/public/capabilities/index.ts
Normal file
20
src/core/public/capabilities/index.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { Capabilities, CapabilitiesService, CapabilitiesSetup } from './capabilities_service';
|
|
@ -23,6 +23,7 @@ import { Subject } from 'rxjs';
|
|||
|
||||
import { CoreSetup } from '.';
|
||||
import { BasePathService } from './base_path';
|
||||
import { CapabilitiesService } from './capabilities';
|
||||
import { ChromeService } from './chrome';
|
||||
import { FatalErrorsService } from './fatal_errors';
|
||||
import { HttpService } from './http';
|
||||
|
@ -64,6 +65,7 @@ export class CoreSystem {
|
|||
private readonly basePath: BasePathService;
|
||||
private readonly chrome: ChromeService;
|
||||
private readonly i18n: I18nService;
|
||||
private readonly capabilities: CapabilitiesService;
|
||||
private readonly overlay: OverlayService;
|
||||
private readonly plugins: PluginsService;
|
||||
|
||||
|
@ -85,6 +87,8 @@ export class CoreSystem {
|
|||
|
||||
this.i18n = new I18nService();
|
||||
|
||||
this.capabilities = new CapabilitiesService();
|
||||
|
||||
this.injectedMetadata = new InjectedMetadataService({
|
||||
injectedMetadata,
|
||||
});
|
||||
|
@ -128,6 +132,7 @@ export class CoreSystem {
|
|||
const http = this.http.setup({ fatalErrors });
|
||||
const overlays = this.overlay.setup({ i18n });
|
||||
const basePath = this.basePath.setup({ injectedMetadata });
|
||||
const capabilities = this.capabilities.setup({ injectedMetadata });
|
||||
const uiSettings = this.uiSettings.setup({
|
||||
notifications,
|
||||
http,
|
||||
|
@ -145,6 +150,7 @@ export class CoreSystem {
|
|||
fatalErrors,
|
||||
http,
|
||||
i18n,
|
||||
capabilities,
|
||||
injectedMetadata,
|
||||
notifications,
|
||||
uiSettings,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import { BasePathSetup } from './base_path';
|
||||
import { Capabilities, CapabilitiesSetup } from './capabilities';
|
||||
import { ChromeBrand, ChromeBreadcrumb, ChromeHelpExtension, ChromeSetup } from './chrome';
|
||||
import { FatalErrorsSetup } from './fatal_errors';
|
||||
import { HttpSetup } from './http';
|
||||
|
@ -43,6 +44,7 @@ export interface CoreSetup {
|
|||
notifications: NotificationsSetup;
|
||||
http: HttpSetup;
|
||||
basePath: BasePathSetup;
|
||||
capabilities: CapabilitiesSetup;
|
||||
uiSettings: UiSettingsSetup;
|
||||
chrome: ChromeSetup;
|
||||
overlays: OverlaySetup;
|
||||
|
@ -53,6 +55,8 @@ export {
|
|||
HttpSetup,
|
||||
FatalErrorsSetup,
|
||||
I18nSetup,
|
||||
CapabilitiesSetup,
|
||||
Capabilities,
|
||||
ChromeSetup,
|
||||
ChromeBreadcrumb,
|
||||
ChromeBrand,
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import { get } from 'lodash';
|
||||
import { DiscoveredPlugin, PluginName } from '../../server';
|
||||
import { UiSettingsState } from '../ui_settings';
|
||||
import { deepFreeze } from './deep_freeze';
|
||||
import { deepFreeze } from '../utils/deep_freeze';
|
||||
|
||||
/** @internal */
|
||||
export interface InjectedMetadataParams {
|
||||
|
|
|
@ -16,6 +16,21 @@ import { Toast } from '@elastic/eui';
|
|||
// @public (undocumented)
|
||||
export type BasePathSetup = ReturnType<BasePathService['setup']>;
|
||||
|
||||
// @public
|
||||
export interface Capabilities {
|
||||
[key: string]: Record<string, boolean | Record<string, boolean>>;
|
||||
catalogue: Record<string, boolean>;
|
||||
management: {
|
||||
[sectionId: string]: Record<string, boolean>;
|
||||
};
|
||||
navLinks: Record<string, boolean>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface CapabilitiesSetup {
|
||||
getCapabilities: () => Capabilities;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export interface ChromeBrand {
|
||||
// (undocumented)
|
||||
|
@ -53,6 +68,8 @@ export interface CoreSetup {
|
|||
// (undocumented)
|
||||
basePath: BasePathSetup;
|
||||
// (undocumented)
|
||||
capabilities: CapabilitiesSetup;
|
||||
// (undocumented)
|
||||
chrome: ChromeSetup;
|
||||
// (undocumented)
|
||||
fatalErrors: FatalErrorsSetup;
|
||||
|
|
|
@ -6,6 +6,7 @@ Array [
|
|||
"ui/i18n",
|
||||
"ui/notify/fatal_error",
|
||||
"ui/notify/toasts",
|
||||
"ui/capabilities",
|
||||
"ui/chrome/api/loading_count",
|
||||
"ui/chrome/api/base_path",
|
||||
"ui/chrome/api/ui_settings",
|
||||
|
@ -26,6 +27,7 @@ Array [
|
|||
"ui/i18n",
|
||||
"ui/notify/fatal_error",
|
||||
"ui/notify/toasts",
|
||||
"ui/capabilities",
|
||||
"ui/chrome/api/loading_count",
|
||||
"ui/chrome/api/base_path",
|
||||
"ui/chrome/api/ui_settings",
|
||||
|
|
|
@ -53,6 +53,14 @@ jest.mock('ui/i18n', () => {
|
|||
};
|
||||
});
|
||||
|
||||
const mockUICapabilitiesInit = jest.fn();
|
||||
jest.mock('ui/capabilities', () => {
|
||||
mockLoadOrder.push('ui/capabilities');
|
||||
return {
|
||||
__newPlatformInit__: mockUICapabilitiesInit,
|
||||
};
|
||||
});
|
||||
|
||||
const mockFatalErrorInit = jest.fn();
|
||||
jest.mock('ui/notify/fatal_error', () => {
|
||||
mockLoadOrder.push('ui/notify/fatal_error');
|
||||
|
@ -142,6 +150,7 @@ jest.mock('ui/chrome/services/global_nav_state', () => {
|
|||
});
|
||||
|
||||
import { basePathServiceMock } from '../base_path/base_path_service.mock';
|
||||
import { capabilitiesServiceMock } from '../capabilities/capabilities_service.mock';
|
||||
import { chromeServiceMock } from '../chrome/chrome_service.mock';
|
||||
import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock';
|
||||
import { httpServiceMock } from '../http/http_service.mock';
|
||||
|
@ -159,6 +168,7 @@ const httpSetup = httpServiceMock.createSetupContract();
|
|||
const i18nSetup = i18nServiceMock.createSetupContract();
|
||||
const injectedMetadataSetup = injectedMetadataServiceMock.createSetupContract();
|
||||
const notificationsSetup = notificationServiceMock.createSetupContract();
|
||||
const capabilitiesSetup = capabilitiesServiceMock.createSetupContract();
|
||||
const uiSettingsSetup = uiSettingsServiceMock.createSetupContract();
|
||||
const overlaySetup = overlayServiceMock.createSetupContract();
|
||||
|
||||
|
@ -176,6 +186,7 @@ const defaultSetupDeps = {
|
|||
notifications: notificationsSetup,
|
||||
http: httpSetup,
|
||||
basePath: basePathSetup,
|
||||
capabilities: capabilitiesSetup,
|
||||
uiSettings: uiSettingsSetup,
|
||||
chrome: chromeSetup,
|
||||
overlays: overlaySetup,
|
||||
|
@ -215,6 +226,17 @@ describe('#setup()', () => {
|
|||
expect(mockI18nContextInit).toHaveBeenCalledWith(i18nSetup.Context);
|
||||
});
|
||||
|
||||
it('passes uiCapabilities to ui/capabilities', () => {
|
||||
const legacyPlatform = new LegacyPlatformService({
|
||||
...defaultParams,
|
||||
});
|
||||
|
||||
legacyPlatform.setup(defaultSetupDeps);
|
||||
|
||||
expect(mockUICapabilitiesInit).toHaveBeenCalledTimes(1);
|
||||
expect(mockUICapabilitiesInit).toHaveBeenCalledWith(capabilitiesSetup);
|
||||
});
|
||||
|
||||
it('passes fatalErrors service to ui/notify/fatal_errors', () => {
|
||||
const legacyPlatform = new LegacyPlatformService({
|
||||
...defaultParams,
|
||||
|
|
|
@ -44,6 +44,7 @@ export class LegacyPlatformService {
|
|||
notifications,
|
||||
http,
|
||||
basePath,
|
||||
capabilities,
|
||||
uiSettings,
|
||||
chrome,
|
||||
} = core;
|
||||
|
@ -54,6 +55,7 @@ export class LegacyPlatformService {
|
|||
require('ui/i18n').__newPlatformInit__(i18n.Context);
|
||||
require('ui/notify/fatal_error').__newPlatformInit__(fatalErrors);
|
||||
require('ui/notify/toasts').__newPlatformInit__(notifications.toasts);
|
||||
require('ui/capabilities').__newPlatformInit__(capabilities);
|
||||
require('ui/chrome/api/loading_count').__newPlatformInit__(http);
|
||||
require('ui/chrome/api/base_path').__newPlatformInit__(basePath);
|
||||
require('ui/chrome/api/ui_settings').__newPlatformInit__(uiSettings);
|
||||
|
|
|
@ -150,6 +150,7 @@ export async function createDefaultSpace({ index, client }) {
|
|||
space: {
|
||||
name: 'Default Space',
|
||||
description: 'This is the default space',
|
||||
disabledFeatures: [],
|
||||
_reserved: true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,12 @@ export default function (kibana) {
|
|||
defaultVars = {
|
||||
elasticsearchUrl: url.format(
|
||||
Object.assign(url.parse(head(legacyEsConfig.hosts)), { auth: false })
|
||||
)
|
||||
),
|
||||
uiCapabilities: {
|
||||
dev_tools: {
|
||||
show: true
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
server.route(createProxyRoute({
|
||||
|
|
|
@ -23,6 +23,7 @@ import template from './index.html';
|
|||
require('brace');
|
||||
|
||||
require('ui/autoload/styles');
|
||||
require('ui/capabilities/route_setup');
|
||||
|
||||
require('./src/controllers/sense_controller');
|
||||
require('./src/directives/sense_history');
|
||||
|
@ -33,6 +34,7 @@ require('./src/directives/console_menu_directive');
|
|||
|
||||
|
||||
uiRoutes.when('/dev_tools/console', {
|
||||
requireUICapability: 'dev_tools.show',
|
||||
controller: 'SenseController',
|
||||
template,
|
||||
});
|
||||
|
|
|
@ -65,6 +65,7 @@ export const createProxyRoute = ({
|
|||
path: '/api/console/proxy',
|
||||
method: 'POST',
|
||||
config: {
|
||||
tags: ['access:console'],
|
||||
payload: {
|
||||
output: 'stream',
|
||||
parse: false
|
||||
|
|
|
@ -138,9 +138,61 @@ export default function (kibana) {
|
|||
},
|
||||
|
||||
injectDefaultVars(server, options) {
|
||||
const { savedObjects } = server;
|
||||
|
||||
return {
|
||||
kbnIndex: options.index,
|
||||
kbnBaseUrl
|
||||
kbnBaseUrl,
|
||||
uiCapabilities: {
|
||||
discover: {
|
||||
show: true,
|
||||
createShortUrl: true,
|
||||
save: true,
|
||||
},
|
||||
visualize: {
|
||||
show: true,
|
||||
createShortUrl: true,
|
||||
delete: true,
|
||||
save: true,
|
||||
},
|
||||
dashboard: {
|
||||
createNew: true,
|
||||
show: true,
|
||||
showWriteControls: true,
|
||||
},
|
||||
catalogue: {
|
||||
discover: true,
|
||||
dashboard: true,
|
||||
visualize: true,
|
||||
console: true,
|
||||
advanced_settings: true,
|
||||
index_patterns: true,
|
||||
},
|
||||
advancedSettings: {
|
||||
save: true
|
||||
},
|
||||
indexPatterns: {
|
||||
createNew: true,
|
||||
},
|
||||
savedObjectsManagement: savedObjects.types.reduce((acc, type) => ({
|
||||
...acc,
|
||||
[type]: {
|
||||
delete: true,
|
||||
edit: true,
|
||||
read: true,
|
||||
}
|
||||
}), {}),
|
||||
management: {
|
||||
/*
|
||||
* Management settings correspond to management section/link ids, and should not be changed
|
||||
* without also updating those definitions.
|
||||
*/
|
||||
kibana: {
|
||||
settings: true,
|
||||
index_patterns: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -500,6 +500,7 @@ app.directive('dashboardApp', function ($injector) {
|
|||
showShareContextMenu({
|
||||
anchorElement,
|
||||
allowEmbed: true,
|
||||
allowShortUrl: !dashboardConfig.getHideWriteControls(),
|
||||
getUnhashableStates,
|
||||
objectId: dash.id,
|
||||
objectType: 'dashboard',
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
|
||||
uiModules.get('kibana')
|
||||
.provider('dashboardConfig', () => {
|
||||
let hideWriteControls = false;
|
||||
let hideWriteControls = !uiCapabilities.dashboard.showWriteControls;
|
||||
|
||||
return {
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,7 @@ import { recentlyAccessed } from 'ui/persisted_log';
|
|||
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
|
||||
import { DashboardListing, EMPTY_FILTER } from './listing/dashboard_listing';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import 'ui/capabilities/route_setup';
|
||||
|
||||
const app = uiModules.get('app/dashboard', [
|
||||
'ngRoute',
|
||||
|
@ -55,7 +56,8 @@ function createNewDashboardCtrl($scope, i18n) {
|
|||
|
||||
uiRoutes
|
||||
.defaults(/dashboard/, {
|
||||
requireDefaultIndex: true
|
||||
requireDefaultIndex: true,
|
||||
requireUICapability: 'dashboard.show'
|
||||
})
|
||||
.when(DashboardConstants.LANDING_PAGE_PATH, {
|
||||
template: dashboardListingTemplate,
|
||||
|
@ -117,6 +119,7 @@ uiRoutes
|
|||
.when(DashboardConstants.CREATE_NEW_DASHBOARD_URL, {
|
||||
template: dashboardTemplate,
|
||||
controller: createNewDashboardCtrl,
|
||||
requireUICapability: 'dashboard.createNew',
|
||||
resolve: {
|
||||
dash: function (savedDashboards, redirectWhenMissing) {
|
||||
return savedDashboards.get()
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
exports[`after fetch hideWriteControls 1`] = `
|
||||
<InjectIntl(TableListViewUi)
|
||||
createItem={[Function]}
|
||||
deleteItems={[Function]}
|
||||
editItem={[Function]}
|
||||
createItem={null}
|
||||
deleteItems={null}
|
||||
editItem={null}
|
||||
entityName="dashboard"
|
||||
entityNamePlural="dashboards"
|
||||
findItems={[Function]}
|
||||
hideWriteControls={true}
|
||||
initialFilter=""
|
||||
listingLimit={1}
|
||||
noItemsFragment={
|
||||
|
@ -56,7 +55,6 @@ exports[`after fetch initialFilter 1`] = `
|
|||
entityName="dashboard"
|
||||
entityNamePlural="dashboards"
|
||||
findItems={[Function]}
|
||||
hideWriteControls={false}
|
||||
initialFilter="my dashboard"
|
||||
listingLimit={1000}
|
||||
noItemsFragment={
|
||||
|
@ -154,7 +152,6 @@ exports[`after fetch renders call to action when no dashboards exist 1`] = `
|
|||
entityName="dashboard"
|
||||
entityNamePlural="dashboards"
|
||||
findItems={[Function]}
|
||||
hideWriteControls={false}
|
||||
initialFilter=""
|
||||
listingLimit={1}
|
||||
noItemsFragment={
|
||||
|
@ -252,7 +249,6 @@ exports[`after fetch renders table rows 1`] = `
|
|||
entityName="dashboard"
|
||||
entityNamePlural="dashboards"
|
||||
findItems={[Function]}
|
||||
hideWriteControls={false}
|
||||
initialFilter=""
|
||||
listingLimit={1000}
|
||||
noItemsFragment={
|
||||
|
@ -350,7 +346,6 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = `
|
|||
entityName="dashboard"
|
||||
entityNamePlural="dashboards"
|
||||
findItems={[Function]}
|
||||
hideWriteControls={false}
|
||||
initialFilter=""
|
||||
listingLimit={1}
|
||||
noItemsFragment={
|
||||
|
@ -448,7 +443,6 @@ exports[`renders empty page in before initial fetch to avoid flickering 1`] = `
|
|||
entityName="dashboard"
|
||||
entityNamePlural="dashboards"
|
||||
findItems={[Function]}
|
||||
hideWriteControls={false}
|
||||
initialFilter=""
|
||||
listingLimit={1000}
|
||||
noItemsFragment={
|
||||
|
|
|
@ -46,14 +46,13 @@ class DashboardListingUi extends React.Component {
|
|||
render() {
|
||||
return (
|
||||
<TableListView
|
||||
createItem={this.props.createItem}
|
||||
createItem={this.props.hideWriteControls ? null : this.props.createItem}
|
||||
findItems={this.props.findItems}
|
||||
deleteItems={this.props.deleteItems}
|
||||
editItem={this.props.editItem}
|
||||
deleteItems={this.props.hideWriteControls ? null : this.props.deleteItems}
|
||||
editItem={this.props.hideWriteControls ? null : this.props.editItem}
|
||||
tableColumns={this.getTableColumns()}
|
||||
listingLimit={this.props.listingLimit}
|
||||
initialFilter={this.props.initialFilter}
|
||||
hideWriteControls={this.props.hideWriteControls}
|
||||
noItemsFragment={this.getNoItemsMessage()}
|
||||
entityName={
|
||||
i18n.translate('kbn.dashboard.listing.table.entityName', {
|
||||
|
|
|
@ -42,7 +42,13 @@ export function getEditPanelAction() {
|
|||
icon: <EuiIcon type="pencil" />,
|
||||
isDisabled: ({ embeddable }) =>
|
||||
!embeddable || !embeddable.metadata || !embeddable.metadata.editUrl,
|
||||
isVisible: ({ containerState }) => containerState.viewMode === DashboardViewMode.EDIT,
|
||||
isVisible: ({ containerState, embeddable }) => {
|
||||
const canEditEmbeddable = Boolean(
|
||||
embeddable && embeddable.metadata && embeddable.metadata.editable
|
||||
);
|
||||
const inDashboardEditMode = containerState.viewMode === DashboardViewMode.EDIT;
|
||||
return canEditEmbeddable && inDashboardEditMode;
|
||||
},
|
||||
getHref: ({ embeddable }) => {
|
||||
if (embeddable && embeddable.metadata.editUrl) {
|
||||
return embeddable.metadata.editUrl;
|
||||
|
|
|
@ -21,6 +21,7 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import { toastNotifications } from 'ui/notify';
|
||||
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
|
||||
|
||||
|
@ -87,18 +88,20 @@ export class DashboardAddPanel extends React.Component {
|
|||
)}
|
||||
/>
|
||||
</EuiFlyoutBody>
|
||||
<EuiFlyoutFooter>
|
||||
<EuiFlexGroup justifyContent="flexEnd">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton fill onClick={this.props.addNewVis} data-test-subj="addNewSavedObjectLink">
|
||||
<FormattedMessage
|
||||
id="kbn.dashboard.topNav.addPanel.createNewVisualizationButtonLabel"
|
||||
defaultMessage="Create new visualization"
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlyoutFooter>
|
||||
{ uiCapabilities.visualize.save ? (
|
||||
<EuiFlyoutFooter>
|
||||
<EuiFlexGroup justifyContent="flexEnd">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton fill onClick={this.props.addNewVis} data-test-subj="addNewSavedObjectLink">
|
||||
<FormattedMessage
|
||||
id="kbn.dashboard.topNav.addPanel.createNewVisualizationButtonLabel"
|
||||
defaultMessage="Create new visualization"
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlyoutFooter>
|
||||
) : null }
|
||||
</EuiFlyout>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,16 @@ import {
|
|||
DashboardAddPanel,
|
||||
} from './add_panel';
|
||||
|
||||
jest.mock('ui/capabilities',
|
||||
() => ({
|
||||
uiCapabilities: {
|
||||
visualize: {
|
||||
show: true,
|
||||
save: true
|
||||
}
|
||||
}
|
||||
}), { virtual: true });
|
||||
|
||||
jest.mock('ui/notify',
|
||||
() => ({
|
||||
toastNotifications: {
|
||||
|
|
|
@ -35,7 +35,8 @@ export function getTopNavConfig(dashboardMode, actions, hideWriteControls) {
|
|||
return (
|
||||
hideWriteControls ?
|
||||
[
|
||||
getFullScreenConfig(actions[TopNavIds.FULL_SCREEN])
|
||||
getFullScreenConfig(actions[TopNavIds.FULL_SCREEN]),
|
||||
getShareConfig(actions[TopNavIds.SHARE]),
|
||||
]
|
||||
: [
|
||||
getFullScreenConfig(actions[TopNavIds.FULL_SCREEN]),
|
||||
|
|
|
@ -24,6 +24,7 @@ import 'ui/directives/css_truncate';
|
|||
import 'ui/directives/field_name';
|
||||
import './string_progress_bar';
|
||||
import detailsHtml from './lib/detail_views/string.html';
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import { uiModules } from 'ui/modules';
|
||||
const app = uiModules.get('apps/discover');
|
||||
|
||||
|
@ -76,6 +77,8 @@ app.directive('discoverField', function ($compile, i18n) {
|
|||
|
||||
};
|
||||
|
||||
$scope.canVisualize = uiCapabilities.visualize.show;
|
||||
|
||||
$scope.toggleDisplay = function (field) {
|
||||
if (field.display) {
|
||||
$scope.onRemoveField(field.name);
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
|
||||
<a
|
||||
ng-href="{{field.details.visualizeUrl}}"
|
||||
ng-show="field.visualizable"
|
||||
ng-show="field.visualizable && canVisualize"
|
||||
class="kuiButton kuiButton--secondary kuiButton--small kuiVerticalRhythmSmall"
|
||||
data-test-subj="fieldVisualize-{{::field.name}}"
|
||||
>
|
||||
|
|
|
@ -68,6 +68,7 @@ import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
|
|||
import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
|
||||
import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
|
||||
import { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
|
||||
import 'ui/capabilities/route_setup';
|
||||
|
||||
const fetchStatuses = {
|
||||
UNINITIALIZED: 'uninitialized',
|
||||
|
@ -85,12 +86,13 @@ const app = uiModules.get('apps/discover', [
|
|||
uiRoutes
|
||||
.defaults(/^\/discover(\/|$)/, {
|
||||
requireDefaultIndex: true,
|
||||
requireUICapability: 'discover.show',
|
||||
k7Breadcrumbs: ($route, $injector) =>
|
||||
$injector.invoke(
|
||||
$route.current.params.id
|
||||
? getSavedSearchBreadcrumbs
|
||||
: getRootBreadcrumbs
|
||||
)
|
||||
),
|
||||
})
|
||||
.when('/discover/:id?', {
|
||||
template: indexTemplate,
|
||||
|
@ -173,6 +175,7 @@ function discoverController(
|
|||
kbnUrl,
|
||||
localStorage,
|
||||
i18n,
|
||||
uiCapabilities,
|
||||
) {
|
||||
const visualizeLoader = Private(VisualizeLoaderProvider);
|
||||
let visualizeHandler;
|
||||
|
@ -211,110 +214,131 @@ function discoverController(
|
|||
dirty: !savedSearch.id
|
||||
};
|
||||
|
||||
$scope.topNavMenu = [{
|
||||
key: 'new',
|
||||
label: i18n('kbn.discover.localMenu.localMenu.newSearchTitle', {
|
||||
defaultMessage: 'New',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.newSearchDescription', {
|
||||
defaultMessage: 'New Search',
|
||||
}),
|
||||
run: function () { kbnUrl.change('/discover'); },
|
||||
testId: 'discoverNewButton',
|
||||
}, {
|
||||
key: 'save',
|
||||
label: i18n('kbn.discover.localMenu.saveTitle', {
|
||||
defaultMessage: 'Save',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.saveSearchDescription', {
|
||||
defaultMessage: 'Save Search',
|
||||
}),
|
||||
testId: 'discoverSaveButton',
|
||||
run: async () => {
|
||||
const onSave = ({ newTitle, newCopyOnSave, isTitleDuplicateConfirmed, onTitleDuplicate }) => {
|
||||
const currentTitle = savedSearch.title;
|
||||
savedSearch.title = newTitle;
|
||||
savedSearch.copyOnSave = newCopyOnSave;
|
||||
const saveOptions = {
|
||||
confirmOverwrite: false,
|
||||
isTitleDuplicateConfirmed,
|
||||
onTitleDuplicate,
|
||||
};
|
||||
return saveDataSource(saveOptions).then(({ id, error }) => {
|
||||
// If the save wasn't successful, put the original values back.
|
||||
if (!id || error) {
|
||||
savedSearch.title = currentTitle;
|
||||
}
|
||||
return { id, error };
|
||||
});
|
||||
};
|
||||
const getTopNavLinks = () => {
|
||||
const newSearch = {
|
||||
key: 'new',
|
||||
label: i18n('kbn.discover.localMenu.localMenu.newSearchTitle', {
|
||||
defaultMessage: 'New',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.newSearchDescription', {
|
||||
defaultMessage: 'New Search',
|
||||
}),
|
||||
run: function () { kbnUrl.change('/discover'); },
|
||||
testId: 'discoverNewButton',
|
||||
};
|
||||
|
||||
const saveModal = (
|
||||
<SavedObjectSaveModal
|
||||
onSave={onSave}
|
||||
onClose={() => {}}
|
||||
title={savedSearch.title}
|
||||
showCopyOnSave={savedSearch.id ? true : false}
|
||||
objectType="search"
|
||||
/>);
|
||||
showSaveModal(saveModal);
|
||||
}
|
||||
}, {
|
||||
key: 'open',
|
||||
label: i18n('kbn.discover.localMenu.openTitle', {
|
||||
defaultMessage: 'Open',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.openSavedSearchDescription', {
|
||||
defaultMessage: 'Open Saved Search',
|
||||
}),
|
||||
testId: 'discoverOpenButton',
|
||||
run: () => {
|
||||
showOpenSearchPanel({
|
||||
makeUrl: (searchId) => {
|
||||
return kbnUrl.eval('#/discover/{{id}}', { id: searchId });
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'share',
|
||||
label: i18n('kbn.discover.localMenu.shareTitle', {
|
||||
defaultMessage: 'Share',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.shareSearchDescription', {
|
||||
defaultMessage: 'Share Search',
|
||||
}),
|
||||
testId: 'shareTopNavButton',
|
||||
run: async (menuItem, navController, anchorElement) => {
|
||||
const sharingData = await this.getSharingData();
|
||||
showShareContextMenu({
|
||||
anchorElement,
|
||||
allowEmbed: false,
|
||||
getUnhashableStates,
|
||||
objectId: savedSearch.id,
|
||||
objectType: 'search',
|
||||
shareContextMenuExtensions,
|
||||
sharingData: {
|
||||
...sharingData,
|
||||
title: savedSearch.title,
|
||||
},
|
||||
isDirty: $appStatus.dirty,
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'inspect',
|
||||
label: i18n('kbn.discover.localMenu.inspectTitle', {
|
||||
defaultMessage: 'Inspect',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.openInspectorForSearchDescription', {
|
||||
defaultMessage: 'Open Inspector for search',
|
||||
}),
|
||||
testId: 'openInspectorButton',
|
||||
run() {
|
||||
Inspector.open(inspectorAdapters, {
|
||||
title: savedSearch.title
|
||||
});
|
||||
}
|
||||
}];
|
||||
const saveSearch = {
|
||||
key: 'save',
|
||||
label: i18n('kbn.discover.localMenu.saveTitle', {
|
||||
defaultMessage: 'Save',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.saveSearchDescription', {
|
||||
defaultMessage: 'Save Search',
|
||||
}),
|
||||
testId: 'discoverSaveButton',
|
||||
run: async () => {
|
||||
const onSave = ({ newTitle, newCopyOnSave, isTitleDuplicateConfirmed, onTitleDuplicate }) => {
|
||||
const currentTitle = savedSearch.title;
|
||||
savedSearch.title = newTitle;
|
||||
savedSearch.copyOnSave = newCopyOnSave;
|
||||
const saveOptions = {
|
||||
confirmOverwrite: false,
|
||||
isTitleDuplicateConfirmed,
|
||||
onTitleDuplicate,
|
||||
};
|
||||
return saveDataSource(saveOptions).then(({ id, error }) => {
|
||||
// If the save wasn't successful, put the original values back.
|
||||
if (!id || error) {
|
||||
savedSearch.title = currentTitle;
|
||||
}
|
||||
return { id, error };
|
||||
});
|
||||
};
|
||||
|
||||
const saveModal = (
|
||||
<SavedObjectSaveModal
|
||||
onSave={onSave}
|
||||
onClose={() => { }}
|
||||
title={savedSearch.title}
|
||||
showCopyOnSave={savedSearch.id ? true : false}
|
||||
objectType="search"
|
||||
/>);
|
||||
showSaveModal(saveModal);
|
||||
}
|
||||
};
|
||||
|
||||
const openSearch = {
|
||||
key: 'open',
|
||||
label: i18n('kbn.discover.localMenu.openTitle', {
|
||||
defaultMessage: 'Open',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.openSavedSearchDescription', {
|
||||
defaultMessage: 'Open Saved Search',
|
||||
}),
|
||||
testId: 'discoverOpenButton',
|
||||
run: () => {
|
||||
showOpenSearchPanel({
|
||||
makeUrl: (searchId) => {
|
||||
return kbnUrl.eval('#/discover/{{id}}', { id: searchId });
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const shareSearch = {
|
||||
key: 'share',
|
||||
label: i18n('kbn.discover.localMenu.shareTitle', {
|
||||
defaultMessage: 'Share',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.shareSearchDescription', {
|
||||
defaultMessage: 'Share Search',
|
||||
}),
|
||||
testId: 'shareTopNavButton',
|
||||
run: async (menuItem, navController, anchorElement) => {
|
||||
const sharingData = await this.getSharingData();
|
||||
showShareContextMenu({
|
||||
anchorElement,
|
||||
allowEmbed: false,
|
||||
allowShortUrl: uiCapabilities.discover.createShortUrl,
|
||||
getUnhashableStates,
|
||||
objectId: savedSearch.id,
|
||||
objectType: 'search',
|
||||
shareContextMenuExtensions,
|
||||
sharingData: {
|
||||
...sharingData,
|
||||
title: savedSearch.title,
|
||||
},
|
||||
isDirty: $appStatus.dirty,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const inspectSearch = {
|
||||
key: 'inspect',
|
||||
label: i18n('kbn.discover.localMenu.inspectTitle', {
|
||||
defaultMessage: 'Inspect',
|
||||
}),
|
||||
description: i18n('kbn.discover.localMenu.openInspectorForSearchDescription', {
|
||||
defaultMessage: 'Open Inspector for search',
|
||||
}),
|
||||
testId: 'openInspectorButton',
|
||||
run() {
|
||||
Inspector.open(inspectorAdapters, {
|
||||
title: savedSearch.title
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return [
|
||||
newSearch,
|
||||
...uiCapabilities.discover.save ? [saveSearch] : [],
|
||||
openSearch,
|
||||
shareSearch,
|
||||
inspectSearch,
|
||||
];
|
||||
};
|
||||
|
||||
$scope.topNavMenu = getTopNavLinks();
|
||||
|
||||
// the actual courier.SearchSource
|
||||
$scope.searchSource = savedSearch.searchSource;
|
||||
|
|
|
@ -58,6 +58,7 @@ interface SearchEmbeddableConfig {
|
|||
onEmbeddableStateChanged: OnEmbeddableStateChanged;
|
||||
savedSearch: SavedSearch;
|
||||
editUrl: string;
|
||||
editable: boolean;
|
||||
$rootScope: ng.IRootScopeService;
|
||||
$compile: ng.ICompileService;
|
||||
}
|
||||
|
@ -80,6 +81,7 @@ export class SearchEmbeddable extends Embeddable {
|
|||
constructor({
|
||||
onEmbeddableStateChanged,
|
||||
savedSearch,
|
||||
editable,
|
||||
editUrl,
|
||||
$rootScope,
|
||||
$compile,
|
||||
|
@ -87,6 +89,7 @@ export class SearchEmbeddable extends Embeddable {
|
|||
super({
|
||||
title: savedSearch.title,
|
||||
editUrl,
|
||||
editable,
|
||||
indexPatterns: _.compact([savedSearch.searchSource.getField('index')]),
|
||||
});
|
||||
this.onEmbeddableStateChanged = onEmbeddableStateChanged;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import '../doc_table';
|
||||
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { EmbeddableFactory } from 'ui/embeddable';
|
||||
import {
|
||||
|
@ -63,6 +63,7 @@ export class SearchEmbeddableFactory extends EmbeddableFactory {
|
|||
onEmbeddableStateChanged: OnEmbeddableStateChanged
|
||||
) {
|
||||
const editUrl = this.getEditPath(id);
|
||||
const editable = uiCapabilities.discover.save as boolean;
|
||||
|
||||
// can't change this to be async / awayt, because an Anglular promise is expected to be returned.
|
||||
return this.searchLoader.get(id).then(savedObject => {
|
||||
|
@ -70,6 +71,7 @@ export class SearchEmbeddableFactory extends EmbeddableFactory {
|
|||
onEmbeddableStateChanged,
|
||||
savedSearch: savedObject,
|
||||
editUrl,
|
||||
editable,
|
||||
$rootScope: this.$rootScope,
|
||||
$compile: this.$compile,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<home-app
|
||||
directories="directories"
|
||||
recently-accessed="recentlyAccessed"
|
||||
data-test-subj="homeApp"
|
||||
/>
|
||||
|
|
|
@ -65,6 +65,7 @@ import 'leaflet';
|
|||
|
||||
routes.enable();
|
||||
|
||||
|
||||
routes
|
||||
.otherwise({
|
||||
redirectTo: `/${chrome.getInjected('kbnDefaultAppId', 'discover')}`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="euiPage mgtPage">
|
||||
<div id="management-sidenav" class="euiPageSideBar" style="position: static;"></div>
|
||||
<div id="management-sidenav" class="euiPageSideBar" style="position: static;" data-test-subj="managementNav"></div>
|
||||
<main class="euiPageBody euiPageBody--restrictWidth-default mgtPage__body" ng-transclude></main>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -141,7 +141,7 @@ uiModules
|
|||
link: function ($scope) {
|
||||
timefilter.disableAutoRefreshSelector();
|
||||
timefilter.disableTimeRangeSelector();
|
||||
$scope.sections = management.items.inOrder;
|
||||
$scope.sections = management.visibleItems;
|
||||
$scope.section = management.getSection($scope.sectionName) || management;
|
||||
|
||||
if ($scope.section) {
|
||||
|
@ -152,7 +152,7 @@ uiModules
|
|||
|
||||
updateSidebar($scope.sections, $scope.section.id);
|
||||
$scope.$on('$destroy', () => destroyReact(SIDENAV_ID));
|
||||
management.addListener(() => updateSidebar(management.items.inOrder, $scope.section.id));
|
||||
management.addListener(() => updateSidebar(management.visibleItems, $scope.section.id));
|
||||
|
||||
updateLandingPage($scope.$root.chrome.getKibanaVersion());
|
||||
$scope.$on('$destroy', () => destroyReact(LANDING_ID));
|
||||
|
@ -166,7 +166,7 @@ uiModules
|
|||
return {
|
||||
restrict: 'E',
|
||||
link: function ($scope) {
|
||||
$scope.sections = management.items.inOrder;
|
||||
$scope.sections = management.visibleItems;
|
||||
$scope.kbnVersion = kbnVersion;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -33,6 +33,8 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { UICapabilities } from 'ui/capabilities';
|
||||
import { injectUICapabilities } from 'ui/capabilities/react';
|
||||
|
||||
interface State {
|
||||
isPopoverOpen: boolean;
|
||||
|
@ -46,21 +48,26 @@ interface Props {
|
|||
isBeta?: boolean;
|
||||
onClick: () => void;
|
||||
}>;
|
||||
uiCapabilities: UICapabilities;
|
||||
}
|
||||
|
||||
export class CreateButton extends Component<Props, State> {
|
||||
class CreateButtonComponent extends Component<Props, State> {
|
||||
public state = {
|
||||
isPopoverOpen: false,
|
||||
};
|
||||
|
||||
public render() {
|
||||
const { options, children } = this.props;
|
||||
const { options, children, uiCapabilities } = this.props;
|
||||
const { isPopoverOpen } = this.state;
|
||||
|
||||
if (!options || !options.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!uiCapabilities.indexPatterns.createNew) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (options.length === 1) {
|
||||
return (
|
||||
<EuiButton
|
||||
|
@ -146,3 +153,5 @@ export class CreateButton extends Component<Props, State> {
|
|||
);
|
||||
};
|
||||
}
|
||||
|
||||
export const CreateButton = injectUICapabilities(CreateButtonComponent);
|
||||
|
|
|
@ -31,6 +31,7 @@ import { SavedObjectsClientProvider } from 'ui/saved_objects';
|
|||
import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { UICapabilitiesProvider } from 'ui/capabilities/react';
|
||||
import { EuiBadge } from '@elastic/eui';
|
||||
import { getListBreadcrumbs } from './breadcrumbs';
|
||||
|
||||
|
@ -51,11 +52,13 @@ export function updateIndexPatternList(
|
|||
|
||||
render(
|
||||
<I18nContext>
|
||||
<IndexPatternTable
|
||||
indexPatterns={indexPatterns}
|
||||
navTo={kbnUrl.redirect}
|
||||
indexPatternCreationOptions={indexPatternCreationOptions}
|
||||
/>
|
||||
<UICapabilitiesProvider>
|
||||
<IndexPatternTable
|
||||
indexPatterns={indexPatterns}
|
||||
navTo={kbnUrl.redirect}
|
||||
indexPatternCreationOptions={indexPatternCreationOptions}
|
||||
/>
|
||||
</UICapabilitiesProvider>
|
||||
</I18nContext>,
|
||||
node,
|
||||
);
|
||||
|
@ -81,7 +84,8 @@ const indexPatternsResolutions = {
|
|||
// add a dependency to all of the subsection routes
|
||||
uiRoutes
|
||||
.defaults(/management\/kibana\/(index_patterns|index_pattern)/, {
|
||||
resolve: indexPatternsResolutions
|
||||
resolve: indexPatternsResolutions,
|
||||
requireUICapability: 'management.kibana.index_patterns',
|
||||
});
|
||||
|
||||
uiRoutes
|
||||
|
|
|
@ -85,7 +85,7 @@ export class IndexPatternTable extends React.Component<Props, State> {
|
|||
|
||||
public render() {
|
||||
return (
|
||||
<EuiPanel paddingSize="l">
|
||||
<EuiPanel paddingSize="l" data-test-subj="indexPatternTable">
|
||||
{this.state.showFlyout && (
|
||||
<CreateIndexPatternPrompt onClose={() => this.setState({ showFlyout: false })} />
|
||||
)}
|
||||
|
|
|
@ -27,7 +27,7 @@ import { uiModules } from 'ui/modules';
|
|||
import React from 'react';
|
||||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import { ObjectsTable } from './components/objects_table';
|
||||
import { getInAppUrl } from './lib/get_in_app_url';
|
||||
import { canViewInApp, getInAppUrl } from './lib/in_app_url';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
||||
import { getIndexBreadcrumbs } from './breadcrumbs';
|
||||
|
@ -40,6 +40,7 @@ function updateObjectsTable($scope, $injector, i18n) {
|
|||
const $http = $injector.get('$http');
|
||||
const kbnUrl = $injector.get('kbnUrl');
|
||||
const config = $injector.get('config');
|
||||
const uiCapabilites = chrome.getInjected('uiCapabilities');
|
||||
|
||||
const savedObjectsClient = Private(SavedObjectsClientProvider);
|
||||
const services = savedObjectManagementRegistry.all().map(obj => $injector.get(obj.service));
|
||||
|
@ -64,6 +65,7 @@ function updateObjectsTable($scope, $injector, i18n) {
|
|||
perPageConfig={config.get('savedObjects:perPage')}
|
||||
basePath={chrome.getBasePath()}
|
||||
newIndexPatternUrl={kbnUrl.eval('#/management/kibana/index_pattern')}
|
||||
uiCapabilities={uiCapabilites}
|
||||
getEditUrl={(id, type) => {
|
||||
if (type === 'index-pattern' || type === 'indexPatterns') {
|
||||
return kbnUrl.eval(`#/management/kibana/index_patterns/${id}`);
|
||||
|
@ -79,6 +81,9 @@ function updateObjectsTable($scope, $injector, i18n) {
|
|||
|
||||
return kbnUrl.eval(`#/management/kibana/objects/${serviceName}/${id}`);
|
||||
}}
|
||||
canGoInApp={(type) => {
|
||||
return canViewInApp(uiCapabilites, type);
|
||||
}}
|
||||
goInApp={(id, type) => {
|
||||
kbnUrl.change(getInAppUrl(id, type));
|
||||
$scope.$apply();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<kbn-management-app section="kibana/objects" class="kuiView">
|
||||
<kbn-management-app section="kibana/objects" class="kuiView" data-test-subj="savedObjectsEdit">
|
||||
<kbn-management-objects-view class="kuiViewContent kuiViewContent--constrainedWidth">
|
||||
<!-- Header -->
|
||||
<div class="kuiViewContentItem kuiBar kuiVerticalRhythm">
|
||||
|
@ -8,6 +8,15 @@
|
|||
i18n-id="kbn.management.objects.view.editItemTitle"
|
||||
i18n-default-message="Edit {title}"
|
||||
i18n-values="{ title }"
|
||||
ng-if="canEdit"
|
||||
></h1>
|
||||
|
||||
<h1
|
||||
class="kuiTitle"
|
||||
i18n-id="kbn.management.objects.view.viewItemTitle"
|
||||
i18n-default-message="View {title}"
|
||||
i18n-values="{ title }"
|
||||
ng-if="!canEdit"
|
||||
></h1>
|
||||
</div>
|
||||
|
||||
|
@ -15,6 +24,7 @@
|
|||
<a
|
||||
class="kuiButton kuiButton--basic kuiButton--iconText"
|
||||
href="{{ link }}"
|
||||
ng-if="canViewInApp"
|
||||
>
|
||||
<span class="kuiButton__inner">
|
||||
<span class="kuiButton__icon kuiIcon fa-eye"></span>
|
||||
|
@ -29,6 +39,8 @@
|
|||
<button
|
||||
class="kuiButton kuiButton--danger kuiButton--iconText"
|
||||
ng-click="delete()"
|
||||
ng-if="canDelete"
|
||||
data-test-subj="savedObjectEditDelete"
|
||||
>
|
||||
<span class="kuiButton__inner">
|
||||
<span class="kuiButton__icon kuiIcon fa-trash-o"></span>
|
||||
|
@ -90,7 +102,7 @@
|
|||
|
||||
<!-- Intro -->
|
||||
<div class="kuiViewContentItem kuiVerticalRhythm">
|
||||
<div class="kuiInfoPanel kuiInfoPanel--warning">
|
||||
<div class="kuiInfoPanel kuiInfoPanel--warning" ng-if="canEdit">
|
||||
<div class="kuiInfoPanelHeader">
|
||||
<span class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--warning fa-bolt"></span>
|
||||
<span
|
||||
|
@ -117,6 +129,7 @@
|
|||
role="form"
|
||||
name="objectForm"
|
||||
ng-submit="submit()"
|
||||
data-test-subj="savedObjectEditForm"
|
||||
>
|
||||
<div class="kuiFormSection" ng-repeat="field in fields">
|
||||
<label for="{{ field.name }}" class="kuiFormLabel">
|
||||
|
@ -129,6 +142,7 @@
|
|||
class="kuiTextInput"
|
||||
type="number"
|
||||
ng-model="field.value"
|
||||
ng-disabled="{{ !canEdit }}"
|
||||
>
|
||||
|
||||
<textarea
|
||||
|
@ -138,6 +152,7 @@
|
|||
rows="1"
|
||||
msd-elastic=" "
|
||||
ng-model="field.value"
|
||||
ng-disabled="{{ !canEdit }}"
|
||||
></textarea>
|
||||
|
||||
<input
|
||||
|
@ -146,11 +161,13 @@
|
|||
type="checkbox"
|
||||
ng-model="field.value"
|
||||
ng-checked="field.value"
|
||||
ng-disabled="{{ !canEdit }}"
|
||||
>
|
||||
|
||||
<div
|
||||
ng-if="field.type === 'json' || field.type === 'array'"
|
||||
kbn-ui-ace-keyboard-mode
|
||||
kbn-ui-ace-keyboard-mod
|
||||
ng-attr-readonly="{{ canEdit ? undefined : true }}"
|
||||
ui-ace="{ onLoad: aceLoaded, mode: 'json' }"
|
||||
id="{{field.name}}"
|
||||
ng-model="field.value"
|
||||
|
@ -169,6 +186,8 @@
|
|||
i18n-id="kbn.management.objects.view.saveButtonLabel"
|
||||
i18n-default-message="Save { title } Object"
|
||||
i18n-values="{ title }"
|
||||
ng-if="canEdit"
|
||||
data-test-subj="savedObjectEditSave"
|
||||
></button>
|
||||
|
||||
<button
|
||||
|
|
|
@ -30,6 +30,7 @@ import 'ui/accessibility/kbn_ui_ace_keyboard_mode';
|
|||
import { castEsToKbnFieldTypeName } from '../../../../../../../legacy/utils';
|
||||
import { SavedObjectsClientProvider } from 'ui/saved_objects';
|
||||
import { isNumeric } from 'ui/utils/numeric';
|
||||
import { canViewInApp } from './lib/in_app_url';
|
||||
|
||||
import { getViewBreadcrumbs } from './breadcrumbs';
|
||||
|
||||
|
@ -45,7 +46,7 @@ uiModules.get('apps/management', ['monospaced.elastic'])
|
|||
.directive('kbnManagementObjectsView', function (kbnIndex, confirmModal, i18n) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
controller: function ($scope, $injector, $routeParams, $location, $window, $rootScope, Private) {
|
||||
controller: function ($scope, $injector, $routeParams, $location, $window, $rootScope, Private, uiCapabilities) {
|
||||
const serviceObj = savedObjectManagementRegistry.get($routeParams.service);
|
||||
const service = $injector.get(serviceObj.service);
|
||||
const savedObjectsClient = Private(SavedObjectsClientProvider);
|
||||
|
@ -136,6 +137,11 @@ uiModules.get('apps/management', ['monospaced.elastic'])
|
|||
}
|
||||
};
|
||||
|
||||
const { edit: canEdit, delete: canDelete } = uiCapabilities.savedObjectsManagement[service.type];
|
||||
$scope.canEdit = canEdit;
|
||||
$scope.canDelete = canDelete;
|
||||
$scope.canViewInApp = canViewInApp(uiCapabilities, service.type);
|
||||
|
||||
$scope.notFound = $routeParams.notFound;
|
||||
|
||||
$scope.title = service.type;
|
||||
|
|
|
@ -220,6 +220,7 @@ exports[`ObjectsTable import should show the flyout 1`] = `
|
|||
|
||||
exports[`ObjectsTable relationships should show the flyout 1`] = `
|
||||
<InjectIntl(RelationshipsUI)
|
||||
canGoInApp={[Function]}
|
||||
close={[Function]}
|
||||
getEditUrl={[Function]}
|
||||
getRelationships={[Function]}
|
||||
|
@ -245,6 +246,8 @@ exports[`ObjectsTable should render normally 1`] = `
|
|||
size="xs"
|
||||
/>
|
||||
<InjectIntl(TableUI)
|
||||
canDeleteSavedObjectTypes={Array []}
|
||||
canGoInApp={[Function]}
|
||||
filterOptions={
|
||||
Array [
|
||||
Object {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import React from 'react';
|
||||
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
|
||||
|
||||
import { ObjectsTable, INCLUDED_TYPES } from '../objects_table';
|
||||
import { ObjectsTable, POSSIBLE_TYPES } from '../objects_table';
|
||||
import { Flyout } from '../components/flyout/';
|
||||
import { Relationships } from '../components/relationships/';
|
||||
|
||||
|
@ -145,7 +145,30 @@ const defaultProps = {
|
|||
kbnIndex: '',
|
||||
services: [],
|
||||
getEditUrl: () => {},
|
||||
canGoInApp: () => {},
|
||||
goInApp: () => {},
|
||||
uiCapabilities: {
|
||||
savedObjectsManagement: {
|
||||
'index-pattern': {
|
||||
read: true
|
||||
},
|
||||
visualization: {
|
||||
read: true
|
||||
},
|
||||
dashboard: {
|
||||
read: true
|
||||
},
|
||||
search: {
|
||||
read: true
|
||||
}
|
||||
}
|
||||
},
|
||||
canDeleteSavedObjectTypes: [
|
||||
'index-pattern',
|
||||
'visualization',
|
||||
'dashboard',
|
||||
'search'
|
||||
]
|
||||
};
|
||||
|
||||
let addDangerMock;
|
||||
|
@ -207,6 +230,41 @@ describe('ObjectsTable', () => {
|
|||
expect(addDangerMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should filter find operation based on the uiCapabilities', async () => {
|
||||
const uiCapabilities = {
|
||||
savedObjectsManagement: {
|
||||
'index-pattern': {
|
||||
read: false,
|
||||
},
|
||||
visualization: {
|
||||
read: false,
|
||||
},
|
||||
dashboard: {
|
||||
read: false,
|
||||
},
|
||||
search: {
|
||||
read: true,
|
||||
}
|
||||
}
|
||||
};
|
||||
const customizedProps = { ...defaultProps, uiCapabilities };
|
||||
const component = shallowWithIntl(
|
||||
<ObjectsTable.WrappedComponent
|
||||
{...customizedProps}
|
||||
perPageConfig={15}
|
||||
/>
|
||||
);
|
||||
|
||||
// Ensure all promises resolve
|
||||
await new Promise(resolve => process.nextTick(resolve));
|
||||
// Ensure the state changes are reflected
|
||||
component.update();
|
||||
|
||||
expect(defaultProps.savedObjectsClient.find).toHaveBeenCalledWith(expect.objectContaining({
|
||||
type: ['search']
|
||||
}));
|
||||
});
|
||||
|
||||
describe('export', () => {
|
||||
it('should export selected objects', async () => {
|
||||
const mockSelectedSavedObjects = [
|
||||
|
@ -288,7 +346,7 @@ describe('ObjectsTable', () => {
|
|||
|
||||
await component.instance().onExportAll();
|
||||
|
||||
expect(fetchExportByType).toHaveBeenCalledWith(INCLUDED_TYPES, true);
|
||||
expect(fetchExportByType).toHaveBeenCalledWith(POSSIBLE_TYPES, true);
|
||||
expect(saveAs).toHaveBeenCalledWith(blob, 'export.ndjson');
|
||||
expect(addSuccessMock).toHaveBeenCalledWith({ title: 'Your file is downloading in the background' });
|
||||
});
|
||||
|
@ -348,7 +406,44 @@ describe('ObjectsTable', () => {
|
|||
component.update();
|
||||
|
||||
await component.instance().getRelationships('search', '1');
|
||||
expect(getRelationships).toHaveBeenCalledWith('search', '1', defaultProps.$http, defaultProps.basePath);
|
||||
const savedObjectTypes = ['index-pattern', 'visualization', 'dashboard', 'search'];
|
||||
expect(getRelationships).toHaveBeenCalledWith('search', '1', savedObjectTypes, defaultProps.$http, defaultProps.basePath);
|
||||
});
|
||||
|
||||
it('should fetch relationships filtered based on the uiCapabilities', async () => {
|
||||
const { getRelationships } = require('../../../lib/get_relationships');
|
||||
|
||||
const uiCapabilities = {
|
||||
savedObjectsManagement: {
|
||||
'index-pattern': {
|
||||
read: false,
|
||||
},
|
||||
visualization: {
|
||||
read: false,
|
||||
},
|
||||
dashboard: {
|
||||
read: false,
|
||||
},
|
||||
search: {
|
||||
read: true,
|
||||
}
|
||||
}
|
||||
};
|
||||
const customizedProps = { ...defaultProps, uiCapabilities };
|
||||
const component = shallowWithIntl(
|
||||
<ObjectsTable.WrappedComponent
|
||||
{...customizedProps}
|
||||
/>
|
||||
);
|
||||
|
||||
// Ensure all promises resolve
|
||||
await new Promise(resolve => process.nextTick(resolve));
|
||||
// Ensure the state changes are reflected
|
||||
component.update();
|
||||
|
||||
await component.instance().getRelationships('search', '1');
|
||||
const savedObjectTypes = ['search'];
|
||||
expect(getRelationships).toHaveBeenCalledWith('search', '1', savedObjectTypes, defaultProps.$http, defaultProps.basePath);
|
||||
});
|
||||
|
||||
it('should show the flyout', async () => {
|
||||
|
|
|
@ -58,7 +58,7 @@ import {
|
|||
resolveIndexPatternConflicts,
|
||||
saveObjects,
|
||||
} from '../../../../lib/resolve_saved_objects';
|
||||
import { INCLUDED_TYPES } from '../../objects_table';
|
||||
import { POSSIBLE_TYPES } from '../../objects_table';
|
||||
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
|
||||
|
||||
class FlyoutUI extends Component {
|
||||
|
@ -246,7 +246,7 @@ class FlyoutUI extends Component {
|
|||
}
|
||||
|
||||
contents = contents.filter(content =>
|
||||
INCLUDED_TYPES.includes(content._type)
|
||||
POSSIBLE_TYPES.includes(content._type)
|
||||
).map(doc => ({
|
||||
...doc,
|
||||
// The server assumes that documents with no migrationVersion are up to date.
|
||||
|
|
|
@ -75,10 +75,12 @@ exports[`Relationships should render dashboards normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"testId": "savedObjectsManagementRelationshipsViewInApp",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
|
@ -223,10 +225,12 @@ exports[`Relationships should render index patterns normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"testId": "savedObjectsManagementRelationshipsViewInApp",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
|
@ -281,10 +285,12 @@ exports[`Relationships should render index patterns normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"testId": "savedObjectsManagementRelationshipsViewInApp",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
|
@ -383,10 +389,12 @@ exports[`Relationships should render searches normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"testId": "savedObjectsManagementRelationshipsViewInApp",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
|
@ -447,10 +455,12 @@ exports[`Relationships should render searches normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"testId": "savedObjectsManagementRelationshipsViewInApp",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
|
@ -549,10 +559,12 @@ exports[`Relationships should render visualizations normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"testId": "savedObjectsManagementRelationshipsViewInApp",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
|
|
|
@ -50,6 +50,7 @@ jest.mock('../../../../../lib/fetch_export_objects', () => ({
|
|||
import { Relationships } from '../relationships';
|
||||
|
||||
describe('Relationships', () => {
|
||||
|
||||
it('should render index patterns normally', async () => {
|
||||
const props = {
|
||||
getRelationships: jest.fn().mockImplementation(() => ({
|
||||
|
@ -65,6 +66,7 @@ describe('Relationships', () => {
|
|||
],
|
||||
})),
|
||||
getEditUrl: () => '',
|
||||
canGoInApp: () => true,
|
||||
goInApp: jest.fn(),
|
||||
id: '1',
|
||||
type: 'index-pattern',
|
||||
|
@ -105,6 +107,7 @@ describe('Relationships', () => {
|
|||
],
|
||||
})),
|
||||
getEditUrl: () => '',
|
||||
canGoInApp: () => true,
|
||||
goInApp: jest.fn(),
|
||||
id: '1',
|
||||
type: 'search',
|
||||
|
@ -143,6 +146,7 @@ describe('Relationships', () => {
|
|||
],
|
||||
})),
|
||||
getEditUrl: () => '',
|
||||
canGoInApp: () => true,
|
||||
goInApp: jest.fn(),
|
||||
id: '1',
|
||||
type: 'visualization',
|
||||
|
@ -181,6 +185,7 @@ describe('Relationships', () => {
|
|||
],
|
||||
})),
|
||||
getEditUrl: () => '',
|
||||
canGoInApp: () => true,
|
||||
goInApp: jest.fn(),
|
||||
id: '1',
|
||||
type: 'dashboard',
|
||||
|
@ -212,6 +217,7 @@ describe('Relationships', () => {
|
|||
throw new Error('foo');
|
||||
}),
|
||||
getEditUrl: () => '',
|
||||
canGoInApp: () => true,
|
||||
goInApp: jest.fn(),
|
||||
id: '1',
|
||||
type: 'dashboard',
|
||||
|
|
|
@ -45,6 +45,7 @@ class RelationshipsUI extends Component {
|
|||
title: PropTypes.string.isRequired,
|
||||
close: PropTypes.func.isRequired,
|
||||
getEditUrl: PropTypes.func.isRequired,
|
||||
canGoInApp: PropTypes.func.isRequired,
|
||||
goInApp: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
@ -101,7 +102,7 @@ class RelationshipsUI extends Component {
|
|||
}
|
||||
|
||||
renderRelationships() {
|
||||
const { getEditUrl, goInApp, intl } = this.props;
|
||||
const { getEditUrl, canGoInApp, goInApp, intl } = this.props;
|
||||
const { relationships, isLoading, error } = this.state;
|
||||
|
||||
if (error) {
|
||||
|
@ -267,7 +268,9 @@ class RelationshipsUI extends Component {
|
|||
defaultMessage: 'View this saved object within Kibana'
|
||||
}),
|
||||
icon: 'eye',
|
||||
available: () => canGoInApp(type),
|
||||
onClick: object => goInApp(object.id, type),
|
||||
testId: 'savedObjectsManagementRelationshipsViewInApp'
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
@ -1,5 +1,208 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Table restricts which saved objects can be deleted based on type 1`] = `
|
||||
<Fragment>
|
||||
<EuiSearchBar
|
||||
box={
|
||||
Object {
|
||||
"data-test-subj": "savedObjectSearchBar",
|
||||
}
|
||||
}
|
||||
filters={
|
||||
Array [
|
||||
Object {
|
||||
"field": "type",
|
||||
"multiSelect": "or",
|
||||
"name": "Type",
|
||||
"options": Array [
|
||||
Object {
|
||||
"value": 2,
|
||||
},
|
||||
],
|
||||
"type": "field_value_selection",
|
||||
},
|
||||
]
|
||||
}
|
||||
onChange={[Function]}
|
||||
toolsRight={
|
||||
Array [
|
||||
<EuiButton
|
||||
color="danger"
|
||||
data-test-subj="savedObjectsManagementDelete"
|
||||
fill={false}
|
||||
iconSide="left"
|
||||
iconType="trash"
|
||||
isDisabled={true}
|
||||
onClick={[Function]}
|
||||
size="m"
|
||||
title="Unable to delete search, index-pattern"
|
||||
type="button"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Delete"
|
||||
id="kbn.management.objects.objectsTable.table.deleteButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButton>,
|
||||
<EuiPopover
|
||||
anchorPosition="downCenter"
|
||||
button={
|
||||
<EuiButton
|
||||
color="primary"
|
||||
fill={false}
|
||||
iconSide="right"
|
||||
iconType="arrowDown"
|
||||
isDisabled={false}
|
||||
onClick={[Function]}
|
||||
size="m"
|
||||
type="button"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Export"
|
||||
id="kbn.management.objects.objectsTable.table.exportPopoverButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButton>
|
||||
}
|
||||
closePopover={[Function]}
|
||||
hasArrow={true}
|
||||
isOpen={false}
|
||||
ownFocus={false}
|
||||
panelPaddingSize="m"
|
||||
>
|
||||
<EuiFormRow
|
||||
describedByIds={Array []}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
label={
|
||||
<FormattedMessage
|
||||
defaultMessage="Options"
|
||||
id="kbn.management.objects.objectsTable.exportObjectsConfirmModal.exportOptionsLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
}
|
||||
labelType="label"
|
||||
>
|
||||
<EuiSwitch
|
||||
checked={true}
|
||||
label={
|
||||
<FormattedMessage
|
||||
defaultMessage="Include related objects"
|
||||
id="kbn.management.objects.objectsTable.exportObjectsConfirmModal.includeReferencesDeepLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
}
|
||||
name="includeReferencesDeep"
|
||||
onChange={[Function]}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
<EuiFormRow
|
||||
describedByIds={Array []}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
labelType="label"
|
||||
>
|
||||
<EuiButton
|
||||
color="primary"
|
||||
fill={true}
|
||||
iconSide="left"
|
||||
iconType="exportAction"
|
||||
onClick={[Function]}
|
||||
size="m"
|
||||
type="button"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="Export"
|
||||
id="kbn.management.objects.objectsTable.table.exportButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiFormRow>
|
||||
</EuiPopover>,
|
||||
]
|
||||
}
|
||||
/>
|
||||
<EuiSpacer
|
||||
size="s"
|
||||
/>
|
||||
<div
|
||||
data-test-subj="savedObjectsTable"
|
||||
>
|
||||
<EuiBasicTable
|
||||
columns={
|
||||
Array [
|
||||
Object {
|
||||
"align": "center",
|
||||
"description": "Type of the saved object",
|
||||
"field": "type",
|
||||
"name": "Type",
|
||||
"render": [Function],
|
||||
"sortable": false,
|
||||
"width": "50px",
|
||||
},
|
||||
Object {
|
||||
"dataType": "string",
|
||||
"description": "Title of the saved object",
|
||||
"field": "title",
|
||||
"name": "Title",
|
||||
"render": [Function],
|
||||
"sortable": false,
|
||||
},
|
||||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
"onClick": [Function],
|
||||
"type": "icon",
|
||||
},
|
||||
Object {
|
||||
"description": "View the relationships this saved object has to other saved objects",
|
||||
"icon": "kqlSelector",
|
||||
"name": "Relationships",
|
||||
"onClick": [Function],
|
||||
"type": "icon",
|
||||
},
|
||||
],
|
||||
"name": "Actions",
|
||||
},
|
||||
]
|
||||
}
|
||||
itemId="id"
|
||||
items={
|
||||
Array [
|
||||
3,
|
||||
]
|
||||
}
|
||||
loading={false}
|
||||
noItemsMessage="No items found"
|
||||
onChange={[Function]}
|
||||
pagination={
|
||||
Object {
|
||||
"pageIndex": 1,
|
||||
"pageSize": 2,
|
||||
"pageSizeOptions": Array [
|
||||
5,
|
||||
10,
|
||||
20,
|
||||
50,
|
||||
],
|
||||
"totalItemCount": 3,
|
||||
}
|
||||
}
|
||||
responsive={true}
|
||||
selection={
|
||||
Object {
|
||||
"onSelectionChange": [Function],
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Fragment>
|
||||
`;
|
||||
|
||||
exports[`Table should render normally 1`] = `
|
||||
<Fragment>
|
||||
<EuiSearchBar
|
||||
|
@ -28,6 +231,7 @@ exports[`Table should render normally 1`] = `
|
|||
Array [
|
||||
<EuiButton
|
||||
color="danger"
|
||||
data-test-subj="savedObjectsManagementDelete"
|
||||
fill={false}
|
||||
iconSide="left"
|
||||
iconType="trash"
|
||||
|
@ -149,6 +353,7 @@ exports[`Table should render normally 1`] = `
|
|||
Object {
|
||||
"actions": Array [
|
||||
Object {
|
||||
"available": [Function],
|
||||
"description": "View this saved object within Kibana",
|
||||
"icon": "eye",
|
||||
"name": "In app",
|
||||
|
|
|
@ -44,7 +44,7 @@ jest.mock('ui/chrome', () => ({
|
|||
import { Table } from '../table';
|
||||
|
||||
const defaultProps = {
|
||||
selectedSavedObjects: [1],
|
||||
selectedSavedObjects: [{ type: 'visualization' }],
|
||||
selectionConfig: {
|
||||
onSelectionChange: () => {},
|
||||
},
|
||||
|
@ -52,6 +52,7 @@ const defaultProps = {
|
|||
onDelete: () => {},
|
||||
onExport: () => {},
|
||||
getEditUrl: () => {},
|
||||
canGoInApp: () => {},
|
||||
goInApp: () => {},
|
||||
pageIndex: 1,
|
||||
pageSize: 2,
|
||||
|
@ -62,6 +63,7 @@ const defaultProps = {
|
|||
onTableChange: () => {},
|
||||
isSearching: false,
|
||||
onShowRelationships: () => {},
|
||||
canDeleteSavedObjectTypes: ['visualization']
|
||||
};
|
||||
|
||||
describe('Table', () => {
|
||||
|
@ -101,4 +103,16 @@ describe('Table', () => {
|
|||
expect(onQueryChangeMock).toHaveBeenCalledTimes(1);
|
||||
expect(component.state().isSearchTextValid).toBe(true);
|
||||
});
|
||||
|
||||
it(`restricts which saved objects can be deleted based on type`, () => {
|
||||
const selectedSavedObjects = [{ type: 'visualization' }, { type: 'search' }, { type: 'index-pattern' }];
|
||||
const customizedProps = { ...defaultProps, selectedSavedObjects, canDeleteSavedObjectTypes: ['visualization'] };
|
||||
const component = shallowWithIntl(
|
||||
<Table.WrappedComponent
|
||||
{...customizedProps}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -45,9 +45,11 @@ class TableUI extends PureComponent {
|
|||
onSelectionChange: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
filterOptions: PropTypes.array.isRequired,
|
||||
canDeleteSavedObjectTypes: PropTypes.array.isRequired,
|
||||
onDelete: PropTypes.func.isRequired,
|
||||
onExport: PropTypes.func.isRequired,
|
||||
getEditUrl: PropTypes.func.isRequired,
|
||||
canGoInApp: PropTypes.func.isRequired,
|
||||
goInApp: PropTypes.func.isRequired,
|
||||
|
||||
pageIndex: PropTypes.number.isRequired,
|
||||
|
@ -124,6 +126,7 @@ class TableUI extends PureComponent {
|
|||
onDelete,
|
||||
selectedSavedObjects,
|
||||
onTableChange,
|
||||
canGoInApp,
|
||||
goInApp,
|
||||
getEditUrl,
|
||||
onShowRelationships,
|
||||
|
@ -208,6 +211,7 @@ class TableUI extends PureComponent {
|
|||
}),
|
||||
type: 'icon',
|
||||
icon: 'eye',
|
||||
available: object => canGoInApp(object.type),
|
||||
onClick: object => goInApp(object.id, object.type),
|
||||
},
|
||||
{
|
||||
|
@ -243,6 +247,10 @@ class TableUI extends PureComponent {
|
|||
);
|
||||
}
|
||||
|
||||
const unableToDeleteSavedObjectTypes = selectedSavedObjects
|
||||
.map(({ type }) => type)
|
||||
.filter(type => !this.props.canDeleteSavedObjectTypes.includes(type));
|
||||
|
||||
const button = (
|
||||
<EuiButton
|
||||
iconType="arrowDown"
|
||||
|
@ -269,7 +277,14 @@ class TableUI extends PureComponent {
|
|||
iconType="trash"
|
||||
color="danger"
|
||||
onClick={onDelete}
|
||||
isDisabled={selectedSavedObjects.length === 0}
|
||||
isDisabled={
|
||||
selectedSavedObjects.length === 0 ||
|
||||
unableToDeleteSavedObjectTypes.length > 0
|
||||
}
|
||||
title={
|
||||
unableToDeleteSavedObjectTypes.length > 0 ? `Unable to delete ${unableToDeleteSavedObjectTypes.join(', ')}` : undefined
|
||||
}
|
||||
data-test-subj="savedObjectsManagementDelete"
|
||||
>
|
||||
<FormattedMessage
|
||||
id="kbn.management.objects.objectsTable.table.deleteButtonLabel"
|
||||
|
|
|
@ -62,7 +62,7 @@ import {
|
|||
} from '../../lib';
|
||||
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
|
||||
|
||||
export const INCLUDED_TYPES = [
|
||||
export const POSSIBLE_TYPES = [
|
||||
'index-pattern',
|
||||
'visualization',
|
||||
'dashboard',
|
||||
|
@ -79,18 +79,23 @@ class ObjectsTableUI extends Component {
|
|||
newIndexPatternUrl: PropTypes.string.isRequired,
|
||||
services: PropTypes.array.isRequired,
|
||||
getEditUrl: PropTypes.func.isRequired,
|
||||
canGoInApp: PropTypes.func.isRequired,
|
||||
goInApp: PropTypes.func.isRequired,
|
||||
uiCapabilities: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.savedObjectTypes = POSSIBLE_TYPES.filter(type => {
|
||||
return this.props.uiCapabilities.savedObjectsManagement[type].read;
|
||||
});
|
||||
|
||||
this.state = {
|
||||
totalCount: 0,
|
||||
page: 0,
|
||||
perPage: props.perPageConfig || 50,
|
||||
savedObjects: [],
|
||||
savedObjectCounts: INCLUDED_TYPES.reduce((typeToCountMap, type) => {
|
||||
savedObjectCounts: this.savedObjectTypes.reduce((typeToCountMap, type) => {
|
||||
typeToCountMap[type] = 0;
|
||||
return typeToCountMap;
|
||||
}, {}),
|
||||
|
@ -126,7 +131,7 @@ class ObjectsTableUI extends Component {
|
|||
fetchCounts = async () => {
|
||||
const { queryText, visibleTypes } = parseQuery(this.state.activeQuery);
|
||||
|
||||
const filteredTypes = INCLUDED_TYPES.filter(
|
||||
const filteredTypes = this.savedObjectTypes.filter(
|
||||
type => !visibleTypes || visibleTypes.includes(type)
|
||||
);
|
||||
|
||||
|
@ -155,7 +160,7 @@ class ObjectsTableUI extends Component {
|
|||
// the table filter dropdown.
|
||||
const savedObjectCounts = await getSavedObjectCounts(
|
||||
this.props.$http,
|
||||
INCLUDED_TYPES,
|
||||
this.savedObjectTypes,
|
||||
queryText
|
||||
);
|
||||
|
||||
|
@ -183,7 +188,7 @@ class ObjectsTableUI extends Component {
|
|||
page: page + 1,
|
||||
fields: ['title', 'id'],
|
||||
searchFields: ['title'],
|
||||
type: INCLUDED_TYPES.filter(
|
||||
type: this.savedObjectTypes.filter(
|
||||
type => !visibleTypes || visibleTypes.includes(type)
|
||||
),
|
||||
};
|
||||
|
@ -388,6 +393,7 @@ class ObjectsTableUI extends Component {
|
|||
return await getRelationships(
|
||||
type,
|
||||
id,
|
||||
this.savedObjectTypes,
|
||||
this.props.$http,
|
||||
this.props.basePath
|
||||
);
|
||||
|
@ -405,6 +411,7 @@ class ObjectsTableUI extends Component {
|
|||
services={this.props.services}
|
||||
indexPatterns={this.props.indexPatterns}
|
||||
newIndexPatternUrl={this.props.newIndexPatternUrl}
|
||||
savedObjectTypes={this.props.savedObjectTypes}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -423,6 +430,7 @@ class ObjectsTableUI extends Component {
|
|||
close={this.onHideRelationships}
|
||||
getDashboardUrl={this.props.getDashboardUrl}
|
||||
getEditUrl={this.props.getEditUrl}
|
||||
canGoInApp={this.props.canGoInApp}
|
||||
goInApp={this.props.goInApp}
|
||||
/>
|
||||
);
|
||||
|
@ -659,12 +667,16 @@ class ObjectsTableUI extends Component {
|
|||
onSelectionChange: this.onSelectionChanged,
|
||||
};
|
||||
|
||||
const filterOptions = INCLUDED_TYPES.map(type => ({
|
||||
const filterOptions = this.savedObjectTypes.map(type => ({
|
||||
value: type,
|
||||
name: type,
|
||||
view: `${type} (${savedObjectCounts[type] || 0})`,
|
||||
}));
|
||||
|
||||
const canDeleteSavedObjectTypes = POSSIBLE_TYPES.filter(type => {
|
||||
return this.props.uiCapabilities.savedObjectsManagement[type].delete;
|
||||
});
|
||||
|
||||
return (
|
||||
<EuiPageContent
|
||||
horizontalPosition="center"
|
||||
|
@ -690,8 +702,10 @@ class ObjectsTableUI extends Component {
|
|||
onTableChange={this.onTableChange}
|
||||
filterOptions={filterOptions}
|
||||
onExport={this.onExport}
|
||||
canDeleteSavedObjectTypes={canDeleteSavedObjectTypes}
|
||||
onDelete={this.onDelete}
|
||||
getEditUrl={this.props.getEditUrl}
|
||||
canGoInApp={this.props.canGoInApp}
|
||||
goInApp={this.props.goInApp}
|
||||
pageIndex={page}
|
||||
pageSize={perPage}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { getInAppUrl } from '../get_in_app_url';
|
||||
|
||||
describe('getInAppUrl', () => {
|
||||
it('should handle saved searches', () => {
|
||||
expect(getInAppUrl(1, 'search')).toEqual('/discover/1');
|
||||
expect(getInAppUrl(1, 'searches')).toEqual('/discover/1');
|
||||
});
|
||||
|
||||
it('should handle visualizations', () => {
|
||||
expect(getInAppUrl(1, 'visualization')).toEqual('/visualize/edit/1');
|
||||
expect(getInAppUrl(1, 'visualizations')).toEqual('/visualize/edit/1');
|
||||
});
|
||||
|
||||
it('should handle index patterns', () => {
|
||||
expect(getInAppUrl(1, 'index-pattern')).toEqual(
|
||||
'/management/kibana/index_patterns/1'
|
||||
);
|
||||
expect(getInAppUrl(1, 'index-patterns')).toEqual(
|
||||
'/management/kibana/index_patterns/1'
|
||||
);
|
||||
expect(getInAppUrl(1, 'indexPatterns')).toEqual(
|
||||
'/management/kibana/index_patterns/1'
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle dashboards', () => {
|
||||
expect(getInAppUrl(1, 'dashboard')).toEqual('/dashboard/1');
|
||||
expect(getInAppUrl(1, 'dashboards')).toEqual('/dashboard/1');
|
||||
});
|
||||
|
||||
it('should have a default case', () => {
|
||||
expect(getInAppUrl(1, 'foo')).toEqual('/foo/1');
|
||||
});
|
||||
});
|
|
@ -24,7 +24,7 @@ describe('getRelationships', () => {
|
|||
const $http = jest.fn();
|
||||
const basePath = 'test';
|
||||
|
||||
await getRelationships('dashboard', 1, $http, basePath);
|
||||
await getRelationships('dashboard', 1, ['search', 'index-pattern'], $http, basePath);
|
||||
expect($http.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
|
@ -32,7 +32,7 @@ describe('getRelationships', () => {
|
|||
const $http = jest.fn().mockImplementation(() => ({ data: [1, 2] }));
|
||||
const basePath = 'test';
|
||||
|
||||
const response = await getRelationships('dashboard', 1, $http, basePath);
|
||||
const response = await getRelationships('dashboard', 1, ['search', 'index-pattern'], $http, basePath);
|
||||
expect(response).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
|
@ -48,7 +48,7 @@ describe('getRelationships', () => {
|
|||
const basePath = 'test';
|
||||
|
||||
try {
|
||||
await getRelationships('dashboard', 1, $http, basePath);
|
||||
await getRelationships('dashboard', 1, ['search', 'index-pattern'], $http, basePath);
|
||||
} catch (e) {
|
||||
// There isn't a great way to handle throwing exceptions
|
||||
// with async/await but this seems to work :shrug:
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { getInAppUrl, canViewInApp } from '../in_app_url';
|
||||
|
||||
describe('getInAppUrl', () => {
|
||||
it('should handle saved searches', () => {
|
||||
expect(getInAppUrl(1, 'search')).toEqual('/discover/1');
|
||||
expect(getInAppUrl(1, 'searches')).toEqual('/discover/1');
|
||||
});
|
||||
|
||||
it('should handle visualizations', () => {
|
||||
expect(getInAppUrl(1, 'visualization')).toEqual('/visualize/edit/1');
|
||||
expect(getInAppUrl(1, 'visualizations')).toEqual('/visualize/edit/1');
|
||||
});
|
||||
|
||||
it('should handle index patterns', () => {
|
||||
expect(getInAppUrl(1, 'index-pattern')).toEqual(
|
||||
'/management/kibana/index_patterns/1'
|
||||
);
|
||||
expect(getInAppUrl(1, 'index-patterns')).toEqual(
|
||||
'/management/kibana/index_patterns/1'
|
||||
);
|
||||
expect(getInAppUrl(1, 'indexPatterns')).toEqual(
|
||||
'/management/kibana/index_patterns/1'
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle dashboards', () => {
|
||||
expect(getInAppUrl(1, 'dashboard')).toEqual('/dashboard/1');
|
||||
expect(getInAppUrl(1, 'dashboards')).toEqual('/dashboard/1');
|
||||
});
|
||||
|
||||
it('should have a default case', () => {
|
||||
expect(getInAppUrl(1, 'foo')).toEqual('/foo/1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('canViewInApp', () => {
|
||||
it('should handle saved searches', () => {
|
||||
let uiCapabilities = {
|
||||
discover: {
|
||||
show: true,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'search')).toEqual(true);
|
||||
expect(canViewInApp(uiCapabilities, 'searches')).toEqual(true);
|
||||
|
||||
uiCapabilities = {
|
||||
discover: {
|
||||
show: false,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'search')).toEqual(false);
|
||||
expect(canViewInApp(uiCapabilities, 'searches')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should handle visualizations', () => {
|
||||
let uiCapabilities = {
|
||||
visualize: {
|
||||
show: true,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'visualization')).toEqual(true);
|
||||
expect(canViewInApp(uiCapabilities, 'visualizations')).toEqual(true);
|
||||
|
||||
uiCapabilities = {
|
||||
visualize: {
|
||||
show: false,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'visualization')).toEqual(false);
|
||||
expect(canViewInApp(uiCapabilities, 'visualizations')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should handle index patterns', () => {
|
||||
let uiCapabilities = {
|
||||
management: {
|
||||
kibana: {
|
||||
index_patterns: true
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'index-pattern')).toEqual(true);
|
||||
expect(canViewInApp(uiCapabilities, 'index-patterns')).toEqual(true);
|
||||
expect(canViewInApp(uiCapabilities, 'indexPatterns')).toEqual(true);
|
||||
|
||||
uiCapabilities = {
|
||||
management: {
|
||||
kibana: {
|
||||
index_patterns: false
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'index-pattern')).toEqual(false);
|
||||
expect(canViewInApp(uiCapabilities, 'index-patterns')).toEqual(false);
|
||||
expect(canViewInApp(uiCapabilities, 'indexPatterns')).toEqual(false);
|
||||
|
||||
});
|
||||
|
||||
it('should handle dashboards', () => {
|
||||
let uiCapabilities = {
|
||||
dashboard: {
|
||||
show: true,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'dashboard')).toEqual(true);
|
||||
expect(canViewInApp(uiCapabilities, 'dashboards')).toEqual(true);
|
||||
|
||||
uiCapabilities = {
|
||||
dashboard: {
|
||||
show: false,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'dashboard')).toEqual(false);
|
||||
expect(canViewInApp(uiCapabilities, 'dashboards')).toEqual(false);
|
||||
});
|
||||
|
||||
it('should have a default case', () => {
|
||||
let uiCapabilities = {
|
||||
foo: {
|
||||
show: true,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'foo')).toEqual(true);
|
||||
|
||||
uiCapabilities = {
|
||||
foo: {
|
||||
show: false,
|
||||
}
|
||||
};
|
||||
expect(canViewInApp(uiCapabilities, 'foo')).toEqual(false);
|
||||
});
|
||||
});
|
|
@ -19,11 +19,14 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
|
||||
export async function getRelationships(type, id, $http, basePath) {
|
||||
const url = `${basePath}/api/kibana/management/saved_objects/relationships/${type}/${id}`;
|
||||
export async function getRelationships(type, id, savedObjectTypes, $http, basePath) {
|
||||
const url = `${basePath}/api/kibana/management/saved_objects/relationships/${encodeURIComponent(type)}/${encodeURIComponent(id)}`;
|
||||
const options = {
|
||||
method: 'GET',
|
||||
url,
|
||||
params: {
|
||||
savedObjectTypes: savedObjectTypes
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -36,3 +36,23 @@ export function getInAppUrl(id, type) {
|
|||
return `/${type.toLowerCase()}/${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
export function canViewInApp(uiCapabilities, type) {
|
||||
switch (type) {
|
||||
case 'search':
|
||||
case 'searches':
|
||||
return uiCapabilities.discover.show;
|
||||
case 'visualization':
|
||||
case 'visualizations':
|
||||
return uiCapabilities.visualize.show;
|
||||
case 'index-pattern':
|
||||
case 'index-patterns':
|
||||
case 'indexPatterns':
|
||||
return uiCapabilities.management.kibana.index_patterns;
|
||||
case 'dashboard':
|
||||
case 'dashboards':
|
||||
return uiCapabilities.dashboard.show;
|
||||
default:
|
||||
return uiCapabilities[type].show;
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
export * from './fetch_export_by_type';
|
||||
export * from './fetch_export_objects';
|
||||
export * from './get_in_app_url';
|
||||
export * from './in_app_url';
|
||||
export * from './get_relationships';
|
||||
export * from './get_saved_object_counts';
|
||||
export * from './get_saved_object_icon';
|
||||
|
|
|
@ -319,6 +319,7 @@ exports[`AdvancedSettings should render normally 1`] = `
|
|||
}
|
||||
clear={[Function]}
|
||||
clearQuery={[Function]}
|
||||
enableSaving={true}
|
||||
save={[Function]}
|
||||
settings={
|
||||
Object {
|
||||
|
@ -601,6 +602,184 @@ exports[`AdvancedSettings should render normally 1`] = `
|
|||
</div>
|
||||
`;
|
||||
|
||||
exports[`AdvancedSettings should render read-only when saving is disabled 1`] = `
|
||||
<div>
|
||||
<EuiFlexGroup
|
||||
gutterSize="none"
|
||||
>
|
||||
<EuiFlexItem>
|
||||
<advanced_settings_page_title />
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<Search
|
||||
categories={
|
||||
Array [
|
||||
"general",
|
||||
"elasticsearch",
|
||||
]
|
||||
}
|
||||
onQueryChange={[Function]}
|
||||
query={
|
||||
Query {
|
||||
"ast": _AST {
|
||||
"_clauses": Array [
|
||||
Object {
|
||||
"field": "ariaName",
|
||||
"match": "must",
|
||||
"operator": "eq",
|
||||
"type": "field",
|
||||
"value": "test string setting",
|
||||
},
|
||||
],
|
||||
"_indexedClauses": Object {
|
||||
"field": Object {
|
||||
"ariaName": Array [
|
||||
Object {
|
||||
"field": "ariaName",
|
||||
"match": "must",
|
||||
"operator": "eq",
|
||||
"type": "field",
|
||||
"value": "test string setting",
|
||||
},
|
||||
],
|
||||
},
|
||||
"group": Array [],
|
||||
"is": Object {},
|
||||
"term": Array [],
|
||||
},
|
||||
},
|
||||
"syntax": Object {
|
||||
"parse": [Function],
|
||||
"print": [Function],
|
||||
"printClause": [Function],
|
||||
},
|
||||
"text": "ariaName:\\"test string setting\\"",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
<advanced_settings_page_subtitle />
|
||||
<EuiSpacer
|
||||
size="m"
|
||||
/>
|
||||
<CallOuts />
|
||||
<EuiSpacer
|
||||
size="m"
|
||||
/>
|
||||
<AdvancedSettingsVoiceAnnouncement
|
||||
queryText="ariaName:\\"test string setting\\""
|
||||
settings={
|
||||
Object {
|
||||
"general": Array [
|
||||
Object {
|
||||
"ariaName": "Test string setting",
|
||||
"category": Array [
|
||||
"general",
|
||||
],
|
||||
"defVal": null,
|
||||
"description": "Description for Test string setting",
|
||||
"displayName": "Test string setting",
|
||||
"isCustom": undefined,
|
||||
"isOverridden": false,
|
||||
"name": "test:string:setting",
|
||||
"optionLabels": undefined,
|
||||
"options": undefined,
|
||||
"readonly": false,
|
||||
"requiresPageReload": false,
|
||||
"type": "string",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
/>
|
||||
<InjectIntl(FormUI)
|
||||
categories={
|
||||
Array [
|
||||
"general",
|
||||
"elasticsearch",
|
||||
]
|
||||
}
|
||||
categoryCounts={
|
||||
Object {
|
||||
"elasticsearch": 2,
|
||||
"general": 11,
|
||||
}
|
||||
}
|
||||
clear={[Function]}
|
||||
clearQuery={[Function]}
|
||||
enableSaving={false}
|
||||
save={[Function]}
|
||||
settings={
|
||||
Object {
|
||||
"general": Array [
|
||||
Object {
|
||||
"ariaName": "Test string setting",
|
||||
"category": Array [
|
||||
"general",
|
||||
],
|
||||
"defVal": null,
|
||||
"description": "Description for Test string setting",
|
||||
"displayName": "Test string setting",
|
||||
"isCustom": undefined,
|
||||
"isOverridden": false,
|
||||
"name": "test:string:setting",
|
||||
"optionLabels": undefined,
|
||||
"options": undefined,
|
||||
"readonly": false,
|
||||
"requiresPageReload": false,
|
||||
"type": "string",
|
||||
"value": undefined,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
showNoResultsMessage={true}
|
||||
/>
|
||||
<advanced_settings_page_footer
|
||||
onQueryMatchChange={[Function]}
|
||||
query={
|
||||
Query {
|
||||
"ast": _AST {
|
||||
"_clauses": Array [
|
||||
Object {
|
||||
"field": "ariaName",
|
||||
"match": "must",
|
||||
"operator": "eq",
|
||||
"type": "field",
|
||||
"value": "test string setting",
|
||||
},
|
||||
],
|
||||
"_indexedClauses": Object {
|
||||
"field": Object {
|
||||
"ariaName": Array [
|
||||
Object {
|
||||
"field": "ariaName",
|
||||
"match": "must",
|
||||
"operator": "eq",
|
||||
"type": "field",
|
||||
"value": "test string setting",
|
||||
},
|
||||
],
|
||||
},
|
||||
"group": Array [],
|
||||
"is": Object {},
|
||||
"term": Array [],
|
||||
},
|
||||
},
|
||||
"syntax": Object {
|
||||
"parse": [Function],
|
||||
"print": [Function],
|
||||
"printClause": [Function],
|
||||
},
|
||||
"text": "ariaName:\\"test string setting\\"",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`AdvancedSettings should render specific setting if given setting key 1`] = `
|
||||
<div>
|
||||
<EuiFlexGroup
|
||||
|
@ -708,6 +887,7 @@ exports[`AdvancedSettings should render specific setting if given setting key 1`
|
|||
}
|
||||
clear={[Function]}
|
||||
clearQuery={[Function]}
|
||||
enableSaving={true}
|
||||
save={[Function]}
|
||||
settings={
|
||||
Object {
|
||||
|
|
|
@ -47,6 +47,7 @@ export class AdvancedSettings extends Component {
|
|||
static propTypes = {
|
||||
config: PropTypes.object.isRequired,
|
||||
query: PropTypes.string,
|
||||
enableSaving: PropTypes.bool.isRequired,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
|
@ -185,6 +186,7 @@ export class AdvancedSettings extends Component {
|
|||
save={this.saveConfig}
|
||||
clear={this.clearConfig}
|
||||
showNoResultsMessage={!footerQueryMatched}
|
||||
enableSaving={this.props.enableSaving}
|
||||
/>
|
||||
<PageFooter query={query} onQueryMatchChange={this.onFooterQueryMatchChange} />
|
||||
</div>
|
||||
|
|
|
@ -154,6 +154,7 @@ describe('AdvancedSettings', () => {
|
|||
const component = shallow(
|
||||
<AdvancedSettings
|
||||
config={config}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -165,6 +166,19 @@ describe('AdvancedSettings', () => {
|
|||
<AdvancedSettings
|
||||
config={config}
|
||||
query="test:string:setting"
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render read-only when saving is disabled', async () => {
|
||||
const component = shallow(
|
||||
<AdvancedSettings
|
||||
config={config}
|
||||
query="test:string:setting"
|
||||
enableSaving={false}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -1,5 +1,71 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Field for array setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Array test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="array:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Array test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"array:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="array:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiFieldText
|
||||
aria-label="array test setting"
|
||||
compressed={false}
|
||||
data-test-subj="advancedSetting-editField-array:test:setting"
|
||||
disabled={true}
|
||||
fullWidth={false}
|
||||
isLoading={false}
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
value="default_value"
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for array setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -351,6 +417,76 @@ exports[`Field for array setting should render user value if there is user value
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for boolean setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Boolean test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="boolean:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Boolean test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"boolean:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="boolean:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiSwitch
|
||||
aria-label="boolean test setting"
|
||||
checked={true}
|
||||
data-test-subj="advancedSetting-editField-boolean:test:setting"
|
||||
disabled={true}
|
||||
label={
|
||||
<FormattedMessage
|
||||
defaultMessage="On"
|
||||
id="kbn.management.settings.field.onLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
}
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for boolean setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -718,6 +854,70 @@ exports[`Field for boolean setting should render user value if there is user val
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for image setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Image test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="image:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Image test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"image:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="image:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiFilePicker
|
||||
accept=".jpg,.jpeg,.png"
|
||||
compressed={false}
|
||||
data-test-subj="advancedSetting-editField-image:test:setting"
|
||||
disabled={true}
|
||||
initialPromptText="Select or drag and drop a file"
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for image setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -1074,6 +1274,116 @@ exports[`Field for image setting should render user value if there is user value
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for json setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Json test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
<React.Fragment>
|
||||
<EuiSpacer
|
||||
size="s"
|
||||
/>
|
||||
<EuiText
|
||||
grow={true}
|
||||
size="xs"
|
||||
>
|
||||
<React.Fragment>
|
||||
<FormattedMessage
|
||||
defaultMessage="Default: {value}"
|
||||
id="kbn.management.settings.field.defaultValueTypeJsonText"
|
||||
values={
|
||||
Object {
|
||||
"value": <EuiCodeBlock
|
||||
language="json"
|
||||
overflowHeight={null}
|
||||
paddingSize="s"
|
||||
>
|
||||
{}
|
||||
</EuiCodeBlock>,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
</EuiText>
|
||||
</React.Fragment>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="json:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Json test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"json:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="json:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<div
|
||||
data-test-subj="advancedSetting-editField-json:test:setting"
|
||||
>
|
||||
<EuiCodeEditor
|
||||
aria-label="json test setting"
|
||||
editorProps={
|
||||
Object {
|
||||
"$blockScrolling": Infinity,
|
||||
}
|
||||
}
|
||||
height="auto"
|
||||
isReadOnly={true}
|
||||
maxLines={30}
|
||||
minLines={6}
|
||||
mode="json"
|
||||
onChange={[Function]}
|
||||
setOptions={
|
||||
Object {
|
||||
"showLineNumbers": false,
|
||||
"tabSize": 2,
|
||||
}
|
||||
}
|
||||
showGutter={false}
|
||||
theme="textmate"
|
||||
value="{\\"foo\\": \\"bar\\"}"
|
||||
width="100%"
|
||||
/>
|
||||
</div>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for json setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -1547,6 +1857,89 @@ exports[`Field for json setting should render user value if there is user value
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for markdown setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Markdown test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="markdown:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Markdown test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"markdown:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="markdown:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<div
|
||||
data-test-subj="advancedSetting-editField-markdown:test:setting"
|
||||
>
|
||||
<EuiCodeEditor
|
||||
aria-label="markdown test setting"
|
||||
editorProps={
|
||||
Object {
|
||||
"$blockScrolling": Infinity,
|
||||
}
|
||||
}
|
||||
height="auto"
|
||||
isReadOnly={true}
|
||||
maxLines={30}
|
||||
minLines={6}
|
||||
mode="markdown"
|
||||
onChange={[Function]}
|
||||
setOptions={
|
||||
Object {
|
||||
"showLineNumbers": false,
|
||||
"tabSize": 2,
|
||||
}
|
||||
}
|
||||
showGutter={false}
|
||||
theme="textmate"
|
||||
value=""
|
||||
width="100%"
|
||||
/>
|
||||
</div>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for markdown setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -1966,6 +2359,72 @@ exports[`Field for markdown setting should render user value if there is user va
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for number setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Number test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="number:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Number test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"number:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="number:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiFieldNumber
|
||||
aria-label="number test setting"
|
||||
compressed={false}
|
||||
data-test-subj="advancedSetting-editField-number:test:setting"
|
||||
disabled={true}
|
||||
fullWidth={false}
|
||||
isLoading={false}
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
value={5}
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for number setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -2317,6 +2776,89 @@ exports[`Field for number setting should render user value if there is user valu
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for select setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for Select test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="select:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
Select test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"select:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="select:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiSelect
|
||||
aria-label="select test setting"
|
||||
compressed={false}
|
||||
data-test-subj="advancedSetting-editField-select:test:setting"
|
||||
disabled={true}
|
||||
fullWidth={false}
|
||||
hasNoInitialSelection={false}
|
||||
isLoading={false}
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"text": "Apple",
|
||||
"value": "apple",
|
||||
},
|
||||
Object {
|
||||
"text": "Orange",
|
||||
"value": "orange",
|
||||
},
|
||||
Object {
|
||||
"text": "banana",
|
||||
"value": "banana",
|
||||
},
|
||||
]
|
||||
}
|
||||
value="orange"
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for select setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
@ -2736,6 +3278,72 @@ exports[`Field for select setting should render user value if there is user valu
|
|||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for string setting should render as read only if saving is disabled 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<EuiDescribedFormGroup
|
||||
className="mgtAdvancedSettings__fieldWrapper"
|
||||
description={
|
||||
<React.Fragment>
|
||||
<div
|
||||
dangerouslySetInnerHTML={
|
||||
Object {
|
||||
"__html": "Description for String test setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
fullWidth={false}
|
||||
gutterSize="l"
|
||||
idAria="string:test:setting-aria"
|
||||
title={
|
||||
<h3>
|
||||
String test setting
|
||||
|
||||
</h3>
|
||||
}
|
||||
titleSize="xs"
|
||||
>
|
||||
<EuiFormRow
|
||||
className="mgtAdvancedSettings__fieldRow"
|
||||
describedByIds={
|
||||
Array [
|
||||
"string:test:setting-aria",
|
||||
]
|
||||
}
|
||||
error={null}
|
||||
fullWidth={false}
|
||||
hasEmptyLabelSpace={false}
|
||||
helpText={null}
|
||||
isInvalid={false}
|
||||
label="string:test:setting"
|
||||
labelType="label"
|
||||
>
|
||||
<EuiFieldText
|
||||
aria-label="string test setting"
|
||||
compressed={false}
|
||||
data-test-subj="advancedSetting-editField-string:test:setting"
|
||||
disabled={true}
|
||||
fullWidth={false}
|
||||
isLoading={false}
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
value=""
|
||||
/>
|
||||
</EuiFormRow>
|
||||
</EuiDescribedFormGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
/>
|
||||
</EuiFlexGroup>
|
||||
`;
|
||||
|
||||
exports[`Field for string setting should render as read only with help text if overridden 1`] = `
|
||||
<EuiFlexGroup
|
||||
className="mgtAdvancedSettings__field"
|
||||
|
|
|
@ -57,6 +57,7 @@ class FieldUI extends PureComponent {
|
|||
setting: PropTypes.object.isRequired,
|
||||
save: PropTypes.func.isRequired,
|
||||
clear: PropTypes.func.isRequired,
|
||||
enableSaving: PropTypes.bool.isRequired,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
|
@ -380,6 +381,7 @@ class FieldUI extends PureComponent {
|
|||
}
|
||||
|
||||
renderField(setting) {
|
||||
const { enableSaving } = this.props;
|
||||
const { loading, changeImage, unsavedValue } = this.state;
|
||||
const { name, value, type, options, optionLabels = {}, isOverridden, ariaName } = setting;
|
||||
|
||||
|
@ -400,7 +402,7 @@ class FieldUI extends PureComponent {
|
|||
)}
|
||||
checked={!!unsavedValue}
|
||||
onChange={this.onFieldChange}
|
||||
disabled={loading || isOverridden}
|
||||
disabled={loading || isOverridden || !enableSaving}
|
||||
onKeyDown={this.onFieldKeyDown}
|
||||
data-test-subj={`advancedSetting-editField-${name}`}
|
||||
aria-label={ariaName}
|
||||
|
@ -420,7 +422,7 @@ class FieldUI extends PureComponent {
|
|||
height="auto"
|
||||
minLines={6}
|
||||
maxLines={30}
|
||||
isReadOnly={isOverridden}
|
||||
isReadOnly={isOverridden || !enableSaving}
|
||||
setOptions={{
|
||||
showLineNumbers: false,
|
||||
tabSize: 2,
|
||||
|
@ -445,7 +447,7 @@ class FieldUI extends PureComponent {
|
|||
} else {
|
||||
return (
|
||||
<EuiFilePicker
|
||||
disabled={loading || isOverridden}
|
||||
disabled={loading || isOverridden || !enableSaving}
|
||||
onChange={this.onImageChange}
|
||||
accept=".jpg,.jpeg,.png"
|
||||
ref={(input) => { this.changeImageForm = input; }}
|
||||
|
@ -467,7 +469,7 @@ class FieldUI extends PureComponent {
|
|||
})}
|
||||
onChange={this.onFieldChange}
|
||||
isLoading={loading}
|
||||
disabled={loading || isOverridden}
|
||||
disabled={loading || isOverridden || !enableSaving}
|
||||
onKeyDown={this.onFieldKeyDown}
|
||||
data-test-subj={`advancedSetting-editField-${name}`}
|
||||
/>
|
||||
|
@ -479,7 +481,7 @@ class FieldUI extends PureComponent {
|
|||
value={unsavedValue}
|
||||
onChange={this.onFieldChange}
|
||||
isLoading={loading}
|
||||
disabled={loading || isOverridden}
|
||||
disabled={loading || isOverridden || !enableSaving}
|
||||
onKeyDown={this.onFieldKeyDown}
|
||||
data-test-subj={`advancedSetting-editField-${name}`}
|
||||
/>
|
||||
|
@ -491,7 +493,7 @@ class FieldUI extends PureComponent {
|
|||
value={unsavedValue}
|
||||
onChange={this.onFieldChange}
|
||||
isLoading={loading}
|
||||
disabled={loading || isOverridden}
|
||||
disabled={loading || isOverridden || !enableSaving}
|
||||
onKeyDown={this.onFieldKeyDown}
|
||||
data-test-subj={`advancedSetting-editField-${name}`}
|
||||
/>
|
||||
|
@ -515,10 +517,11 @@ class FieldUI extends PureComponent {
|
|||
);
|
||||
}
|
||||
|
||||
const canUpdateSetting = this.props.enableSaving;
|
||||
const defaultLink = this.renderResetToDefaultLink(setting);
|
||||
const imageLink = this.renderChangeImageLink(setting);
|
||||
|
||||
if (defaultLink || imageLink) {
|
||||
if (canUpdateSetting && (defaultLink || imageLink)) {
|
||||
return (
|
||||
<span>
|
||||
{defaultLink}
|
||||
|
|
|
@ -168,6 +168,7 @@ describe('Field', () => {
|
|||
setting={setting}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -184,6 +185,20 @@ describe('Field', () => {
|
|||
}}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render as read only if saving is disabled', async () => {
|
||||
const component = shallowWithIntl(
|
||||
<Field.WrappedComponent
|
||||
setting={setting}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={false}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -199,6 +214,7 @@ describe('Field', () => {
|
|||
}}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -214,6 +230,7 @@ describe('Field', () => {
|
|||
}}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -231,6 +248,7 @@ describe('Field', () => {
|
|||
}}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
const select = findTestSubject(component, `advancedSetting-editField-${setting.name}`);
|
||||
|
@ -247,6 +265,7 @@ describe('Field', () => {
|
|||
}}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
const select = findTestSubject(component, `advancedSetting-editField-${setting.name}`);
|
||||
|
@ -262,6 +281,7 @@ describe('Field', () => {
|
|||
setting={setting}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -318,6 +338,7 @@ describe('Field', () => {
|
|||
setting={setting}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -364,6 +385,7 @@ describe('Field', () => {
|
|||
setting={setting}
|
||||
save={save}
|
||||
clear={clear}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ exports[`Form should render normally 1`] = `
|
|||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={true}
|
||||
key="general:test:date"
|
||||
save={[Function]}
|
||||
setting={
|
||||
|
@ -77,6 +78,7 @@ exports[`Form should render normally 1`] = `
|
|||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={true}
|
||||
key="setting:test"
|
||||
save={[Function]}
|
||||
setting={
|
||||
|
@ -123,6 +125,7 @@ exports[`Form should render normally 1`] = `
|
|||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={true}
|
||||
key="dashboard:test:setting"
|
||||
save={[Function]}
|
||||
setting={
|
||||
|
@ -196,6 +199,197 @@ exports[`Form should render normally 1`] = `
|
|||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={true}
|
||||
key="xpack:test:setting"
|
||||
save={[Function]}
|
||||
setting={
|
||||
Object {
|
||||
"ariaName": "xpack test setting",
|
||||
"category": Array [
|
||||
"x-pack",
|
||||
],
|
||||
"description": "bar",
|
||||
"displayName": "X-Pack test setting",
|
||||
"name": "xpack:test:setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</EuiForm>
|
||||
</EuiPanel>
|
||||
<EuiSpacer
|
||||
size="l"
|
||||
/>
|
||||
</Fragment>
|
||||
`;
|
||||
|
||||
exports[`Form should render read-only when saving is disabled 1`] = `
|
||||
<Fragment>
|
||||
<EuiPanel
|
||||
grow={true}
|
||||
hasShadow={false}
|
||||
paddingSize="l"
|
||||
>
|
||||
<EuiForm>
|
||||
<EuiText
|
||||
grow={true}
|
||||
size="m"
|
||||
>
|
||||
<EuiFlexGroup
|
||||
alignItems="baseline"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<h2>
|
||||
General
|
||||
</h2>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiText>
|
||||
<EuiSpacer
|
||||
size="m"
|
||||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={false}
|
||||
key="general:test:date"
|
||||
save={[Function]}
|
||||
setting={
|
||||
Object {
|
||||
"ariaName": "general test date",
|
||||
"category": Array [
|
||||
"general",
|
||||
],
|
||||
"description": "bar",
|
||||
"displayName": "Test date",
|
||||
"name": "general:test:date",
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={false}
|
||||
key="setting:test"
|
||||
save={[Function]}
|
||||
setting={
|
||||
Object {
|
||||
"ariaName": "setting test",
|
||||
"category": Array [
|
||||
"general",
|
||||
],
|
||||
"description": "foo",
|
||||
"displayName": "Test setting",
|
||||
"name": "setting:test",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</EuiForm>
|
||||
</EuiPanel>
|
||||
<EuiSpacer
|
||||
size="l"
|
||||
/>
|
||||
<EuiPanel
|
||||
grow={true}
|
||||
hasShadow={false}
|
||||
paddingSize="l"
|
||||
>
|
||||
<EuiForm>
|
||||
<EuiText
|
||||
grow={true}
|
||||
size="m"
|
||||
>
|
||||
<EuiFlexGroup
|
||||
alignItems="baseline"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<h2>
|
||||
Dashboard
|
||||
</h2>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiText>
|
||||
<EuiSpacer
|
||||
size="m"
|
||||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={false}
|
||||
key="dashboard:test:setting"
|
||||
save={[Function]}
|
||||
setting={
|
||||
Object {
|
||||
"ariaName": "dashboard test setting",
|
||||
"category": Array [
|
||||
"dashboard",
|
||||
],
|
||||
"displayName": "Dashboard test setting",
|
||||
"name": "dashboard:test:setting",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</EuiForm>
|
||||
</EuiPanel>
|
||||
<EuiSpacer
|
||||
size="l"
|
||||
/>
|
||||
<EuiPanel
|
||||
grow={true}
|
||||
hasShadow={false}
|
||||
paddingSize="l"
|
||||
>
|
||||
<EuiForm>
|
||||
<EuiText
|
||||
grow={true}
|
||||
size="m"
|
||||
>
|
||||
<EuiFlexGroup
|
||||
alignItems="baseline"
|
||||
>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<h2>
|
||||
X-pack
|
||||
</h2>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem
|
||||
grow={false}
|
||||
>
|
||||
<em>
|
||||
<FormattedMessage
|
||||
defaultMessage="Search terms are hiding {settingsCount} settings {clearSearch}"
|
||||
id="kbn.management.settings.form.searchResultText"
|
||||
values={
|
||||
Object {
|
||||
"clearSearch": <EuiLink
|
||||
color="primary"
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
<em>
|
||||
<FormattedMessage
|
||||
defaultMessage="(clear search)"
|
||||
id="kbn.management.settings.form.clearSearchResultText"
|
||||
values={Object {}}
|
||||
/>
|
||||
</em>
|
||||
</EuiLink>,
|
||||
"settingsCount": 9,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</em>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiText>
|
||||
<EuiSpacer
|
||||
size="m"
|
||||
/>
|
||||
<Field
|
||||
clear={[Function]}
|
||||
enableSaving={false}
|
||||
key="xpack:test:setting"
|
||||
save={[Function]}
|
||||
setting={
|
||||
|
|
|
@ -44,6 +44,7 @@ class FormUI extends PureComponent {
|
|||
save: PropTypes.func.isRequired,
|
||||
clear: PropTypes.func.isRequired,
|
||||
showNoResultsMessage: PropTypes.bool.isRequired,
|
||||
enableSaving: PropTypes.bool.isRequired,
|
||||
}
|
||||
|
||||
renderClearQueryLink(totalSettings, currentSettings) {
|
||||
|
@ -99,6 +100,7 @@ class FormUI extends PureComponent {
|
|||
setting={setting}
|
||||
save={this.props.save}
|
||||
clear={this.props.clear}
|
||||
enableSaving={this.props.enableSaving}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -84,6 +84,24 @@ describe('Form', () => {
|
|||
clear={clear}
|
||||
clearQuery={clearQuery}
|
||||
showNoResultsMessage={true}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(component).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render read-only when saving is disabled', async () => {
|
||||
const component = shallowWithIntl(
|
||||
<Form.WrappedComponent
|
||||
settings={settings}
|
||||
categories={categories}
|
||||
categoryCounts={categoryCounts}
|
||||
save={save}
|
||||
clear={clear}
|
||||
clearQuery={clearQuery}
|
||||
showNoResultsMessage={true}
|
||||
enableSaving={false}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -100,6 +118,7 @@ describe('Form', () => {
|
|||
clear={clear}
|
||||
clearQuery={clearQuery}
|
||||
showNoResultsMessage={true}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
@ -116,6 +135,7 @@ describe('Form', () => {
|
|||
clear={clear}
|
||||
clearQuery={clearQuery}
|
||||
showNoResultsMessage={false}
|
||||
enableSaving={true}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import { management } from 'ui/management';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import indexTemplate from './index.html';
|
||||
import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
|
||||
|
@ -44,6 +45,7 @@ function updateAdvancedSettings($scope, config, query) {
|
|||
<AdvancedSettings
|
||||
config={config}
|
||||
query={query}
|
||||
enableSaving={uiCapabilities.advancedSettings.save}
|
||||
/>
|
||||
</I18nContext>,
|
||||
node,
|
||||
|
@ -59,7 +61,8 @@ function destroyAdvancedSettings() {
|
|||
uiRoutes
|
||||
.when('/management/kibana/settings/:setting?', {
|
||||
template: indexTemplate,
|
||||
k7Breadcrumbs: getBreadcrumbs
|
||||
k7Breadcrumbs: getBreadcrumbs,
|
||||
requireUICapability: 'management.kibana.settings',
|
||||
});
|
||||
|
||||
uiModules.get('apps/management')
|
||||
|
|
|
@ -315,13 +315,13 @@ class TableListViewUi extends React.Component {
|
|||
pageSizeOptions: PAGE_SIZE_OPTIONS,
|
||||
};
|
||||
|
||||
const selection = {
|
||||
const selection = this.props.deleteItems ? {
|
||||
onSelectionChange: (selection) => {
|
||||
this.setState({
|
||||
selectedIds: selection.map(item => { return item.id; })
|
||||
});
|
||||
}
|
||||
};
|
||||
} : null;
|
||||
|
||||
const actions = [{
|
||||
name: i18n.translate('kbn.table_list_view.listing.table.editActionName', {
|
||||
|
@ -345,7 +345,7 @@ class TableListViewUi extends React.Component {
|
|||
};
|
||||
|
||||
const columns = this.props.tableColumns.slice();
|
||||
if (!this.props.hideWriteControls) {
|
||||
if (this.props.editItem) {
|
||||
columns.push({
|
||||
name: i18n.translate('kbn.table_list_view.listing.table.actionTitle', {
|
||||
defaultMessage: 'Actions'
|
||||
|
@ -374,7 +374,7 @@ class TableListViewUi extends React.Component {
|
|||
selection={selection}
|
||||
search={search}
|
||||
sorting={true}
|
||||
hasActions={!this.state.hideWriteControls}
|
||||
hasActions={this.props.editItem}
|
||||
data-test-subj="itemsInMemTable"
|
||||
/>
|
||||
);
|
||||
|
@ -390,7 +390,7 @@ class TableListViewUi extends React.Component {
|
|||
|
||||
renderListing() {
|
||||
let createButton;
|
||||
if (!this.props.hideWriteControls) {
|
||||
if (this.props.createItem) {
|
||||
createButton = (
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton
|
||||
|
@ -467,12 +467,11 @@ TableListViewUi.propTypes = {
|
|||
noItemsFragment: PropTypes.object,
|
||||
|
||||
findItems: PropTypes.func.isRequired,
|
||||
deleteItems: PropTypes.func.isRequired,
|
||||
createItem: PropTypes.func.isRequired,
|
||||
editItem: PropTypes.func.isRequired,
|
||||
deleteItems: PropTypes.func,
|
||||
createItem: PropTypes.func,
|
||||
editItem: PropTypes.func,
|
||||
|
||||
listingLimit: PropTypes.number,
|
||||
hideWriteControls: PropTypes.bool.isRequired,
|
||||
initialFilter: PropTypes.string,
|
||||
|
||||
entityName: PropTypes.string.isRequired,
|
||||
|
|
|
@ -23,6 +23,8 @@ import './visualization_editor';
|
|||
import 'ui/vis/editors/default/sidebar';
|
||||
import 'ui/visualize';
|
||||
import 'ui/collapsible_sidebar';
|
||||
import 'ui/query_bar';
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import 'ui/search_bar';
|
||||
import 'ui/apply_filters';
|
||||
import 'ui/listen';
|
||||
|
@ -148,7 +150,7 @@ function VisEditor(
|
|||
dirty: !savedVis.id
|
||||
};
|
||||
|
||||
$scope.topNavMenu = [{
|
||||
$scope.topNavMenu = [...(uiCapabilities.visualize.save ? [{
|
||||
key: i18n('kbn.topNavMenu.saveVisualizationButtonLabel', { defaultMessage: 'save' }),
|
||||
description: i18n('kbn.visualize.topNavMenu.saveVisualizationButtonAriaLabel', {
|
||||
defaultMessage: 'Save Visualization',
|
||||
|
@ -201,7 +203,7 @@ function VisEditor(
|
|||
/>);
|
||||
showSaveModal(saveModal);
|
||||
}
|
||||
}, {
|
||||
}] : []), {
|
||||
key: i18n('kbn.topNavMenu.shareVisualizationButtonLabel', { defaultMessage: 'share' }),
|
||||
description: i18n('kbn.visualize.topNavMenu.shareVisualizationButtonAriaLabel', {
|
||||
defaultMessage: 'Share Visualization',
|
||||
|
@ -213,6 +215,7 @@ function VisEditor(
|
|||
showShareContextMenu({
|
||||
anchorElement,
|
||||
allowEmbed: true,
|
||||
allowShortUrl: uiCapabilities.visualize.createShortUrl,
|
||||
getUnhashableStates,
|
||||
objectId: savedVis.id,
|
||||
objectType: 'visualization',
|
||||
|
|
|
@ -36,6 +36,7 @@ export interface VisualizeEmbeddableConfiguration {
|
|||
savedVisualization: VisSavedObject;
|
||||
indexPatterns?: StaticIndexPattern[];
|
||||
editUrl?: string;
|
||||
editable: boolean;
|
||||
loader: VisualizeLoader;
|
||||
}
|
||||
|
||||
|
@ -56,11 +57,13 @@ export class VisualizeEmbeddable extends Embeddable {
|
|||
savedVisualization,
|
||||
indexPatterns,
|
||||
editUrl,
|
||||
editable,
|
||||
loader,
|
||||
}: VisualizeEmbeddableConfiguration) {
|
||||
super({
|
||||
title: savedVisualization.title,
|
||||
editUrl,
|
||||
editable,
|
||||
indexPatterns,
|
||||
});
|
||||
this.onEmbeddableStateChanged = onEmbeddableStateChanged;
|
||||
|
|
|
@ -23,6 +23,7 @@ import { EmbeddableFactory } from 'ui/embeddable';
|
|||
import { getVisualizeLoader } from 'ui/visualize/loader';
|
||||
|
||||
import { Legacy } from 'kibana';
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import {
|
||||
EmbeddableInstanceConfiguration,
|
||||
OnEmbeddableStateChanged,
|
||||
|
@ -89,6 +90,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<VisualizationA
|
|||
) {
|
||||
const visId = panelMetadata.id;
|
||||
const editUrl = this.getEditPath(visId);
|
||||
const editable: boolean = uiCapabilities.visualize.save as boolean;
|
||||
|
||||
const loader = await getVisualizeLoader();
|
||||
const savedObject = await this.savedVisualizations.get(visId);
|
||||
|
@ -104,6 +106,7 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<VisualizationA
|
|||
onEmbeddableStateChanged,
|
||||
savedVisualization: savedObject,
|
||||
editUrl,
|
||||
editable,
|
||||
loader,
|
||||
indexPatterns,
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ import './saved_visualizations/_saved_vis';
|
|||
import './saved_visualizations/saved_visualizations';
|
||||
import 'ui/filter_bar';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import 'ui/capabilities/route_setup';
|
||||
import visualizeListingTemplate from './listing/visualize_listing.html';
|
||||
import { VisualizeListingController } from './listing/visualize_listing';
|
||||
import { VisualizeConstants } from './visualize_constants';
|
||||
|
@ -30,7 +31,8 @@ import { getLandingBreadcrumbs, getWizardStep1Breadcrumbs } from './breadcrumbs'
|
|||
|
||||
uiRoutes
|
||||
.defaults(/visualize/, {
|
||||
requireDefaultIndex: true
|
||||
requireDefaultIndex: true,
|
||||
requireUICapability: 'visualize.show',
|
||||
})
|
||||
.when(VisualizeConstants.LANDING_PAGE_PATH, {
|
||||
template: visualizeListingTemplate,
|
||||
|
|
|
@ -21,7 +21,7 @@ import React, { Component, Fragment } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import { TableListView } from './../../table_list_view';
|
||||
|
||||
import {
|
||||
|
@ -42,14 +42,15 @@ class VisualizeListingTableUi extends Component {
|
|||
const { intl } = this.props;
|
||||
return (
|
||||
<TableListView
|
||||
// we allow users to create visualizations even if they can't save them
|
||||
// for data exploration purposes
|
||||
createItem={this.props.createItem}
|
||||
findItems={this.props.findItems}
|
||||
deleteItems={this.props.deleteItems}
|
||||
editItem={this.props.editItem}
|
||||
deleteItems={uiCapabilities.visualize.delete ? this.props.deleteItems : null}
|
||||
editItem={uiCapabilities.visualize.save ? this.props.editItem : null}
|
||||
tableColumns={this.getTableColumns()}
|
||||
listingLimit={100}
|
||||
initialFilter={''}
|
||||
hideWriteControls={false}
|
||||
noItemsFragment={this.getNoItemsMessage()}
|
||||
entityName={
|
||||
intl.formatMessage({
|
||||
|
|
|
@ -25,7 +25,12 @@ export async function findRelationships(type, id, options = {}) {
|
|||
} = options;
|
||||
|
||||
const { references = [] } = await savedObjectsClient.get(type, id);
|
||||
const bulkGetOpts = references.map(ref => ({ id: ref.id, type: ref.type }));
|
||||
|
||||
// we filter the objects which we execute bulk requests for based on the saved
|
||||
// object types as well, these are the only types we should be concerned with
|
||||
const bulkGetOpts = references
|
||||
.filter(({ type }) => savedObjectTypes.includes(type))
|
||||
.map(ref => ({ id: ref.id, type: ref.type }));
|
||||
|
||||
const [referencedObjects, referencedResponse] = await Promise.all([
|
||||
bulkGetOpts.length > 0
|
||||
|
|
|
@ -32,6 +32,7 @@ export function registerRelationships(server) {
|
|||
}),
|
||||
query: Joi.object().keys({
|
||||
size: Joi.number().default(10000),
|
||||
savedObjectTypes: Joi.array().single().items(Joi.string()).required()
|
||||
}),
|
||||
},
|
||||
},
|
||||
|
@ -40,13 +41,13 @@ export function registerRelationships(server) {
|
|||
const type = req.params.type;
|
||||
const id = req.params.id;
|
||||
const size = req.query.size;
|
||||
const savedObjectTypes = req.query.savedObjectTypes;
|
||||
const savedObjectsClient = req.getSavedObjectsClient();
|
||||
|
||||
return await findRelationships(type, id, {
|
||||
size,
|
||||
savedObjectsClient,
|
||||
// Pass in all types except space, spaces wrapper will throw error
|
||||
savedObjectTypes: server.savedObjects.types.filter(type => type !== 'space'),
|
||||
savedObjectTypes,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -85,6 +85,24 @@ new CoreSystem({
|
|||
enabled: true,
|
||||
enableExternalUrls: true
|
||||
},
|
||||
uiCapabilities: {
|
||||
navLinks: {
|
||||
myLink: true,
|
||||
notMyLink: true,
|
||||
},
|
||||
discover: {
|
||||
showWriteControls: true
|
||||
},
|
||||
visualize: {
|
||||
save: true
|
||||
},
|
||||
dashboard: {
|
||||
showWriteControls: true
|
||||
},
|
||||
timelion: {
|
||||
save: true
|
||||
},
|
||||
},
|
||||
interpreterConfig: {
|
||||
enableInVisualize: true
|
||||
}
|
||||
|
|
|
@ -64,7 +64,15 @@ export default function (kibana) {
|
|||
'plugins/timelion/register_feature'
|
||||
],
|
||||
mappings: require('./mappings.json'),
|
||||
|
||||
injectDefaultVars() {
|
||||
return {
|
||||
uiCapabilities: {
|
||||
timelion: {
|
||||
save: true,
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
uiSettingDefaults: {
|
||||
'timelion:showTutorial': {
|
||||
name: i18n.translate('timelion.uiSettings.showTutorialLabel', {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
|
||||
import { uiCapabilities } from 'ui/capabilities';
|
||||
import { DocTitleProvider } from 'ui/doc_title';
|
||||
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
|
||||
import { notify, fatalError, toastNotifications } from 'ui/notify';
|
||||
|
@ -127,112 +128,7 @@ app.controller('timelion', function (
|
|||
const defaultExpression = '.es(*)';
|
||||
const savedSheet = $route.current.locals.savedSheet;
|
||||
|
||||
$scope.topNavMenu = [{
|
||||
key: 'new',
|
||||
label: i18n('timelion.topNavMenu.newSheetButtonLabel', {
|
||||
defaultMessage: 'New',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.newSheetButtonAriaLabel', {
|
||||
defaultMessage: 'New Sheet',
|
||||
}),
|
||||
run: function () { kbnUrl.change('/'); },
|
||||
testId: 'timelionNewButton',
|
||||
}, {
|
||||
key: 'add',
|
||||
label: i18n('timelion.topNavMenu.addChartButtonLabel', {
|
||||
defaultMessage: 'Add',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.addChartButtonAriaLabel', {
|
||||
defaultMessage: 'Add a chart',
|
||||
}),
|
||||
run: function () { $scope.newCell(); },
|
||||
testId: 'timelionAddChartButton',
|
||||
}, {
|
||||
key: 'save',
|
||||
label: i18n('timelion.topNavMenu.saveSheetButtonLabel', {
|
||||
defaultMessage: 'Save',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.saveSheetButtonAriaLabel', {
|
||||
defaultMessage: 'Save Sheet',
|
||||
}),
|
||||
template: require('plugins/timelion/partials/save_sheet.html'),
|
||||
testId: 'timelionSaveButton',
|
||||
}, {
|
||||
key: 'delete',
|
||||
label: i18n('timelion.topNavMenu.deleteSheetButtonLabel', {
|
||||
defaultMessage: 'Delete',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.deleteSheetButtonAriaLabel', {
|
||||
defaultMessage: 'Delete current sheet',
|
||||
}),
|
||||
disableButton: function () {
|
||||
return !savedSheet.id;
|
||||
},
|
||||
run: function () {
|
||||
const title = savedSheet.title;
|
||||
function doDelete() {
|
||||
savedSheet.delete().then(() => {
|
||||
toastNotifications.addSuccess(i18n(
|
||||
'timelion.topNavMenu.delete.modal.successNotificationText',
|
||||
{
|
||||
defaultMessage: `Deleted '{title}'`,
|
||||
values: { title },
|
||||
}
|
||||
));
|
||||
kbnUrl.change('/');
|
||||
}).catch(error => fatalError(error, location));
|
||||
}
|
||||
|
||||
const confirmModalOptions = {
|
||||
onConfirm: doDelete,
|
||||
confirmButtonText: i18n('timelion.topNavMenu.delete.modal.confirmButtonLabel', {
|
||||
defaultMessage: 'Delete',
|
||||
}),
|
||||
title: i18n('timelion.topNavMenu.delete.modalTitle', {
|
||||
defaultMessage: `Delete Timelion sheet '{title}'?`,
|
||||
values: { title }
|
||||
}),
|
||||
};
|
||||
|
||||
confirmModal(
|
||||
i18n('timelion.topNavMenu.delete.modal.warningText', {
|
||||
defaultMessage: `You can't recover deleted sheets.`,
|
||||
}),
|
||||
confirmModalOptions
|
||||
);
|
||||
},
|
||||
testId: 'timelionDeleteButton',
|
||||
}, {
|
||||
key: 'open',
|
||||
label: i18n('timelion.topNavMenu.openSheetButtonLabel', {
|
||||
defaultMessage: 'Open',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.openSheetButtonAriaLabel', {
|
||||
defaultMessage: 'Open Sheet',
|
||||
}),
|
||||
template: require('plugins/timelion/partials/load_sheet.html'),
|
||||
testId: 'timelionOpenButton',
|
||||
}, {
|
||||
key: 'options',
|
||||
label: i18n('timelion.topNavMenu.optionsButtonLabel', {
|
||||
defaultMessage: 'Options',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.optionsButtonAriaLabel', {
|
||||
defaultMessage: 'Options',
|
||||
}),
|
||||
template: require('plugins/timelion/partials/sheet_options.html'),
|
||||
testId: 'timelionOptionsButton',
|
||||
}, {
|
||||
key: 'help',
|
||||
label: i18n('timelion.topNavMenu.helpButtonLabel', {
|
||||
defaultMessage: 'Help',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.helpButtonAriaLabel', {
|
||||
defaultMessage: 'Help',
|
||||
}),
|
||||
template: '<timelion-help></timelion-help>',
|
||||
testId: 'timelionDocsButton',
|
||||
}];
|
||||
$scope.topNavMenu = getTopNavMenu();
|
||||
|
||||
$timeout(function () {
|
||||
if (config.get('timelion:showTutorial', true)) {
|
||||
|
@ -252,6 +148,133 @@ app.controller('timelion', function (
|
|||
};
|
||||
}
|
||||
|
||||
function getTopNavMenu() {
|
||||
|
||||
const newSheetAction = {
|
||||
key: 'new',
|
||||
label: i18n('timelion.topNavMenu.newSheetButtonLabel', {
|
||||
defaultMessage: 'New',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.newSheetButtonAriaLabel', {
|
||||
defaultMessage: 'New Sheet',
|
||||
}),
|
||||
run: function () { kbnUrl.change('/'); },
|
||||
testId: 'timelionNewButton',
|
||||
};
|
||||
|
||||
const addSheetAction = {
|
||||
key: 'add',
|
||||
label: i18n('timelion.topNavMenu.addChartButtonLabel', {
|
||||
defaultMessage: 'Add',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.addChartButtonAriaLabel', {
|
||||
defaultMessage: 'Add a chart',
|
||||
}),
|
||||
run: function () { $scope.newCell(); },
|
||||
testId: 'timelionAddChartButton',
|
||||
};
|
||||
|
||||
const saveSheetAction = {
|
||||
key: 'save',
|
||||
label: i18n('timelion.topNavMenu.saveSheetButtonLabel', {
|
||||
defaultMessage: 'Save',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.saveSheetButtonAriaLabel', {
|
||||
defaultMessage: 'Save Sheet',
|
||||
}),
|
||||
template: require('plugins/timelion/partials/save_sheet.html'),
|
||||
testId: 'timelionSaveButton',
|
||||
};
|
||||
|
||||
const deleteSheetAction = {
|
||||
key: 'delete',
|
||||
label: i18n('timelion.topNavMenu.deleteSheetButtonLabel', {
|
||||
defaultMessage: 'Delete',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.deleteSheetButtonAriaLabel', {
|
||||
defaultMessage: 'Delete current sheet',
|
||||
}),
|
||||
disableButton: function () {
|
||||
return !savedSheet.id;
|
||||
},
|
||||
run: function () {
|
||||
const title = savedSheet.title;
|
||||
function doDelete() {
|
||||
savedSheet.delete().then(() => {
|
||||
toastNotifications.addSuccess(i18n(
|
||||
'timelion.topNavMenu.delete.modal.successNotificationText',
|
||||
{
|
||||
defaultMessage: `Deleted '{title}'`,
|
||||
values: { title },
|
||||
}
|
||||
));
|
||||
kbnUrl.change('/');
|
||||
}).catch(error => fatalError(error, location));
|
||||
}
|
||||
|
||||
const confirmModalOptions = {
|
||||
onConfirm: doDelete,
|
||||
confirmButtonText: i18n('timelion.topNavMenu.delete.modal.confirmButtonLabel', {
|
||||
defaultMessage: 'Delete',
|
||||
}),
|
||||
title: i18n('timelion.topNavMenu.delete.modalTitle', {
|
||||
defaultMessage: `Delete Timelion sheet '{title}'?`,
|
||||
values: { title }
|
||||
}),
|
||||
};
|
||||
|
||||
confirmModal(
|
||||
i18n('timelion.topNavMenu.delete.modal.warningText', {
|
||||
defaultMessage: `You can't recover deleted sheets.`,
|
||||
}),
|
||||
confirmModalOptions
|
||||
);
|
||||
},
|
||||
testId: 'timelionDeleteButton',
|
||||
};
|
||||
|
||||
const openSheetAction = {
|
||||
key: 'open',
|
||||
label: i18n('timelion.topNavMenu.openSheetButtonLabel', {
|
||||
defaultMessage: 'Open',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.openSheetButtonAriaLabel', {
|
||||
defaultMessage: 'Open Sheet',
|
||||
}),
|
||||
template: require('plugins/timelion/partials/load_sheet.html'),
|
||||
testId: 'timelionOpenButton',
|
||||
};
|
||||
|
||||
const optionsAction = {
|
||||
key: 'options',
|
||||
label: i18n('timelion.topNavMenu.optionsButtonLabel', {
|
||||
defaultMessage: 'Options',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.optionsButtonAriaLabel', {
|
||||
defaultMessage: 'Options',
|
||||
}),
|
||||
template: require('plugins/timelion/partials/sheet_options.html'),
|
||||
testId: 'timelionOptionsButton',
|
||||
};
|
||||
|
||||
const helpAction = {
|
||||
key: 'help',
|
||||
label: i18n('timelion.topNavMenu.helpButtonLabel', {
|
||||
defaultMessage: 'Help',
|
||||
}),
|
||||
description: i18n('timelion.topNavMenu.helpButtonAriaLabel', {
|
||||
defaultMessage: 'Help',
|
||||
}),
|
||||
template: '<timelion-help></timelion-help>',
|
||||
testId: 'timelionDocsButton',
|
||||
};
|
||||
|
||||
if (uiCapabilities.timelion.save) {
|
||||
return [newSheetAction, addSheetAction, saveSheetAction, deleteSheetAction, openSheetAction, optionsAction, helpAction];
|
||||
}
|
||||
return [newSheetAction, addSheetAction, openSheetAction, optionsAction, helpAction];
|
||||
}
|
||||
|
||||
const init = function () {
|
||||
$scope.running = false;
|
||||
$scope.search();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="list-group">
|
||||
<button class="list-group-item" ng-click="section = 'sheet'" type="button">
|
||||
<button class="list-group-item" ng-click="section = 'sheet'" type="button" data-test-subj="timelionSaveAsSheetButton">
|
||||
<h4
|
||||
class="list-group-item-heading"
|
||||
i18n-id="timelion.topNavMenu.save.saveEntireSheetTitle"
|
||||
|
@ -44,6 +44,7 @@
|
|||
class="kuiButton kuiButton--primary kuiVerticalRhythmSmall"
|
||||
i18n-id="timelion.topNavMenu.save.saveEntireSheet.submitButtonLabel"
|
||||
i18n-default-message="Save"
|
||||
data-test-subj="timelionFinishSaveButton"
|
||||
></button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -62,6 +62,7 @@ export class PluginSpec {
|
|||
deprecations,
|
||||
preInit,
|
||||
init,
|
||||
postInit,
|
||||
isEnabled,
|
||||
} = options;
|
||||
|
||||
|
@ -81,6 +82,7 @@ export class PluginSpec {
|
|||
this._isEnabled = isEnabled;
|
||||
this._preInit = preInit;
|
||||
this._init = init;
|
||||
this._postInit = postInit;
|
||||
|
||||
if (!this.getId()) {
|
||||
throw createInvalidPluginError(this, 'Unable to determine plugin id');
|
||||
|
@ -176,6 +178,10 @@ export class PluginSpec {
|
|||
return this._init;
|
||||
}
|
||||
|
||||
getPostInitHandler() {
|
||||
return this._postInit;
|
||||
}
|
||||
|
||||
getConfigPrefix() {
|
||||
return this._configPrefix || this.getId();
|
||||
}
|
||||
|
|
|
@ -43,4 +43,5 @@ export async function initializeMixin(kbnServer, server, config) {
|
|||
|
||||
await callHookOnPlugins('preInit');
|
||||
await callHookOnPlugins('init');
|
||||
await callHookOnPlugins('postInit');
|
||||
}
|
||||
|
|
|
@ -43,12 +43,14 @@ export class Plugin {
|
|||
this.requiredIds = spec.getRequiredPluginIds() || [];
|
||||
this.externalPreInit = spec.getPreInitHandler();
|
||||
this.externalInit = spec.getInitHandler();
|
||||
this.externalPostInit = spec.getPostInitHandler();
|
||||
this.enabled = spec.isEnabled(kbnServer.config);
|
||||
this.configPrefix = spec.getConfigPrefix();
|
||||
this.publicDir = spec.getPublicDir();
|
||||
|
||||
this.preInit = once(this.preInit);
|
||||
this.init = once(this.init);
|
||||
this.postInit = once(this.postInit);
|
||||
}
|
||||
|
||||
async preInit() {
|
||||
|
@ -96,6 +98,12 @@ export class Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
async postInit() {
|
||||
if (this.externalPostInit) {
|
||||
return await this.externalPostInit(this.kbnServer.server);
|
||||
}
|
||||
}
|
||||
|
||||
getServer() {
|
||||
return this._server;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue