Skip to content

Commit

Permalink
[UnifiedFieldList] Convert from a plugin into a package (#158718)
Browse files Browse the repository at this point in the history
- Closes #149336

## Summary

This PR converts `unifiedFieldList` plugin into a new
`@kbn/unified-field-list` package.

Had to also move some deps:
- from `uiActions` plugin to the existing `@kbn/ui-actions-browser`
package
- from `data` plugin to a new `@kbn/data-service` package

Please test that Field Stats from the package are still working on your
pages.

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
jughosta and kibanamachine authored Jun 23, 2023
1 parent 2bf4ed4 commit 7f0d57d
Show file tree
Hide file tree
Showing 231 changed files with 405 additions and 361 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ x-pack/plugins/dashboard_enhanced @elastic/kibana-presentation
src/plugins/dashboard @elastic/kibana-presentation
src/plugins/data @elastic/kibana-visualizations @elastic/kibana-data-discovery
test/plugin_functional/plugins/data_search @elastic/kibana-app-services
packages/kbn-data-service @elastic/kibana-visualizations @elastic/kibana-data-discovery
src/plugins/data_view_editor @elastic/kibana-data-discovery
examples/data_view_field_editor_example @elastic/kibana-app-services
src/plugins/data_view_field_editor @elastic/kibana-data-discovery
Expand Down Expand Up @@ -719,8 +720,8 @@ test/plugin_functional/plugins/ui_settings_plugin @elastic/kibana-core
packages/kbn-ui-shared-deps-npm @elastic/kibana-operations
packages/kbn-ui-shared-deps-src @elastic/kibana-operations
packages/kbn-ui-theme @elastic/kibana-operations
packages/kbn-unified-field-list @elastic/kibana-data-discovery
examples/unified_field_list_examples @elastic/kibana-data-discovery
src/plugins/unified_field_list @elastic/kibana-data-discovery
src/plugins/unified_histogram @elastic/kibana-data-discovery
src/plugins/unified_search @elastic/kibana-visualizations
x-pack/plugins/upgrade_assistant @elastic/platform-deployment-management
Expand Down
4 changes: 2 additions & 2 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"statusPage": "src/legacy/core_plugins/status_page",
"telemetry": ["src/plugins/telemetry", "src/plugins/telemetry_management_section"],
"timelion": ["src/plugins/vis_types/timelion"],
"uiActions": "src/plugins/ui_actions",
"uiActions": ["src/plugins/ui_actions", "packages/kbn-ui-actions-browser"],
"uiActionsEnhanced": "src/plugins/ui_actions_enhanced",
"uiActionsExamples": "examples/ui_action_examples",
"usageCollection": "src/plugins/usage_collection",
Expand All @@ -114,7 +114,7 @@
"visualizations": "src/plugins/visualizations",
"visualizationUiComponents": "src/plugins/visualization_ui_components",
"unifiedSearch": "src/plugins/unified_search",
"unifiedFieldList": "src/plugins/unified_field_list",
"unifiedFieldList": "packages/kbn-unified-field-list",
"unifiedHistogram": "src/plugins/unified_histogram"
},
"translations": []
Expand Down
4 changes: 0 additions & 4 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ In general this plugin provides:
|Registers commercially licensed generic actions like per panel time range and contains some code that supports drilldown work.
|{kib-repo}blob/{branch}/src/plugins/unified_field_list/README.md[unifiedFieldList]
|This Kibana plugin contains components and services for field list UI (as in fields sidebar on Discover and Lens pages).
|{kib-repo}blob/{branch}/src/plugins/unified_histogram/README.md[unifiedHistogram]
|Unified Histogram is a UX Building Block including a layout with a resizable histogram and a main display.
It manages its own state and data fetching, and can easily be dropped into pages with minimal setup.
Expand Down
1 change: 0 additions & 1 deletion examples/unified_field_list_examples/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"inspector",
"kibanaUtils",
"unifiedSearch",
"unifiedFieldList",
"data",
"dataViews",
"dataViewFieldEditor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
hasQuerySubscriberData,
RenderFieldItemParams,
useQuerySubscriber,
} from '@kbn/unified-field-list-plugin/public';
} from '@kbn/unified-field-list';
import { generateFilters } from '@kbn/data-plugin/public';
import type { CoreStart } from '@kbn/core-lifecycle-browser';
import type { AppPluginStartDependencies } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
useExistingFieldsFetcher,
useGroupedFields,
useQuerySubscriber,
} from '@kbn/unified-field-list-plugin/public';
} from '@kbn/unified-field-list';
import { FieldListItem, FieldListItemProps } from './field_list_item';

export interface FieldListSidebarProps {
Expand Down
2 changes: 1 addition & 1 deletion examples/unified_field_list_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class UnifiedFieldListExamplesPlugin
links: [
{
label: 'README',
href: 'https://github.com/elastic/kibana/tree/main/src/plugins/unified_field_list/README.md',
href: 'https://github.com/elastic/kibana/tree/main/packages/kbn-unified-field-list/README.md',
iconType: 'logoGithub',
target: '_blank',
size: 's',
Expand Down
2 changes: 1 addition & 1 deletion examples/unified_field_list_examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"@kbn/i18n-react",
"@kbn/i18n",
"@kbn/dom-drag-drop",
"@kbn/unified-field-list-plugin",
"@kbn/core-lifecycle-browser",
"@kbn/charts-plugin",
"@kbn/field-formats-plugin",
"@kbn/data-view-field-editor-plugin",
"@kbn/unified-field-list",
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
"@kbn/dashboard-plugin": "link:src/plugins/dashboard",
"@kbn/data-plugin": "link:src/plugins/data",
"@kbn/data-search-plugin": "link:test/plugin_functional/plugins/data_search",
"@kbn/data-service": "link:packages/kbn-data-service",
"@kbn/data-view-editor-plugin": "link:src/plugins/data_view_editor",
"@kbn/data-view-field-editor-example-plugin": "link:examples/data_view_field_editor_example",
"@kbn/data-view-field-editor-plugin": "link:src/plugins/data_view_field_editor",
Expand Down Expand Up @@ -709,8 +710,8 @@
"@kbn/ui-shared-deps-npm": "link:packages/kbn-ui-shared-deps-npm",
"@kbn/ui-shared-deps-src": "link:packages/kbn-ui-shared-deps-src",
"@kbn/ui-theme": "link:packages/kbn-ui-theme",
"@kbn/unified-field-list": "link:packages/kbn-unified-field-list",
"@kbn/unified-field-list-examples-plugin": "link:examples/unified_field_list_examples",
"@kbn/unified-field-list-plugin": "link:src/plugins/unified_field_list",
"@kbn/unified-histogram-plugin": "link:src/plugins/unified_histogram",
"@kbn/unified-search-plugin": "link:src/plugins/unified_search",
"@kbn/upgrade-assistant-plugin": "link:x-pack/plugins/upgrade_assistant",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-data-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/data-service

A package version of `data` plugin.
12 changes: 12 additions & 0 deletions packages/kbn-data-service/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export type { GetConfigFn } from './src/types';
export { UI_SETTINGS } from './src/constants';
export { getEsQueryConfig } from './src/es_query';
export { tabifyDocs, flattenHit } from './src/search/tabify';
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

module.exports = {
preset: '@kbn/test',
rootDir: '../../..',
roots: ['<rootDir>/src/plugins/unified_field_list'],
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/src/plugins/unified_field_list',
coverageReporters: ['text', 'html'],
collectCoverageFrom: ['<rootDir>/src/plugins/unified_field_list/public/**/*.{ts,tsx}'],
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-data-service'],
};
8 changes: 8 additions & 0 deletions packages/kbn-data-service/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "shared-common",
"id": "@kbn/data-service",
"owner": [
"@elastic/kibana-visualizations",
"@elastic/kibana-data-discovery"
]
}
7 changes: 7 additions & 0 deletions packages/kbn-data-service/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/data-service",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"sideEffects": false
}
34 changes: 34 additions & 0 deletions packages/kbn-data-service/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const UI_SETTINGS = {
META_FIELDS: 'metaFields',
DOC_HIGHLIGHT: 'doc_table:highlight',
QUERY_STRING_OPTIONS: 'query:queryString:options',
QUERY_ALLOW_LEADING_WILDCARDS: 'query:allowLeadingWildcards',
SEARCH_QUERY_LANGUAGE: 'search:queryLanguage',
SORT_OPTIONS: 'sort:options',
COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX: 'courier:ignoreFilterIfFieldNotInIndex',
COURIER_SET_REQUEST_PREFERENCE: 'courier:setRequestPreference',
COURIER_CUSTOM_REQUEST_PREFERENCE: 'courier:customRequestPreference',
COURIER_MAX_CONCURRENT_SHARD_REQUESTS: 'courier:maxConcurrentShardRequests',
SEARCH_INCLUDE_FROZEN: 'search:includeFrozen',
SEARCH_TIMEOUT: 'search:timeout',
HISTOGRAM_BAR_TARGET: 'histogram:barTarget',
HISTOGRAM_MAX_BARS: 'histogram:maxBars',
HISTORY_LIMIT: 'history:limit',
TIMEPICKER_REFRESH_INTERVAL_DEFAULTS: 'timepicker:refreshIntervalDefaults',
TIMEPICKER_QUICK_RANGES: 'timepicker:quickRanges',
TIMEPICKER_TIME_DEFAULTS: 'timepicker:timeDefaults',
FILTERS_PINNED_BY_DEFAULT: 'filters:pinnedByDefault',
FILTERS_EDITOR_SUGGEST_VALUES: 'filterEditor:suggestValues',
AUTOCOMPLETE_USE_TIMERANGE: 'autocomplete:useTimeRange',
AUTOCOMPLETE_VALUE_SUGGESTION_METHOD: 'autocomplete:valueSuggestionMethod',
DATE_FORMAT: 'dateFormat',
DATEFORMAT_TZ: 'dateFormat:tz',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { get } from 'lodash';
import { getEsQueryConfig } from './get_es_query_config';
import { IUiSettingsClient } from '@kbn/core/public';
import { UI_SETTINGS } from '..';
import { UI_SETTINGS } from '../constants';

const config = {
get(item: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { EsQueryConfig } from '@kbn/es-query';
import { GetConfigFn, UI_SETTINGS } from '..';
import { GetConfigFn } from '../types';
import { UI_SETTINGS } from '../constants';

interface KibanaConfig {
get: GetConfigFn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export type { FieldStatsResponse, BucketedAggregation, NumberSummary } from './stats';
export { getEsQueryConfig } from './get_es_query_config';
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
* Side Public License, v 1.
*/

export const PLUGIN_ID = 'unifiedFieldList';
export { tabifyDocs, flattenHit } from './tabify_docs';
19 changes: 19 additions & 0 deletions packages/kbn-data-service/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

/**
* If a service is being shared on both the client and the server, and
* the client code requires synchronous access to uiSettings, both client
* and server should wrap the core uiSettings services in a function
* matching this signature.
*
* This matches the signature of the public `core.uiSettings.get`, and
* should only be used in scenarios where async access to uiSettings is
* not possible.
*/
export type GetConfigFn = <T = any>(key: string, defaultOverride?: T) => T;
15 changes: 15 additions & 0 deletions packages/kbn-data-service/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types"
},
"include": ["*.ts", "src/**/*"],
"kbn_references": [
"@kbn/core",
"@kbn/es-query",
"@kbn/data-views-plugin",
"@kbn/field-formats-plugin",
"@kbn/expressions-plugin",
],
"exclude": ["target/**/*"]
}
1 change: 0 additions & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ pageLoadAssetSize:
triggersActionsUi: 135613
uiActions: 35121
uiActionsEnhanced: 38494
unifiedFieldList: 65500
unifiedHistogram: 19928
unifiedSearch: 71059
upgradeAssistant: 81241
Expand Down
14 changes: 13 additions & 1 deletion packages/kbn-ui-actions-browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@
* Side Public License, v 1.
*/

export * from './src';
export * from './src/types';
export type { Trigger, RowClickContext } from './src/triggers';
export {
VISUALIZE_FIELD_TRIGGER,
visualizeFieldTrigger,
VISUALIZE_GEO_FIELD_TRIGGER,
visualizeGeoFieldTrigger,
ROW_CLICK_TRIGGER,
rowClickTrigger,
CATEGORIZE_FIELD_TRIGGER,
categorizeFieldTrigger,
defaultTrigger,
} from './src/triggers';
1 change: 1 addition & 0 deletions packages/kbn-ui-actions-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*/

export * from './types';
export * from './triggers';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { Trigger } from '.';
import { Trigger } from './trigger';

export const CATEGORIZE_FIELD_TRIGGER = 'CATEGORIZE_FIELD_TRIGGER';
export const categorizeFieldTrigger: Trigger = {
Expand Down
14 changes: 14 additions & 0 deletions packages/kbn-ui-actions-browser/src/triggers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * from './trigger';
export * from './row_click_trigger';
export * from './default_trigger';
export * from './visualize_field_trigger';
export * from './visualize_geo_field_trigger';
export * from './categorize_field_trigger';
5 changes: 4 additions & 1 deletion packages/kbn-ui-actions-browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"exclude": [
"target/**/*"
],
"kbn_references": []
"kbn_references": [
"@kbn/i18n",
"@kbn/expressions-plugin",
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# unifiedFieldList
# @kbn/unified-field-list

This Kibana plugin contains components and services for field list UI (as in fields sidebar on Discover and Lens pages).
This Kibana package contains components and services for field list UI (as in fields sidebar on Discover and Lens pages).

---

Expand Down
Loading

0 comments on commit 7f0d57d

Please sign in to comment.