From e6671e5210b44e723de52353d2d2da74e6451e57 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Tue, 14 Jan 2020 16:40:27 -0500 Subject: [PATCH 001/186] initial discover DataGrid proof of concept --- src/core/public/chrome/ui/header/_index.scss | 4 + .../public/discover/get_inner_angular.ts | 4 +- .../public/discover/np_ready/_discover.scss | 15 - .../np_ready/angular/directives/_index.scss | 2 +- .../discover/np_ready/angular/discover.html | 60 +-- .../discover/np_ready/angular/discover.js | 31 +- .../public/discover/np_ready/angular/doc.ts | 1 - .../discover/np_ready/components/_index.scss | 1 + .../components/discover_grid/_index.scss | 1 + .../components/discover_grid/_table.scss | 10 + .../create_discover_grid_directive.tsx | 24 ++ .../discover_grid/discover_grid.tsx | 404 ++++++++++++++++++ .../_collapsible_sidebar.scss | 11 +- .../public/index_patterns/fields/field.ts | 3 +- .../index_patterns/index_pattern.ts | 4 +- 15 files changed, 503 insertions(+), 72 deletions(-) create mode 100644 src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_index.scss create mode 100644 src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss create mode 100644 src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/create_discover_grid_directive.tsx create mode 100644 src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx diff --git a/src/core/public/chrome/ui/header/_index.scss b/src/core/public/chrome/ui/header/_index.scss index f19728a52dd70..1ab1885fe01d2 100644 --- a/src/core/public/chrome/ui/header/_index.scss +++ b/src/core/public/chrome/ui/header/_index.scss @@ -8,6 +8,10 @@ z-index: 10; } +.euiDataGrid__restrictBody .chrHeaderWrapper { + z-index: 0; +} + .chrHeaderWrapper ~ .app-wrapper:not(.hidden-chrome) { top: $euiHeaderChildSize; left: $euiHeaderChildSize; diff --git a/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts b/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts index 1cefabe08c2d5..351b52f8b0322 100644 --- a/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts +++ b/src/legacy/core_plugins/kibana/public/discover/get_inner_angular.ts @@ -82,6 +82,7 @@ import { createDocViewerDirective } from './np_ready/angular/doc_viewer'; import { createFieldSearchDirective } from './np_ready/components/field_chooser/discover_field_search_directive'; import { createIndexPatternSelectDirective } from './np_ready/components/field_chooser/discover_index_pattern_directive'; import { createStringFieldProgressBarDirective } from './np_ready/components/field_chooser/string_progress_bar'; +import { createDiscoverGridDirective } from './np_ready/components/discover_grid/create_discover_grid_directive'; // @ts-ignore import { createFieldChooserDirective } from './np_ready/components/field_chooser/field_chooser'; @@ -329,5 +330,6 @@ function createDocTableModule() { .directive('kbnTableRow', createTableRowDirective) .directive('toolBarPagerButtons', createToolBarPagerButtonsDirective) .directive('kbnInfiniteScroll', createInfiniteScrollDirective) - .directive('docViewer', createDocViewerDirective); + .directive('docViewer', createDocViewerDirective) + .directive('discoverGrid', createDiscoverGridDirective); } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss index 0da28e41579ae..534c95f460d71 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss @@ -28,11 +28,9 @@ discover-app { padding-right: $euiSizeS; } -// SASSTODO: replace the z-index value with a variable .dscWrapper { padding-right: $euiSizeS; padding-left: 21px; - z-index: 1; } @include euiPanel('.dscWrapper__content'); @@ -94,19 +92,6 @@ discover-app { .dscTable { overflow: auto; - - // SASSTODO: add a monospace modifier to the doc-table component - .kbnDocTable__row { - font-family: $euiCodeFontFamily; - font-size: $euiFontSizeXS; - } -} - -// SASSTODO: replace the padding value with a variable -.dscTable__footer { - background-color: $euiColorLightShade; - padding: 5px 10px; - text-align: center; } /** diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/_index.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/_index.scss index c65243d99c8f4..d4b365547b40c 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/_index.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/directives/_index.scss @@ -1,2 +1,2 @@ @import 'no_results'; -@import 'histogram'; \ No newline at end of file +@import 'histogram'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html index 45490ac7adc0f..66125b9eace09 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html @@ -161,7 +161,6 @@

{{screenTitle}}

- {{screenTitle}} > -
-

+

- - - - -
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index 78ac99567d10e..99b63b6abd736 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -17,6 +17,7 @@ * under the License. */ +import rison from 'rison-node'; import _ from 'lodash'; import React from 'react'; import { Subscription } from 'rxjs'; @@ -73,7 +74,7 @@ const { } = getServices(); import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../helpers/breadcrumbs'; -import { generateFilters } from '../../../../../../../plugins/data/public'; +import { esFilters, generateFilters } from '../../../../../../../plugins/data/public'; import { getIndexPatternId } from '../helpers/get_index_pattern_id'; import { FilterStateManager } from '../../../../../data/public'; @@ -186,8 +187,8 @@ function discoverController( $scope, $timeout, $window, + $httpParamSerializer, AppState, - Private, Promise, config, kbnUrl, @@ -220,6 +221,7 @@ function discoverController( $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.refreshInterval = timefilter.getRefreshInterval(); $scope.showSaveQuery = uiCapabilities.discover.saveQuery; + $scope.useShortDots = config.get('shortDots:enable'); $scope.$watch( () => uiCapabilities.discover.saveQuery, @@ -553,10 +555,33 @@ function discoverController( }); }; - $scope.$watchCollection('state.columns', function() { + $scope.$watchCollection('state.columns', function(columns) { + const tableColumns = [...columns]; + const { timeFieldName } = $scope.indexPattern; + + if (!config.get('doc_table:hideTimeColumn') && timeFieldName) { + tableColumns.unshift(timeFieldName); + } + + $scope.tableColumns = tableColumns; $state.save(); }); + $scope.getContextAppHref = anchorId => { + const path = kbnUrl.eval('#/context/{{ indexPattern }}/{{ anchorId }}', { + anchorId, + indexPattern: $scope.indexPattern.id, + }); + + const hash = $httpParamSerializer({ + _a: rison.encode({ + columns: $state.columns, + filters: ($scope.filters || []).map(esFilters.disableFilter), + }), + }); + return `${path}?${hash}`; + }; + $scope.opts = { // number of records to fetch, then paginate through sampleSize: config.get('discover:sampleSize'), diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc.ts index 459dcfb30d17b..39bdbc93ab7ce 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc.ts @@ -17,7 +17,6 @@ * under the License. */ import { getAngularModule, wrapInI18nContext, getServices } from '../../kibana_services'; -// @ts-ignore import { getRootBreadcrumbs } from '../helpers/breadcrumbs'; import html from './doc.html'; import { Doc } from '../components/doc/doc'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss index 0491430e5fddd..4097ad6fb95f0 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss @@ -1,3 +1,4 @@ @import 'fetch_error/index'; @import 'field_chooser/index'; @import 'doc_viewer/index'; +@import 'data_grid/index'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_index.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_index.scss new file mode 100644 index 0000000000000..999e0d69e2480 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_index.scss @@ -0,0 +1 @@ +@import 'table'; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss new file mode 100644 index 0000000000000..23823ab78fa9e --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss @@ -0,0 +1,10 @@ +.dscTable__footer { + background-color: $euiColorLightShade; + padding: $euiSize / 2 $euiSize; + margin-top: $euiSize / 4; + text-align: center; +} + +.dscTable__flyoutHeader { + white-space: nowrap; +} diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/create_discover_grid_directive.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/create_discover_grid_directive.tsx new file mode 100644 index 0000000000000..c861ed9ec18fc --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/create_discover_grid_directive.tsx @@ -0,0 +1,24 @@ +/* + * 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 { wrapInI18nContext } from '../../../kibana_services'; +import { DiscoverGrid } from './discover_grid'; + +export function createDiscoverGridDirective(reactDirective: any) { + return reactDirective(wrapInI18nContext(DiscoverGrid)); +} diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx new file mode 100644 index 0000000000000..b06d9e6570561 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -0,0 +1,404 @@ +/* + * 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 React, { useMemo, useState, useCallback, ReactNode } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiButtonToggle, + EuiDataGrid, + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiIcon, + EuiLink, + EuiPortal, + EuiTitle, + useRenderToText, + htmlIdGenerator, + EuiButtonEmpty, + EuiSpacer, + EuiDataGridColumn, + EuiDataGridCellValueElementProps, +} from '@elastic/eui'; +import { DocViewer } from '../doc_viewer/doc_viewer'; +import { IndexPattern } from '../../../kibana_services'; +import { ElasticSearchHit, DocViewFilterFn } from '../../doc_views/doc_views_types'; +import { shortenDottedString } from '../../../../../../../../plugins/data/common/utils/shorten_dotted_string'; + +type Direction = 'asc' | 'desc'; +type SortArr = [string, Direction]; +interface SortObj { + id: string; + direction: Direction; +} + +interface Props { + rows: ElasticSearchHit[]; + columns: string[]; + sort: SortArr[]; + ariaLabelledBy: string; + indexPattern: IndexPattern; + searchTitle?: string; + searchDescription?: string; + sampleSize: number; + onFilter: DocViewFilterFn; + useShortDots: boolean; + onSort: Function; + getContextAppHref: (id: string | number | Record) => string; + onRemoveColumn: (column: string) => void; + onAddColumn: (column: string) => void; +} + +const cellPopoverRenderer = ( + value: string | ReactNode, + positiveFilterClick: () => void, + negativeFilterClick: () => void +) => { + return ( + <> + {value} + + + + + Filter on value + + + + + Filter without value + + + + + ); +}; + +export function DiscoverGrid({ + rows, + columns, + sort, + indexPattern, + ariaLabelledBy, + searchTitle, + searchDescription, + useShortDots, + onSort, + sampleSize, + onFilter, + getContextAppHref, + onRemoveColumn, + onAddColumn, +}: Props) { + const actionColumnId = 'uniqueString'; // TODO should be guaranteed unique... + const lowestPageSize = 50; + const timeNode = useMemo( + () => ( + + {i18n.translate('kbn.discover.timeLabel', { + defaultMessage: 'Time', + })} + + ), + [] + ); + const timeString = useRenderToText(timeNode, 'Time'); + const [flyoutRow, setFlyoutRow] = useState(undefined); + + const dataGridColumns = columns.map( + (columnName, i): EuiDataGridColumn => { + // Discover always injects a Time column as the first item (unless advance settings turned it off) + // Have to guard against this to allow users to request the same column again later + if (columnName === indexPattern.timeFieldName && i === 0) { + return { id: timeString, schema: 'datetime' }; + } + + const column: EuiDataGridColumn = { + id: columnName, + schema: indexPattern.getFieldByName(columnName)?.type, + }; + + // Default DataGrid schemas: boolean, numeric, datetime, json, currency + // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts + switch (column.schema) { + case 'date': + column.schema = 'datetime'; + break; + case 'numeric': + column.schema = 'number'; + break; + case '_source': + case 'object': + column.schema = 'json'; + break; + } + + if (useShortDots) { + column.display = <>{shortenDottedString(columnName)}; + } + + return column; + } + ); + + dataGridColumns.unshift({ id: actionColumnId, isExpandable: false, display: <> }); + + /** + * Pagination + */ + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: lowestPageSize }); + const onChangeItemsPerPage = useCallback( + pageSize => setPagination(paginationData => ({ ...paginationData, pageSize })), + [setPagination] + ); + const onChangePage = useCallback( + pageIndex => setPagination(paginationData => ({ ...paginationData, pageIndex })), + [setPagination] + ); + + /** + * Sorting + */ + const sortingColumns = useMemo(() => sort.map(([id, direction]) => ({ id, direction })), [sort]); + const onTableSort = useCallback( + sortingColumnsData => { + onSort(sortingColumnsData.map(({ id, direction }: SortObj) => [id, direction])); + }, + [onSort] + ); + + /** + * Visibility and order + */ + const [visibleColumns, setVisibleColumns] = useState(dataGridColumns.map(obj => obj.id)); + + /** + * Cell rendering + */ + const renderCellValue = useMemo(() => { + const showFilterActions = (isDetails: boolean, fieldName: string) => { + return isDetails && indexPattern.fields.getByName(fieldName)?.filterable; + }; + const createFilter = (fieldName: string, row: any, type: '-' | '+') => { + return onFilter( + indexPattern.fields.getByName(fieldName), + indexPattern.flattenHit(row)[fieldName], + type + ); + }; + const formattedField = function(row: any, columnId: string) { + const formattedValue = indexPattern.formatField(row, columnId); + + // TODO Field formatters need to be fixed + // eslint-disable-next-line react/no-danger + return ; + }; + + return ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { + const adjustedRowIndex = rowIndex - pagination.pageIndex * pagination.pageSize; + const row = rows[adjustedRowIndex]; + let value: string | ReactNode; + value = '-'; + + if (typeof row === 'undefined') { + return value; + } + + if (columnId === actionColumnId) { + const showFlyout = typeof flyoutRow === 'undefined'; + + return ( + setFlyoutRow(row)} + isSelected={showFlyout} + isEmpty + isIconOnly + /> + ); + } + + const fieldName = columnId === timeString ? indexPattern.timeFieldName! : columnId; + value = formattedField(row, fieldName); + + if (showFilterActions(isDetails, fieldName)) { + return cellPopoverRenderer( + value, + () => createFilter(fieldName, rows[rowIndex], '+'), + () => createFilter(fieldName, rows[rowIndex], '-') + ); + } + + return value; + }; + }, [ + indexPattern, + onFilter, + pagination.pageIndex, + pagination.pageSize, + rows, + timeString, + flyoutRow, + ]); + + /** + * Render variables + */ + const pageCount = Math.ceil(rows.length / pagination.pageSize); + const isOnLastPage = pagination.pageIndex === pageCount - 1; + const showDisclaimer = rows.length === sampleSize && isOnLastPage; + const randomId = htmlIdGenerator()(); + let searchString: ReactNode = <>; + if (searchTitle) { + if (searchDescription) { + searchString = i18n.translate('kbn.discover.timeLabel', { + defaultMessage: 'Table generated by search {searchTitle} ({searchDescription})', + values: { searchTitle, searchDescription }, + }); + } else { + searchString = i18n.translate('kbn.discover.timeLabel', { + defaultMessage: 'Table generated by search {searchTitle}', + values: { searchTitle }, + }); + } + } + + return ( + <> + + {showDisclaimer && ( + <> +

+ {i18n.translate('kbn.discover.howToSeeOtherMatchingDocumentsDescription', { + defaultMessage: + 'These are the first {sampleSize} documents matching your search, refine your search to see others. ', + values: { sampleSize }, + })} + + {i18n.translate('kbn.discover.backToTopLinkText', { + defaultMessage: 'Back to top.', + })} + +

+ + )} + {searchString &&

{searchString}

} + {typeof flyoutRow !== 'undefined' && ( + + setFlyoutRow(undefined)} size="l" ownFocus> + + + + + + + + + +

+ {i18n.translate('kbn.docTable.tableRow.detailHeading', { + defaultMessage: 'Expanded document', + })} +

+
+
+
+
+ + + {indexPattern.isTimeBased() && ( + + + {i18n.translate( + 'kbn.docTable.tableRow.viewSurroundingDocumentsLinkText', + { + defaultMessage: 'View surrounding documents', + } + )} + + + )} + + + {i18n.translate('kbn.docTable.tableRow.viewSingleDocumentLinkText', { + defaultMessage: 'View single document', + })} + + + + +
+
+ + + +
+
+ )} + + ); +} diff --git a/src/legacy/ui/public/collapsible_sidebar/_collapsible_sidebar.scss b/src/legacy/ui/public/collapsible_sidebar/_collapsible_sidebar.scss index 68594cbe538cf..5840ebc92578c 100644 --- a/src/legacy/ui/public/collapsible_sidebar/_collapsible_sidebar.scss +++ b/src/legacy/ui/public/collapsible_sidebar/_collapsible_sidebar.scss @@ -1,15 +1,12 @@ // SASSTODO: Can't rename main class // because it's also the name of the angular directive .collapsible-sidebar { - position: relative; - z-index: $kbnDiscoverSidebarDepth; - .kbnCollapsibleSidebar__collapseButton { position: absolute; top: 0; right: -21px; cursor: pointer; - z-index: -1; + z-index: 1; } &.closed { @@ -25,12 +22,16 @@ visibility: visible; .chevron-cont:before { - content: "\F138"; + content: '\F138'; } } } } +.visEditor__content .collapsible-sidebar { + position: relative; +} + @include euiBreakpoint('xs', 's', 'm') { .collapsible-sidebar { &.closed { diff --git a/src/plugins/data/public/index_patterns/fields/field.ts b/src/plugins/data/public/index_patterns/fields/field.ts index 6ed3c2be8f96e..ee14f4bb76e87 100644 --- a/src/plugins/data/public/index_patterns/fields/field.ts +++ b/src/plugins/data/public/index_patterns/fields/field.ts @@ -28,13 +28,14 @@ import { IFieldSubType, FieldFormat, shortenDottedString, + KBN_FIELD_TYPES, } from '../../../common'; export type FieldSpec = Record; export class Field implements IFieldType { name: string; - type: string; + type: KBN_FIELD_TYPES; script?: string; lang?: string; count?: number; diff --git a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts index e3482dd483035..a6a8806616954 100644 --- a/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts +++ b/src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts @@ -331,8 +331,8 @@ export class IndexPattern implements IIndexPattern { return this.fields.getByName(this.timeFieldName); } - getFieldByName(name: string): Field | void { - if (!this.fields || !this.fields.getByName) return; + getFieldByName(name: string): Field | undefined { + if (!this.fields || !this.fields.getByName) return undefined; return this.fields.getByName(name); } From cd000cf0e4d7472e363f40919edb14f7a31f716f Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Wed, 15 Jan 2020 12:47:57 -0500 Subject: [PATCH 002/186] fixing scss import --- .../kibana/public/discover/np_ready/components/_index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss index 4097ad6fb95f0..56703ebf595d9 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/_index.scss @@ -1,4 +1,4 @@ @import 'fetch_error/index'; @import 'field_chooser/index'; @import 'doc_viewer/index'; -@import 'data_grid/index'; +@import 'discover_grid/index'; From c13b349bd5cde6d2c640fcfcb500c11b39f58011 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Wed, 29 Jan 2020 14:10:13 -0500 Subject: [PATCH 003/186] bringing back old table with advanced setting --- .../public/discover/np_ready/_discover.scss | 13 ++++++ .../discover/np_ready/angular/discover.html | 43 ++++++++++++++++++- .../discover/np_ready/angular/discover.js | 1 + .../kibana/ui_setting_defaults.js | 11 +++++ 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss index 534c95f460d71..43cb937c5b4a8 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss @@ -92,6 +92,19 @@ discover-app { .dscTable { overflow: auto; + + // TODO: Delete when old Discover table is removed + .kbnDocTable__row { + font-family: $euiCodeFontFamily; + font-size: $euiFontSizeXS; + } + + // TODO: Delete when old Discover table is removed + .dscTable__footer { + background-color: $euiColorLightShade; + padding: 5px 10px; + text-align: center; + } } /** diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html index 66125b9eace09..35eee2b8f2656 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html @@ -116,7 +116,8 @@

{{screenTitle}}

id="reload_saved_search" ng-click="resetQuery()" > - {{::'kbn.discover.reloadSavedSearchButton' | i18n: {defaultMessage: 'Reset search'} }} + {{::'kbn.discover.reloadSavedSearchButton' | i18n: {defaultMessage: 'Reset search'} + }} @@ -181,7 +182,7 @@

{{screenTitle}}

i18n-default-message="Documents" > {{screenTitle}} on-remove-column="removeColumn" on-sort="setSortOrder" > +
+ + + + +
diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index 6d1b7a7f33d23..bcd7574615219 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -224,6 +224,7 @@ function discoverController( $scope.refreshInterval = timefilter.getRefreshInterval(); $scope.showSaveQuery = uiCapabilities.discover.saveQuery; $scope.useShortDots = config.get('shortDots:enable'); + $scope.useNewGrid = config.get('doc_table:legacyTable'); $scope.$watch( () => uiCapabilities.discover.saveQuery, diff --git a/src/legacy/core_plugins/kibana/ui_setting_defaults.js b/src/legacy/core_plugins/kibana/ui_setting_defaults.js index 02a4f10a543c4..c5bf6ef8353a2 100644 --- a/src/legacy/core_plugins/kibana/ui_setting_defaults.js +++ b/src/legacy/core_plugins/kibana/ui_setting_defaults.js @@ -1190,5 +1190,16 @@ export function getUiSettingDefaults() { }), }, }, + 'doc_table:legacyTable': { + name: i18n.translate('kbn.advancedSettings.context.tieBreakerFieldsTitle', { + defaultMessage: 'Use legacy table', + }), + value: false, + description: i18n.translate('kbn.advancedSettings.docTableVersion', { + defaultMessage: + 'Prefer the legacy version of the documents table in Discover while available', + }), + category: ['discover'], + }, }; } From 5f19bf2fc418cea688419d4c88a6b0c36d11e04d Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Wed, 29 Jan 2020 18:51:43 -0500 Subject: [PATCH 004/186] fixing old tests --- .../public/discover/np_ready/_discover.scss | 12 ++++----- .../discover_grid/discover_grid.tsx | 27 ++++++++++++++----- test/accessibility/apps/discover.ts | 1 + .../apps/context/_discover_navigation.js | 3 ++- .../apps/dashboard/dashboard_time_picker.js | 1 + test/functional/apps/discover/_discover.js | 1 + .../apps/management/_scripted_fields.js | 2 +- test/functional/page_objects/settings_page.ts | 6 +++++ .../apps/security/doc_level_security_roles.js | 2 +- 9 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss index 43cb937c5b4a8..5f5d2c3f22d81 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss @@ -98,13 +98,13 @@ discover-app { font-family: $euiCodeFontFamily; font-size: $euiFontSizeXS; } +} - // TODO: Delete when old Discover table is removed - .dscTable__footer { - background-color: $euiColorLightShade; - padding: 5px 10px; - text-align: center; - } +// TODO: Delete when old Discover table is removed +.dscTable__footer { + background-color: $euiColorLightShade; + padding: 5px 10px; + text-align: center; } /** diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx index b06d9e6570561..0ecef05559d03 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -74,26 +74,39 @@ const cellPopoverRenderer = ( ) => { return ( <> - {value} + {value} - Filter on value + {i18n.translate('kbn.discover.grid.filterOn', { + defaultMessage: 'Filter on value', + })} - Filter without value + {i18n.translate('kbn.discover.grid.filterOut', { + defaultMessage: 'Filter without value', + })} @@ -236,7 +249,9 @@ export function DiscoverGrid({ return ( setFlyoutRow(row)} isSelected={showFlyout} diff --git a/test/accessibility/apps/discover.ts b/test/accessibility/apps/discover.ts index e25d295515971..f9ca006ec0cff 100644 --- a/test/accessibility/apps/discover.ts +++ b/test/accessibility/apps/discover.ts @@ -33,6 +33,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('logstash_functional'); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', + 'doc_table:legacyTable': true, }); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index aabce6baa8783..b405f85571e64 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -29,11 +29,12 @@ export default function({ getService, getPageObjects }) { const retry = getService('retry'); const docTable = getService('docTable'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings']); describe('context link in discover', function contextSize() { this.tags('smoke'); before(async function() { + await PageObjects.settings.toggleDiscoverDataGrid(); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await Promise.all( diff --git a/test/functional/apps/dashboard/dashboard_time_picker.js b/test/functional/apps/dashboard/dashboard_time_picker.js index b99de9fee6db1..74bfeac786b05 100644 --- a/test/functional/apps/dashboard/dashboard_time_picker.js +++ b/test/functional/apps/dashboard/dashboard_time_picker.js @@ -30,6 +30,7 @@ export default function({ getService, getPageObjects }) { describe('dashboard time picker', function describeIndexTests() { before(async function() { + await PageObjects.settings.toggleDiscoverDataGrid(); await PageObjects.dashboard.initTests(); await PageObjects.dashboard.preserveCrossAppState(); }); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 432e83891aa92..db8d98f6934a7 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -29,6 +29,7 @@ export default function({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*', + 'doc_table:legacyTable': true, }; describe('discover test', function describeIndexTests() { diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 65291c3c4772c..4c43468c8f0b9 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -58,7 +58,7 @@ export default function({ getService, getPageObjects }) { before(async function() { await browser.setWindowSize(1200, 800); // delete .kibana index and then wait for Kibana to re-create it - await kibanaServer.uiSettings.replace({}); + await kibanaServer.uiSettings.replace({ 'doc_table:legacyTable': true }); await PageObjects.settings.createIndexPattern(); await kibanaServer.uiSettings.update({}); }); diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index e92780143f09a..27391c5678c24 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -739,6 +739,12 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider await this.clickKibanaSettings(); await this.setAdvancedSettingsSelect('pageNavigation', navType); } + + async toggleDiscoverDataGrid(legacyTable: boolean) { + await PageObjects.common.navigateToApp('settings'); + await this.clickKibanaSettings(); + await this.toggleAdvancedSettingCheckbox('doc_table:legacyTable'); + } } return new SettingsPage(); diff --git a/x-pack/test/functional/apps/security/doc_level_security_roles.js b/x-pack/test/functional/apps/security/doc_level_security_roles.js index 5761369f9e468..dde4d8ab846bf 100644 --- a/x-pack/test/functional/apps/security/doc_level_security_roles.js +++ b/x-pack/test/functional/apps/security/doc_level_security_roles.js @@ -20,7 +20,7 @@ export default function({ getService, getPageObjects }) { await esArchiver.load('empty_kibana'); await esArchiver.loadIfNeeded('security/dlstest'); await browser.setWindowSize(1600, 1000); - + await PageObjects.settings.toggleDiscoverDataGrid(); await PageObjects.settings.createIndexPattern('dlstest', null); await PageObjects.settings.navigateTo(); From 6543d263d57bfdd86793d786937d0dc3721ba4ca Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Thu, 30 Jan 2020 18:17:12 -0500 Subject: [PATCH 005/186] removing hide fields action and fixing field add/sub bug --- .../components/discover_grid/discover_grid.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx index 0ecef05559d03..a3de5637fded6 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -17,7 +17,7 @@ * under the License. */ -import React, { useMemo, useState, useCallback, ReactNode } from 'react'; +import React, { useMemo, useState, useEffect, useCallback, ReactNode } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButtonToggle, @@ -211,6 +211,9 @@ export function DiscoverGrid({ * Visibility and order */ const [visibleColumns, setVisibleColumns] = useState(dataGridColumns.map(obj => obj.id)); + useEffect(() => { + setVisibleColumns(dataGridColumns.map(obj => obj.id)); + }, [dataGridColumns.length]); // eslint-disable-line react-hooks/exhaustive-deps /** * Cell rendering @@ -326,10 +329,9 @@ export function DiscoverGrid({ onChangePage, pageSizeOptions: [lowestPageSize, 100, 500], }} - // TODO - EUI feature: disable visibility but keep ability to reorder - // toolbarVisibility={{ - // showColumnSelector: false, - // }} + toolbarVisibility={{ + showColumnSelector: false, + }} gridStyle={{ border: 'horizontal', }} From f4fd8c23e8bb43caa9138dd491c675a1e0a8e2d4 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Fri, 31 Jan 2020 16:23:23 -0500 Subject: [PATCH 006/186] fixing old tests --- src/plugins/data/public/index_patterns/fields/field.ts | 3 +-- test/functional/apps/dashboard/dashboard_time_picker.js | 7 +++++-- test/functional/apps/discover/_discover.js | 7 +++++-- test/functional/apps/discover/_field_data.js | 1 + x-pack/test/functional/apps/security/secure_roles_perm.js | 5 ++++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/plugins/data/public/index_patterns/fields/field.ts b/src/plugins/data/public/index_patterns/fields/field.ts index 03945f4ed8642..730a2f88c5eb7 100644 --- a/src/plugins/data/public/index_patterns/fields/field.ts +++ b/src/plugins/data/public/index_patterns/fields/field.ts @@ -28,14 +28,13 @@ import { IFieldSubType, fieldFormats, shortenDottedString, - KBN_FIELD_TYPES, } from '../../../common'; export type FieldSpec = Record; export class Field implements IFieldType { name: string; - type: KBN_FIELD_TYPES; + type: string; script?: string; lang?: string; count?: number; diff --git a/test/functional/apps/dashboard/dashboard_time_picker.js b/test/functional/apps/dashboard/dashboard_time_picker.js index 74bfeac786b05..094119c879913 100644 --- a/test/functional/apps/dashboard/dashboard_time_picker.js +++ b/test/functional/apps/dashboard/dashboard_time_picker.js @@ -22,6 +22,7 @@ import expect from '@kbn/expect'; export default function({ getService, getPageObjects }) { const dashboardExpect = getService('dashboardExpect'); + const testSubjects = getService('testSubjects'); const pieChart = getService('pieChart'); const dashboardVisualizations = getService('dashboardVisualizations'); const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'timePicker']); @@ -30,7 +31,6 @@ export default function({ getService, getPageObjects }) { describe('dashboard time picker', function describeIndexTests() { before(async function() { - await PageObjects.settings.toggleDiscoverDataGrid(); await PageObjects.dashboard.initTests(); await PageObjects.dashboard.preserveCrossAppState(); }); @@ -56,13 +56,16 @@ export default function({ getService, getPageObjects }) { name: 'saved search', fields: ['bytes', 'agent'], }); - await dashboardExpect.docTableFieldCount(150); + + const tableFields = await testSubjects.findAll('docTableField', 2500); + expect(tableFields).to.greaterThan(0); // Set to time range with no data await PageObjects.timePicker.setAbsoluteRange( 'Jan 1, 2000 @ 00:00:00.000', 'Jan 1, 2000 @ 01:00:00.000' ); + await dashboardExpect.docTableFieldCount(0); }); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index db8d98f6934a7..6da5cab8b5d17 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -187,8 +187,11 @@ export default function({ getService, getPageObjects }) { }); describe('time zone switch', () => { - it('should show bars in the correct time zone after switching', async function() { - await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'America/Phoenix' }); + it('should show bars in the correct time zone after switching failing', async function() { + await kibanaServer.uiSettings.replace({ + 'dateFormat:tz': 'America/Phoenix', + 'doc_table:legacyTable': true, + }); await browser.refresh(); await PageObjects.header.awaitKibanaChrome(); await PageObjects.timePicker.setDefaultAbsoluteRange(); diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js index 62d42f3da5c84..e90e05776cf93 100644 --- a/test/functional/apps/discover/_field_data.js +++ b/test/functional/apps/discover/_field_data.js @@ -35,6 +35,7 @@ export default function({ getService, getPageObjects }) { // delete .kibana index and update configDoc await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', + 'doc_table:legacyTable': true, }); await PageObjects.common.navigateToApp('discover'); diff --git a/x-pack/test/functional/apps/security/secure_roles_perm.js b/x-pack/test/functional/apps/security/secure_roles_perm.js index ece289b4a666e..333ba96a0253c 100644 --- a/x-pack/test/functional/apps/security/secure_roles_perm.js +++ b/x-pack/test/functional/apps/security/secure_roles_perm.js @@ -30,7 +30,10 @@ export default function({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('logstash_functional'); log.debug('load kibana index with default index pattern'); await esArchiver.load('security/discover'); - await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); + await kibanaServer.uiSettings.replace({ + defaultIndex: 'logstash-*', + 'doc_table:legacyTable': true, + }); await PageObjects.settings.navigateTo(); }); From 472e2402993b5b8c4bac161dd8b5028436fd50bd Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Fri, 31 Jan 2020 19:01:49 -0500 Subject: [PATCH 007/186] adding tests --- .../discover_grid/discover_grid.tsx | 4 +- .../kibana/ui_setting_defaults.js | 4 +- .../apps/dashboard/dashboard_time_picker.js | 2 +- test/functional/apps/discover/_data_grid.ts | 51 +++++++++++++++++++ .../functional/apps/discover/_large_string.js | 5 +- test/functional/apps/discover/index.js | 1 + test/functional/page_objects/discover_page.js | 5 ++ .../apps/security/field_level_security.js | 1 + 8 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 test/functional/apps/discover/_data_grid.ts diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx index a3de5637fded6..76f7602d80a32 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -297,12 +297,12 @@ export function DiscoverGrid({ let searchString: ReactNode = <>; if (searchTitle) { if (searchDescription) { - searchString = i18n.translate('kbn.discover.timeLabel', { + searchString = i18n.translate('kbn.discover.searchGenerationWithDescription', { defaultMessage: 'Table generated by search {searchTitle} ({searchDescription})', values: { searchTitle, searchDescription }, }); } else { - searchString = i18n.translate('kbn.discover.timeLabel', { + searchString = i18n.translate('kbn.discover.searchGeneration', { defaultMessage: 'Table generated by search {searchTitle}', values: { searchTitle }, }); diff --git a/src/legacy/core_plugins/kibana/ui_setting_defaults.js b/src/legacy/core_plugins/kibana/ui_setting_defaults.js index c5bf6ef8353a2..778056a9ee0eb 100644 --- a/src/legacy/core_plugins/kibana/ui_setting_defaults.js +++ b/src/legacy/core_plugins/kibana/ui_setting_defaults.js @@ -1191,11 +1191,11 @@ export function getUiSettingDefaults() { }, }, 'doc_table:legacyTable': { - name: i18n.translate('kbn.advancedSettings.context.tieBreakerFieldsTitle', { + name: i18n.translate('kbn.advancedSettings.docTableVersionName', { defaultMessage: 'Use legacy table', }), value: false, - description: i18n.translate('kbn.advancedSettings.docTableVersion', { + description: i18n.translate('kbn.advancedSettings.docTableVersionDescription', { defaultMessage: 'Prefer the legacy version of the documents table in Discover while available', }), diff --git a/test/functional/apps/dashboard/dashboard_time_picker.js b/test/functional/apps/dashboard/dashboard_time_picker.js index 094119c879913..ec8c506fb7fa9 100644 --- a/test/functional/apps/dashboard/dashboard_time_picker.js +++ b/test/functional/apps/dashboard/dashboard_time_picker.js @@ -58,7 +58,7 @@ export default function({ getService, getPageObjects }) { }); const tableFields = await testSubjects.findAll('docTableField', 2500); - expect(tableFields).to.greaterThan(0); + expect(tableFields.length).to.greaterThan(0); // Set to time range with no data await PageObjects.timePicker.setAbsoluteRange( diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts new file mode 100644 index 0000000000000..75d8980e7e94f --- /dev/null +++ b/test/functional/apps/discover/_data_grid.ts @@ -0,0 +1,51 @@ +/* + * 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 expect from '@kbn/expect'; + +export default function({ + getService, + getPageObjects, +}: { + getService: (service: string) => any; + getPageObjects: (pageObjects: string[]) => any; +}) { + describe('discover data grid tests', function describeDiscoverDataGrid() { + const esArchiver = getService('esArchiver'); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); + const kibanaServer = getService('kibanaServer'); + const defaultSettings = { defaultIndex: 'logstash-*' }; + + before(async function() { + await esArchiver.load('discover'); + await esArchiver.loadIfNeeded('logstash_functional'); + await kibanaServer.uiSettings.replace(defaultSettings); + await PageObjects.common.navigateToApp('discover'); + await PageObjects.timePicker.setDefaultAbsoluteRange(); + }); + + // TODO@myasonik unskip + it.skip('can add fields to the table', async function() { + const defaultColumnsCount = await PageObjects.discover.getDataGridHeaders().length; + await PageObjects.discover.clickFieldListItemAdd('bytes'); + const updatedColumnsCount = await PageObjects.discover.getDataGridHeaders().length; + expect(defaultColumnsCount + 1).to.be(updatedColumnsCount); + }); + }); +} diff --git a/test/functional/apps/discover/_large_string.js b/test/functional/apps/discover/_large_string.js index a5052b2403074..9fb73e6020d72 100644 --- a/test/functional/apps/discover/_large_string.js +++ b/test/functional/apps/discover/_large_string.js @@ -31,7 +31,10 @@ export default function({ getService, getPageObjects }) { before(async function() { await esArchiver.load('empty_kibana'); await esArchiver.loadIfNeeded('hamlet'); - await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring' }); + await kibanaServer.uiSettings.replace({ + defaultIndex: 'testlargestring', + 'doc_table:legacyTable': true, + }); }); it('verify the large string book present', async function() { diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index 64a5a61335365..82b94fafc8af0 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -46,5 +46,6 @@ export default function({ getService, loadTestFile }) { loadTestFile(require.resolve('./_doc_navigation')); loadTestFile(require.resolve('./_date_nanos')); loadTestFile(require.resolve('./_date_nanos_mixed')); + loadTestFile(require.resolve('./_data_grid')); }); } diff --git a/test/functional/page_objects/discover_page.js b/test/functional/page_objects/discover_page.js index 85d8cff675f2d..310dc7dba4bc0 100644 --- a/test/functional/page_objects/discover_page.js +++ b/test/functional/page_objects/discover_page.js @@ -327,6 +327,11 @@ export function DiscoverPageProvider({ getService, getPageObjects }) { async waitForChartLoadingComplete(renderCount) { await elasticChart.waitForRenderingCount('discoverChart', renderCount); } + + async getDataGridHeaders() { + const $ = await (await testSubjects.find('dataGridHeader')).parseDomContent(); + return await $('[role="columnheader"]').toArray(); + } } return new DiscoverPage(); diff --git a/x-pack/test/functional/apps/security/field_level_security.js b/x-pack/test/functional/apps/security/field_level_security.js index 16e9d755bf261..a39f6ea3c9581 100644 --- a/x-pack/test/functional/apps/security/field_level_security.js +++ b/x-pack/test/functional/apps/security/field_level_security.js @@ -19,6 +19,7 @@ export default function({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('security/flstest/data'); //( data) await esArchiver.load('security/flstest/kibana'); //(savedobject) await browser.setWindowSize(1600, 1000); + await PageObjects.settings.toggleDiscoverDataGrid(); }); it('should add new role a_viewssnrole', async function() { From 6105c05c62e9d02498015f04884f99b17dd4eae2 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Mon, 3 Feb 2020 15:40:38 -0500 Subject: [PATCH 008/186] added new test --- test/functional/apps/dashboard/dashboard_state.js | 8 +++++--- test/functional/apps/discover/_data_grid.ts | 9 ++++----- test/functional/apps/discover/_doc_navigation.js | 3 ++- test/functional/page_objects/discover_page.js | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/functional/apps/dashboard/dashboard_state.js b/test/functional/apps/dashboard/dashboard_state.js index b9172990c501d..9f31112a83ef6 100644 --- a/test/functional/apps/dashboard/dashboard_state.js +++ b/test/functional/apps/dashboard/dashboard_state.js @@ -22,9 +22,7 @@ import expect from '@kbn/expect'; import { PIE_CHART_VIS_NAME, AREA_CHART_VIS_NAME } from '../../page_objects/dashboard_page'; // eslint-disable-next-line -import { - DEFAULT_PANEL_WIDTH -} from '../../../../src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_constants'; +import { DEFAULT_PANEL_WIDTH } from '../../../../src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_constants'; export default function({ getService, getPageObjects }) { const PageObjects = getPageObjects([ @@ -35,6 +33,8 @@ export default function({ getService, getPageObjects }) { 'tileMap', 'visChart', 'timePicker', + 'settings', + 'common', ]); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -49,6 +49,8 @@ export default function({ getService, getPageObjects }) { before(async function() { await PageObjects.dashboard.initTests(); await PageObjects.dashboard.preserveCrossAppState(); + await PageObjects.settings.toggleDiscoverDataGrid(); + await PageObjects.common.navigateToApp('dashboard'); }); after(async function() { diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts index 75d8980e7e94f..64391d2e2c68d 100644 --- a/test/functional/apps/discover/_data_grid.ts +++ b/test/functional/apps/discover/_data_grid.ts @@ -40,12 +40,11 @@ export default function({ await PageObjects.timePicker.setDefaultAbsoluteRange(); }); - // TODO@myasonik unskip - it.skip('can add fields to the table', async function() { - const defaultColumnsCount = await PageObjects.discover.getDataGridHeaders().length; + it('can add fields to the table', async function() { + const defaultColumnsCount = await PageObjects.discover.getDataGridHeaders(); await PageObjects.discover.clickFieldListItemAdd('bytes'); - const updatedColumnsCount = await PageObjects.discover.getDataGridHeaders().length; - expect(defaultColumnsCount + 1).to.be(updatedColumnsCount); + const updatedColumnsCount = await PageObjects.discover.getDataGridHeaders(); + expect(defaultColumnsCount.length + 1).to.be(updatedColumnsCount.length); }); }); } diff --git a/test/functional/apps/discover/_doc_navigation.js b/test/functional/apps/discover/_doc_navigation.js index d7fc267ab1d5e..e6f6838f1efaa 100644 --- a/test/functional/apps/discover/_doc_navigation.js +++ b/test/functional/apps/discover/_doc_navigation.js @@ -28,13 +28,14 @@ const TEST_FILTER_COLUMN_NAMES = [ export default function({ getService, getPageObjects }) { const docTable = getService('docTable'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings']); const esArchiver = getService('esArchiver'); describe('doc link in discover', function contextSize() { this.tags('smoke'); before(async function() { await esArchiver.loadIfNeeded('logstash_functional'); + await PageObjects.settings.toggleDiscoverDataGrid(); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await Promise.all( diff --git a/test/functional/page_objects/discover_page.js b/test/functional/page_objects/discover_page.js index 310dc7dba4bc0..b1830557b1b59 100644 --- a/test/functional/page_objects/discover_page.js +++ b/test/functional/page_objects/discover_page.js @@ -330,7 +330,7 @@ export function DiscoverPageProvider({ getService, getPageObjects }) { async getDataGridHeaders() { const $ = await (await testSubjects.find('dataGridHeader')).parseDomContent(); - return await $('[role="columnheader"]').toArray(); + return await $('[role="columnheader"]'); } } From 4d4b63fde642b6ba712ec4597b9ae73ae1d13225 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Mon, 3 Feb 2020 17:07:48 -0500 Subject: [PATCH 009/186] json field formatter work --- .../components/discover_grid/_table.scss | 7 +++++++ .../discover_grid/discover_grid.tsx | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss index 23823ab78fa9e..2a6d3dfb3ef34 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/_table.scss @@ -1,3 +1,5 @@ +@import '../../mixins'; + .dscTable__footer { background-color: $euiColorLightShade; padding: $euiSize / 2 $euiSize; @@ -8,3 +10,8 @@ .dscTable__flyoutHeader { white-space: nowrap; } + +.euiDataGridRowCell__popover, +.euiDataGridRowCell__truncate { + @include dscDocSourceStyle(); +} diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx index 76f7602d80a32..6a23ad492f1f4 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -45,6 +45,7 @@ import { shortenDottedString } from '../../../../../../../../plugins/data/common type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; +const KibanaJSON = 'kibana-json'; interface SortObj { id: string; direction: Direction; @@ -169,7 +170,7 @@ export function DiscoverGrid({ break; case '_source': case 'object': - column.schema = 'json'; + column.schema = KibanaJSON; break; } @@ -335,6 +336,22 @@ export function DiscoverGrid({ gridStyle={{ border: 'horizontal', }} + schemaDetectors={[ + { + type: KibanaJSON, + detector() { + return 0; // this schema is always explicitly defined + }, + comparator(a, b, direction) { + // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + return 1; + }, + sortTextAsc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + sortTextDesc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + }, + ]} /> {showDisclaimer && ( <> From 179ee067f7a908685a39b969cc7a88e1948a0381 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Mon, 3 Feb 2020 18:18:22 -0500 Subject: [PATCH 010/186] fixing old test --- test/functional/apps/discover/_date_nanos.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/functional/apps/discover/_date_nanos.js b/test/functional/apps/discover/_date_nanos.js index 9b06b9ac84cfd..341c47bc55957 100644 --- a/test/functional/apps/discover/_date_nanos.js +++ b/test/functional/apps/discover/_date_nanos.js @@ -26,10 +26,13 @@ export default function({ getService, getPageObjects }) { const fromTime = 'Sep 22, 2019 @ 20:31:44.000'; const toTime = 'Sep 23, 2019 @ 03:31:44.000'; - describe('date_nanos', function() { + describe('date_nanos foo', function() { before(async function() { await esArchiver.loadIfNeeded('date_nanos'); - await kibanaServer.uiSettings.replace({ defaultIndex: 'date-nanos' }); + await kibanaServer.uiSettings.replace({ + defaultIndex: 'date-nanos', + 'doc_table:legacyTable': true, + }); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); From 9cf8c75e52db14a55e6ce779a7fcd7651f1adc34 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Tue, 4 Feb 2020 12:38:01 -0500 Subject: [PATCH 011/186] futzing with tests --- test/functional/apps/context/_discover_navigation.js | 2 +- test/functional/apps/dashboard/dashboard_state.js | 2 +- test/functional/apps/discover/_date_nanos.js | 2 +- test/functional/apps/discover/_date_nanos_mixed.js | 5 ++++- test/functional/apps/discover/_doc_navigation.js | 2 +- test/functional/page_objects/settings_page.ts | 7 +++++-- .../functional/apps/security/doc_level_security_roles.js | 2 +- .../test/functional/apps/security/field_level_security.js | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index b405f85571e64..1a849459837b5 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -34,7 +34,7 @@ export default function({ getService, getPageObjects }) { describe('context link in discover', function contextSize() { this.tags('smoke'); before(async function() { - await PageObjects.settings.toggleDiscoverDataGrid(); + await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await Promise.all( diff --git a/test/functional/apps/dashboard/dashboard_state.js b/test/functional/apps/dashboard/dashboard_state.js index 9f31112a83ef6..b807de205fab5 100644 --- a/test/functional/apps/dashboard/dashboard_state.js +++ b/test/functional/apps/dashboard/dashboard_state.js @@ -49,7 +49,7 @@ export default function({ getService, getPageObjects }) { before(async function() { await PageObjects.dashboard.initTests(); await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.settings.toggleDiscoverDataGrid(); + await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.common.navigateToApp('dashboard'); }); diff --git a/test/functional/apps/discover/_date_nanos.js b/test/functional/apps/discover/_date_nanos.js index 341c47bc55957..06c0620b1925c 100644 --- a/test/functional/apps/discover/_date_nanos.js +++ b/test/functional/apps/discover/_date_nanos.js @@ -26,7 +26,7 @@ export default function({ getService, getPageObjects }) { const fromTime = 'Sep 22, 2019 @ 20:31:44.000'; const toTime = 'Sep 23, 2019 @ 03:31:44.000'; - describe('date_nanos foo', function() { + describe('date_nanos', function() { before(async function() { await esArchiver.loadIfNeeded('date_nanos'); await kibanaServer.uiSettings.replace({ diff --git a/test/functional/apps/discover/_date_nanos_mixed.js b/test/functional/apps/discover/_date_nanos_mixed.js index 0bb6848db4d10..edaa4d03eb068 100644 --- a/test/functional/apps/discover/_date_nanos_mixed.js +++ b/test/functional/apps/discover/_date_nanos_mixed.js @@ -29,7 +29,10 @@ export default function({ getService, getPageObjects }) { describe('date_nanos_mixed', function() { before(async function() { await esArchiver.loadIfNeeded('date_nanos_mixed'); - await kibanaServer.uiSettings.replace({ defaultIndex: 'timestamp-*' }); + await kibanaServer.uiSettings.replace({ + defaultIndex: 'timestamp-*', + 'doc_table:legacyTable': true, + }); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); }); diff --git a/test/functional/apps/discover/_doc_navigation.js b/test/functional/apps/discover/_doc_navigation.js index e6f6838f1efaa..f9f69a2b03f53 100644 --- a/test/functional/apps/discover/_doc_navigation.js +++ b/test/functional/apps/discover/_doc_navigation.js @@ -35,7 +35,7 @@ export default function({ getService, getPageObjects }) { this.tags('smoke'); before(async function() { await esArchiver.loadIfNeeded('logstash_functional'); - await PageObjects.settings.toggleDiscoverDataGrid(); + await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await Promise.all( diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index 27391c5678c24..d4ea370690b44 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -740,10 +740,13 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider await this.setAdvancedSettingsSelect('pageNavigation', navType); } - async toggleDiscoverDataGrid(legacyTable: boolean) { + async setLegacyDiscoverTable() { await PageObjects.common.navigateToApp('settings'); await this.clickKibanaSettings(); - await this.toggleAdvancedSettingCheckbox('doc_table:legacyTable'); + + if ((await this.getAdvancedSettingCheckbox('doc_table:legacyTable')) !== 'true') { + await this.toggleAdvancedSettingCheckbox('doc_table:legacyTable'); + } } } diff --git a/x-pack/test/functional/apps/security/doc_level_security_roles.js b/x-pack/test/functional/apps/security/doc_level_security_roles.js index 9acb90801ce25..94203c9bd902c 100644 --- a/x-pack/test/functional/apps/security/doc_level_security_roles.js +++ b/x-pack/test/functional/apps/security/doc_level_security_roles.js @@ -20,7 +20,7 @@ export default function({ getService, getPageObjects }) { await esArchiver.load('empty_kibana'); await esArchiver.loadIfNeeded('security/dlstest'); await browser.setWindowSize(1600, 1000); - await PageObjects.settings.toggleDiscoverDataGrid(); + await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.settings.createIndexPattern('dlstest', null); await PageObjects.settings.navigateTo(); diff --git a/x-pack/test/functional/apps/security/field_level_security.js b/x-pack/test/functional/apps/security/field_level_security.js index bd90ad6e18dd3..32d75c834c90b 100644 --- a/x-pack/test/functional/apps/security/field_level_security.js +++ b/x-pack/test/functional/apps/security/field_level_security.js @@ -19,7 +19,7 @@ export default function({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('security/flstest/data'); //( data) await esArchiver.load('security/flstest/kibana'); //(savedobject) await browser.setWindowSize(1600, 1000); - await PageObjects.settings.toggleDiscoverDataGrid(); + await PageObjects.settings.setLegacyDiscoverTable(); }); it('should add new role a_viewssnrole', async function() { From a81dc9afb0bdd5764f1e247f1205f14002e088c7 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Tue, 4 Feb 2020 13:18:03 -0500 Subject: [PATCH 012/186] i18n fix --- .../discover_grid/discover_grid.tsx | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx index 6a23ad492f1f4..ab91884f81710 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -68,14 +68,23 @@ interface Props { onAddColumn: (column: string) => void; } -const cellPopoverRenderer = ( - value: string | ReactNode, - positiveFilterClick: () => void, - negativeFilterClick: () => void -) => { +function CellPopover({ + value, + onPositiveFilterClick, + onNegativeFilterClick, +}: { + value: string | ReactNode; + onPositiveFilterClick: () => void; + onNegativeFilterClick: () => void; +}) { + const node = useMemo(() => <>{value}!, [value]); + const placeholder = i18n.translate('kbn.discover.grid.filterValuePlaceholder', { + defaultMessage: 'value', + }); + const text = useRenderToText(node, placeholder); return ( <> - {value} + {value} @@ -83,11 +92,9 @@ const cellPopoverRenderer = ( iconType="magnifyWithPlus" aria-label={i18n.translate('kbn.discover.grid.ariaFilterOn', { defaultMessage: 'Filter on {value}', - // @ts-ignore // TODO@myasonik value renders as [object Object] - values: { value }, + values: { value: text }, })} - aria-describedby="foo" - onClick={positiveFilterClick} + onClick={onPositiveFilterClick} > {i18n.translate('kbn.discover.grid.filterOn', { defaultMessage: 'Filter on value', @@ -99,11 +106,10 @@ const cellPopoverRenderer = ( iconType="magnifyWithMinus" aria-label={i18n.translate('kbn.discover.grid.ariaFilterOut', { defaultMessage: 'Filter without {value}', - // @ts-ignore // TODO@myasonik value renders as [object Object] - values: { value }, + values: { value: text }, })} color="danger" - onClick={negativeFilterClick} + onClick={onNegativeFilterClick} > {i18n.translate('kbn.discover.grid.filterOut', { defaultMessage: 'Filter without value', @@ -113,7 +119,7 @@ const cellPopoverRenderer = ( ); -}; +} export function DiscoverGrid({ rows, @@ -269,10 +275,12 @@ export function DiscoverGrid({ value = formattedField(row, fieldName); if (showFilterActions(isDetails, fieldName)) { - return cellPopoverRenderer( - value, - () => createFilter(fieldName, rows[rowIndex], '+'), - () => createFilter(fieldName, rows[rowIndex], '-') + return ( + createFilter(fieldName, rows[rowIndex], '+')} + onNegativeFilterClick={() => createFilter(fieldName, rows[rowIndex], '-')} + /> ); } From 977c6371a05d1e337b38aaa43f5a19def862ac01 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Tue, 4 Feb 2020 15:48:12 -0500 Subject: [PATCH 013/186] only show _source when no other columns are shown --- .../discover/np_ready/angular/discover.js | 8 ++++++++ .../np_ready/angular/doc_table/doc_table.ts | 17 ----------------- .../components/discover_grid/discover_grid.tsx | 1 + 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index bcd7574615219..d8e604460732e 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -566,6 +566,14 @@ function discoverController( const tableColumns = [...columns]; const { timeFieldName } = $scope.indexPattern; + if (tableColumns.length > 1 && tableColumns.find(id => id === '_source')) { + $state.columns = tableColumns.filter(id => id !== '_source'); + $state.replace(); + } else if (tableColumns.length === 0) { + $state.columns = ['_source']; + $state.replace(); + } + if (!config.get('doc_table:hideTimeColumn') && timeFieldName) { tableColumns.unshift(timeFieldName); } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts index 3329ffc7cd102..0d199e22a02fc 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/doc_table.ts @@ -83,23 +83,6 @@ export function createDocTableDirective( $scope.limit += 50; }; - // This exists to fix the problem of an empty initial column list not playing nice with watchCollection. - $scope.$watch('columns', function(columns: string[]) { - if (columns.length !== 0) return; - - const $state = getAppState(); - $scope.columns.push('_source'); - if ($state) $state.replace(); - }); - - $scope.$watchCollection('columns', function(columns: string[], oldColumns: string[]) { - if (oldColumns.length === 1 && oldColumns[0] === '_source' && $scope.columns.length > 1) { - _.pull($scope.columns, '_source'); - } - - if ($scope.columns.length === 0) $scope.columns.push('_source'); - }); - $scope.$watch('hits', (hits: any) => { if (!hits) return; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx index ab91884f81710..900d9274b2982 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/discover_grid/discover_grid.tsx @@ -219,6 +219,7 @@ export function DiscoverGrid({ */ const [visibleColumns, setVisibleColumns] = useState(dataGridColumns.map(obj => obj.id)); useEffect(() => { + // every time a column is added, make it visible setVisibleColumns(dataGridColumns.map(obj => obj.id)); }, [dataGridColumns.length]); // eslint-disable-line react-hooks/exhaustive-deps From 887bf3ab2604248848a5aa9a87a1708a18567997 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Wed, 5 Feb 2020 16:03:50 -0500 Subject: [PATCH 014/186] more test fixes --- test/functional/apps/discover/_data_grid.ts | 19 ++++++++++++++++--- .../apps/discover/_doc_navigation.js | 5 +++-- test/functional/page_objects/discover_page.js | 5 ----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts index 64391d2e2c68d..83f40a489eca7 100644 --- a/test/functional/apps/discover/_data_grid.ts +++ b/test/functional/apps/discover/_data_grid.ts @@ -31,6 +31,7 @@ export default function({ const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); const kibanaServer = getService('kibanaServer'); const defaultSettings = { defaultIndex: 'logstash-*' }; + const testSubjects = getService('testSubjects'); before(async function() { await esArchiver.load('discover'); @@ -41,10 +42,22 @@ export default function({ }); it('can add fields to the table', async function() { - const defaultColumnsCount = await PageObjects.discover.getDataGridHeaders(); + const getTitles = async () => + (await testSubjects.getVisibleText('dataGridHeader')).replace(/\s|\r?\n|\r/g, ' '); + + expect(await getTitles()).to.be('Time _source'); + + await PageObjects.discover.clickFieldListItemAdd('bytes'); + expect(await getTitles()).to.be('Time bytes'); + + await PageObjects.discover.clickFieldListItemAdd('agent'); + expect(await getTitles()).to.be('Time bytes agent'); + await PageObjects.discover.clickFieldListItemAdd('bytes'); - const updatedColumnsCount = await PageObjects.discover.getDataGridHeaders(); - expect(defaultColumnsCount.length + 1).to.be(updatedColumnsCount.length); + expect(await getTitles()).to.be('Time agent'); + + await PageObjects.discover.clickFieldListItemAdd('agent'); + expect(await getTitles()).to.be('Time _source'); }); }); } diff --git a/test/functional/apps/discover/_doc_navigation.js b/test/functional/apps/discover/_doc_navigation.js index f9f69a2b03f53..9c52664f5cf85 100644 --- a/test/functional/apps/discover/_doc_navigation.js +++ b/test/functional/apps/discover/_doc_navigation.js @@ -28,14 +28,15 @@ const TEST_FILTER_COLUMN_NAMES = [ export default function({ getService, getPageObjects }) { const docTable = getService('docTable'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings']); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); describe('doc link in discover', function contextSize() { this.tags('smoke'); before(async function() { await esArchiver.loadIfNeeded('logstash_functional'); - await PageObjects.settings.setLegacyDiscoverTable(); + await kibanaServer.uiSettings.replace({ 'doc_table:legacyTable': true }); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await Promise.all( diff --git a/test/functional/page_objects/discover_page.js b/test/functional/page_objects/discover_page.js index b1830557b1b59..85d8cff675f2d 100644 --- a/test/functional/page_objects/discover_page.js +++ b/test/functional/page_objects/discover_page.js @@ -327,11 +327,6 @@ export function DiscoverPageProvider({ getService, getPageObjects }) { async waitForChartLoadingComplete(renderCount) { await elasticChart.waitForRenderingCount('discoverChart', renderCount); } - - async getDataGridHeaders() { - const $ = await (await testSubjects.find('dataGridHeader')).parseDomContent(); - return await $('[role="columnheader"]'); - } } return new DiscoverPage(); From 70c6a33db0d56c0d20592b0dd8db4cad5e20208d Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Thu, 6 Feb 2020 18:05:56 -0500 Subject: [PATCH 015/186] add docs for new legacyTable advanced setting --- docs/management/advanced-options.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/management/advanced-options.asciidoc b/docs/management/advanced-options.asciidoc index 8a10a2bde3b44..3cac100a25bd9 100644 --- a/docs/management/advanced-options.asciidoc +++ b/docs/management/advanced-options.asciidoc @@ -144,6 +144,7 @@ This setting does not have an effect when loading a saved search. `doc_table:highlight`:: Highlights results in Discover and saved searches on dashboards. Highlighting slows requests when working on big documents. +`doc_table:legacyTable`:: Control the way the Discover's table looks and works. Set this property to `true` to revert to the legacy implementation. From 7ac7f9b7fdd2151745b5bf2e99adf14579d0cb12 Mon Sep 17 00:00:00 2001 From: Dave Snider Date: Wed, 5 Feb 2020 13:02:25 -0800 Subject: [PATCH 016/186] basic layout --- .../public/discover/np_ready/_discover.scss | 36 +- .../discover/np_ready/angular/discover.html | 385 +++++++++--------- .../field_chooser/_field_chooser.scss | 5 +- 3 files changed, 222 insertions(+), 204 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss index 5f5d2c3f22d81..fbe0fcfea625a 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/_discover.scss @@ -1,14 +1,44 @@ -discover-app { - flex-grow: 1; +.dscApp { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + display: flex; + flex-direction: column; + height: 100%; + overflow: hidden; .sidebar-container { background-color: transparent; } } +.dscApp__header { + border-bottom: $euiBorderThin; + margin-bottom: $euiSize; +} + +.dscApp__frame { + position: relative; + flex-grow: 1; + display: flex; +} + +.dscApp__sidebar { + flex-grow: 0; + flex-basis: auto; + min-width: 304px; + padding: 0 $euiSizeS; +} + +.dscApp__content { + flex-grow: 1; +} + .dscHistogram { display: flex; - height: 200px; + height: $euiSize * 8; padding: $euiSizeS; } diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html index f8a3e67a0f5f5..08710ea19db2c 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.html @@ -1,4 +1,4 @@ - +

{{screenTitle}}

@@ -9,231 +9,220 @@

{{screenTitle}}

show-search-bar="true" show-date-picker="enableTimeRangeSelector" index-patterns="[indexPattern]" - query="state.query" on-query-submit="updateQuery" - show-save-query="showSaveQuery" saved-query-id="state.savedQuery" on-saved-query-id-change="updateSavedQueryId" - + class="dscApp__header" use-default-behaviors="true" > -
-
- + +
+
- + {formatNumWithCommas(hits)}{' '} diff --git a/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx b/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx index 8789847058aff..eb50d15fd3076 100644 --- a/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx +++ b/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx @@ -87,7 +87,7 @@ export function TimechartHeader({ return ( - + Date: Wed, 10 Jun 2020 09:46:34 +0200 Subject: [PATCH 035/186] Fix adding columns --- .../create_discover_grid_directive.tsx | 2 +- .../discover_grid/discover_grid.tsx | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx index 95dcb0fbc678a..9d14998d88d5f 100644 --- a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx @@ -24,7 +24,7 @@ export function createDiscoverGridDirective(reactDirective: any) { ['columns', { watchDepth: 'collection' }], ['rows', { watchDepth: 'collection' }], ['indexPattern', { watchDepth: 'reference' }], - ['sort', { watchDepth: 'value' }], + ['sort', { watchDepth: 'collection' }], ['sampleSize', { watchDepth: 'reference' }], ['searchDescription', { watchDepth: 'reference' }], ['searchTitle', { watchDepth: 'reference' }], diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index f148064f71e1f..fa19f2c485154 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -152,7 +152,7 @@ export const DiscoverGrid = function DiscoverGridInner({ const [flyoutRow, setFlyoutRow] = useState(undefined); const buildColumns = useCallback( (cols: any) => { - const mappedCols = cols.map( + return cols.map( (columnName: string): EuiDataGridColumn => { const column: EuiDataGridColumn = { id: columnName, @@ -187,26 +187,31 @@ export const DiscoverGrid = function DiscoverGridInner({ return column; } ); - // Discover always injects a Time column as the first item (unless advance settings turned it off) - // Have to guard against this to allow users to request the same column again later - if (showTimeCol) { - mappedCols.unshift({ id: timeString, schema: 'datetime', initialWidth: 200 }); - } - return mappedCols; }, - [indexPattern, showTimeCol, timeString, useShortDots] + [indexPattern, useShortDots] ); const [dataGridColumns, setDataGridColumns] = useState( buildColumns(columns) ); useEffect(() => { - const prevColums = dataGridColumns.map((col) => col.id); - if (isEqual(columns, prevColums)) { + const prevColumns = dataGridColumns.map((col) => col.id); + if (!isEqual(columns, prevColumns)) { setDataGridColumns(buildColumns(columns)); } }, [columns, buildColumns, setDataGridColumns, dataGridColumns]); + const getColumns = useCallback(() => { + // Discover always injects a Time column as the first item (unless advance settings turned it off) + // Have to guard against this to allow users to request the same column again later + + if (showTimeCol) { + return [{ id: timeString, schema: 'datetime', initialWidth: 200 }, ...dataGridColumns]; + } else { + return dataGridColumns; + } + }, [dataGridColumns, showTimeCol, timeString]); + /** * Pagination */ @@ -345,11 +350,11 @@ export const DiscoverGrid = function DiscoverGridInner({ inMemory={{ level: 'sorting' }} sorting={{ columns: sortingColumns, onSort: onTableSort }} rowCount={rowCount} - columns={dataGridColumns} + columns={getColumns()} renderCellValue={renderCellValue} leadingControlColumns={leadingControlControls} columnVisibility={{ - visibleColumns: dataGridColumns.map((obj) => obj.id), + visibleColumns: getColumns().map((obj) => obj.id), setVisibleColumns: (col) => { const newColumns = showTimeCol ? col.slice(1) : col; setDataGridColumns(buildColumns(newColumns)); From 338851988206ff7300d3ee81747f9a6ab61d5919 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jun 2020 11:57:07 +0200 Subject: [PATCH 036/186] Make position of timecolumn sortable --- .../discover_grid/discover_grid.tsx | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index fa19f2c485154..4065e34d35178 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -202,15 +202,21 @@ export const DiscoverGrid = function DiscoverGridInner({ }, [columns, buildColumns, setDataGridColumns, dataGridColumns]); const getColumns = useCallback(() => { - // Discover always injects a Time column as the first item (unless advance settings turned it off) - // Have to guard against this to allow users to request the same column again later + const timeFieldName = indexPattern.timeFieldName; - if (showTimeCol) { - return [{ id: timeString, schema: 'datetime', initialWidth: 200 }, ...dataGridColumns]; - } else { - return dataGridColumns; + if (showTimeCol && !dataGridColumns.find((col) => col.id === timeFieldName)) { + return [ + { + id: indexPattern.timeFieldName, + display: timeString, + schema: 'datetime', + initialWidth: 200, + } as EuiDataGridColumn, + ...dataGridColumns, + ]; } - }, [dataGridColumns, showTimeCol, timeString]); + return dataGridColumns; + }, [dataGridColumns, showTimeCol, timeString, indexPattern.timeFieldName]); /** * Pagination @@ -228,15 +234,13 @@ export const DiscoverGrid = function DiscoverGridInner({ /** * Sorting */ - const sortingColumns = useMemo( - () => - sort.length === 0 - ? getDefaultSort(indexPattern).map( - ([id, direction]) => ({ id, direction } as { id: string; direction: 'asc' | 'desc' }) - ) - : sort.map(([id, direction]) => ({ id, direction })), - [sort, indexPattern] - ); + const sortingColumns = useMemo(() => { + return sort.length === 0 + ? getDefaultSort(indexPattern).map( + ([id, direction]) => ({ id, direction } as { id: string; direction: 'asc' | 'desc' }) + ) + : sort.map(([id, direction]) => ({ id, direction })); + }, [sort, indexPattern]); const onTableSort = useCallback( (sortingColumnsData) => { onSort(sortingColumnsData.map(({ id, direction }: SortObj) => [id, direction])); @@ -263,26 +267,24 @@ export const DiscoverGrid = function DiscoverGridInner({ ); }; - const fieldName = columnId === timeString ? indexPattern.timeFieldName! : columnId; - const value = ( // TODO Field formatters need to be fixed // eslint-disable-next-line react/no-danger - + ); - if (isDetails && indexPattern.fields.getByName(fieldName)?.filterable) { + if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { return ( createFilter(fieldName, '+')} - onNegativeFilterClick={() => createFilter(fieldName, '-')} + onPositiveFilterClick={() => createFilter(columnId, '+')} + onNegativeFilterClick={() => createFilter(columnId, '-')} /> ); } return value; }, - [rows, indexPattern, onFilter, timeString] + [rows, indexPattern, onFilter] ); /** @@ -347,7 +349,7 @@ export const DiscoverGrid = function DiscoverGridInner({ obj.id), - setVisibleColumns: (col) => { - const newColumns = showTimeCol ? col.slice(1) : col; + setVisibleColumns: (newColumns) => { setDataGridColumns(buildColumns(newColumns)); onSetColumns(newColumns); }, From f3b90e61225e74fbba42b3ccfacad04120fe658a Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jun 2020 12:24:53 +0200 Subject: [PATCH 037/186] Modify naming of a indexpatterns timefield --- .../application/components/discover_grid/discover_grid.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 4065e34d35178..f451d0245a194 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -183,12 +183,15 @@ export const DiscoverGrid = function DiscoverGridInner({ if (useShortDots) { column.display = <>{shortenDottedString(columnName)}; } + if (column.id === indexPattern.timeFieldName) { + column.display = `${timeString} (${indexPattern.timeFieldName})`; + } return column; } ); }, - [indexPattern, useShortDots] + [indexPattern, useShortDots, timeString] ); const [dataGridColumns, setDataGridColumns] = useState( @@ -208,7 +211,7 @@ export const DiscoverGrid = function DiscoverGridInner({ return [ { id: indexPattern.timeFieldName, - display: timeString, + display: `${timeString} (${indexPattern.timeFieldName})`, schema: 'datetime', initialWidth: 200, } as EuiDataGridColumn, From fedddb99e8b7446062f1cb9c771154f73769e2b9 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jun 2020 13:36:08 +0200 Subject: [PATCH 038/186] Undo accidentally commited kbn-pm changes --- packages/kbn-pm/dist/index.js | 6094 +++++++++++++------------- packages/kbn-pm/src/utils/scripts.ts | 2 +- 2 files changed, 3048 insertions(+), 3048 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 832210be1b335..53e7bc6a816a6 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -622,192 +622,192 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; }); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed 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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); -}; - -function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - -var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - } - return __assign.apply(this, arguments); -} - -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; -} - -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - -function __param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -} - -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - -function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} - -function __values(o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -} - -function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -} - -function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} - -function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } -} - -function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } -} - -function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } -} - -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; - -function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result.default = mod; - return result; -} - -function __importDefault(mod) { - return (mod && mod.__esModule) ? mod : { default: mod }; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed 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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result.default = mod; + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} /***/ }), @@ -29702,7 +29702,7 @@ function startProc(name, options, log) { throw errors_1.createCliError(`[${name}] exited with code ${code}`); } return code; - })), + })), // observe first error event Rx.fromEvent(childProcess, 'error').pipe(operators_1.take(1), operators_1.mergeMap((err) => Rx.throwError(err)))).pipe(operators_1.share()); const lines$ = Rx.merge(observe_lines_1.observeLines(childProcess.stdout), observe_lines_1.observeLines(childProcess.stderr)).pipe(operators_1.tap((line) => log.write(` ${chalk_1.default.gray('proc')} [${chalk_1.default.gray(name)}] ${line}`)), operators_1.share()); @@ -33867,158 +33867,158 @@ convert.rgb.gray = function (rgb) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - - -module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; + + +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; /***/ }), @@ -34600,16 +34600,16 @@ function observeLines(readable) { buffer = buffer.slice(match.index + match[0].length); } return { buffer, lines }; - }, { buffer: '' }), + }, { buffer: '' }), // stop if done completes or errors operators_1.takeUntil(done$.pipe(operators_1.materialize())), operators_1.share()); return Rx.merge( // use done$ to provide completion/errors - done$, + done$, // merge in the "lines" from each step - scan$.pipe(operators_1.mergeMap(({ lines }) => lines || [])), + scan$.pipe(operators_1.mergeMap(({ lines }) => lines || [])), // inject the "unsplit" data at the end - scan$.pipe(operators_1.last(), operators_1.mergeMap(({ buffer }) => (buffer ? [buffer] : [])), + scan$.pipe(operators_1.last(), operators_1.mergeMap(({ buffer }) => (buffer ? [buffer] : [])), // if there were no lines, last() will error, so catch and complete operators_1.catchError(() => Rx.empty()))); } @@ -34821,7 +34821,7 @@ const MSG_PREFIXES = { const has = (obj, key) => obj.hasOwnProperty(key); function shouldWriteType(level, type) { if (type === 'write') { - return true; + return level.name !== 'silent'; } return Boolean(level.flags[type === 'success' ? 'info' : type]); } @@ -34956,9 +34956,9 @@ exports.parseLogLevel = parseLogLevel; Object.defineProperty(exports, "__esModule", { value: true }); const tooling_log_text_writer_1 = __webpack_require__(402); class ToolingLogCollectingWriter extends tooling_log_text_writer_1.ToolingLogTextWriter { - constructor() { + constructor(level = 'verbose') { super({ - level: 'verbose', + level, writeTo: { write: (msg) => { // trim trailing new line @@ -43544,18 +43544,18 @@ function mkdirP (p, opts, f, made) { else if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } if (!made) made = null; - + var cb = f || function () {}; p = path.resolve(p); - + xfs.mkdir(p, mode, function (er) { if (!er) { made = made || p; @@ -43589,10 +43589,10 @@ mkdirP.sync = function sync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } @@ -43635,58 +43635,58 @@ mkdirP.sync = function sync (p, opts, made) { /* 498 */ /***/ (function(module, exports) { -exports.replaceDollarWithPercentPair = replaceDollarWithPercentPair -exports.convertToSetCommand = convertToSetCommand -exports.convertToSetCommands = convertToSetCommands - -function convertToSetCommand(key, value) { - var line = "" - key = key || "" - key = key.trim() - value = value || "" - value = value.trim() - if(key && value && value.length > 0) { - line = "@SET " + key + "=" + replaceDollarWithPercentPair(value) + "\r\n" - } - return line -} - -function extractVariableValuePairs(declarations) { - var pairs = {} - declarations.map(function(declaration) { - var split = declaration.split("=") - pairs[split[0]]=split[1] - }) - return pairs -} - -function convertToSetCommands(variableString) { - var variableValuePairs = extractVariableValuePairs(variableString.split(" ")) - var variableDeclarationsAsBatch = "" - Object.keys(variableValuePairs).forEach(function (key) { - variableDeclarationsAsBatch += convertToSetCommand(key, variableValuePairs[key]) - }) - return variableDeclarationsAsBatch -} - -function replaceDollarWithPercentPair(value) { - var dollarExpressions = /\$\{?([^\$@#\?\- \t{}:]+)\}?/g - var result = "" - var startIndex = 0 - value = value || "" - do { - var match = dollarExpressions.exec(value) - if(match) { - var betweenMatches = value.substring(startIndex, match.index) || "" - result += betweenMatches + "%" + match[1] + "%" - startIndex = dollarExpressions.lastIndex - } - } while (dollarExpressions.lastIndex > 0) - result += value.substr(startIndex) - return result -} - - +exports.replaceDollarWithPercentPair = replaceDollarWithPercentPair +exports.convertToSetCommand = convertToSetCommand +exports.convertToSetCommands = convertToSetCommands + +function convertToSetCommand(key, value) { + var line = "" + key = key || "" + key = key.trim() + value = value || "" + value = value.trim() + if(key && value && value.length > 0) { + line = "@SET " + key + "=" + replaceDollarWithPercentPair(value) + "\r\n" + } + return line +} + +function extractVariableValuePairs(declarations) { + var pairs = {} + declarations.map(function(declaration) { + var split = declaration.split("=") + pairs[split[0]]=split[1] + }) + return pairs +} + +function convertToSetCommands(variableString) { + var variableValuePairs = extractVariableValuePairs(variableString.split(" ")) + var variableDeclarationsAsBatch = "" + Object.keys(variableValuePairs).forEach(function (key) { + variableDeclarationsAsBatch += convertToSetCommand(key, variableValuePairs[key]) + }) + return variableDeclarationsAsBatch +} + +function replaceDollarWithPercentPair(value) { + var dollarExpressions = /\$\{?([^\$@#\?\- \t{}:]+)\}?/g + var result = "" + var startIndex = 0 + value = value || "" + do { + var match = dollarExpressions.exec(value) + if(match) { + var betweenMatches = value.substring(startIndex, match.index) || "" + result += betweenMatches + "%" + match[1] + "%" + startIndex = dollarExpressions.lastIndex + } + } while (dollarExpressions.lastIndex > 0) + result += value.substr(startIndex) + return result +} + + /***/ }), @@ -43725,7 +43725,7 @@ function ncp (source, dest, options, callback) { limit = (limit < 1) ? 1 : (limit > 512) ? 512 : limit; startCopy(currentPath); - + function startCopy(source) { started++; if (filter) { @@ -43808,10 +43808,10 @@ function ncp (source, dest, options, callback) { function copyFile(file, target) { var readStream = fs.createReadStream(file.name), writeStream = fs.createWriteStream(target, { mode: file.mode }); - + readStream.on('error', onError); writeStream.on('error', onError); - + if(transform) { transform(readStream, writeStream, file); } else { @@ -43936,7 +43936,7 @@ function ncp (source, dest, options, callback) { if (typeof errs.write === 'undefined') { errs.push(err); } - else { + else { errs.write(err.stack + '\n\n'); } return cb(); @@ -54739,7 +54739,7 @@ function legacy (fs) { // @return {number} The 32-bit hash MurmurHash3.prototype.result = function() { var k1, h1; - + k1 = this.k1; h1 = this.h1; @@ -55248,7 +55248,7 @@ const YARN_EXEC = process.env.npm_execpath || 'yarn'; * Install all dependencies in the given directory */ async function installInDir(directory, extraArgs = []) { - const options = ['install', '--non-interactive', '--verbose', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any + const options = ['install', '--non-interactive', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any // given time (e.g. to avoid conflicts). await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])(YARN_EXEC, options, { @@ -55904,7 +55904,7 @@ function usage($0, p) { module.exports = function (args, opts) { if (!opts) opts = {}; - + var flags = { bools : {}, strings : {}, unknownFn: null }; if (typeof opts['unknown'] === 'function') { @@ -55918,7 +55918,7 @@ module.exports = function (args, opts) { flags.bools[key] = true; }); } - + var aliases = {}; Object.keys(opts.alias || {}).forEach(function (key) { aliases[key] = [].concat(opts.alias[key]); @@ -55937,12 +55937,12 @@ module.exports = function (args, opts) { }); var defaults = opts['default'] || {}; - + var argv = { _ : [] }; Object.keys(flags.bools).forEach(function (key) { setArg(key, defaults[key] === undefined ? false : defaults[key]); }); - + var notFlags = []; if (args.indexOf('--') !== -1) { @@ -55964,7 +55964,7 @@ module.exports = function (args, opts) { ? Number(val) : val ; setKey(argv, key.split('.'), value); - + (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), value); }); @@ -55988,7 +55988,7 @@ module.exports = function (args, opts) { o[key] = [ o[key], value ]; } } - + function aliasIsBoolean(key) { return aliases[key].some(function (x) { return flags.bools[x]; @@ -55997,7 +55997,7 @@ module.exports = function (args, opts) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - + if (/^--.+=/.test(arg)) { // Using [\s\S] instead of . because js doesn't support the // 'dotall' regex modifier. See: @@ -56034,29 +56034,29 @@ module.exports = function (args, opts) { } else if (/^-[^-]+/.test(arg)) { var letters = arg.slice(1,-1).split(''); - + var broken = false; for (var j = 0; j < letters.length; j++) { var next = arg.slice(j+2); - + if (next === '-') { setArg(letters[j], next, arg) continue; } - + if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { setArg(letters[j], next.split('=')[1], arg); broken = true; break; } - + if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { setArg(letters[j], next, arg); broken = true; break; } - + if (letters[j+1] && letters[j+1].match(/\W/)) { setArg(letters[j], arg.slice(j+2), arg); broken = true; @@ -56066,7 +56066,7 @@ module.exports = function (args, opts) { setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); } } - + var key = arg.slice(-1)[0]; if (!broken && key !== '-') { if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) @@ -56096,17 +56096,17 @@ module.exports = function (args, opts) { } } } - + Object.keys(defaults).forEach(function (key) { if (!hasKey(argv, key.split('.'))) { setKey(argv, key.split('.'), defaults[key]); - + (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), defaults[key]); }); } }); - + if (opts['--']) { argv['--'] = new Array(); notFlags.forEach(function(key) { @@ -62963,18 +62963,18 @@ function mkdirP (p, opts, f, made) { else if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } if (!made) made = null; - + var cb = f || function () {}; p = path.resolve(p); - + xfs.mkdir(p, mode, function (er) { if (!er) { made = made || p; @@ -63007,10 +63007,10 @@ mkdirP.sync = function sync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } @@ -69138,67 +69138,67 @@ function childrenIgnored (self, path) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -const taskManager = __webpack_require__(592); -const async_1 = __webpack_require__(620); -const stream_1 = __webpack_require__(653); -const sync_1 = __webpack_require__(654); -const settings_1 = __webpack_require__(656); -const utils = __webpack_require__(593); -function FastGlob(source, options) { - try { - assertPatternsInput(source); - } - catch (error) { - return Promise.reject(error); - } - const works = getWorks(source, async_1.default, options); - return Promise.all(works).then(utils.array.flatten); -} -(function (FastGlob) { - function sync(source, options) { - assertPatternsInput(source); - const works = getWorks(source, sync_1.default, options); - return utils.array.flatten(works); - } - FastGlob.sync = sync; - function stream(source, options) { - assertPatternsInput(source); - const works = getWorks(source, stream_1.default, options); - /** - * The stream returned by the provider cannot work with an asynchronous iterator. - * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams. - * This affects performance (+25%). I don't see best solution right now. - */ - return utils.stream.merge(works); - } - FastGlob.stream = stream; - function generateTasks(source, options) { - assertPatternsInput(source); - const patterns = [].concat(source); - const settings = new settings_1.default(options); - return taskManager.generate(patterns, settings); - } - FastGlob.generateTasks = generateTasks; -})(FastGlob || (FastGlob = {})); -function getWorks(source, _Provider, options) { - const patterns = [].concat(source); - const settings = new settings_1.default(options); - const tasks = taskManager.generate(patterns, settings); - const provider = new _Provider(settings); - return tasks.map(provider.read, provider); -} -function assertPatternsInput(source) { - if ([].concat(source).every(isString)) { - return; - } - throw new TypeError('Patterns must be a string or an array of strings'); -} -function isString(source) { - /* tslint:disable-next-line strict-type-predicates */ - return typeof source === 'string'; -} -module.exports = FastGlob; + +const taskManager = __webpack_require__(592); +const async_1 = __webpack_require__(620); +const stream_1 = __webpack_require__(653); +const sync_1 = __webpack_require__(654); +const settings_1 = __webpack_require__(656); +const utils = __webpack_require__(593); +function FastGlob(source, options) { + try { + assertPatternsInput(source); + } + catch (error) { + return Promise.reject(error); + } + const works = getWorks(source, async_1.default, options); + return Promise.all(works).then(utils.array.flatten); +} +(function (FastGlob) { + function sync(source, options) { + assertPatternsInput(source); + const works = getWorks(source, sync_1.default, options); + return utils.array.flatten(works); + } + FastGlob.sync = sync; + function stream(source, options) { + assertPatternsInput(source); + const works = getWorks(source, stream_1.default, options); + /** + * The stream returned by the provider cannot work with an asynchronous iterator. + * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams. + * This affects performance (+25%). I don't see best solution right now. + */ + return utils.stream.merge(works); + } + FastGlob.stream = stream; + function generateTasks(source, options) { + assertPatternsInput(source); + const patterns = [].concat(source); + const settings = new settings_1.default(options); + return taskManager.generate(patterns, settings); + } + FastGlob.generateTasks = generateTasks; +})(FastGlob || (FastGlob = {})); +function getWorks(source, _Provider, options) { + const patterns = [].concat(source); + const settings = new settings_1.default(options); + const tasks = taskManager.generate(patterns, settings); + const provider = new _Provider(settings); + return tasks.map(provider.read, provider); +} +function assertPatternsInput(source) { + if ([].concat(source).every(isString)) { + return; + } + throw new TypeError('Patterns must be a string or an array of strings'); +} +function isString(source) { + /* tslint:disable-next-line strict-type-predicates */ + return typeof source === 'string'; +} +module.exports = FastGlob; /***/ }), @@ -69206,73 +69206,73 @@ module.exports = FastGlob; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -function generate(patterns, settings) { - const positivePatterns = getPositivePatterns(patterns); - const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); - /** - * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check - * filepath directly (without read directory). - */ - const staticPatterns = !settings.caseSensitiveMatch ? [] : positivePatterns.filter(utils.pattern.isStaticPattern); - const dynamicPatterns = !settings.caseSensitiveMatch ? positivePatterns : positivePatterns.filter(utils.pattern.isDynamicPattern); - const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); - const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); - return staticTasks.concat(dynamicTasks); -} -exports.generate = generate; -function convertPatternsToTasks(positive, negative, dynamic) { - const positivePatternsGroup = groupPatternsByBaseDirectory(positive); - // When we have a global group – there is no reason to divide the patterns into independent tasks. - // In this case, the global task covers the rest. - if ('.' in positivePatternsGroup) { - const task = convertPatternGroupToTask('.', positive, negative, dynamic); - return [task]; - } - return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); -} -exports.convertPatternsToTasks = convertPatternsToTasks; -function getPositivePatterns(patterns) { - return utils.pattern.getPositivePatterns(patterns); -} -exports.getPositivePatterns = getPositivePatterns; -function getNegativePatternsAsPositive(patterns, ignore) { - const negative = utils.pattern.getNegativePatterns(patterns).concat(ignore); - const positive = negative.map(utils.pattern.convertToPositivePattern); - return positive; -} -exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; -function groupPatternsByBaseDirectory(patterns) { - return patterns.reduce((collection, pattern) => { - const base = utils.pattern.getBaseDirectory(pattern); - if (base in collection) { - collection[base].push(pattern); - } - else { - collection[base] = [pattern]; - } - return collection; - }, {}); -} -exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; -function convertPatternGroupsToTasks(positive, negative, dynamic) { - return Object.keys(positive).map((base) => { - return convertPatternGroupToTask(base, positive[base], negative, dynamic); - }); -} -exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; -function convertPatternGroupToTask(base, positive, negative, dynamic) { - return { - dynamic, - positive, - negative, - base, - patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern)) - }; -} -exports.convertPatternGroupToTask = convertPatternGroupToTask; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +function generate(patterns, settings) { + const positivePatterns = getPositivePatterns(patterns); + const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); + /** + * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check + * filepath directly (without read directory). + */ + const staticPatterns = !settings.caseSensitiveMatch ? [] : positivePatterns.filter(utils.pattern.isStaticPattern); + const dynamicPatterns = !settings.caseSensitiveMatch ? positivePatterns : positivePatterns.filter(utils.pattern.isDynamicPattern); + const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); + const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); + return staticTasks.concat(dynamicTasks); +} +exports.generate = generate; +function convertPatternsToTasks(positive, negative, dynamic) { + const positivePatternsGroup = groupPatternsByBaseDirectory(positive); + // When we have a global group – there is no reason to divide the patterns into independent tasks. + // In this case, the global task covers the rest. + if ('.' in positivePatternsGroup) { + const task = convertPatternGroupToTask('.', positive, negative, dynamic); + return [task]; + } + return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); +} +exports.convertPatternsToTasks = convertPatternsToTasks; +function getPositivePatterns(patterns) { + return utils.pattern.getPositivePatterns(patterns); +} +exports.getPositivePatterns = getPositivePatterns; +function getNegativePatternsAsPositive(patterns, ignore) { + const negative = utils.pattern.getNegativePatterns(patterns).concat(ignore); + const positive = negative.map(utils.pattern.convertToPositivePattern); + return positive; +} +exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; +function groupPatternsByBaseDirectory(patterns) { + return patterns.reduce((collection, pattern) => { + const base = utils.pattern.getBaseDirectory(pattern); + if (base in collection) { + collection[base].push(pattern); + } + else { + collection[base] = [pattern]; + } + return collection; + }, {}); +} +exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; +function convertPatternGroupsToTasks(positive, negative, dynamic) { + return Object.keys(positive).map((base) => { + return convertPatternGroupToTask(base, positive[base], negative, dynamic); + }); +} +exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; +function convertPatternGroupToTask(base, positive, negative, dynamic) { + return { + dynamic, + positive, + negative, + base, + patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern)) + }; +} +exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ }), @@ -69280,20 +69280,20 @@ exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const array = __webpack_require__(594); -exports.array = array; -const errno = __webpack_require__(595); -exports.errno = errno; -const fs = __webpack_require__(596); -exports.fs = fs; -const path = __webpack_require__(597); -exports.path = path; -const pattern = __webpack_require__(598); -exports.pattern = pattern; -const stream = __webpack_require__(619); -exports.stream = stream; + +Object.defineProperty(exports, "__esModule", { value: true }); +const array = __webpack_require__(594); +exports.array = array; +const errno = __webpack_require__(595); +exports.errno = errno; +const fs = __webpack_require__(596); +exports.fs = fs; +const path = __webpack_require__(597); +exports.path = path; +const pattern = __webpack_require__(598); +exports.pattern = pattern; +const stream = __webpack_require__(619); +exports.stream = stream; /***/ }), @@ -69301,12 +69301,12 @@ exports.stream = stream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function flatten(items) { - return items.reduce((collection, item) => [].concat(collection, item), []); -} -exports.flatten = flatten; + +Object.defineProperty(exports, "__esModule", { value: true }); +function flatten(items) { + return items.reduce((collection, item) => [].concat(collection, item), []); +} +exports.flatten = flatten; /***/ }), @@ -69314,12 +69314,12 @@ exports.flatten = flatten; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function isEnoentCodeError(error) { - return error.code === 'ENOENT'; -} -exports.isEnoentCodeError = isEnoentCodeError; + +Object.defineProperty(exports, "__esModule", { value: true }); +function isEnoentCodeError(error) { + return error.code === 'ENOENT'; +} +exports.isEnoentCodeError = isEnoentCodeError; /***/ }), @@ -69327,24 +69327,24 @@ exports.isEnoentCodeError = isEnoentCodeError; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; + +Object.defineProperty(exports, "__esModule", { value: true }); +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; /***/ }), @@ -69352,20 +69352,20 @@ exports.createDirentFromStats = createDirentFromStats; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -/** - * Designed to work only with simple paths: `dir\\file`. - */ -function unixify(filepath) { - return filepath.replace(/\\/g, '/'); -} -exports.unixify = unixify; -function makeAbsolute(cwd, filepath) { - return path.resolve(cwd, filepath); -} -exports.makeAbsolute = makeAbsolute; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +/** + * Designed to work only with simple paths: `dir\\file`. + */ +function unixify(filepath) { + return filepath.replace(/\\/g, '/'); +} +exports.unixify = unixify; +function makeAbsolute(cwd, filepath) { + return path.resolve(cwd, filepath); +} +exports.makeAbsolute = makeAbsolute; /***/ }), @@ -69373,97 +69373,97 @@ exports.makeAbsolute = makeAbsolute; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const globParent = __webpack_require__(599); -const isGlob = __webpack_require__(600); -const micromatch = __webpack_require__(602); -const GLOBSTAR = '**'; -function isStaticPattern(pattern) { - return !isDynamicPattern(pattern); -} -exports.isStaticPattern = isStaticPattern; -function isDynamicPattern(pattern) { - return isGlob(pattern, { strict: false }); -} -exports.isDynamicPattern = isDynamicPattern; -function convertToPositivePattern(pattern) { - return isNegativePattern(pattern) ? pattern.slice(1) : pattern; -} -exports.convertToPositivePattern = convertToPositivePattern; -function convertToNegativePattern(pattern) { - return '!' + pattern; -} -exports.convertToNegativePattern = convertToNegativePattern; -function isNegativePattern(pattern) { - return pattern.startsWith('!') && pattern[1] !== '('; -} -exports.isNegativePattern = isNegativePattern; -function isPositivePattern(pattern) { - return !isNegativePattern(pattern); -} -exports.isPositivePattern = isPositivePattern; -function getNegativePatterns(patterns) { - return patterns.filter(isNegativePattern); -} -exports.getNegativePatterns = getNegativePatterns; -function getPositivePatterns(patterns) { - return patterns.filter(isPositivePattern); -} -exports.getPositivePatterns = getPositivePatterns; -function getBaseDirectory(pattern) { - return globParent(pattern); -} -exports.getBaseDirectory = getBaseDirectory; -function hasGlobStar(pattern) { - return pattern.indexOf(GLOBSTAR) !== -1; -} -exports.hasGlobStar = hasGlobStar; -function endsWithSlashGlobStar(pattern) { - return pattern.endsWith('/' + GLOBSTAR); -} -exports.endsWithSlashGlobStar = endsWithSlashGlobStar; -function isAffectDepthOfReadingPattern(pattern) { - const basename = path.basename(pattern); - return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); -} -exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; -function getNaiveDepth(pattern) { - const base = getBaseDirectory(pattern); - const patternDepth = pattern.split('/').length; - const patternBaseDepth = base.split('/').length; - /** - * This is a hack for pattern that has no base directory. - * - * This is related to the `*\something\*` pattern. - */ - if (base === '.') { - return patternDepth - patternBaseDepth; - } - return patternDepth - patternBaseDepth - 1; -} -exports.getNaiveDepth = getNaiveDepth; -function getMaxNaivePatternsDepth(patterns) { - return patterns.reduce((max, pattern) => { - const depth = getNaiveDepth(pattern); - return depth > max ? depth : max; - }, 0); -} -exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; -function makeRe(pattern, options) { - return micromatch.makeRe(pattern, options); -} -exports.makeRe = makeRe; -function convertPatternsToRe(patterns, options) { - return patterns.map((pattern) => makeRe(pattern, options)); -} -exports.convertPatternsToRe = convertPatternsToRe; -function matchAny(entry, patternsRe) { - const filepath = entry.replace(/^\.[\\\/]/, ''); - return patternsRe.some((patternRe) => patternRe.test(filepath)); -} -exports.matchAny = matchAny; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const globParent = __webpack_require__(599); +const isGlob = __webpack_require__(600); +const micromatch = __webpack_require__(602); +const GLOBSTAR = '**'; +function isStaticPattern(pattern) { + return !isDynamicPattern(pattern); +} +exports.isStaticPattern = isStaticPattern; +function isDynamicPattern(pattern) { + return isGlob(pattern, { strict: false }); +} +exports.isDynamicPattern = isDynamicPattern; +function convertToPositivePattern(pattern) { + return isNegativePattern(pattern) ? pattern.slice(1) : pattern; +} +exports.convertToPositivePattern = convertToPositivePattern; +function convertToNegativePattern(pattern) { + return '!' + pattern; +} +exports.convertToNegativePattern = convertToNegativePattern; +function isNegativePattern(pattern) { + return pattern.startsWith('!') && pattern[1] !== '('; +} +exports.isNegativePattern = isNegativePattern; +function isPositivePattern(pattern) { + return !isNegativePattern(pattern); +} +exports.isPositivePattern = isPositivePattern; +function getNegativePatterns(patterns) { + return patterns.filter(isNegativePattern); +} +exports.getNegativePatterns = getNegativePatterns; +function getPositivePatterns(patterns) { + return patterns.filter(isPositivePattern); +} +exports.getPositivePatterns = getPositivePatterns; +function getBaseDirectory(pattern) { + return globParent(pattern); +} +exports.getBaseDirectory = getBaseDirectory; +function hasGlobStar(pattern) { + return pattern.indexOf(GLOBSTAR) !== -1; +} +exports.hasGlobStar = hasGlobStar; +function endsWithSlashGlobStar(pattern) { + return pattern.endsWith('/' + GLOBSTAR); +} +exports.endsWithSlashGlobStar = endsWithSlashGlobStar; +function isAffectDepthOfReadingPattern(pattern) { + const basename = path.basename(pattern); + return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); +} +exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; +function getNaiveDepth(pattern) { + const base = getBaseDirectory(pattern); + const patternDepth = pattern.split('/').length; + const patternBaseDepth = base.split('/').length; + /** + * This is a hack for pattern that has no base directory. + * + * This is related to the `*\something\*` pattern. + */ + if (base === '.') { + return patternDepth - patternBaseDepth; + } + return patternDepth - patternBaseDepth - 1; +} +exports.getNaiveDepth = getNaiveDepth; +function getMaxNaivePatternsDepth(patterns) { + return patterns.reduce((max, pattern) => { + const depth = getNaiveDepth(pattern); + return depth > max ? depth : max; + }, 0); +} +exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; +function makeRe(pattern, options) { + return micromatch.makeRe(pattern, options); +} +exports.makeRe = makeRe; +function convertPatternsToRe(patterns, options) { + return patterns.map((pattern) => makeRe(pattern, options)); +} +exports.convertPatternsToRe = convertPatternsToRe; +function matchAny(entry, patternsRe) { + const filepath = entry.replace(/^\.[\\\/]/, ''); + return patternsRe.some((patternRe) => patternRe.test(filepath)); +} +exports.matchAny = matchAny; /***/ }), @@ -73377,17 +73377,17 @@ module.exports = parse; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const merge2 = __webpack_require__(585); -function merge(streams) { - const mergedStream = merge2(streams); - streams.forEach((stream) => { - stream.once('error', (err) => mergedStream.emit('error', err)); - }); - return mergedStream; -} -exports.merge = merge; + +Object.defineProperty(exports, "__esModule", { value: true }); +const merge2 = __webpack_require__(585); +function merge(streams) { + const mergedStream = merge2(streams); + streams.forEach((stream) => { + stream.once('error', (err) => mergedStream.emit('error', err)); + }); + return mergedStream; +} +exports.merge = merge; /***/ }), @@ -73395,34 +73395,34 @@ exports.merge = merge; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(621); -const provider_1 = __webpack_require__(648); -class ProviderAsync extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new stream_1.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const entries = []; - return new Promise((resolve, reject) => { - const stream = this.api(root, task, options); - stream.once('error', reject); - stream.on('data', (entry) => entries.push(options.transform(entry))); - stream.once('end', () => resolve(entries)); - }); - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderAsync; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(621); +const provider_1 = __webpack_require__(648); +class ProviderAsync extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new stream_1.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const entries = []; + return new Promise((resolve, reject) => { + const stream = this.api(root, task, options); + stream.once('error', reject); + stream.on('data', (entry) => entries.push(options.transform(entry))); + stream.once('end', () => resolve(entries)); + }); + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderAsync; /***/ }), @@ -73430,61 +73430,61 @@ exports.default = ProviderAsync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(382); -const fsStat = __webpack_require__(622); -const fsWalk = __webpack_require__(627); -const reader_1 = __webpack_require__(647); -class ReaderStream extends reader_1.default { - constructor() { - super(...arguments); - this._walkStream = fsWalk.walkStream; - this._stat = fsStat.stat; - } - dynamic(root, options) { - return this._walkStream(root, options); - } - static(patterns, options) { - const filepaths = patterns.map(this._getFullEntryPath, this); - const stream = new stream_1.PassThrough({ objectMode: true }); - stream._write = (index, _enc, done) => { - return this._getEntry(filepaths[index], patterns[index], options) - .then((entry) => { - if (entry !== null && options.entryFilter(entry)) { - stream.push(entry); - } - if (index === filepaths.length - 1) { - stream.end(); - } - done(); - }) - .catch(done); - }; - for (let i = 0; i < filepaths.length; i++) { - stream.write(i); - } - return stream; - } - _getEntry(filepath, pattern, options) { - return this._getStat(filepath) - .then((stats) => this._makeEntry(stats, pattern)) - .catch((error) => { - if (options.errorFilter(error)) { - return null; - } - throw error; - }); - } - _getStat(filepath) { - return new Promise((resolve, reject) => { - this._stat(filepath, this._fsStatSettings, (error, stats) => { - error ? reject(error) : resolve(stats); - }); - }); - } -} -exports.default = ReaderStream; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(382); +const fsStat = __webpack_require__(622); +const fsWalk = __webpack_require__(627); +const reader_1 = __webpack_require__(647); +class ReaderStream extends reader_1.default { + constructor() { + super(...arguments); + this._walkStream = fsWalk.walkStream; + this._stat = fsStat.stat; + } + dynamic(root, options) { + return this._walkStream(root, options); + } + static(patterns, options) { + const filepaths = patterns.map(this._getFullEntryPath, this); + const stream = new stream_1.PassThrough({ objectMode: true }); + stream._write = (index, _enc, done) => { + return this._getEntry(filepaths[index], patterns[index], options) + .then((entry) => { + if (entry !== null && options.entryFilter(entry)) { + stream.push(entry); + } + if (index === filepaths.length - 1) { + stream.end(); + } + done(); + }) + .catch(done); + }; + for (let i = 0; i < filepaths.length; i++) { + stream.write(i); + } + return stream; + } + _getEntry(filepath, pattern, options) { + return this._getStat(filepath) + .then((stats) => this._makeEntry(stats, pattern)) + .catch((error) => { + if (options.errorFilter(error)) { + return null; + } + throw error; + }); + } + _getStat(filepath) { + return new Promise((resolve, reject) => { + this._stat(filepath, this._fsStatSettings, (error, stats) => { + error ? reject(error) : resolve(stats); + }); + }); + } +} +exports.default = ReaderStream; /***/ }), @@ -73492,30 +73492,30 @@ exports.default = ReaderStream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async = __webpack_require__(623); -const sync = __webpack_require__(624); -const settings_1 = __webpack_require__(625); -exports.Settings = settings_1.default; -function stat(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return async.read(path, getSettings(), optionsOrSettingsOrCallback); - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.stat = stat; -function statSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.statSync = statSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async = __webpack_require__(623); +const sync = __webpack_require__(624); +const settings_1 = __webpack_require__(625); +exports.Settings = settings_1.default; +function stat(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return async.read(path, getSettings(), optionsOrSettingsOrCallback); + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.stat = stat; +function statSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.statSync = statSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} /***/ }), @@ -73523,37 +73523,37 @@ function getSettings(settingsOrOptions = {}) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function read(path, settings, callback) { - settings.fs.lstat(path, (lstatError, lstat) => { - if (lstatError) { - return callFailureCallback(callback, lstatError); - } - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return callSuccessCallback(callback, lstat); - } - settings.fs.stat(path, (statError, stat) => { - if (statError) { - if (settings.throwErrorOnBrokenSymbolicLink) { - return callFailureCallback(callback, statError); - } - return callSuccessCallback(callback, lstat); - } - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - callSuccessCallback(callback, stat); - }); - }); -} -exports.read = read; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +function read(path, settings, callback) { + settings.fs.lstat(path, (lstatError, lstat) => { + if (lstatError) { + return callFailureCallback(callback, lstatError); + } + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return callSuccessCallback(callback, lstat); + } + settings.fs.stat(path, (statError, stat) => { + if (statError) { + if (settings.throwErrorOnBrokenSymbolicLink) { + return callFailureCallback(callback, statError); + } + return callSuccessCallback(callback, lstat); + } + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + callSuccessCallback(callback, stat); + }); + }); +} +exports.read = read; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} /***/ }), @@ -73561,28 +73561,28 @@ function callSuccessCallback(callback, result) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function read(path, settings) { - const lstat = settings.fs.lstatSync(path); - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return lstat; - } - try { - const stat = settings.fs.statSync(path); - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - return stat; - } - catch (error) { - if (!settings.throwErrorOnBrokenSymbolicLink) { - return lstat; - } - throw error; - } -} -exports.read = read; + +Object.defineProperty(exports, "__esModule", { value: true }); +function read(path, settings) { + const lstat = settings.fs.lstatSync(path); + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return lstat; + } + try { + const stat = settings.fs.statSync(path); + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + return stat; + } + catch (error) { + if (!settings.throwErrorOnBrokenSymbolicLink) { + return lstat; + } + throw error; + } +} +exports.read = read; /***/ }), @@ -73590,22 +73590,22 @@ exports.read = read; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(626); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(626); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; /***/ }), @@ -73613,22 +73613,22 @@ exports.default = Settings; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(349); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync -}; -function createFileSystemAdapter(fsMethods) { - if (!fsMethods) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(349); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync +}; +function createFileSystemAdapter(fsMethods) { + if (!fsMethods) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; /***/ }), @@ -73636,38 +73636,38 @@ exports.createFileSystemAdapter = createFileSystemAdapter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = __webpack_require__(628); -const stream_1 = __webpack_require__(643); -const sync_1 = __webpack_require__(644); -const settings_1 = __webpack_require__(646); -exports.Settings = settings_1.default; -function walk(dir, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); - } - new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); -} -exports.walk = walk; -function walkSync(dir, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new sync_1.default(dir, settings); - return provider.read(); -} -exports.walkSync = walkSync; -function walkStream(dir, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new stream_1.default(dir, settings); - return provider.read(); -} -exports.walkStream = walkStream; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = __webpack_require__(628); +const stream_1 = __webpack_require__(643); +const sync_1 = __webpack_require__(644); +const settings_1 = __webpack_require__(646); +exports.Settings = settings_1.default; +function walk(dir, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); + } + new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); +} +exports.walk = walk; +function walkSync(dir, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new sync_1.default(dir, settings); + return provider.read(); +} +exports.walkSync = walkSync; +function walkStream(dir, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new stream_1.default(dir, settings); + return provider.read(); +} +exports.walkStream = walkStream; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} /***/ }), @@ -73675,36 +73675,36 @@ function getSettings(settingsOrOptions = {}) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = __webpack_require__(629); -class AsyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._storage = new Set(); - } - read(callback) { - this._reader.onError((error) => { - callFailureCallback(callback, error); - }); - this._reader.onEntry((entry) => { - this._storage.add(entry); - }); - this._reader.onEnd(() => { - callSuccessCallback(callback, Array.from(this._storage)); - }); - this._reader.read(); - } -} -exports.default = AsyncProvider; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, entries) { - callback(null, entries); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = __webpack_require__(629); +class AsyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._storage = new Set(); + } + read(callback) { + this._reader.onError((error) => { + callFailureCallback(callback, error); + }); + this._reader.onEntry((entry) => { + this._storage.add(entry); + }); + this._reader.onEnd(() => { + callSuccessCallback(callback, Array.from(this._storage)); + }); + this._reader.read(); + } +} +exports.default = AsyncProvider; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, entries) { + callback(null, entries); +} /***/ }), @@ -73712,99 +73712,99 @@ function callSuccessCallback(callback, entries) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const events_1 = __webpack_require__(373); -const fsScandir = __webpack_require__(630); -const fastq = __webpack_require__(639); -const common = __webpack_require__(641); -const reader_1 = __webpack_require__(642); -class AsyncReader extends reader_1.default { - constructor(_root, _settings) { - super(_root, _settings); - this._settings = _settings; - this._scandir = fsScandir.scandir; - this._emitter = new events_1.EventEmitter(); - this._queue = fastq(this._worker.bind(this), this._settings.concurrency); - this._isFatalError = false; - this._isDestroyed = false; - this._queue.drain = () => { - if (!this._isFatalError) { - this._emitter.emit('end'); - } - }; - } - read() { - this._isFatalError = false; - this._isDestroyed = false; - setImmediate(() => { - this._pushToQueue(this._root, this._settings.basePath); - }); - return this._emitter; - } - destroy() { - if (this._isDestroyed) { - throw new Error('The reader is already destroyed'); - } - this._isDestroyed = true; - this._queue.killAndDrain(); - } - onEntry(callback) { - this._emitter.on('entry', callback); - } - onError(callback) { - this._emitter.once('error', callback); - } - onEnd(callback) { - this._emitter.once('end', callback); - } - _pushToQueue(dir, base) { - const queueItem = { dir, base }; - this._queue.push(queueItem, (error) => { - if (error) { - this._handleError(error); - } - }); - } - _worker(item, done) { - this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { - if (error) { - return done(error, undefined); - } - for (const entry of entries) { - this._handleEntry(entry, item.base); - } - done(null, undefined); - }); - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - this._isFatalError = true; - this._isDestroyed = true; - this._emitter.emit('error', error); - } - _handleEntry(entry, base) { - if (this._isDestroyed || this._isFatalError) { - return; - } - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._emitEntry(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, entry.path); - } - } - _emitEntry(entry) { - this._emitter.emit('entry', entry); - } -} -exports.default = AsyncReader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const events_1 = __webpack_require__(373); +const fsScandir = __webpack_require__(630); +const fastq = __webpack_require__(639); +const common = __webpack_require__(641); +const reader_1 = __webpack_require__(642); +class AsyncReader extends reader_1.default { + constructor(_root, _settings) { + super(_root, _settings); + this._settings = _settings; + this._scandir = fsScandir.scandir; + this._emitter = new events_1.EventEmitter(); + this._queue = fastq(this._worker.bind(this), this._settings.concurrency); + this._isFatalError = false; + this._isDestroyed = false; + this._queue.drain = () => { + if (!this._isFatalError) { + this._emitter.emit('end'); + } + }; + } + read() { + this._isFatalError = false; + this._isDestroyed = false; + setImmediate(() => { + this._pushToQueue(this._root, this._settings.basePath); + }); + return this._emitter; + } + destroy() { + if (this._isDestroyed) { + throw new Error('The reader is already destroyed'); + } + this._isDestroyed = true; + this._queue.killAndDrain(); + } + onEntry(callback) { + this._emitter.on('entry', callback); + } + onError(callback) { + this._emitter.once('error', callback); + } + onEnd(callback) { + this._emitter.once('end', callback); + } + _pushToQueue(dir, base) { + const queueItem = { dir, base }; + this._queue.push(queueItem, (error) => { + if (error) { + this._handleError(error); + } + }); + } + _worker(item, done) { + this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { + if (error) { + return done(error, undefined); + } + for (const entry of entries) { + this._handleEntry(entry, item.base); + } + done(null, undefined); + }); + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + this._isFatalError = true; + this._isDestroyed = true; + this._emitter.emit('error', error); + } + _handleEntry(entry, base) { + if (this._isDestroyed || this._isFatalError) { + return; + } + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._emitEntry(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, entry.path); + } + } + _emitEntry(entry) { + this._emitter.emit('entry', entry); + } +} +exports.default = AsyncReader; /***/ }), @@ -73812,30 +73812,30 @@ exports.default = AsyncReader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async = __webpack_require__(631); -const sync = __webpack_require__(636); -const settings_1 = __webpack_require__(637); -exports.Settings = settings_1.default; -function scandir(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return async.read(path, getSettings(), optionsOrSettingsOrCallback); - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.scandir = scandir; -function scandirSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.scandirSync = scandirSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async = __webpack_require__(631); +const sync = __webpack_require__(636); +const settings_1 = __webpack_require__(637); +exports.Settings = settings_1.default; +function scandir(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return async.read(path, getSettings(), optionsOrSettingsOrCallback); + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.scandir = scandir; +function scandirSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.scandirSync = scandirSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} /***/ }), @@ -73843,97 +73843,97 @@ function getSettings(settingsOrOptions = {}) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(622); -const rpl = __webpack_require__(632); -const constants_1 = __webpack_require__(633); -const utils = __webpack_require__(634); -function read(dir, settings, callback) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(dir, settings, callback); - } - return readdir(dir, settings, callback); -} -exports.read = read; -function readdirWithFileTypes(dir, settings, callback) { - settings.fs.readdir(dir, { withFileTypes: true }, (readdirError, dirents) => { - if (readdirError) { - return callFailureCallback(callback, readdirError); - } - const entries = dirents.map((dirent) => ({ - dirent, - name: dirent.name, - path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` - })); - if (!settings.followSymbolicLinks) { - return callSuccessCallback(callback, entries); - } - const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); - rpl(tasks, (rplError, rplEntries) => { - if (rplError) { - return callFailureCallback(callback, rplError); - } - callSuccessCallback(callback, rplEntries); - }); - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function makeRplTaskEntry(entry, settings) { - return (done) => { - if (!entry.dirent.isSymbolicLink()) { - return done(null, entry); - } - settings.fs.stat(entry.path, (statError, stats) => { - if (statError) { - if (settings.throwErrorOnBrokenSymbolicLink) { - return done(statError); - } - return done(null, entry); - } - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - return done(null, entry); - }); - }; -} -function readdir(dir, settings, callback) { - settings.fs.readdir(dir, (readdirError, names) => { - if (readdirError) { - return callFailureCallback(callback, readdirError); - } - const filepaths = names.map((name) => `${dir}${settings.pathSegmentSeparator}${name}`); - const tasks = filepaths.map((filepath) => { - return (done) => fsStat.stat(filepath, settings.fsStatSettings, done); - }); - rpl(tasks, (rplError, results) => { - if (rplError) { - return callFailureCallback(callback, rplError); - } - const entries = []; - for (let index = 0; index < names.length; index++) { - const name = names[index]; - const stats = results[index]; - const entry = { - name, - path: filepaths[index], - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - entries.push(entry); - } - callSuccessCallback(callback, entries); - }); - }); -} -exports.readdir = readdir; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(622); +const rpl = __webpack_require__(632); +const constants_1 = __webpack_require__(633); +const utils = __webpack_require__(634); +function read(dir, settings, callback) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(dir, settings, callback); + } + return readdir(dir, settings, callback); +} +exports.read = read; +function readdirWithFileTypes(dir, settings, callback) { + settings.fs.readdir(dir, { withFileTypes: true }, (readdirError, dirents) => { + if (readdirError) { + return callFailureCallback(callback, readdirError); + } + const entries = dirents.map((dirent) => ({ + dirent, + name: dirent.name, + path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` + })); + if (!settings.followSymbolicLinks) { + return callSuccessCallback(callback, entries); + } + const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); + rpl(tasks, (rplError, rplEntries) => { + if (rplError) { + return callFailureCallback(callback, rplError); + } + callSuccessCallback(callback, rplEntries); + }); + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function makeRplTaskEntry(entry, settings) { + return (done) => { + if (!entry.dirent.isSymbolicLink()) { + return done(null, entry); + } + settings.fs.stat(entry.path, (statError, stats) => { + if (statError) { + if (settings.throwErrorOnBrokenSymbolicLink) { + return done(statError); + } + return done(null, entry); + } + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + return done(null, entry); + }); + }; +} +function readdir(dir, settings, callback) { + settings.fs.readdir(dir, (readdirError, names) => { + if (readdirError) { + return callFailureCallback(callback, readdirError); + } + const filepaths = names.map((name) => `${dir}${settings.pathSegmentSeparator}${name}`); + const tasks = filepaths.map((filepath) => { + return (done) => fsStat.stat(filepath, settings.fsStatSettings, done); + }); + rpl(tasks, (rplError, results) => { + if (rplError) { + return callFailureCallback(callback, rplError); + } + const entries = []; + for (let index = 0; index < names.length; index++) { + const name = names[index]; + const stats = results[index]; + const entry = { + name, + path: filepaths[index], + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + entries.push(entry); + } + callSuccessCallback(callback, entries); + }); + }); +} +exports.readdir = readdir; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} /***/ }), @@ -73995,15 +73995,15 @@ function runParallel (tasks, cb) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); -const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); -const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); -/** - * IS `true` for Node.js 10.10 and greater. - */ -exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSION === 10 && MINOR_VERSION >= 10); + +Object.defineProperty(exports, "__esModule", { value: true }); +const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); +const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); +const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); +/** + * IS `true` for Node.js 10.10 and greater. + */ +exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSION === 10 && MINOR_VERSION >= 10); /***/ }), @@ -74011,10 +74011,10 @@ exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSIO /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(635); -exports.fs = fs; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(635); +exports.fs = fs; /***/ }), @@ -74022,24 +74022,24 @@ exports.fs = fs; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; + +Object.defineProperty(exports, "__esModule", { value: true }); +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; /***/ }), @@ -74047,58 +74047,58 @@ exports.createDirentFromStats = createDirentFromStats; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(622); -const constants_1 = __webpack_require__(633); -const utils = __webpack_require__(634); -function read(dir, settings) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(dir, settings); - } - return readdir(dir, settings); -} -exports.read = read; -function readdirWithFileTypes(dir, settings) { - const dirents = settings.fs.readdirSync(dir, { withFileTypes: true }); - return dirents.map((dirent) => { - const entry = { - dirent, - name: dirent.name, - path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` - }; - if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { - try { - const stats = settings.fs.statSync(entry.path); - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - } - catch (error) { - if (settings.throwErrorOnBrokenSymbolicLink) { - throw error; - } - } - } - return entry; - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function readdir(dir, settings) { - const names = settings.fs.readdirSync(dir); - return names.map((name) => { - const entryPath = `${dir}${settings.pathSegmentSeparator}${name}`; - const stats = fsStat.statSync(entryPath, settings.fsStatSettings); - const entry = { - name, - path: entryPath, - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - return entry; - }); -} -exports.readdir = readdir; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(622); +const constants_1 = __webpack_require__(633); +const utils = __webpack_require__(634); +function read(dir, settings) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(dir, settings); + } + return readdir(dir, settings); +} +exports.read = read; +function readdirWithFileTypes(dir, settings) { + const dirents = settings.fs.readdirSync(dir, { withFileTypes: true }); + return dirents.map((dirent) => { + const entry = { + dirent, + name: dirent.name, + path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` + }; + if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { + try { + const stats = settings.fs.statSync(entry.path); + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + } + catch (error) { + if (settings.throwErrorOnBrokenSymbolicLink) { + throw error; + } + } + } + return entry; + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function readdir(dir, settings) { + const names = settings.fs.readdirSync(dir); + return names.map((name) => { + const entryPath = `${dir}${settings.pathSegmentSeparator}${name}`; + const stats = fsStat.statSync(entryPath, settings.fsStatSettings); + const entry = { + name, + path: entryPath, + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + return entry; + }); +} +exports.readdir = readdir; /***/ }), @@ -74106,30 +74106,30 @@ exports.readdir = readdir; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const fsStat = __webpack_require__(622); -const fs = __webpack_require__(638); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.stats = this._getValue(this._options.stats, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - this.fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this.followSymbolicLinks, - fs: this.fs, - throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const fsStat = __webpack_require__(622); +const fs = __webpack_require__(638); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.stats = this._getValue(this._options.stats, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + this.fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this.followSymbolicLinks, + fs: this.fs, + throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; /***/ }), @@ -74137,24 +74137,24 @@ exports.default = Settings; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(349); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -function createFileSystemAdapter(fsMethods) { - if (!fsMethods) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(349); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +function createFileSystemAdapter(fsMethods) { + if (!fsMethods) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; /***/ }), @@ -74382,30 +74382,30 @@ module.exports = reusify /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function isFatalError(settings, error) { - if (settings.errorFilter === null) { - return true; - } - return !settings.errorFilter(error); -} -exports.isFatalError = isFatalError; -function isAppliedFilter(filter, value) { - return filter === null || filter(value); -} -exports.isAppliedFilter = isAppliedFilter; -function replacePathSegmentSeparator(filepath, separator) { - return filepath.split(/[\\\/]/).join(separator); -} -exports.replacePathSegmentSeparator = replacePathSegmentSeparator; -function joinPathSegments(a, b, separator) { - if (a === '') { - return b; - } - return a + separator + b; -} -exports.joinPathSegments = joinPathSegments; + +Object.defineProperty(exports, "__esModule", { value: true }); +function isFatalError(settings, error) { + if (settings.errorFilter === null) { + return true; + } + return !settings.errorFilter(error); +} +exports.isFatalError = isFatalError; +function isAppliedFilter(filter, value) { + return filter === null || filter(value); +} +exports.isAppliedFilter = isAppliedFilter; +function replacePathSegmentSeparator(filepath, separator) { + return filepath.split(/[\\\/]/).join(separator); +} +exports.replacePathSegmentSeparator = replacePathSegmentSeparator; +function joinPathSegments(a, b, separator) { + if (a === '') { + return b; + } + return a + separator + b; +} +exports.joinPathSegments = joinPathSegments; /***/ }), @@ -74413,17 +74413,17 @@ exports.joinPathSegments = joinPathSegments; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const common = __webpack_require__(641); -class Reader { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); - } -} -exports.default = Reader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const common = __webpack_require__(641); +class Reader { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); + } +} +exports.default = Reader; /***/ }), @@ -74431,36 +74431,36 @@ exports.default = Reader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(382); -const async_1 = __webpack_require__(629); -class StreamProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._stream = new stream_1.Readable({ - objectMode: true, - read: () => { }, - destroy: this._reader.destroy.bind(this._reader) - }); - } - read() { - this._reader.onError((error) => { - this._stream.emit('error', error); - }); - this._reader.onEntry((entry) => { - this._stream.push(entry); - }); - this._reader.onEnd(() => { - this._stream.push(null); - }); - this._reader.read(); - return this._stream; - } -} -exports.default = StreamProvider; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(382); +const async_1 = __webpack_require__(629); +class StreamProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._stream = new stream_1.Readable({ + objectMode: true, + read: () => { }, + destroy: this._reader.destroy.bind(this._reader) + }); + } + read() { + this._reader.onError((error) => { + this._stream.emit('error', error); + }); + this._reader.onEntry((entry) => { + this._stream.push(entry); + }); + this._reader.onEnd(() => { + this._stream.push(null); + }); + this._reader.read(); + return this._stream; + } +} +exports.default = StreamProvider; /***/ }), @@ -74468,20 +74468,20 @@ exports.default = StreamProvider; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = __webpack_require__(645); -class SyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new sync_1.default(this._root, this._settings); - } - read() { - return this._reader.read(); - } -} -exports.default = SyncProvider; + +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = __webpack_require__(645); +class SyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new sync_1.default(this._root, this._settings); + } + read() { + return this._reader.read(); + } +} +exports.default = SyncProvider; /***/ }), @@ -74489,65 +74489,65 @@ exports.default = SyncProvider; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsScandir = __webpack_require__(630); -const common = __webpack_require__(641); -const reader_1 = __webpack_require__(642); -class SyncReader extends reader_1.default { - constructor() { - super(...arguments); - this._scandir = fsScandir.scandirSync; - this._storage = new Set(); - this._queue = new Set(); - } - read() { - this._pushToQueue(this._root, this._settings.basePath); - this._handleQueue(); - return Array.from(this._storage); - } - _pushToQueue(dir, base) { - this._queue.add({ dir, base }); - } - _handleQueue() { - for (const item of this._queue.values()) { - this._handleDirectory(item.dir, item.base); - } - } - _handleDirectory(dir, base) { - try { - const entries = this._scandir(dir, this._settings.fsScandirSettings); - for (const entry of entries) { - this._handleEntry(entry, base); - } - } - catch (error) { - this._handleError(error); - } - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - throw error; - } - _handleEntry(entry, base) { - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._pushToStorage(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, entry.path); - } - } - _pushToStorage(entry) { - this._storage.add(entry); - } -} -exports.default = SyncReader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsScandir = __webpack_require__(630); +const common = __webpack_require__(641); +const reader_1 = __webpack_require__(642); +class SyncReader extends reader_1.default { + constructor() { + super(...arguments); + this._scandir = fsScandir.scandirSync; + this._storage = new Set(); + this._queue = new Set(); + } + read() { + this._pushToQueue(this._root, this._settings.basePath); + this._handleQueue(); + return Array.from(this._storage); + } + _pushToQueue(dir, base) { + this._queue.add({ dir, base }); + } + _handleQueue() { + for (const item of this._queue.values()) { + this._handleDirectory(item.dir, item.base); + } + } + _handleDirectory(dir, base) { + try { + const entries = this._scandir(dir, this._settings.fsScandirSettings); + for (const entry of entries) { + this._handleEntry(entry, base); + } + } + catch (error) { + this._handleError(error); + } + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + throw error; + } + _handleEntry(entry, base) { + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._pushToStorage(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, entry.path); + } + } + _pushToStorage(entry) { + this._storage.add(entry); + } +} +exports.default = SyncReader; /***/ }), @@ -74555,32 +74555,32 @@ exports.default = SyncReader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const fsScandir = __webpack_require__(630); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.basePath = this._getValue(this._options.basePath, undefined); - this.concurrency = this._getValue(this._options.concurrency, Infinity); - this.deepFilter = this._getValue(this._options.deepFilter, null); - this.entryFilter = this._getValue(this._options.entryFilter, null); - this.errorFilter = this._getValue(this._options.errorFilter, null); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.fsScandirSettings = new fsScandir.Settings({ - followSymbolicLinks: this._options.followSymbolicLinks, - fs: this._options.fs, - pathSegmentSeparator: this._options.pathSegmentSeparator, - stats: this._options.stats, - throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const fsScandir = __webpack_require__(630); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.basePath = this._getValue(this._options.basePath, undefined); + this.concurrency = this._getValue(this._options.concurrency, Infinity); + this.deepFilter = this._getValue(this._options.deepFilter, null); + this.entryFilter = this._getValue(this._options.entryFilter, null); + this.errorFilter = this._getValue(this._options.errorFilter, null); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.fsScandirSettings = new fsScandir.Settings({ + followSymbolicLinks: this._options.followSymbolicLinks, + fs: this._options.fs, + pathSegmentSeparator: this._options.pathSegmentSeparator, + stats: this._options.stats, + throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; /***/ }), @@ -74588,39 +74588,39 @@ exports.default = Settings; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const fsStat = __webpack_require__(622); -const utils = __webpack_require__(593); -class Reader { - constructor(_settings) { - this._settings = _settings; - this._fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this._settings.followSymbolicLinks, - fs: this._settings.fs, - throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks - }); - } - _getFullEntryPath(filepath) { - return path.resolve(this._settings.cwd, filepath); - } - _makeEntry(stats, pattern) { - const entry = { - name: pattern, - path: pattern, - dirent: utils.fs.createDirentFromStats(pattern, stats) - }; - if (this._settings.stats) { - entry.stats = stats; - } - return entry; - } - _isFatalError(error) { - return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors; - } -} -exports.default = Reader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const fsStat = __webpack_require__(622); +const utils = __webpack_require__(593); +class Reader { + constructor(_settings) { + this._settings = _settings; + this._fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this._settings.followSymbolicLinks, + fs: this._settings.fs, + throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks + }); + } + _getFullEntryPath(filepath) { + return path.resolve(this._settings.cwd, filepath); + } + _makeEntry(stats, pattern) { + const entry = { + name: pattern, + path: pattern, + dirent: utils.fs.createDirentFromStats(pattern, stats) + }; + if (this._settings.stats) { + entry.stats = stats; + } + return entry; + } + _isFatalError(error) { + return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors; + } +} +exports.default = Reader; /***/ }), @@ -74628,54 +74628,54 @@ exports.default = Reader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const deep_1 = __webpack_require__(649); -const entry_1 = __webpack_require__(650); -const error_1 = __webpack_require__(651); -const entry_2 = __webpack_require__(652); -class Provider { - constructor(_settings) { - this._settings = _settings; - this.errorFilter = new error_1.default(this._settings); - this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions()); - this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions()); - this.entryTransformer = new entry_2.default(this._settings); - } - _getRootDirectory(task) { - return path.resolve(this._settings.cwd, task.base); - } - _getReaderOptions(task) { - const basePath = task.base === '.' ? '' : task.base; - return { - basePath, - pathSegmentSeparator: '/', - concurrency: this._settings.concurrency, - deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative), - entryFilter: this.entryFilter.getFilter(task.positive, task.negative), - errorFilter: this.errorFilter.getFilter(), - followSymbolicLinks: this._settings.followSymbolicLinks, - fs: this._settings.fs, - stats: this._settings.stats, - throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink, - transform: this.entryTransformer.getTransformer() - }; - } - _getMicromatchOptions() { - return { - dot: this._settings.dot, - matchBase: this._settings.baseNameMatch, - nobrace: !this._settings.braceExpansion, - nocase: !this._settings.caseSensitiveMatch, - noext: !this._settings.extglob, - noglobstar: !this._settings.globstar, - posix: true, - strictSlashes: false - }; - } -} -exports.default = Provider; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const deep_1 = __webpack_require__(649); +const entry_1 = __webpack_require__(650); +const error_1 = __webpack_require__(651); +const entry_2 = __webpack_require__(652); +class Provider { + constructor(_settings) { + this._settings = _settings; + this.errorFilter = new error_1.default(this._settings); + this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions()); + this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions()); + this.entryTransformer = new entry_2.default(this._settings); + } + _getRootDirectory(task) { + return path.resolve(this._settings.cwd, task.base); + } + _getReaderOptions(task) { + const basePath = task.base === '.' ? '' : task.base; + return { + basePath, + pathSegmentSeparator: '/', + concurrency: this._settings.concurrency, + deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative), + entryFilter: this.entryFilter.getFilter(task.positive, task.negative), + errorFilter: this.errorFilter.getFilter(), + followSymbolicLinks: this._settings.followSymbolicLinks, + fs: this._settings.fs, + stats: this._settings.stats, + throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink, + transform: this.entryTransformer.getTransformer() + }; + } + _getMicromatchOptions() { + return { + dot: this._settings.dot, + matchBase: this._settings.baseNameMatch, + nobrace: !this._settings.braceExpansion, + nocase: !this._settings.caseSensitiveMatch, + noext: !this._settings.extglob, + noglobstar: !this._settings.globstar, + posix: true, + strictSlashes: false + }; + } +} +exports.default = Provider; /***/ }), @@ -74683,65 +74683,65 @@ exports.default = Provider; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class DeepFilter { - constructor(_settings, _micromatchOptions) { - this._settings = _settings; - this._micromatchOptions = _micromatchOptions; - } - getFilter(basePath, positive, negative) { - const maxPatternDepth = this._getMaxPatternDepth(positive); - const negativeRe = this._getNegativePatternsRe(negative); - return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth); - } - _getMaxPatternDepth(patterns) { - const globstar = patterns.some(utils.pattern.hasGlobStar); - return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns); - } - _getNegativePatternsRe(patterns) { - const affectDepthOfReadingPatterns = patterns.filter(utils.pattern.isAffectDepthOfReadingPattern); - return utils.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions); - } - _filter(basePath, entry, negativeRe, maxPatternDepth) { - const depth = this._getEntryDepth(basePath, entry.path); - if (this._isSkippedByDeep(depth)) { - return false; - } - if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) { - return false; - } - if (this._isSkippedSymbolicLink(entry)) { - return false; - } - if (this._isSkippedDotDirectory(entry)) { - return false; - } - return this._isSkippedByNegativePatterns(entry, negativeRe); - } - _getEntryDepth(basePath, entryPath) { - const basePathDepth = basePath.split('/').length; - const entryPathDepth = entryPath.split('/').length; - return entryPathDepth - (basePath === '' ? 0 : basePathDepth); - } - _isSkippedByDeep(entryDepth) { - return entryDepth >= this._settings.deep; - } - _isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) { - return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth; - } - _isSkippedSymbolicLink(entry) { - return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink(); - } - _isSkippedDotDirectory(entry) { - return !this._settings.dot && entry.name.startsWith('.'); - } - _isSkippedByNegativePatterns(entry, negativeRe) { - return !utils.pattern.matchAny(entry.path, negativeRe); - } -} -exports.default = DeepFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class DeepFilter { + constructor(_settings, _micromatchOptions) { + this._settings = _settings; + this._micromatchOptions = _micromatchOptions; + } + getFilter(basePath, positive, negative) { + const maxPatternDepth = this._getMaxPatternDepth(positive); + const negativeRe = this._getNegativePatternsRe(negative); + return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth); + } + _getMaxPatternDepth(patterns) { + const globstar = patterns.some(utils.pattern.hasGlobStar); + return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns); + } + _getNegativePatternsRe(patterns) { + const affectDepthOfReadingPatterns = patterns.filter(utils.pattern.isAffectDepthOfReadingPattern); + return utils.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions); + } + _filter(basePath, entry, negativeRe, maxPatternDepth) { + const depth = this._getEntryDepth(basePath, entry.path); + if (this._isSkippedByDeep(depth)) { + return false; + } + if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) { + return false; + } + if (this._isSkippedSymbolicLink(entry)) { + return false; + } + if (this._isSkippedDotDirectory(entry)) { + return false; + } + return this._isSkippedByNegativePatterns(entry, negativeRe); + } + _getEntryDepth(basePath, entryPath) { + const basePathDepth = basePath.split('/').length; + const entryPathDepth = entryPath.split('/').length; + return entryPathDepth - (basePath === '' ? 0 : basePathDepth); + } + _isSkippedByDeep(entryDepth) { + return entryDepth >= this._settings.deep; + } + _isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) { + return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth; + } + _isSkippedSymbolicLink(entry) { + return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink(); + } + _isSkippedDotDirectory(entry) { + return !this._settings.dot && entry.name.startsWith('.'); + } + _isSkippedByNegativePatterns(entry, negativeRe) { + return !utils.pattern.matchAny(entry.path, negativeRe); + } +} +exports.default = DeepFilter; /***/ }), @@ -74749,60 +74749,60 @@ exports.default = DeepFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class EntryFilter { - constructor(_settings, _micromatchOptions) { - this._settings = _settings; - this._micromatchOptions = _micromatchOptions; - this.index = new Map(); - } - getFilter(positive, negative) { - const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions); - const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions); - return (entry) => this._filter(entry, positiveRe, negativeRe); - } - _filter(entry, positiveRe, negativeRe) { - if (this._settings.unique) { - if (this._isDuplicateEntry(entry)) { - return false; - } - this._createIndexRecord(entry); - } - if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) { - return false; - } - if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { - return false; - } - const filepath = this._settings.baseNameMatch ? entry.name : entry.path; - return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe); - } - _isDuplicateEntry(entry) { - return this.index.has(entry.path); - } - _createIndexRecord(entry) { - this.index.set(entry.path, undefined); - } - _onlyFileFilter(entry) { - return this._settings.onlyFiles && !entry.dirent.isFile(); - } - _onlyDirectoryFilter(entry) { - return this._settings.onlyDirectories && !entry.dirent.isDirectory(); - } - _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) { - if (!this._settings.absolute) { - return false; - } - const fullpath = utils.path.makeAbsolute(this._settings.cwd, entry.path); - return this._isMatchToPatterns(fullpath, negativeRe); - } - _isMatchToPatterns(filepath, patternsRe) { - return utils.pattern.matchAny(filepath, patternsRe); - } -} -exports.default = EntryFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class EntryFilter { + constructor(_settings, _micromatchOptions) { + this._settings = _settings; + this._micromatchOptions = _micromatchOptions; + this.index = new Map(); + } + getFilter(positive, negative) { + const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions); + const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions); + return (entry) => this._filter(entry, positiveRe, negativeRe); + } + _filter(entry, positiveRe, negativeRe) { + if (this._settings.unique) { + if (this._isDuplicateEntry(entry)) { + return false; + } + this._createIndexRecord(entry); + } + if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) { + return false; + } + if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { + return false; + } + const filepath = this._settings.baseNameMatch ? entry.name : entry.path; + return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe); + } + _isDuplicateEntry(entry) { + return this.index.has(entry.path); + } + _createIndexRecord(entry) { + this.index.set(entry.path, undefined); + } + _onlyFileFilter(entry) { + return this._settings.onlyFiles && !entry.dirent.isFile(); + } + _onlyDirectoryFilter(entry) { + return this._settings.onlyDirectories && !entry.dirent.isDirectory(); + } + _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) { + if (!this._settings.absolute) { + return false; + } + const fullpath = utils.path.makeAbsolute(this._settings.cwd, entry.path); + return this._isMatchToPatterns(fullpath, negativeRe); + } + _isMatchToPatterns(filepath, patternsRe) { + return utils.pattern.matchAny(filepath, patternsRe); + } +} +exports.default = EntryFilter; /***/ }), @@ -74810,21 +74810,21 @@ exports.default = EntryFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class ErrorFilter { - constructor(_settings) { - this._settings = _settings; - } - getFilter() { - return (error) => this._isNonFatalError(error); - } - _isNonFatalError(error) { - return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors; - } -} -exports.default = ErrorFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class ErrorFilter { + constructor(_settings) { + this._settings = _settings; + } + getFilter() { + return (error) => this._isNonFatalError(error); + } + _isNonFatalError(error) { + return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors; + } +} +exports.default = ErrorFilter; /***/ }), @@ -74832,32 +74832,32 @@ exports.default = ErrorFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class EntryTransformer { - constructor(_settings) { - this._settings = _settings; - } - getTransformer() { - return (entry) => this._transform(entry); - } - _transform(entry) { - let filepath = entry.path; - if (this._settings.absolute) { - filepath = utils.path.makeAbsolute(this._settings.cwd, filepath); - filepath = utils.path.unixify(filepath); - } - if (this._settings.markDirectories && entry.dirent.isDirectory()) { - filepath += '/'; - } - if (!this._settings.objectMode) { - return filepath; - } - return Object.assign({}, entry, { path: filepath }); - } -} -exports.default = EntryTransformer; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class EntryTransformer { + constructor(_settings) { + this._settings = _settings; + } + getTransformer() { + return (entry) => this._transform(entry); + } + _transform(entry) { + let filepath = entry.path; + if (this._settings.absolute) { + filepath = utils.path.makeAbsolute(this._settings.cwd, filepath); + filepath = utils.path.unixify(filepath); + } + if (this._settings.markDirectories && entry.dirent.isDirectory()) { + filepath += '/'; + } + if (!this._settings.objectMode) { + return filepath; + } + return Object.assign({}, entry, { path: filepath }); + } +} +exports.default = EntryTransformer; /***/ }), @@ -74865,35 +74865,35 @@ exports.default = EntryTransformer; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(382); -const stream_2 = __webpack_require__(621); -const provider_1 = __webpack_require__(648); -class ProviderStream extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new stream_2.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const source = this.api(root, task, options); - const dest = new stream_1.Readable({ objectMode: true, read: () => { } }); - source - .once('error', (error) => dest.emit('error', error)) - .on('data', (entry) => dest.emit('data', options.transform(entry))) - .once('end', () => dest.emit('end')); - return dest; - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderStream; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(382); +const stream_2 = __webpack_require__(621); +const provider_1 = __webpack_require__(648); +class ProviderStream extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new stream_2.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const source = this.api(root, task, options); + const dest = new stream_1.Readable({ objectMode: true, read: () => { } }); + source + .once('error', (error) => dest.emit('error', error)) + .on('data', (entry) => dest.emit('data', options.transform(entry))) + .once('end', () => dest.emit('end')); + return dest; + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderStream; /***/ }), @@ -74901,29 +74901,29 @@ exports.default = ProviderStream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = __webpack_require__(655); -const provider_1 = __webpack_require__(648); -class ProviderSync extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new sync_1.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const entries = this.api(root, task, options); - return entries.map(options.transform); - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderSync; + +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = __webpack_require__(655); +const provider_1 = __webpack_require__(648); +class ProviderSync extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new sync_1.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const entries = this.api(root, task, options); + return entries.map(options.transform); + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderSync; /***/ }), @@ -74931,49 +74931,49 @@ exports.default = ProviderSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(622); -const fsWalk = __webpack_require__(627); -const reader_1 = __webpack_require__(647); -class ReaderSync extends reader_1.default { - constructor() { - super(...arguments); - this._walkSync = fsWalk.walkSync; - this._statSync = fsStat.statSync; - } - dynamic(root, options) { - return this._walkSync(root, options); - } - static(patterns, options) { - const entries = []; - for (const pattern of patterns) { - const filepath = this._getFullEntryPath(pattern); - const entry = this._getEntry(filepath, pattern, options); - if (entry === null || !options.entryFilter(entry)) { - continue; - } - entries.push(entry); - } - return entries; - } - _getEntry(filepath, pattern, options) { - try { - const stats = this._getStat(filepath); - return this._makeEntry(stats, pattern); - } - catch (error) { - if (options.errorFilter(error)) { - return null; - } - throw error; - } - } - _getStat(filepath) { - return this._statSync(filepath, this._fsStatSettings); - } -} -exports.default = ReaderSync; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(622); +const fsWalk = __webpack_require__(627); +const reader_1 = __webpack_require__(647); +class ReaderSync extends reader_1.default { + constructor() { + super(...arguments); + this._walkSync = fsWalk.walkSync; + this._statSync = fsStat.statSync; + } + dynamic(root, options) { + return this._walkSync(root, options); + } + static(patterns, options) { + const entries = []; + for (const pattern of patterns) { + const filepath = this._getFullEntryPath(pattern); + const entry = this._getEntry(filepath, pattern, options); + if (entry === null || !options.entryFilter(entry)) { + continue; + } + entries.push(entry); + } + return entries; + } + _getEntry(filepath, pattern, options) { + try { + const stats = this._getStat(filepath); + return this._makeEntry(stats, pattern); + } + catch (error) { + if (options.errorFilter(error)) { + return null; + } + throw error; + } + } + _getStat(filepath) { + return this._statSync(filepath, this._fsStatSettings); + } +} +exports.default = ReaderSync; /***/ }), @@ -74981,59 +74981,59 @@ exports.default = ReaderSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(349); -const os = __webpack_require__(364); -const CPU_COUNT = os.cpus().length; -exports.DEFAULT_FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - lstatSync: fs.lstatSync, - stat: fs.stat, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -// tslint:enable no-redundant-jsdoc -class Settings { - constructor(_options = {}) { - this._options = _options; - this.absolute = this._getValue(this._options.absolute, false); - this.baseNameMatch = this._getValue(this._options.baseNameMatch, false); - this.braceExpansion = this._getValue(this._options.braceExpansion, true); - this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true); - this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT); - this.cwd = this._getValue(this._options.cwd, process.cwd()); - this.deep = this._getValue(this._options.deep, Infinity); - this.dot = this._getValue(this._options.dot, false); - this.extglob = this._getValue(this._options.extglob, true); - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true); - this.fs = this._getFileSystemMethods(this._options.fs); - this.globstar = this._getValue(this._options.globstar, true); - this.ignore = this._getValue(this._options.ignore, []); - this.markDirectories = this._getValue(this._options.markDirectories, false); - this.objectMode = this._getValue(this._options.objectMode, false); - this.onlyDirectories = this._getValue(this._options.onlyDirectories, false); - this.onlyFiles = this._getValue(this._options.onlyFiles, true); - this.stats = this._getValue(this._options.stats, false); - this.suppressErrors = this._getValue(this._options.suppressErrors, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false); - this.unique = this._getValue(this._options.unique, true); - if (this.onlyDirectories) { - this.onlyFiles = false; - } - if (this.stats) { - this.objectMode = true; - } - } - _getValue(option, value) { - return option === undefined ? value : option; - } - _getFileSystemMethods(methods = {}) { - return Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER, methods); - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(349); +const os = __webpack_require__(364); +const CPU_COUNT = os.cpus().length; +exports.DEFAULT_FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + lstatSync: fs.lstatSync, + stat: fs.stat, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +// tslint:enable no-redundant-jsdoc +class Settings { + constructor(_options = {}) { + this._options = _options; + this.absolute = this._getValue(this._options.absolute, false); + this.baseNameMatch = this._getValue(this._options.baseNameMatch, false); + this.braceExpansion = this._getValue(this._options.braceExpansion, true); + this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true); + this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT); + this.cwd = this._getValue(this._options.cwd, process.cwd()); + this.deep = this._getValue(this._options.deep, Infinity); + this.dot = this._getValue(this._options.dot, false); + this.extglob = this._getValue(this._options.extglob, true); + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true); + this.fs = this._getFileSystemMethods(this._options.fs); + this.globstar = this._getValue(this._options.globstar, true); + this.ignore = this._getValue(this._options.ignore, []); + this.markDirectories = this._getValue(this._options.markDirectories, false); + this.objectMode = this._getValue(this._options.objectMode, false); + this.onlyDirectories = this._getValue(this._options.onlyDirectories, false); + this.onlyFiles = this._getValue(this._options.onlyFiles, true); + this.stats = this._getValue(this._options.stats, false); + this.suppressErrors = this._getValue(this._options.suppressErrors, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false); + this.unique = this._getValue(this._options.unique, true); + if (this.onlyDirectories) { + this.onlyFiles = false; + } + if (this.stats) { + this.objectMode = true; + } + } + _getValue(option, value) { + return option === undefined ? value : option; + } + _getFileSystemMethods(methods = {}) { + return Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER, methods); + } +} +exports.default = Settings; /***/ }), @@ -81322,77 +81322,77 @@ module.exports.generateTasks = pkg.generateTasks; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var optionsManager = __webpack_require__(713); -var taskManager = __webpack_require__(714); -var reader_async_1 = __webpack_require__(882); -var reader_stream_1 = __webpack_require__(906); -var reader_sync_1 = __webpack_require__(907); -var arrayUtils = __webpack_require__(909); -var streamUtils = __webpack_require__(910); -/** - * Synchronous API. - */ -function sync(source, opts) { - assertPatternsInput(source); - var works = getWorks(source, reader_sync_1.default, opts); - return arrayUtils.flatten(works); -} -exports.sync = sync; -/** - * Asynchronous API. - */ -function async(source, opts) { - try { - assertPatternsInput(source); - } - catch (error) { - return Promise.reject(error); - } - var works = getWorks(source, reader_async_1.default, opts); - return Promise.all(works).then(arrayUtils.flatten); -} -exports.async = async; -/** - * Stream API. - */ -function stream(source, opts) { - assertPatternsInput(source); - var works = getWorks(source, reader_stream_1.default, opts); - return streamUtils.merge(works); -} -exports.stream = stream; -/** - * Return a set of tasks based on provided patterns. - */ -function generateTasks(source, opts) { - assertPatternsInput(source); - var patterns = [].concat(source); - var options = optionsManager.prepare(opts); - return taskManager.generate(patterns, options); -} -exports.generateTasks = generateTasks; -/** - * Returns a set of works based on provided tasks and class of the reader. - */ -function getWorks(source, _Reader, opts) { - var patterns = [].concat(source); - var options = optionsManager.prepare(opts); - var tasks = taskManager.generate(patterns, options); - var reader = new _Reader(options); - return tasks.map(reader.read, reader); -} -function assertPatternsInput(source) { - if ([].concat(source).every(isString)) { - return; - } - throw new TypeError('Patterns must be a string or an array of strings'); -} -function isString(source) { - /* tslint:disable-next-line strict-type-predicates */ - return typeof source === 'string'; -} + +Object.defineProperty(exports, "__esModule", { value: true }); +var optionsManager = __webpack_require__(713); +var taskManager = __webpack_require__(714); +var reader_async_1 = __webpack_require__(882); +var reader_stream_1 = __webpack_require__(906); +var reader_sync_1 = __webpack_require__(907); +var arrayUtils = __webpack_require__(909); +var streamUtils = __webpack_require__(910); +/** + * Synchronous API. + */ +function sync(source, opts) { + assertPatternsInput(source); + var works = getWorks(source, reader_sync_1.default, opts); + return arrayUtils.flatten(works); +} +exports.sync = sync; +/** + * Asynchronous API. + */ +function async(source, opts) { + try { + assertPatternsInput(source); + } + catch (error) { + return Promise.reject(error); + } + var works = getWorks(source, reader_async_1.default, opts); + return Promise.all(works).then(arrayUtils.flatten); +} +exports.async = async; +/** + * Stream API. + */ +function stream(source, opts) { + assertPatternsInput(source); + var works = getWorks(source, reader_stream_1.default, opts); + return streamUtils.merge(works); +} +exports.stream = stream; +/** + * Return a set of tasks based on provided patterns. + */ +function generateTasks(source, opts) { + assertPatternsInput(source); + var patterns = [].concat(source); + var options = optionsManager.prepare(opts); + return taskManager.generate(patterns, options); +} +exports.generateTasks = generateTasks; +/** + * Returns a set of works based on provided tasks and class of the reader. + */ +function getWorks(source, _Reader, opts) { + var patterns = [].concat(source); + var options = optionsManager.prepare(opts); + var tasks = taskManager.generate(patterns, options); + var reader = new _Reader(options); + return tasks.map(reader.read, reader); +} +function assertPatternsInput(source) { + if ([].concat(source).every(isString)) { + return; + } + throw new TypeError('Patterns must be a string or an array of strings'); +} +function isString(source) { + /* tslint:disable-next-line strict-type-predicates */ + return typeof source === 'string'; +} /***/ }), @@ -81400,37 +81400,37 @@ function isString(source) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -function prepare(options) { - var opts = __assign({ cwd: process.cwd(), deep: true, ignore: [], dot: false, stats: false, onlyFiles: true, onlyDirectories: false, followSymlinkedDirectories: true, unique: true, markDirectories: false, absolute: false, nobrace: false, brace: true, noglobstar: false, globstar: true, noext: false, extension: true, nocase: false, case: true, matchBase: false, transform: null }, options); - if (opts.onlyDirectories) { - opts.onlyFiles = false; - } - opts.brace = !opts.nobrace; - opts.globstar = !opts.noglobstar; - opts.extension = !opts.noext; - opts.case = !opts.nocase; - if (options) { - opts.brace = ('brace' in options ? options.brace : opts.brace); - opts.globstar = ('globstar' in options ? options.globstar : opts.globstar); - opts.extension = ('extension' in options ? options.extension : opts.extension); - opts.case = ('case' in options ? options.case : opts.case); - } - return opts; -} -exports.prepare = prepare; + +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +function prepare(options) { + var opts = __assign({ cwd: process.cwd(), deep: true, ignore: [], dot: false, stats: false, onlyFiles: true, onlyDirectories: false, followSymlinkedDirectories: true, unique: true, markDirectories: false, absolute: false, nobrace: false, brace: true, noglobstar: false, globstar: true, noext: false, extension: true, nocase: false, case: true, matchBase: false, transform: null }, options); + if (opts.onlyDirectories) { + opts.onlyFiles = false; + } + opts.brace = !opts.nobrace; + opts.globstar = !opts.noglobstar; + opts.extension = !opts.noext; + opts.case = !opts.nocase; + if (options) { + opts.brace = ('brace' in options ? options.brace : opts.brace); + opts.globstar = ('globstar' in options ? options.globstar : opts.globstar); + opts.extension = ('extension' in options ? options.extension : opts.extension); + opts.case = ('case' in options ? options.case : opts.case); + } + return opts; +} +exports.prepare = prepare; /***/ }), @@ -81438,96 +81438,96 @@ exports.prepare = prepare; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var patternUtils = __webpack_require__(715); -/** - * Generate tasks based on parent directory of each pattern. - */ -function generate(patterns, options) { - var unixPatterns = patterns.map(patternUtils.unixifyPattern); - var unixIgnore = options.ignore.map(patternUtils.unixifyPattern); - var positivePatterns = getPositivePatterns(unixPatterns); - var negativePatterns = getNegativePatternsAsPositive(unixPatterns, unixIgnore); - /** - * When the `case` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath - * directly (without read directory). - */ - var staticPatterns = !options.case ? [] : positivePatterns.filter(patternUtils.isStaticPattern); - var dynamicPatterns = !options.case ? positivePatterns : positivePatterns.filter(patternUtils.isDynamicPattern); - var staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); - var dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); - return staticTasks.concat(dynamicTasks); -} -exports.generate = generate; -/** - * Convert patterns to tasks based on parent directory of each pattern. - */ -function convertPatternsToTasks(positive, negative, dynamic) { - var positivePatternsGroup = groupPatternsByBaseDirectory(positive); - // When we have a global group – there is no reason to divide the patterns into independent tasks. - // In this case, the global task covers the rest. - if ('.' in positivePatternsGroup) { - var task = convertPatternGroupToTask('.', positive, negative, dynamic); - return [task]; - } - return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); -} -exports.convertPatternsToTasks = convertPatternsToTasks; -/** - * Return only positive patterns. - */ -function getPositivePatterns(patterns) { - return patternUtils.getPositivePatterns(patterns); -} -exports.getPositivePatterns = getPositivePatterns; -/** - * Return only negative patterns. - */ -function getNegativePatternsAsPositive(patterns, ignore) { - var negative = patternUtils.getNegativePatterns(patterns).concat(ignore); - var positive = negative.map(patternUtils.convertToPositivePattern); - return positive; -} -exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; -/** - * Group patterns by base directory of each pattern. - */ -function groupPatternsByBaseDirectory(patterns) { - return patterns.reduce(function (collection, pattern) { - var base = patternUtils.getBaseDirectory(pattern); - if (base in collection) { - collection[base].push(pattern); - } - else { - collection[base] = [pattern]; - } - return collection; - }, {}); -} -exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; -/** - * Convert group of patterns to tasks. - */ -function convertPatternGroupsToTasks(positive, negative, dynamic) { - return Object.keys(positive).map(function (base) { - return convertPatternGroupToTask(base, positive[base], negative, dynamic); - }); -} -exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; -/** - * Create a task for positive and negative patterns. - */ -function convertPatternGroupToTask(base, positive, negative, dynamic) { - return { - base: base, - dynamic: dynamic, - positive: positive, - negative: negative, - patterns: [].concat(positive, negative.map(patternUtils.convertToNegativePattern)) - }; -} -exports.convertPatternGroupToTask = convertPatternGroupToTask; + +Object.defineProperty(exports, "__esModule", { value: true }); +var patternUtils = __webpack_require__(715); +/** + * Generate tasks based on parent directory of each pattern. + */ +function generate(patterns, options) { + var unixPatterns = patterns.map(patternUtils.unixifyPattern); + var unixIgnore = options.ignore.map(patternUtils.unixifyPattern); + var positivePatterns = getPositivePatterns(unixPatterns); + var negativePatterns = getNegativePatternsAsPositive(unixPatterns, unixIgnore); + /** + * When the `case` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath + * directly (without read directory). + */ + var staticPatterns = !options.case ? [] : positivePatterns.filter(patternUtils.isStaticPattern); + var dynamicPatterns = !options.case ? positivePatterns : positivePatterns.filter(patternUtils.isDynamicPattern); + var staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); + var dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); + return staticTasks.concat(dynamicTasks); +} +exports.generate = generate; +/** + * Convert patterns to tasks based on parent directory of each pattern. + */ +function convertPatternsToTasks(positive, negative, dynamic) { + var positivePatternsGroup = groupPatternsByBaseDirectory(positive); + // When we have a global group – there is no reason to divide the patterns into independent tasks. + // In this case, the global task covers the rest. + if ('.' in positivePatternsGroup) { + var task = convertPatternGroupToTask('.', positive, negative, dynamic); + return [task]; + } + return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); +} +exports.convertPatternsToTasks = convertPatternsToTasks; +/** + * Return only positive patterns. + */ +function getPositivePatterns(patterns) { + return patternUtils.getPositivePatterns(patterns); +} +exports.getPositivePatterns = getPositivePatterns; +/** + * Return only negative patterns. + */ +function getNegativePatternsAsPositive(patterns, ignore) { + var negative = patternUtils.getNegativePatterns(patterns).concat(ignore); + var positive = negative.map(patternUtils.convertToPositivePattern); + return positive; +} +exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; +/** + * Group patterns by base directory of each pattern. + */ +function groupPatternsByBaseDirectory(patterns) { + return patterns.reduce(function (collection, pattern) { + var base = patternUtils.getBaseDirectory(pattern); + if (base in collection) { + collection[base].push(pattern); + } + else { + collection[base] = [pattern]; + } + return collection; + }, {}); +} +exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; +/** + * Convert group of patterns to tasks. + */ +function convertPatternGroupsToTasks(positive, negative, dynamic) { + return Object.keys(positive).map(function (base) { + return convertPatternGroupToTask(base, positive[base], negative, dynamic); + }); +} +exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; +/** + * Create a task for positive and negative patterns. + */ +function convertPatternGroupToTask(base, positive, negative, dynamic) { + return { + base: base, + dynamic: dynamic, + positive: positive, + negative: negative, + patterns: [].concat(positive, negative.map(patternUtils.convertToNegativePattern)) + }; +} +exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ }), @@ -81535,154 +81535,154 @@ exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -var globParent = __webpack_require__(716); -var isGlob = __webpack_require__(719); -var micromatch = __webpack_require__(720); -var GLOBSTAR = '**'; -/** - * Return true for static pattern. - */ -function isStaticPattern(pattern) { - return !isDynamicPattern(pattern); -} -exports.isStaticPattern = isStaticPattern; -/** - * Return true for pattern that looks like glob. - */ -function isDynamicPattern(pattern) { - return isGlob(pattern, { strict: false }); -} -exports.isDynamicPattern = isDynamicPattern; -/** - * Convert a windows «path» to a unix-style «path». - */ -function unixifyPattern(pattern) { - return pattern.replace(/\\/g, '/'); -} -exports.unixifyPattern = unixifyPattern; -/** - * Returns negative pattern as positive pattern. - */ -function convertToPositivePattern(pattern) { - return isNegativePattern(pattern) ? pattern.slice(1) : pattern; -} -exports.convertToPositivePattern = convertToPositivePattern; -/** - * Returns positive pattern as negative pattern. - */ -function convertToNegativePattern(pattern) { - return '!' + pattern; -} -exports.convertToNegativePattern = convertToNegativePattern; -/** - * Return true if provided pattern is negative pattern. - */ -function isNegativePattern(pattern) { - return pattern.startsWith('!') && pattern[1] !== '('; -} -exports.isNegativePattern = isNegativePattern; -/** - * Return true if provided pattern is positive pattern. - */ -function isPositivePattern(pattern) { - return !isNegativePattern(pattern); -} -exports.isPositivePattern = isPositivePattern; -/** - * Extracts negative patterns from array of patterns. - */ -function getNegativePatterns(patterns) { - return patterns.filter(isNegativePattern); -} -exports.getNegativePatterns = getNegativePatterns; -/** - * Extracts positive patterns from array of patterns. - */ -function getPositivePatterns(patterns) { - return patterns.filter(isPositivePattern); -} -exports.getPositivePatterns = getPositivePatterns; -/** - * Extract base directory from provided pattern. - */ -function getBaseDirectory(pattern) { - return globParent(pattern); -} -exports.getBaseDirectory = getBaseDirectory; -/** - * Return true if provided pattern has globstar. - */ -function hasGlobStar(pattern) { - return pattern.indexOf(GLOBSTAR) !== -1; -} -exports.hasGlobStar = hasGlobStar; -/** - * Return true if provided pattern ends with slash and globstar. - */ -function endsWithSlashGlobStar(pattern) { - return pattern.endsWith('/' + GLOBSTAR); -} -exports.endsWithSlashGlobStar = endsWithSlashGlobStar; -/** - * Returns «true» when pattern ends with a slash and globstar or the last partial of the pattern is static pattern. - */ -function isAffectDepthOfReadingPattern(pattern) { - var basename = path.basename(pattern); - return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); -} -exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; -/** - * Return naive depth of provided pattern without depth of the base directory. - */ -function getNaiveDepth(pattern) { - var base = getBaseDirectory(pattern); - var patternDepth = pattern.split('/').length; - var patternBaseDepth = base.split('/').length; - /** - * This is a hack for pattern that has no base directory. - * - * This is related to the `*\something\*` pattern. - */ - if (base === '.') { - return patternDepth - patternBaseDepth; - } - return patternDepth - patternBaseDepth - 1; -} -exports.getNaiveDepth = getNaiveDepth; -/** - * Return max naive depth of provided patterns without depth of the base directory. - */ -function getMaxNaivePatternsDepth(patterns) { - return patterns.reduce(function (max, pattern) { - var depth = getNaiveDepth(pattern); - return depth > max ? depth : max; - }, 0); -} -exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; -/** - * Make RegExp for provided pattern. - */ -function makeRe(pattern, options) { - return micromatch.makeRe(pattern, options); -} -exports.makeRe = makeRe; -/** - * Convert patterns to regexps. - */ -function convertPatternsToRe(patterns, options) { - return patterns.map(function (pattern) { return makeRe(pattern, options); }); -} -exports.convertPatternsToRe = convertPatternsToRe; -/** - * Returns true if the entry match any of the given RegExp's. - */ -function matchAny(entry, patternsRe) { - return patternsRe.some(function (patternRe) { return patternRe.test(entry); }); -} -exports.matchAny = matchAny; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +var globParent = __webpack_require__(716); +var isGlob = __webpack_require__(719); +var micromatch = __webpack_require__(720); +var GLOBSTAR = '**'; +/** + * Return true for static pattern. + */ +function isStaticPattern(pattern) { + return !isDynamicPattern(pattern); +} +exports.isStaticPattern = isStaticPattern; +/** + * Return true for pattern that looks like glob. + */ +function isDynamicPattern(pattern) { + return isGlob(pattern, { strict: false }); +} +exports.isDynamicPattern = isDynamicPattern; +/** + * Convert a windows «path» to a unix-style «path». + */ +function unixifyPattern(pattern) { + return pattern.replace(/\\/g, '/'); +} +exports.unixifyPattern = unixifyPattern; +/** + * Returns negative pattern as positive pattern. + */ +function convertToPositivePattern(pattern) { + return isNegativePattern(pattern) ? pattern.slice(1) : pattern; +} +exports.convertToPositivePattern = convertToPositivePattern; +/** + * Returns positive pattern as negative pattern. + */ +function convertToNegativePattern(pattern) { + return '!' + pattern; +} +exports.convertToNegativePattern = convertToNegativePattern; +/** + * Return true if provided pattern is negative pattern. + */ +function isNegativePattern(pattern) { + return pattern.startsWith('!') && pattern[1] !== '('; +} +exports.isNegativePattern = isNegativePattern; +/** + * Return true if provided pattern is positive pattern. + */ +function isPositivePattern(pattern) { + return !isNegativePattern(pattern); +} +exports.isPositivePattern = isPositivePattern; +/** + * Extracts negative patterns from array of patterns. + */ +function getNegativePatterns(patterns) { + return patterns.filter(isNegativePattern); +} +exports.getNegativePatterns = getNegativePatterns; +/** + * Extracts positive patterns from array of patterns. + */ +function getPositivePatterns(patterns) { + return patterns.filter(isPositivePattern); +} +exports.getPositivePatterns = getPositivePatterns; +/** + * Extract base directory from provided pattern. + */ +function getBaseDirectory(pattern) { + return globParent(pattern); +} +exports.getBaseDirectory = getBaseDirectory; +/** + * Return true if provided pattern has globstar. + */ +function hasGlobStar(pattern) { + return pattern.indexOf(GLOBSTAR) !== -1; +} +exports.hasGlobStar = hasGlobStar; +/** + * Return true if provided pattern ends with slash and globstar. + */ +function endsWithSlashGlobStar(pattern) { + return pattern.endsWith('/' + GLOBSTAR); +} +exports.endsWithSlashGlobStar = endsWithSlashGlobStar; +/** + * Returns «true» when pattern ends with a slash and globstar or the last partial of the pattern is static pattern. + */ +function isAffectDepthOfReadingPattern(pattern) { + var basename = path.basename(pattern); + return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); +} +exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; +/** + * Return naive depth of provided pattern without depth of the base directory. + */ +function getNaiveDepth(pattern) { + var base = getBaseDirectory(pattern); + var patternDepth = pattern.split('/').length; + var patternBaseDepth = base.split('/').length; + /** + * This is a hack for pattern that has no base directory. + * + * This is related to the `*\something\*` pattern. + */ + if (base === '.') { + return patternDepth - patternBaseDepth; + } + return patternDepth - patternBaseDepth - 1; +} +exports.getNaiveDepth = getNaiveDepth; +/** + * Return max naive depth of provided patterns without depth of the base directory. + */ +function getMaxNaivePatternsDepth(patterns) { + return patterns.reduce(function (max, pattern) { + var depth = getNaiveDepth(pattern); + return depth > max ? depth : max; + }, 0); +} +exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; +/** + * Make RegExp for provided pattern. + */ +function makeRe(pattern, options) { + return micromatch.makeRe(pattern, options); +} +exports.makeRe = makeRe; +/** + * Convert patterns to regexps. + */ +function convertPatternsToRe(patterns, options) { + return patterns.map(function (pattern) { return makeRe(pattern, options); }); +} +exports.convertPatternsToRe = convertPatternsToRe; +/** + * Returns true if the entry match any of the given RegExp's. + */ +function matchAny(entry, patternsRe) { + return patternsRe.some(function (patternRe) { return patternRe.test(entry); }); +} +exports.matchAny = matchAny; /***/ }), @@ -83474,7 +83474,7 @@ module.exports = function kindOf(val) { if (type === '[object Symbol]') { return 'symbol'; } - + if (type === '[object Map Iterator]') { return 'mapiterator'; } @@ -83487,7 +83487,7 @@ module.exports = function kindOf(val) { if (type === '[object Array Iterator]') { return 'arrayiterator'; } - + // typed arrays if (type === '[object Int8Array]') { return 'int8array'; @@ -89598,169 +89598,169 @@ module.exports.namespace = namespace; /* 769 */ /***/ (function(module, exports, __webpack_require__) { - -/** - * Expose `Emitter`. - */ - -if (true) { - module.exports = Emitter; -} - -/** - * Initialize a new `Emitter`. - * - * @api public - */ - -function Emitter(obj) { - if (obj) return mixin(obj); -}; - -/** - * Mixin the emitter properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - -function mixin(obj) { - for (var key in Emitter.prototype) { - obj[key] = Emitter.prototype[key]; - } - return obj; -} - -/** - * Listen on the given `event` with `fn`. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.on = -Emitter.prototype.addEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - (this._callbacks['$' + event] = this._callbacks['$' + event] || []) - .push(fn); - return this; -}; - -/** - * Adds an `event` listener that will be invoked a single - * time then automatically removed. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.once = function(event, fn){ - function on() { - this.off(event, on); - fn.apply(this, arguments); - } - - on.fn = fn; - this.on(event, on); - return this; -}; - -/** - * Remove the given callback for `event` or all - * registered callbacks. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.off = -Emitter.prototype.removeListener = -Emitter.prototype.removeAllListeners = -Emitter.prototype.removeEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - - // all - if (0 == arguments.length) { - this._callbacks = {}; - return this; - } - - // specific event - var callbacks = this._callbacks['$' + event]; - if (!callbacks) return this; - - // remove all handlers - if (1 == arguments.length) { - delete this._callbacks['$' + event]; - return this; - } - - // remove specific handler - var cb; - for (var i = 0; i < callbacks.length; i++) { - cb = callbacks[i]; - if (cb === fn || cb.fn === fn) { - callbacks.splice(i, 1); - break; - } - } - return this; -}; - -/** - * Emit `event` with the given args. - * - * @param {String} event - * @param {Mixed} ... - * @return {Emitter} - */ - -Emitter.prototype.emit = function(event){ - this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) - , callbacks = this._callbacks['$' + event]; - - if (callbacks) { - callbacks = callbacks.slice(0); - for (var i = 0, len = callbacks.length; i < len; ++i) { - callbacks[i].apply(this, args); - } - } - - return this; -}; - -/** - * Return array of callbacks for `event`. - * - * @param {String} event - * @return {Array} - * @api public - */ - -Emitter.prototype.listeners = function(event){ - this._callbacks = this._callbacks || {}; - return this._callbacks['$' + event] || []; -}; - -/** - * Check if this emitter has `event` handlers. - * - * @param {String} event - * @return {Boolean} - * @api public - */ - -Emitter.prototype.hasListeners = function(event){ - return !! this.listeners(event).length; -}; + +/** + * Expose `Emitter`. + */ + +if (true) { + module.exports = Emitter; +} + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks['$' + event] = this._callbacks['$' + event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + function on() { + this.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks['$' + event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks['$' + event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks['$' + event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks['$' + event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; /***/ }), @@ -91173,7 +91173,7 @@ module.exports = function kindOf(val) { if (type === '[object Symbol]') { return 'symbol'; } - + if (type === '[object Map Iterator]') { return 'mapiterator'; } @@ -91186,7 +91186,7 @@ module.exports = function kindOf(val) { if (type === '[object Array Iterator]') { return 'arrayiterator'; } - + // typed arrays if (type === '[object Int8Array]') { return 'int8array'; @@ -96755,23 +96755,23 @@ module.exports = function (encodedURI) { /* 828 */ /***/ (function(module, exports, __webpack_require__) { -// Copyright 2014 Simon Lydell -// X11 (“MIT”) Licensed. (See LICENSE.) - -var path = __webpack_require__(4) - -"use strict" - -function urix(aPath) { - if (path.sep === "\\") { - return aPath - .replace(/\\/g, "/") - .replace(/^[a-z]:\/?/i, "/") - } - return aPath -} - -module.exports = urix +// Copyright 2014 Simon Lydell +// X11 (“MIT”) Licensed. (See LICENSE.) + +var path = __webpack_require__(4) + +"use strict" + +function urix(aPath) { + if (path.sep === "\\") { + return aPath + .replace(/\\/g, "/") + .replace(/^[a-z]:\/?/i, "/") + } + return aPath +} + +module.exports = urix /***/ }), @@ -97780,13 +97780,13 @@ var types = parse.types; module.exports = function (re, opts) { if (!opts) opts = {}; var replimit = opts.limit === undefined ? 25 : opts.limit; - + if (isRegExp(re)) re = re.source; else if (typeof re !== 'string') re = String(re); - + try { re = parse(re) } catch (err) { return false } - + var reps = 0; return (function walk (node, starHeight) { if (node.type === types.REPETITION) { @@ -97795,7 +97795,7 @@ module.exports = function (re, opts) { if (starHeight > 1) return false; if (reps > replimit) return false; } - + if (node.options) { for (var i = 0, len = node.options.length; i < len; i++) { var ok = walk({ stack: node.options[i] }, starHeight); @@ -97804,12 +97804,12 @@ module.exports = function (re, opts) { } var stack = node.stack || (node.value && node.value.stack); if (!stack) return true; - + for (var i = 0; i < stack.length; i++) { var ok = walk(stack[i], starHeight); if (!ok) return false; } - + return true; })(re, 0); }; @@ -104226,81 +104226,81 @@ function isBuffer(val) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(883); -var reader_1 = __webpack_require__(896); -var fs_stream_1 = __webpack_require__(900); -var ReaderAsync = /** @class */ (function (_super) { - __extends(ReaderAsync, _super); - function ReaderAsync() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(ReaderAsync.prototype, "fsAdapter", { - /** - * Returns FileSystem adapter. - */ - get: function () { - return new fs_stream_1.default(this.options); - }, - enumerable: true, - configurable: true - }); - /** - * Use async API to read entries for Task. - */ - ReaderAsync.prototype.read = function (task) { - var _this = this; - var root = this.getRootDirectory(task); - var options = this.getReaderOptions(task); - var entries = []; - return new Promise(function (resolve, reject) { - var stream = _this.api(root, task, options); - stream.on('error', function (err) { - _this.isEnoentCodeError(err) ? resolve([]) : reject(err); - stream.pause(); - }); - stream.on('data', function (entry) { return entries.push(_this.transform(entry)); }); - stream.on('end', function () { return resolve(entries); }); - }); - }; - /** - * Returns founded paths. - */ - ReaderAsync.prototype.api = function (root, task, options) { - if (task.dynamic) { - return this.dynamicApi(root, options); - } - return this.staticApi(task, options); - }; - /** - * Api for dynamic tasks. - */ - ReaderAsync.prototype.dynamicApi = function (root, options) { - return readdir.readdirStreamStat(root, options); - }; - /** - * Api for static tasks. - */ - ReaderAsync.prototype.staticApi = function (task, options) { - return this.fsAdapter.read(task.patterns, options.filter); - }; - return ReaderAsync; -}(reader_1.default)); -exports.default = ReaderAsync; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var readdir = __webpack_require__(883); +var reader_1 = __webpack_require__(896); +var fs_stream_1 = __webpack_require__(900); +var ReaderAsync = /** @class */ (function (_super) { + __extends(ReaderAsync, _super); + function ReaderAsync() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ReaderAsync.prototype, "fsAdapter", { + /** + * Returns FileSystem adapter. + */ + get: function () { + return new fs_stream_1.default(this.options); + }, + enumerable: true, + configurable: true + }); + /** + * Use async API to read entries for Task. + */ + ReaderAsync.prototype.read = function (task) { + var _this = this; + var root = this.getRootDirectory(task); + var options = this.getReaderOptions(task); + var entries = []; + return new Promise(function (resolve, reject) { + var stream = _this.api(root, task, options); + stream.on('error', function (err) { + _this.isEnoentCodeError(err) ? resolve([]) : reject(err); + stream.pause(); + }); + stream.on('data', function (entry) { return entries.push(_this.transform(entry)); }); + stream.on('end', function () { return resolve(entries); }); + }); + }; + /** + * Returns founded paths. + */ + ReaderAsync.prototype.api = function (root, task, options) { + if (task.dynamic) { + return this.dynamicApi(root, options); + } + return this.staticApi(task, options); + }; + /** + * Api for dynamic tasks. + */ + ReaderAsync.prototype.dynamicApi = function (root, options) { + return readdir.readdirStreamStat(root, options); + }; + /** + * Api for static tasks. + */ + ReaderAsync.prototype.staticApi = function (task, options) { + return this.fsAdapter.read(task.patterns, options.filter); + }; + return ReaderAsync; +}(reader_1.default)); +exports.default = ReaderAsync; /***/ }), @@ -105541,74 +105541,74 @@ function readdirStream (dir, options, internalOptions) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -var deep_1 = __webpack_require__(897); -var entry_1 = __webpack_require__(899); -var pathUtil = __webpack_require__(898); -var Reader = /** @class */ (function () { - function Reader(options) { - this.options = options; - this.micromatchOptions = this.getMicromatchOptions(); - this.entryFilter = new entry_1.default(options, this.micromatchOptions); - this.deepFilter = new deep_1.default(options, this.micromatchOptions); - } - /** - * Returns root path to scanner. - */ - Reader.prototype.getRootDirectory = function (task) { - return path.resolve(this.options.cwd, task.base); - }; - /** - * Returns options for reader. - */ - Reader.prototype.getReaderOptions = function (task) { - return { - basePath: task.base === '.' ? '' : task.base, - filter: this.entryFilter.getFilter(task.positive, task.negative), - deep: this.deepFilter.getFilter(task.positive, task.negative), - sep: '/' - }; - }; - /** - * Returns options for micromatch. - */ - Reader.prototype.getMicromatchOptions = function () { - return { - dot: this.options.dot, - nobrace: !this.options.brace, - noglobstar: !this.options.globstar, - noext: !this.options.extension, - nocase: !this.options.case, - matchBase: this.options.matchBase - }; - }; - /** - * Returns transformed entry. - */ - Reader.prototype.transform = function (entry) { - if (this.options.absolute) { - entry.path = pathUtil.makeAbsolute(this.options.cwd, entry.path); - } - if (this.options.markDirectories && entry.isDirectory()) { - entry.path += '/'; - } - var item = this.options.stats ? entry : entry.path; - if (this.options.transform === null) { - return item; - } - return this.options.transform(item); - }; - /** - * Returns true if error has ENOENT code. - */ - Reader.prototype.isEnoentCodeError = function (err) { - return err.code === 'ENOENT'; - }; - return Reader; -}()); -exports.default = Reader; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +var deep_1 = __webpack_require__(897); +var entry_1 = __webpack_require__(899); +var pathUtil = __webpack_require__(898); +var Reader = /** @class */ (function () { + function Reader(options) { + this.options = options; + this.micromatchOptions = this.getMicromatchOptions(); + this.entryFilter = new entry_1.default(options, this.micromatchOptions); + this.deepFilter = new deep_1.default(options, this.micromatchOptions); + } + /** + * Returns root path to scanner. + */ + Reader.prototype.getRootDirectory = function (task) { + return path.resolve(this.options.cwd, task.base); + }; + /** + * Returns options for reader. + */ + Reader.prototype.getReaderOptions = function (task) { + return { + basePath: task.base === '.' ? '' : task.base, + filter: this.entryFilter.getFilter(task.positive, task.negative), + deep: this.deepFilter.getFilter(task.positive, task.negative), + sep: '/' + }; + }; + /** + * Returns options for micromatch. + */ + Reader.prototype.getMicromatchOptions = function () { + return { + dot: this.options.dot, + nobrace: !this.options.brace, + noglobstar: !this.options.globstar, + noext: !this.options.extension, + nocase: !this.options.case, + matchBase: this.options.matchBase + }; + }; + /** + * Returns transformed entry. + */ + Reader.prototype.transform = function (entry) { + if (this.options.absolute) { + entry.path = pathUtil.makeAbsolute(this.options.cwd, entry.path); + } + if (this.options.markDirectories && entry.isDirectory()) { + entry.path += '/'; + } + var item = this.options.stats ? entry : entry.path; + if (this.options.transform === null) { + return item; + } + return this.options.transform(item); + }; + /** + * Returns true if error has ENOENT code. + */ + Reader.prototype.isEnoentCodeError = function (err) { + return err.code === 'ENOENT'; + }; + return Reader; +}()); +exports.default = Reader; /***/ }), @@ -105616,89 +105616,89 @@ exports.default = Reader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(898); -var patternUtils = __webpack_require__(715); -var DeepFilter = /** @class */ (function () { - function DeepFilter(options, micromatchOptions) { - this.options = options; - this.micromatchOptions = micromatchOptions; - } - /** - * Returns filter for directories. - */ - DeepFilter.prototype.getFilter = function (positive, negative) { - var _this = this; - var maxPatternDepth = this.getMaxPatternDepth(positive); - var negativeRe = this.getNegativePatternsRe(negative); - return function (entry) { return _this.filter(entry, negativeRe, maxPatternDepth); }; - }; - /** - * Returns max depth of the provided patterns. - */ - DeepFilter.prototype.getMaxPatternDepth = function (patterns) { - var globstar = patterns.some(patternUtils.hasGlobStar); - return globstar ? Infinity : patternUtils.getMaxNaivePatternsDepth(patterns); - }; - /** - * Returns RegExp's for patterns that can affect the depth of reading. - */ - DeepFilter.prototype.getNegativePatternsRe = function (patterns) { - var affectDepthOfReadingPatterns = patterns.filter(patternUtils.isAffectDepthOfReadingPattern); - return patternUtils.convertPatternsToRe(affectDepthOfReadingPatterns, this.micromatchOptions); - }; - /** - * Returns «true» for directory that should be read. - */ - DeepFilter.prototype.filter = function (entry, negativeRe, maxPatternDepth) { - if (this.isSkippedByDeepOption(entry.depth)) { - return false; - } - if (this.isSkippedByMaxPatternDepth(entry.depth, maxPatternDepth)) { - return false; - } - if (this.isSkippedSymlinkedDirectory(entry)) { - return false; - } - if (this.isSkippedDotDirectory(entry)) { - return false; - } - return this.isSkippedByNegativePatterns(entry, negativeRe); - }; - /** - * Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value. - */ - DeepFilter.prototype.isSkippedByDeepOption = function (entryDepth) { - return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth >= this.options.deep); - }; - /** - * Returns «true» when depth parameter is not an Infinity and entry depth greater that the parameter value. - */ - DeepFilter.prototype.isSkippedByMaxPatternDepth = function (entryDepth, maxPatternDepth) { - return maxPatternDepth !== Infinity && entryDepth >= maxPatternDepth; - }; - /** - * Returns «true» for symlinked directory if the «followSymlinkedDirectories» option is disabled. - */ - DeepFilter.prototype.isSkippedSymlinkedDirectory = function (entry) { - return !this.options.followSymlinkedDirectories && entry.isSymbolicLink(); - }; - /** - * Returns «true» for a directory whose name starts with a period if «dot» option is disabled. - */ - DeepFilter.prototype.isSkippedDotDirectory = function (entry) { - return !this.options.dot && pathUtils.isDotDirectory(entry.path); - }; - /** - * Returns «true» for a directory whose path math to any negative pattern. - */ - DeepFilter.prototype.isSkippedByNegativePatterns = function (entry, negativeRe) { - return !patternUtils.matchAny(entry.path, negativeRe); - }; - return DeepFilter; -}()); -exports.default = DeepFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +var pathUtils = __webpack_require__(898); +var patternUtils = __webpack_require__(715); +var DeepFilter = /** @class */ (function () { + function DeepFilter(options, micromatchOptions) { + this.options = options; + this.micromatchOptions = micromatchOptions; + } + /** + * Returns filter for directories. + */ + DeepFilter.prototype.getFilter = function (positive, negative) { + var _this = this; + var maxPatternDepth = this.getMaxPatternDepth(positive); + var negativeRe = this.getNegativePatternsRe(negative); + return function (entry) { return _this.filter(entry, negativeRe, maxPatternDepth); }; + }; + /** + * Returns max depth of the provided patterns. + */ + DeepFilter.prototype.getMaxPatternDepth = function (patterns) { + var globstar = patterns.some(patternUtils.hasGlobStar); + return globstar ? Infinity : patternUtils.getMaxNaivePatternsDepth(patterns); + }; + /** + * Returns RegExp's for patterns that can affect the depth of reading. + */ + DeepFilter.prototype.getNegativePatternsRe = function (patterns) { + var affectDepthOfReadingPatterns = patterns.filter(patternUtils.isAffectDepthOfReadingPattern); + return patternUtils.convertPatternsToRe(affectDepthOfReadingPatterns, this.micromatchOptions); + }; + /** + * Returns «true» for directory that should be read. + */ + DeepFilter.prototype.filter = function (entry, negativeRe, maxPatternDepth) { + if (this.isSkippedByDeepOption(entry.depth)) { + return false; + } + if (this.isSkippedByMaxPatternDepth(entry.depth, maxPatternDepth)) { + return false; + } + if (this.isSkippedSymlinkedDirectory(entry)) { + return false; + } + if (this.isSkippedDotDirectory(entry)) { + return false; + } + return this.isSkippedByNegativePatterns(entry, negativeRe); + }; + /** + * Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value. + */ + DeepFilter.prototype.isSkippedByDeepOption = function (entryDepth) { + return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth >= this.options.deep); + }; + /** + * Returns «true» when depth parameter is not an Infinity and entry depth greater that the parameter value. + */ + DeepFilter.prototype.isSkippedByMaxPatternDepth = function (entryDepth, maxPatternDepth) { + return maxPatternDepth !== Infinity && entryDepth >= maxPatternDepth; + }; + /** + * Returns «true» for symlinked directory if the «followSymlinkedDirectories» option is disabled. + */ + DeepFilter.prototype.isSkippedSymlinkedDirectory = function (entry) { + return !this.options.followSymlinkedDirectories && entry.isSymbolicLink(); + }; + /** + * Returns «true» for a directory whose name starts with a period if «dot» option is disabled. + */ + DeepFilter.prototype.isSkippedDotDirectory = function (entry) { + return !this.options.dot && pathUtils.isDotDirectory(entry.path); + }; + /** + * Returns «true» for a directory whose path math to any negative pattern. + */ + DeepFilter.prototype.isSkippedByNegativePatterns = function (entry, negativeRe) { + return !patternUtils.matchAny(entry.path, negativeRe); + }; + return DeepFilter; +}()); +exports.default = DeepFilter; /***/ }), @@ -105706,30 +105706,30 @@ exports.default = DeepFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -/** - * Returns «true» if the last partial of the path starting with a period. - */ -function isDotDirectory(filepath) { - return path.basename(filepath).startsWith('.'); -} -exports.isDotDirectory = isDotDirectory; -/** - * Convert a windows-like path to a unix-style path. - */ -function normalize(filepath) { - return filepath.replace(/\\/g, '/'); -} -exports.normalize = normalize; -/** - * Returns normalized absolute path of provided filepath. - */ -function makeAbsolute(cwd, filepath) { - return normalize(path.resolve(cwd, filepath)); -} -exports.makeAbsolute = makeAbsolute; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +/** + * Returns «true» if the last partial of the path starting with a period. + */ +function isDotDirectory(filepath) { + return path.basename(filepath).startsWith('.'); +} +exports.isDotDirectory = isDotDirectory; +/** + * Convert a windows-like path to a unix-style path. + */ +function normalize(filepath) { + return filepath.replace(/\\/g, '/'); +} +exports.normalize = normalize; +/** + * Returns normalized absolute path of provided filepath. + */ +function makeAbsolute(cwd, filepath) { + return normalize(path.resolve(cwd, filepath)); +} +exports.makeAbsolute = makeAbsolute; /***/ }), @@ -105737,91 +105737,91 @@ exports.makeAbsolute = makeAbsolute; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(898); -var patternUtils = __webpack_require__(715); -var EntryFilter = /** @class */ (function () { - function EntryFilter(options, micromatchOptions) { - this.options = options; - this.micromatchOptions = micromatchOptions; - this.index = new Map(); - } - /** - * Returns filter for directories. - */ - EntryFilter.prototype.getFilter = function (positive, negative) { - var _this = this; - var positiveRe = patternUtils.convertPatternsToRe(positive, this.micromatchOptions); - var negativeRe = patternUtils.convertPatternsToRe(negative, this.micromatchOptions); - return function (entry) { return _this.filter(entry, positiveRe, negativeRe); }; - }; - /** - * Returns true if entry must be added to result. - */ - EntryFilter.prototype.filter = function (entry, positiveRe, negativeRe) { - // Exclude duplicate results - if (this.options.unique) { - if (this.isDuplicateEntry(entry)) { - return false; - } - this.createIndexRecord(entry); - } - // Filter files and directories by options - if (this.onlyFileFilter(entry) || this.onlyDirectoryFilter(entry)) { - return false; - } - if (this.isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { - return false; - } - return this.isMatchToPatterns(entry.path, positiveRe) && !this.isMatchToPatterns(entry.path, negativeRe); - }; - /** - * Return true if the entry already has in the cross reader index. - */ - EntryFilter.prototype.isDuplicateEntry = function (entry) { - return this.index.has(entry.path); - }; - /** - * Create record in the cross reader index. - */ - EntryFilter.prototype.createIndexRecord = function (entry) { - this.index.set(entry.path, undefined); - }; - /** - * Returns true for non-files if the «onlyFiles» option is enabled. - */ - EntryFilter.prototype.onlyFileFilter = function (entry) { - return this.options.onlyFiles && !entry.isFile(); - }; - /** - * Returns true for non-directories if the «onlyDirectories» option is enabled. - */ - EntryFilter.prototype.onlyDirectoryFilter = function (entry) { - return this.options.onlyDirectories && !entry.isDirectory(); - }; - /** - * Return true when `absolute` option is enabled and matched to the negative patterns. - */ - EntryFilter.prototype.isSkippedByAbsoluteNegativePatterns = function (entry, negativeRe) { - if (!this.options.absolute) { - return false; - } - var fullpath = pathUtils.makeAbsolute(this.options.cwd, entry.path); - return this.isMatchToPatterns(fullpath, negativeRe); - }; - /** - * Return true when entry match to provided patterns. - * - * First, just trying to apply patterns to the path. - * Second, trying to apply patterns to the path with final slash (need to micromatch to support «directory/**» patterns). - */ - EntryFilter.prototype.isMatchToPatterns = function (filepath, patternsRe) { - return patternUtils.matchAny(filepath, patternsRe) || patternUtils.matchAny(filepath + '/', patternsRe); - }; - return EntryFilter; -}()); -exports.default = EntryFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +var pathUtils = __webpack_require__(898); +var patternUtils = __webpack_require__(715); +var EntryFilter = /** @class */ (function () { + function EntryFilter(options, micromatchOptions) { + this.options = options; + this.micromatchOptions = micromatchOptions; + this.index = new Map(); + } + /** + * Returns filter for directories. + */ + EntryFilter.prototype.getFilter = function (positive, negative) { + var _this = this; + var positiveRe = patternUtils.convertPatternsToRe(positive, this.micromatchOptions); + var negativeRe = patternUtils.convertPatternsToRe(negative, this.micromatchOptions); + return function (entry) { return _this.filter(entry, positiveRe, negativeRe); }; + }; + /** + * Returns true if entry must be added to result. + */ + EntryFilter.prototype.filter = function (entry, positiveRe, negativeRe) { + // Exclude duplicate results + if (this.options.unique) { + if (this.isDuplicateEntry(entry)) { + return false; + } + this.createIndexRecord(entry); + } + // Filter files and directories by options + if (this.onlyFileFilter(entry) || this.onlyDirectoryFilter(entry)) { + return false; + } + if (this.isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { + return false; + } + return this.isMatchToPatterns(entry.path, positiveRe) && !this.isMatchToPatterns(entry.path, negativeRe); + }; + /** + * Return true if the entry already has in the cross reader index. + */ + EntryFilter.prototype.isDuplicateEntry = function (entry) { + return this.index.has(entry.path); + }; + /** + * Create record in the cross reader index. + */ + EntryFilter.prototype.createIndexRecord = function (entry) { + this.index.set(entry.path, undefined); + }; + /** + * Returns true for non-files if the «onlyFiles» option is enabled. + */ + EntryFilter.prototype.onlyFileFilter = function (entry) { + return this.options.onlyFiles && !entry.isFile(); + }; + /** + * Returns true for non-directories if the «onlyDirectories» option is enabled. + */ + EntryFilter.prototype.onlyDirectoryFilter = function (entry) { + return this.options.onlyDirectories && !entry.isDirectory(); + }; + /** + * Return true when `absolute` option is enabled and matched to the negative patterns. + */ + EntryFilter.prototype.isSkippedByAbsoluteNegativePatterns = function (entry, negativeRe) { + if (!this.options.absolute) { + return false; + } + var fullpath = pathUtils.makeAbsolute(this.options.cwd, entry.path); + return this.isMatchToPatterns(fullpath, negativeRe); + }; + /** + * Return true when entry match to provided patterns. + * + * First, just trying to apply patterns to the path. + * Second, trying to apply patterns to the path with final slash (need to micromatch to support «directory/**» patterns). + */ + EntryFilter.prototype.isMatchToPatterns = function (filepath, patternsRe) { + return patternUtils.matchAny(filepath, patternsRe) || patternUtils.matchAny(filepath + '/', patternsRe); + }; + return EntryFilter; +}()); +exports.default = EntryFilter; /***/ }), @@ -105829,70 +105829,70 @@ exports.default = EntryFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var stream = __webpack_require__(382); -var fsStat = __webpack_require__(901); -var fs_1 = __webpack_require__(905); -var FileSystemStream = /** @class */ (function (_super) { - __extends(FileSystemStream, _super); - function FileSystemStream() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Use stream API to read entries for Task. - */ - FileSystemStream.prototype.read = function (patterns, filter) { - var _this = this; - var filepaths = patterns.map(this.getFullEntryPath, this); - var transform = new stream.Transform({ objectMode: true }); - transform._transform = function (index, _enc, done) { - return _this.getEntry(filepaths[index], patterns[index]).then(function (entry) { - if (entry !== null && filter(entry)) { - transform.push(entry); - } - if (index === filepaths.length - 1) { - transform.end(); - } - done(); - }); - }; - for (var i = 0; i < filepaths.length; i++) { - transform.write(i); - } - return transform; - }; - /** - * Return entry for the provided path. - */ - FileSystemStream.prototype.getEntry = function (filepath, pattern) { - var _this = this; - return this.getStat(filepath) - .then(function (stat) { return _this.makeEntry(stat, pattern); }) - .catch(function () { return null; }); - }; - /** - * Return fs.Stats for the provided path. - */ - FileSystemStream.prototype.getStat = function (filepath) { - return fsStat.stat(filepath, { throwErrorOnBrokenSymlinks: false }); - }; - return FileSystemStream; -}(fs_1.default)); -exports.default = FileSystemStream; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var stream = __webpack_require__(382); +var fsStat = __webpack_require__(901); +var fs_1 = __webpack_require__(905); +var FileSystemStream = /** @class */ (function (_super) { + __extends(FileSystemStream, _super); + function FileSystemStream() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Use stream API to read entries for Task. + */ + FileSystemStream.prototype.read = function (patterns, filter) { + var _this = this; + var filepaths = patterns.map(this.getFullEntryPath, this); + var transform = new stream.Transform({ objectMode: true }); + transform._transform = function (index, _enc, done) { + return _this.getEntry(filepaths[index], patterns[index]).then(function (entry) { + if (entry !== null && filter(entry)) { + transform.push(entry); + } + if (index === filepaths.length - 1) { + transform.end(); + } + done(); + }); + }; + for (var i = 0; i < filepaths.length; i++) { + transform.write(i); + } + return transform; + }; + /** + * Return entry for the provided path. + */ + FileSystemStream.prototype.getEntry = function (filepath, pattern) { + var _this = this; + return this.getStat(filepath) + .then(function (stat) { return _this.makeEntry(stat, pattern); }) + .catch(function () { return null; }); + }; + /** + * Return fs.Stats for the provided path. + */ + FileSystemStream.prototype.getStat = function (filepath) { + return fsStat.stat(filepath, { throwErrorOnBrokenSymlinks: false }); + }; + return FileSystemStream; +}(fs_1.default)); +exports.default = FileSystemStream; /***/ }), @@ -106032,30 +106032,30 @@ exports.isFollowedSymlink = isFollowedSymlink; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -var FileSystem = /** @class */ (function () { - function FileSystem(options) { - this.options = options; - } - /** - * Return full path to entry. - */ - FileSystem.prototype.getFullEntryPath = function (filepath) { - return path.resolve(this.options.cwd, filepath); - }; - /** - * Return an implementation of the Entry interface. - */ - FileSystem.prototype.makeEntry = function (stat, pattern) { - stat.path = pattern; - stat.depth = pattern.split('/').length; - return stat; - }; - return FileSystem; -}()); -exports.default = FileSystem; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +var FileSystem = /** @class */ (function () { + function FileSystem(options) { + this.options = options; + } + /** + * Return full path to entry. + */ + FileSystem.prototype.getFullEntryPath = function (filepath) { + return path.resolve(this.options.cwd, filepath); + }; + /** + * Return an implementation of the Entry interface. + */ + FileSystem.prototype.makeEntry = function (stat, pattern) { + stat.path = pattern; + stat.depth = pattern.split('/').length; + return stat; + }; + return FileSystem; +}()); +exports.default = FileSystem; /***/ }), @@ -106063,89 +106063,89 @@ exports.default = FileSystem; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var stream = __webpack_require__(382); -var readdir = __webpack_require__(883); -var reader_1 = __webpack_require__(896); -var fs_stream_1 = __webpack_require__(900); -var TransformStream = /** @class */ (function (_super) { - __extends(TransformStream, _super); - function TransformStream(reader) { - var _this = _super.call(this, { objectMode: true }) || this; - _this.reader = reader; - return _this; - } - TransformStream.prototype._transform = function (entry, _encoding, callback) { - callback(null, this.reader.transform(entry)); - }; - return TransformStream; -}(stream.Transform)); -var ReaderStream = /** @class */ (function (_super) { - __extends(ReaderStream, _super); - function ReaderStream() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(ReaderStream.prototype, "fsAdapter", { - /** - * Returns FileSystem adapter. - */ - get: function () { - return new fs_stream_1.default(this.options); - }, - enumerable: true, - configurable: true - }); - /** - * Use stream API to read entries for Task. - */ - ReaderStream.prototype.read = function (task) { - var _this = this; - var root = this.getRootDirectory(task); - var options = this.getReaderOptions(task); - var transform = new TransformStream(this); - var readable = this.api(root, task, options); - return readable - .on('error', function (err) { return _this.isEnoentCodeError(err) ? null : transform.emit('error', err); }) - .pipe(transform); - }; - /** - * Returns founded paths. - */ - ReaderStream.prototype.api = function (root, task, options) { - if (task.dynamic) { - return this.dynamicApi(root, options); - } - return this.staticApi(task, options); - }; - /** - * Api for dynamic tasks. - */ - ReaderStream.prototype.dynamicApi = function (root, options) { - return readdir.readdirStreamStat(root, options); - }; - /** - * Api for static tasks. - */ - ReaderStream.prototype.staticApi = function (task, options) { - return this.fsAdapter.read(task.patterns, options.filter); - }; - return ReaderStream; -}(reader_1.default)); -exports.default = ReaderStream; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var stream = __webpack_require__(382); +var readdir = __webpack_require__(883); +var reader_1 = __webpack_require__(896); +var fs_stream_1 = __webpack_require__(900); +var TransformStream = /** @class */ (function (_super) { + __extends(TransformStream, _super); + function TransformStream(reader) { + var _this = _super.call(this, { objectMode: true }) || this; + _this.reader = reader; + return _this; + } + TransformStream.prototype._transform = function (entry, _encoding, callback) { + callback(null, this.reader.transform(entry)); + }; + return TransformStream; +}(stream.Transform)); +var ReaderStream = /** @class */ (function (_super) { + __extends(ReaderStream, _super); + function ReaderStream() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ReaderStream.prototype, "fsAdapter", { + /** + * Returns FileSystem adapter. + */ + get: function () { + return new fs_stream_1.default(this.options); + }, + enumerable: true, + configurable: true + }); + /** + * Use stream API to read entries for Task. + */ + ReaderStream.prototype.read = function (task) { + var _this = this; + var root = this.getRootDirectory(task); + var options = this.getReaderOptions(task); + var transform = new TransformStream(this); + var readable = this.api(root, task, options); + return readable + .on('error', function (err) { return _this.isEnoentCodeError(err) ? null : transform.emit('error', err); }) + .pipe(transform); + }; + /** + * Returns founded paths. + */ + ReaderStream.prototype.api = function (root, task, options) { + if (task.dynamic) { + return this.dynamicApi(root, options); + } + return this.staticApi(task, options); + }; + /** + * Api for dynamic tasks. + */ + ReaderStream.prototype.dynamicApi = function (root, options) { + return readdir.readdirStreamStat(root, options); + }; + /** + * Api for static tasks. + */ + ReaderStream.prototype.staticApi = function (task, options) { + return this.fsAdapter.read(task.patterns, options.filter); + }; + return ReaderStream; +}(reader_1.default)); +exports.default = ReaderStream; /***/ }), @@ -106153,80 +106153,80 @@ exports.default = ReaderStream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(883); -var reader_1 = __webpack_require__(896); -var fs_sync_1 = __webpack_require__(908); -var ReaderSync = /** @class */ (function (_super) { - __extends(ReaderSync, _super); - function ReaderSync() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(ReaderSync.prototype, "fsAdapter", { - /** - * Returns FileSystem adapter. - */ - get: function () { - return new fs_sync_1.default(this.options); - }, - enumerable: true, - configurable: true - }); - /** - * Use sync API to read entries for Task. - */ - ReaderSync.prototype.read = function (task) { - var root = this.getRootDirectory(task); - var options = this.getReaderOptions(task); - try { - var entries = this.api(root, task, options); - return entries.map(this.transform, this); - } - catch (err) { - if (this.isEnoentCodeError(err)) { - return []; - } - throw err; - } - }; - /** - * Returns founded paths. - */ - ReaderSync.prototype.api = function (root, task, options) { - if (task.dynamic) { - return this.dynamicApi(root, options); - } - return this.staticApi(task, options); - }; - /** - * Api for dynamic tasks. - */ - ReaderSync.prototype.dynamicApi = function (root, options) { - return readdir.readdirSyncStat(root, options); - }; - /** - * Api for static tasks. - */ - ReaderSync.prototype.staticApi = function (task, options) { - return this.fsAdapter.read(task.patterns, options.filter); - }; - return ReaderSync; -}(reader_1.default)); -exports.default = ReaderSync; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var readdir = __webpack_require__(883); +var reader_1 = __webpack_require__(896); +var fs_sync_1 = __webpack_require__(908); +var ReaderSync = /** @class */ (function (_super) { + __extends(ReaderSync, _super); + function ReaderSync() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ReaderSync.prototype, "fsAdapter", { + /** + * Returns FileSystem adapter. + */ + get: function () { + return new fs_sync_1.default(this.options); + }, + enumerable: true, + configurable: true + }); + /** + * Use sync API to read entries for Task. + */ + ReaderSync.prototype.read = function (task) { + var root = this.getRootDirectory(task); + var options = this.getReaderOptions(task); + try { + var entries = this.api(root, task, options); + return entries.map(this.transform, this); + } + catch (err) { + if (this.isEnoentCodeError(err)) { + return []; + } + throw err; + } + }; + /** + * Returns founded paths. + */ + ReaderSync.prototype.api = function (root, task, options) { + if (task.dynamic) { + return this.dynamicApi(root, options); + } + return this.staticApi(task, options); + }; + /** + * Api for dynamic tasks. + */ + ReaderSync.prototype.dynamicApi = function (root, options) { + return readdir.readdirSyncStat(root, options); + }; + /** + * Api for static tasks. + */ + ReaderSync.prototype.staticApi = function (task, options) { + return this.fsAdapter.read(task.patterns, options.filter); + }; + return ReaderSync; +}(reader_1.default)); +exports.default = ReaderSync; /***/ }), @@ -106234,65 +106234,65 @@ exports.default = ReaderSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var fsStat = __webpack_require__(901); -var fs_1 = __webpack_require__(905); -var FileSystemSync = /** @class */ (function (_super) { - __extends(FileSystemSync, _super); - function FileSystemSync() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Use sync API to read entries for Task. - */ - FileSystemSync.prototype.read = function (patterns, filter) { - var _this = this; - var entries = []; - patterns.forEach(function (pattern) { - var filepath = _this.getFullEntryPath(pattern); - var entry = _this.getEntry(filepath, pattern); - if (entry === null || !filter(entry)) { - return; - } - entries.push(entry); - }); - return entries; - }; - /** - * Return entry for the provided path. - */ - FileSystemSync.prototype.getEntry = function (filepath, pattern) { - try { - var stat = this.getStat(filepath); - return this.makeEntry(stat, pattern); - } - catch (err) { - return null; - } - }; - /** - * Return fs.Stats for the provided path. - */ - FileSystemSync.prototype.getStat = function (filepath) { - return fsStat.statSync(filepath, { throwErrorOnBrokenSymlinks: false }); - }; - return FileSystemSync; -}(fs_1.default)); -exports.default = FileSystemSync; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var fsStat = __webpack_require__(901); +var fs_1 = __webpack_require__(905); +var FileSystemSync = /** @class */ (function (_super) { + __extends(FileSystemSync, _super); + function FileSystemSync() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Use sync API to read entries for Task. + */ + FileSystemSync.prototype.read = function (patterns, filter) { + var _this = this; + var entries = []; + patterns.forEach(function (pattern) { + var filepath = _this.getFullEntryPath(pattern); + var entry = _this.getEntry(filepath, pattern); + if (entry === null || !filter(entry)) { + return; + } + entries.push(entry); + }); + return entries; + }; + /** + * Return entry for the provided path. + */ + FileSystemSync.prototype.getEntry = function (filepath, pattern) { + try { + var stat = this.getStat(filepath); + return this.makeEntry(stat, pattern); + } + catch (err) { + return null; + } + }; + /** + * Return fs.Stats for the provided path. + */ + FileSystemSync.prototype.getStat = function (filepath) { + return fsStat.statSync(filepath, { throwErrorOnBrokenSymlinks: false }); + }; + return FileSystemSync; +}(fs_1.default)); +exports.default = FileSystemSync; /***/ }), @@ -106300,15 +106300,15 @@ exports.default = FileSystemSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Flatten nested arrays (max depth is 2) into a non-nested array of non-array items. - */ -function flatten(items) { - return items.reduce(function (collection, item) { return [].concat(collection, item); }, []); -} -exports.flatten = flatten; + +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Flatten nested arrays (max depth is 2) into a non-nested array of non-array items. + */ +function flatten(items) { + return items.reduce(function (collection, item) { return [].concat(collection, item); }, []); +} +exports.flatten = flatten; /***/ }), @@ -106316,20 +106316,20 @@ exports.flatten = flatten; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var merge2 = __webpack_require__(585); -/** - * Merge multiple streams and propagate their errors into one stream in parallel. - */ -function merge(streams) { - var mergedStream = merge2(streams); - streams.forEach(function (stream) { - stream.on('error', function (err) { return mergedStream.emit('error', err); }); - }); - return mergedStream; -} -exports.merge = merge; + +Object.defineProperty(exports, "__esModule", { value: true }); +var merge2 = __webpack_require__(585); +/** + * Merge multiple streams and propagate their errors into one stream in parallel. + */ +function merge(streams) { + var mergedStream = merge2(streams); + streams.forEach(function (stream) { + stream.on('error', function (err) { return mergedStream.emit('error', err); }); + }); + return mergedStream; +} +exports.merge = merge; /***/ }), @@ -109916,4 +109916,4 @@ async function prepareExternalProjectDependencies(projectPath) { } /***/ }) -/******/ ]); \ No newline at end of file +/******/ ]); diff --git a/packages/kbn-pm/src/utils/scripts.ts b/packages/kbn-pm/src/utils/scripts.ts index 6c0ac5af3abd4..6b1dc729906f2 100644 --- a/packages/kbn-pm/src/utils/scripts.ts +++ b/packages/kbn-pm/src/utils/scripts.ts @@ -35,7 +35,7 @@ interface WorkspacesInfo { * Install all dependencies in the given directory */ export async function installInDir(directory: string, extraArgs: string[] = []) { - const options = ['install', '--non-interactive', '--verbose', ...extraArgs]; + const options = ['install', '--non-interactive', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any // given time (e.g. to avoid conflicts). From 1334dec1260e2270d0ccc69328894ee36d47ea56 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jun 2020 15:52:11 +0200 Subject: [PATCH 039/186] Undo accidentally commited kbn-pm changes II --- packages/kbn-pm/dist/index.js | 6086 ++++++++++++++++----------------- 1 file changed, 3043 insertions(+), 3043 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 53e7bc6a816a6..ef2b7e7c06a25 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -622,192 +622,192 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; }); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed 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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); -}; - -function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - -var __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - } - return __assign.apply(this, arguments); -} - -function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; -} - -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - -function __param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -} - -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - -function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} - -function __values(o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -} - -function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -} - -function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} - -function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } -} - -function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } -} - -function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } -} - -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; - -function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result.default = mod; - return result; -} - -function __importDefault(mod) { - return (mod && mod.__esModule) ? mod : { default: mod }; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed 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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result.default = mod; + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} /***/ }), @@ -29702,7 +29702,7 @@ function startProc(name, options, log) { throw errors_1.createCliError(`[${name}] exited with code ${code}`); } return code; - })), + })), // observe first error event Rx.fromEvent(childProcess, 'error').pipe(operators_1.take(1), operators_1.mergeMap((err) => Rx.throwError(err)))).pipe(operators_1.share()); const lines$ = Rx.merge(observe_lines_1.observeLines(childProcess.stdout), observe_lines_1.observeLines(childProcess.stderr)).pipe(operators_1.tap((line) => log.write(` ${chalk_1.default.gray('proc')} [${chalk_1.default.gray(name)}] ${line}`)), operators_1.share()); @@ -33867,158 +33867,158 @@ convert.rgb.gray = function (rgb) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - - -module.exports = { - "aliceblue": [240, 248, 255], - "antiquewhite": [250, 235, 215], - "aqua": [0, 255, 255], - "aquamarine": [127, 255, 212], - "azure": [240, 255, 255], - "beige": [245, 245, 220], - "bisque": [255, 228, 196], - "black": [0, 0, 0], - "blanchedalmond": [255, 235, 205], - "blue": [0, 0, 255], - "blueviolet": [138, 43, 226], - "brown": [165, 42, 42], - "burlywood": [222, 184, 135], - "cadetblue": [95, 158, 160], - "chartreuse": [127, 255, 0], - "chocolate": [210, 105, 30], - "coral": [255, 127, 80], - "cornflowerblue": [100, 149, 237], - "cornsilk": [255, 248, 220], - "crimson": [220, 20, 60], - "cyan": [0, 255, 255], - "darkblue": [0, 0, 139], - "darkcyan": [0, 139, 139], - "darkgoldenrod": [184, 134, 11], - "darkgray": [169, 169, 169], - "darkgreen": [0, 100, 0], - "darkgrey": [169, 169, 169], - "darkkhaki": [189, 183, 107], - "darkmagenta": [139, 0, 139], - "darkolivegreen": [85, 107, 47], - "darkorange": [255, 140, 0], - "darkorchid": [153, 50, 204], - "darkred": [139, 0, 0], - "darksalmon": [233, 150, 122], - "darkseagreen": [143, 188, 143], - "darkslateblue": [72, 61, 139], - "darkslategray": [47, 79, 79], - "darkslategrey": [47, 79, 79], - "darkturquoise": [0, 206, 209], - "darkviolet": [148, 0, 211], - "deeppink": [255, 20, 147], - "deepskyblue": [0, 191, 255], - "dimgray": [105, 105, 105], - "dimgrey": [105, 105, 105], - "dodgerblue": [30, 144, 255], - "firebrick": [178, 34, 34], - "floralwhite": [255, 250, 240], - "forestgreen": [34, 139, 34], - "fuchsia": [255, 0, 255], - "gainsboro": [220, 220, 220], - "ghostwhite": [248, 248, 255], - "gold": [255, 215, 0], - "goldenrod": [218, 165, 32], - "gray": [128, 128, 128], - "green": [0, 128, 0], - "greenyellow": [173, 255, 47], - "grey": [128, 128, 128], - "honeydew": [240, 255, 240], - "hotpink": [255, 105, 180], - "indianred": [205, 92, 92], - "indigo": [75, 0, 130], - "ivory": [255, 255, 240], - "khaki": [240, 230, 140], - "lavender": [230, 230, 250], - "lavenderblush": [255, 240, 245], - "lawngreen": [124, 252, 0], - "lemonchiffon": [255, 250, 205], - "lightblue": [173, 216, 230], - "lightcoral": [240, 128, 128], - "lightcyan": [224, 255, 255], - "lightgoldenrodyellow": [250, 250, 210], - "lightgray": [211, 211, 211], - "lightgreen": [144, 238, 144], - "lightgrey": [211, 211, 211], - "lightpink": [255, 182, 193], - "lightsalmon": [255, 160, 122], - "lightseagreen": [32, 178, 170], - "lightskyblue": [135, 206, 250], - "lightslategray": [119, 136, 153], - "lightslategrey": [119, 136, 153], - "lightsteelblue": [176, 196, 222], - "lightyellow": [255, 255, 224], - "lime": [0, 255, 0], - "limegreen": [50, 205, 50], - "linen": [250, 240, 230], - "magenta": [255, 0, 255], - "maroon": [128, 0, 0], - "mediumaquamarine": [102, 205, 170], - "mediumblue": [0, 0, 205], - "mediumorchid": [186, 85, 211], - "mediumpurple": [147, 112, 219], - "mediumseagreen": [60, 179, 113], - "mediumslateblue": [123, 104, 238], - "mediumspringgreen": [0, 250, 154], - "mediumturquoise": [72, 209, 204], - "mediumvioletred": [199, 21, 133], - "midnightblue": [25, 25, 112], - "mintcream": [245, 255, 250], - "mistyrose": [255, 228, 225], - "moccasin": [255, 228, 181], - "navajowhite": [255, 222, 173], - "navy": [0, 0, 128], - "oldlace": [253, 245, 230], - "olive": [128, 128, 0], - "olivedrab": [107, 142, 35], - "orange": [255, 165, 0], - "orangered": [255, 69, 0], - "orchid": [218, 112, 214], - "palegoldenrod": [238, 232, 170], - "palegreen": [152, 251, 152], - "paleturquoise": [175, 238, 238], - "palevioletred": [219, 112, 147], - "papayawhip": [255, 239, 213], - "peachpuff": [255, 218, 185], - "peru": [205, 133, 63], - "pink": [255, 192, 203], - "plum": [221, 160, 221], - "powderblue": [176, 224, 230], - "purple": [128, 0, 128], - "rebeccapurple": [102, 51, 153], - "red": [255, 0, 0], - "rosybrown": [188, 143, 143], - "royalblue": [65, 105, 225], - "saddlebrown": [139, 69, 19], - "salmon": [250, 128, 114], - "sandybrown": [244, 164, 96], - "seagreen": [46, 139, 87], - "seashell": [255, 245, 238], - "sienna": [160, 82, 45], - "silver": [192, 192, 192], - "skyblue": [135, 206, 235], - "slateblue": [106, 90, 205], - "slategray": [112, 128, 144], - "slategrey": [112, 128, 144], - "snow": [255, 250, 250], - "springgreen": [0, 255, 127], - "steelblue": [70, 130, 180], - "tan": [210, 180, 140], - "teal": [0, 128, 128], - "thistle": [216, 191, 216], - "tomato": [255, 99, 71], - "turquoise": [64, 224, 208], - "violet": [238, 130, 238], - "wheat": [245, 222, 179], - "white": [255, 255, 255], - "whitesmoke": [245, 245, 245], - "yellow": [255, 255, 0], - "yellowgreen": [154, 205, 50] -}; + + +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; /***/ }), @@ -34600,16 +34600,16 @@ function observeLines(readable) { buffer = buffer.slice(match.index + match[0].length); } return { buffer, lines }; - }, { buffer: '' }), + }, { buffer: '' }), // stop if done completes or errors operators_1.takeUntil(done$.pipe(operators_1.materialize())), operators_1.share()); return Rx.merge( // use done$ to provide completion/errors - done$, + done$, // merge in the "lines" from each step - scan$.pipe(operators_1.mergeMap(({ lines }) => lines || [])), + scan$.pipe(operators_1.mergeMap(({ lines }) => lines || [])), // inject the "unsplit" data at the end - scan$.pipe(operators_1.last(), operators_1.mergeMap(({ buffer }) => (buffer ? [buffer] : [])), + scan$.pipe(operators_1.last(), operators_1.mergeMap(({ buffer }) => (buffer ? [buffer] : [])), // if there were no lines, last() will error, so catch and complete operators_1.catchError(() => Rx.empty()))); } @@ -43544,18 +43544,18 @@ function mkdirP (p, opts, f, made) { else if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } if (!made) made = null; - + var cb = f || function () {}; p = path.resolve(p); - + xfs.mkdir(p, mode, function (er) { if (!er) { made = made || p; @@ -43589,10 +43589,10 @@ mkdirP.sync = function sync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } @@ -43635,58 +43635,58 @@ mkdirP.sync = function sync (p, opts, made) { /* 498 */ /***/ (function(module, exports) { -exports.replaceDollarWithPercentPair = replaceDollarWithPercentPair -exports.convertToSetCommand = convertToSetCommand -exports.convertToSetCommands = convertToSetCommands - -function convertToSetCommand(key, value) { - var line = "" - key = key || "" - key = key.trim() - value = value || "" - value = value.trim() - if(key && value && value.length > 0) { - line = "@SET " + key + "=" + replaceDollarWithPercentPair(value) + "\r\n" - } - return line -} - -function extractVariableValuePairs(declarations) { - var pairs = {} - declarations.map(function(declaration) { - var split = declaration.split("=") - pairs[split[0]]=split[1] - }) - return pairs -} - -function convertToSetCommands(variableString) { - var variableValuePairs = extractVariableValuePairs(variableString.split(" ")) - var variableDeclarationsAsBatch = "" - Object.keys(variableValuePairs).forEach(function (key) { - variableDeclarationsAsBatch += convertToSetCommand(key, variableValuePairs[key]) - }) - return variableDeclarationsAsBatch -} - -function replaceDollarWithPercentPair(value) { - var dollarExpressions = /\$\{?([^\$@#\?\- \t{}:]+)\}?/g - var result = "" - var startIndex = 0 - value = value || "" - do { - var match = dollarExpressions.exec(value) - if(match) { - var betweenMatches = value.substring(startIndex, match.index) || "" - result += betweenMatches + "%" + match[1] + "%" - startIndex = dollarExpressions.lastIndex - } - } while (dollarExpressions.lastIndex > 0) - result += value.substr(startIndex) - return result -} - - +exports.replaceDollarWithPercentPair = replaceDollarWithPercentPair +exports.convertToSetCommand = convertToSetCommand +exports.convertToSetCommands = convertToSetCommands + +function convertToSetCommand(key, value) { + var line = "" + key = key || "" + key = key.trim() + value = value || "" + value = value.trim() + if(key && value && value.length > 0) { + line = "@SET " + key + "=" + replaceDollarWithPercentPair(value) + "\r\n" + } + return line +} + +function extractVariableValuePairs(declarations) { + var pairs = {} + declarations.map(function(declaration) { + var split = declaration.split("=") + pairs[split[0]]=split[1] + }) + return pairs +} + +function convertToSetCommands(variableString) { + var variableValuePairs = extractVariableValuePairs(variableString.split(" ")) + var variableDeclarationsAsBatch = "" + Object.keys(variableValuePairs).forEach(function (key) { + variableDeclarationsAsBatch += convertToSetCommand(key, variableValuePairs[key]) + }) + return variableDeclarationsAsBatch +} + +function replaceDollarWithPercentPair(value) { + var dollarExpressions = /\$\{?([^\$@#\?\- \t{}:]+)\}?/g + var result = "" + var startIndex = 0 + value = value || "" + do { + var match = dollarExpressions.exec(value) + if(match) { + var betweenMatches = value.substring(startIndex, match.index) || "" + result += betweenMatches + "%" + match[1] + "%" + startIndex = dollarExpressions.lastIndex + } + } while (dollarExpressions.lastIndex > 0) + result += value.substr(startIndex) + return result +} + + /***/ }), @@ -43725,7 +43725,7 @@ function ncp (source, dest, options, callback) { limit = (limit < 1) ? 1 : (limit > 512) ? 512 : limit; startCopy(currentPath); - + function startCopy(source) { started++; if (filter) { @@ -43808,10 +43808,10 @@ function ncp (source, dest, options, callback) { function copyFile(file, target) { var readStream = fs.createReadStream(file.name), writeStream = fs.createWriteStream(target, { mode: file.mode }); - + readStream.on('error', onError); writeStream.on('error', onError); - + if(transform) { transform(readStream, writeStream, file); } else { @@ -43936,7 +43936,7 @@ function ncp (source, dest, options, callback) { if (typeof errs.write === 'undefined') { errs.push(err); } - else { + else { errs.write(err.stack + '\n\n'); } return cb(); @@ -54739,7 +54739,7 @@ function legacy (fs) { // @return {number} The 32-bit hash MurmurHash3.prototype.result = function() { var k1, h1; - + k1 = this.k1; h1 = this.h1; @@ -55904,7 +55904,7 @@ function usage($0, p) { module.exports = function (args, opts) { if (!opts) opts = {}; - + var flags = { bools : {}, strings : {}, unknownFn: null }; if (typeof opts['unknown'] === 'function') { @@ -55918,7 +55918,7 @@ module.exports = function (args, opts) { flags.bools[key] = true; }); } - + var aliases = {}; Object.keys(opts.alias || {}).forEach(function (key) { aliases[key] = [].concat(opts.alias[key]); @@ -55937,12 +55937,12 @@ module.exports = function (args, opts) { }); var defaults = opts['default'] || {}; - + var argv = { _ : [] }; Object.keys(flags.bools).forEach(function (key) { setArg(key, defaults[key] === undefined ? false : defaults[key]); }); - + var notFlags = []; if (args.indexOf('--') !== -1) { @@ -55964,7 +55964,7 @@ module.exports = function (args, opts) { ? Number(val) : val ; setKey(argv, key.split('.'), value); - + (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), value); }); @@ -55988,7 +55988,7 @@ module.exports = function (args, opts) { o[key] = [ o[key], value ]; } } - + function aliasIsBoolean(key) { return aliases[key].some(function (x) { return flags.bools[x]; @@ -55997,7 +55997,7 @@ module.exports = function (args, opts) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - + if (/^--.+=/.test(arg)) { // Using [\s\S] instead of . because js doesn't support the // 'dotall' regex modifier. See: @@ -56034,29 +56034,29 @@ module.exports = function (args, opts) { } else if (/^-[^-]+/.test(arg)) { var letters = arg.slice(1,-1).split(''); - + var broken = false; for (var j = 0; j < letters.length; j++) { var next = arg.slice(j+2); - + if (next === '-') { setArg(letters[j], next, arg) continue; } - + if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) { setArg(letters[j], next.split('=')[1], arg); broken = true; break; } - + if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { setArg(letters[j], next, arg); broken = true; break; } - + if (letters[j+1] && letters[j+1].match(/\W/)) { setArg(letters[j], arg.slice(j+2), arg); broken = true; @@ -56066,7 +56066,7 @@ module.exports = function (args, opts) { setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg); } } - + var key = arg.slice(-1)[0]; if (!broken && key !== '-') { if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1]) @@ -56096,17 +56096,17 @@ module.exports = function (args, opts) { } } } - + Object.keys(defaults).forEach(function (key) { if (!hasKey(argv, key.split('.'))) { setKey(argv, key.split('.'), defaults[key]); - + (aliases[key] || []).forEach(function (x) { setKey(argv, x.split('.'), defaults[key]); }); } }); - + if (opts['--']) { argv['--'] = new Array(); notFlags.forEach(function(key) { @@ -62963,18 +62963,18 @@ function mkdirP (p, opts, f, made) { else if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } if (!made) made = null; - + var cb = f || function () {}; p = path.resolve(p); - + xfs.mkdir(p, mode, function (er) { if (!er) { made = made || p; @@ -63007,10 +63007,10 @@ mkdirP.sync = function sync (p, opts, made) { if (!opts || typeof opts !== 'object') { opts = { mode: opts }; } - + var mode = opts.mode; var xfs = opts.fs || fs; - + if (mode === undefined) { mode = _0777 & (~process.umask()); } @@ -69138,67 +69138,67 @@ function childrenIgnored (self, path) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -const taskManager = __webpack_require__(592); -const async_1 = __webpack_require__(620); -const stream_1 = __webpack_require__(653); -const sync_1 = __webpack_require__(654); -const settings_1 = __webpack_require__(656); -const utils = __webpack_require__(593); -function FastGlob(source, options) { - try { - assertPatternsInput(source); - } - catch (error) { - return Promise.reject(error); - } - const works = getWorks(source, async_1.default, options); - return Promise.all(works).then(utils.array.flatten); -} -(function (FastGlob) { - function sync(source, options) { - assertPatternsInput(source); - const works = getWorks(source, sync_1.default, options); - return utils.array.flatten(works); - } - FastGlob.sync = sync; - function stream(source, options) { - assertPatternsInput(source); - const works = getWorks(source, stream_1.default, options); - /** - * The stream returned by the provider cannot work with an asynchronous iterator. - * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams. - * This affects performance (+25%). I don't see best solution right now. - */ - return utils.stream.merge(works); - } - FastGlob.stream = stream; - function generateTasks(source, options) { - assertPatternsInput(source); - const patterns = [].concat(source); - const settings = new settings_1.default(options); - return taskManager.generate(patterns, settings); - } - FastGlob.generateTasks = generateTasks; -})(FastGlob || (FastGlob = {})); -function getWorks(source, _Provider, options) { - const patterns = [].concat(source); - const settings = new settings_1.default(options); - const tasks = taskManager.generate(patterns, settings); - const provider = new _Provider(settings); - return tasks.map(provider.read, provider); -} -function assertPatternsInput(source) { - if ([].concat(source).every(isString)) { - return; - } - throw new TypeError('Patterns must be a string or an array of strings'); -} -function isString(source) { - /* tslint:disable-next-line strict-type-predicates */ - return typeof source === 'string'; -} -module.exports = FastGlob; + +const taskManager = __webpack_require__(592); +const async_1 = __webpack_require__(620); +const stream_1 = __webpack_require__(653); +const sync_1 = __webpack_require__(654); +const settings_1 = __webpack_require__(656); +const utils = __webpack_require__(593); +function FastGlob(source, options) { + try { + assertPatternsInput(source); + } + catch (error) { + return Promise.reject(error); + } + const works = getWorks(source, async_1.default, options); + return Promise.all(works).then(utils.array.flatten); +} +(function (FastGlob) { + function sync(source, options) { + assertPatternsInput(source); + const works = getWorks(source, sync_1.default, options); + return utils.array.flatten(works); + } + FastGlob.sync = sync; + function stream(source, options) { + assertPatternsInput(source); + const works = getWorks(source, stream_1.default, options); + /** + * The stream returned by the provider cannot work with an asynchronous iterator. + * To support asynchronous iterators, regardless of the number of tasks, we always multiplex streams. + * This affects performance (+25%). I don't see best solution right now. + */ + return utils.stream.merge(works); + } + FastGlob.stream = stream; + function generateTasks(source, options) { + assertPatternsInput(source); + const patterns = [].concat(source); + const settings = new settings_1.default(options); + return taskManager.generate(patterns, settings); + } + FastGlob.generateTasks = generateTasks; +})(FastGlob || (FastGlob = {})); +function getWorks(source, _Provider, options) { + const patterns = [].concat(source); + const settings = new settings_1.default(options); + const tasks = taskManager.generate(patterns, settings); + const provider = new _Provider(settings); + return tasks.map(provider.read, provider); +} +function assertPatternsInput(source) { + if ([].concat(source).every(isString)) { + return; + } + throw new TypeError('Patterns must be a string or an array of strings'); +} +function isString(source) { + /* tslint:disable-next-line strict-type-predicates */ + return typeof source === 'string'; +} +module.exports = FastGlob; /***/ }), @@ -69206,73 +69206,73 @@ module.exports = FastGlob; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -function generate(patterns, settings) { - const positivePatterns = getPositivePatterns(patterns); - const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); - /** - * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check - * filepath directly (without read directory). - */ - const staticPatterns = !settings.caseSensitiveMatch ? [] : positivePatterns.filter(utils.pattern.isStaticPattern); - const dynamicPatterns = !settings.caseSensitiveMatch ? positivePatterns : positivePatterns.filter(utils.pattern.isDynamicPattern); - const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); - const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); - return staticTasks.concat(dynamicTasks); -} -exports.generate = generate; -function convertPatternsToTasks(positive, negative, dynamic) { - const positivePatternsGroup = groupPatternsByBaseDirectory(positive); - // When we have a global group – there is no reason to divide the patterns into independent tasks. - // In this case, the global task covers the rest. - if ('.' in positivePatternsGroup) { - const task = convertPatternGroupToTask('.', positive, negative, dynamic); - return [task]; - } - return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); -} -exports.convertPatternsToTasks = convertPatternsToTasks; -function getPositivePatterns(patterns) { - return utils.pattern.getPositivePatterns(patterns); -} -exports.getPositivePatterns = getPositivePatterns; -function getNegativePatternsAsPositive(patterns, ignore) { - const negative = utils.pattern.getNegativePatterns(patterns).concat(ignore); - const positive = negative.map(utils.pattern.convertToPositivePattern); - return positive; -} -exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; -function groupPatternsByBaseDirectory(patterns) { - return patterns.reduce((collection, pattern) => { - const base = utils.pattern.getBaseDirectory(pattern); - if (base in collection) { - collection[base].push(pattern); - } - else { - collection[base] = [pattern]; - } - return collection; - }, {}); -} -exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; -function convertPatternGroupsToTasks(positive, negative, dynamic) { - return Object.keys(positive).map((base) => { - return convertPatternGroupToTask(base, positive[base], negative, dynamic); - }); -} -exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; -function convertPatternGroupToTask(base, positive, negative, dynamic) { - return { - dynamic, - positive, - negative, - base, - patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern)) - }; -} -exports.convertPatternGroupToTask = convertPatternGroupToTask; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +function generate(patterns, settings) { + const positivePatterns = getPositivePatterns(patterns); + const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore); + /** + * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check + * filepath directly (without read directory). + */ + const staticPatterns = !settings.caseSensitiveMatch ? [] : positivePatterns.filter(utils.pattern.isStaticPattern); + const dynamicPatterns = !settings.caseSensitiveMatch ? positivePatterns : positivePatterns.filter(utils.pattern.isDynamicPattern); + const staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); + const dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); + return staticTasks.concat(dynamicTasks); +} +exports.generate = generate; +function convertPatternsToTasks(positive, negative, dynamic) { + const positivePatternsGroup = groupPatternsByBaseDirectory(positive); + // When we have a global group – there is no reason to divide the patterns into independent tasks. + // In this case, the global task covers the rest. + if ('.' in positivePatternsGroup) { + const task = convertPatternGroupToTask('.', positive, negative, dynamic); + return [task]; + } + return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); +} +exports.convertPatternsToTasks = convertPatternsToTasks; +function getPositivePatterns(patterns) { + return utils.pattern.getPositivePatterns(patterns); +} +exports.getPositivePatterns = getPositivePatterns; +function getNegativePatternsAsPositive(patterns, ignore) { + const negative = utils.pattern.getNegativePatterns(patterns).concat(ignore); + const positive = negative.map(utils.pattern.convertToPositivePattern); + return positive; +} +exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; +function groupPatternsByBaseDirectory(patterns) { + return patterns.reduce((collection, pattern) => { + const base = utils.pattern.getBaseDirectory(pattern); + if (base in collection) { + collection[base].push(pattern); + } + else { + collection[base] = [pattern]; + } + return collection; + }, {}); +} +exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; +function convertPatternGroupsToTasks(positive, negative, dynamic) { + return Object.keys(positive).map((base) => { + return convertPatternGroupToTask(base, positive[base], negative, dynamic); + }); +} +exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; +function convertPatternGroupToTask(base, positive, negative, dynamic) { + return { + dynamic, + positive, + negative, + base, + patterns: [].concat(positive, negative.map(utils.pattern.convertToNegativePattern)) + }; +} +exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ }), @@ -69280,20 +69280,20 @@ exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const array = __webpack_require__(594); -exports.array = array; -const errno = __webpack_require__(595); -exports.errno = errno; -const fs = __webpack_require__(596); -exports.fs = fs; -const path = __webpack_require__(597); -exports.path = path; -const pattern = __webpack_require__(598); -exports.pattern = pattern; -const stream = __webpack_require__(619); -exports.stream = stream; + +Object.defineProperty(exports, "__esModule", { value: true }); +const array = __webpack_require__(594); +exports.array = array; +const errno = __webpack_require__(595); +exports.errno = errno; +const fs = __webpack_require__(596); +exports.fs = fs; +const path = __webpack_require__(597); +exports.path = path; +const pattern = __webpack_require__(598); +exports.pattern = pattern; +const stream = __webpack_require__(619); +exports.stream = stream; /***/ }), @@ -69301,12 +69301,12 @@ exports.stream = stream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function flatten(items) { - return items.reduce((collection, item) => [].concat(collection, item), []); -} -exports.flatten = flatten; + +Object.defineProperty(exports, "__esModule", { value: true }); +function flatten(items) { + return items.reduce((collection, item) => [].concat(collection, item), []); +} +exports.flatten = flatten; /***/ }), @@ -69314,12 +69314,12 @@ exports.flatten = flatten; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function isEnoentCodeError(error) { - return error.code === 'ENOENT'; -} -exports.isEnoentCodeError = isEnoentCodeError; + +Object.defineProperty(exports, "__esModule", { value: true }); +function isEnoentCodeError(error) { + return error.code === 'ENOENT'; +} +exports.isEnoentCodeError = isEnoentCodeError; /***/ }), @@ -69327,24 +69327,24 @@ exports.isEnoentCodeError = isEnoentCodeError; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; + +Object.defineProperty(exports, "__esModule", { value: true }); +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; /***/ }), @@ -69352,20 +69352,20 @@ exports.createDirentFromStats = createDirentFromStats; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -/** - * Designed to work only with simple paths: `dir\\file`. - */ -function unixify(filepath) { - return filepath.replace(/\\/g, '/'); -} -exports.unixify = unixify; -function makeAbsolute(cwd, filepath) { - return path.resolve(cwd, filepath); -} -exports.makeAbsolute = makeAbsolute; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +/** + * Designed to work only with simple paths: `dir\\file`. + */ +function unixify(filepath) { + return filepath.replace(/\\/g, '/'); +} +exports.unixify = unixify; +function makeAbsolute(cwd, filepath) { + return path.resolve(cwd, filepath); +} +exports.makeAbsolute = makeAbsolute; /***/ }), @@ -69373,97 +69373,97 @@ exports.makeAbsolute = makeAbsolute; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const globParent = __webpack_require__(599); -const isGlob = __webpack_require__(600); -const micromatch = __webpack_require__(602); -const GLOBSTAR = '**'; -function isStaticPattern(pattern) { - return !isDynamicPattern(pattern); -} -exports.isStaticPattern = isStaticPattern; -function isDynamicPattern(pattern) { - return isGlob(pattern, { strict: false }); -} -exports.isDynamicPattern = isDynamicPattern; -function convertToPositivePattern(pattern) { - return isNegativePattern(pattern) ? pattern.slice(1) : pattern; -} -exports.convertToPositivePattern = convertToPositivePattern; -function convertToNegativePattern(pattern) { - return '!' + pattern; -} -exports.convertToNegativePattern = convertToNegativePattern; -function isNegativePattern(pattern) { - return pattern.startsWith('!') && pattern[1] !== '('; -} -exports.isNegativePattern = isNegativePattern; -function isPositivePattern(pattern) { - return !isNegativePattern(pattern); -} -exports.isPositivePattern = isPositivePattern; -function getNegativePatterns(patterns) { - return patterns.filter(isNegativePattern); -} -exports.getNegativePatterns = getNegativePatterns; -function getPositivePatterns(patterns) { - return patterns.filter(isPositivePattern); -} -exports.getPositivePatterns = getPositivePatterns; -function getBaseDirectory(pattern) { - return globParent(pattern); -} -exports.getBaseDirectory = getBaseDirectory; -function hasGlobStar(pattern) { - return pattern.indexOf(GLOBSTAR) !== -1; -} -exports.hasGlobStar = hasGlobStar; -function endsWithSlashGlobStar(pattern) { - return pattern.endsWith('/' + GLOBSTAR); -} -exports.endsWithSlashGlobStar = endsWithSlashGlobStar; -function isAffectDepthOfReadingPattern(pattern) { - const basename = path.basename(pattern); - return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); -} -exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; -function getNaiveDepth(pattern) { - const base = getBaseDirectory(pattern); - const patternDepth = pattern.split('/').length; - const patternBaseDepth = base.split('/').length; - /** - * This is a hack for pattern that has no base directory. - * - * This is related to the `*\something\*` pattern. - */ - if (base === '.') { - return patternDepth - patternBaseDepth; - } - return patternDepth - patternBaseDepth - 1; -} -exports.getNaiveDepth = getNaiveDepth; -function getMaxNaivePatternsDepth(patterns) { - return patterns.reduce((max, pattern) => { - const depth = getNaiveDepth(pattern); - return depth > max ? depth : max; - }, 0); -} -exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; -function makeRe(pattern, options) { - return micromatch.makeRe(pattern, options); -} -exports.makeRe = makeRe; -function convertPatternsToRe(patterns, options) { - return patterns.map((pattern) => makeRe(pattern, options)); -} -exports.convertPatternsToRe = convertPatternsToRe; -function matchAny(entry, patternsRe) { - const filepath = entry.replace(/^\.[\\\/]/, ''); - return patternsRe.some((patternRe) => patternRe.test(filepath)); -} -exports.matchAny = matchAny; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const globParent = __webpack_require__(599); +const isGlob = __webpack_require__(600); +const micromatch = __webpack_require__(602); +const GLOBSTAR = '**'; +function isStaticPattern(pattern) { + return !isDynamicPattern(pattern); +} +exports.isStaticPattern = isStaticPattern; +function isDynamicPattern(pattern) { + return isGlob(pattern, { strict: false }); +} +exports.isDynamicPattern = isDynamicPattern; +function convertToPositivePattern(pattern) { + return isNegativePattern(pattern) ? pattern.slice(1) : pattern; +} +exports.convertToPositivePattern = convertToPositivePattern; +function convertToNegativePattern(pattern) { + return '!' + pattern; +} +exports.convertToNegativePattern = convertToNegativePattern; +function isNegativePattern(pattern) { + return pattern.startsWith('!') && pattern[1] !== '('; +} +exports.isNegativePattern = isNegativePattern; +function isPositivePattern(pattern) { + return !isNegativePattern(pattern); +} +exports.isPositivePattern = isPositivePattern; +function getNegativePatterns(patterns) { + return patterns.filter(isNegativePattern); +} +exports.getNegativePatterns = getNegativePatterns; +function getPositivePatterns(patterns) { + return patterns.filter(isPositivePattern); +} +exports.getPositivePatterns = getPositivePatterns; +function getBaseDirectory(pattern) { + return globParent(pattern); +} +exports.getBaseDirectory = getBaseDirectory; +function hasGlobStar(pattern) { + return pattern.indexOf(GLOBSTAR) !== -1; +} +exports.hasGlobStar = hasGlobStar; +function endsWithSlashGlobStar(pattern) { + return pattern.endsWith('/' + GLOBSTAR); +} +exports.endsWithSlashGlobStar = endsWithSlashGlobStar; +function isAffectDepthOfReadingPattern(pattern) { + const basename = path.basename(pattern); + return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); +} +exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; +function getNaiveDepth(pattern) { + const base = getBaseDirectory(pattern); + const patternDepth = pattern.split('/').length; + const patternBaseDepth = base.split('/').length; + /** + * This is a hack for pattern that has no base directory. + * + * This is related to the `*\something\*` pattern. + */ + if (base === '.') { + return patternDepth - patternBaseDepth; + } + return patternDepth - patternBaseDepth - 1; +} +exports.getNaiveDepth = getNaiveDepth; +function getMaxNaivePatternsDepth(patterns) { + return patterns.reduce((max, pattern) => { + const depth = getNaiveDepth(pattern); + return depth > max ? depth : max; + }, 0); +} +exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; +function makeRe(pattern, options) { + return micromatch.makeRe(pattern, options); +} +exports.makeRe = makeRe; +function convertPatternsToRe(patterns, options) { + return patterns.map((pattern) => makeRe(pattern, options)); +} +exports.convertPatternsToRe = convertPatternsToRe; +function matchAny(entry, patternsRe) { + const filepath = entry.replace(/^\.[\\\/]/, ''); + return patternsRe.some((patternRe) => patternRe.test(filepath)); +} +exports.matchAny = matchAny; /***/ }), @@ -73377,17 +73377,17 @@ module.exports = parse; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const merge2 = __webpack_require__(585); -function merge(streams) { - const mergedStream = merge2(streams); - streams.forEach((stream) => { - stream.once('error', (err) => mergedStream.emit('error', err)); - }); - return mergedStream; -} -exports.merge = merge; + +Object.defineProperty(exports, "__esModule", { value: true }); +const merge2 = __webpack_require__(585); +function merge(streams) { + const mergedStream = merge2(streams); + streams.forEach((stream) => { + stream.once('error', (err) => mergedStream.emit('error', err)); + }); + return mergedStream; +} +exports.merge = merge; /***/ }), @@ -73395,34 +73395,34 @@ exports.merge = merge; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(621); -const provider_1 = __webpack_require__(648); -class ProviderAsync extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new stream_1.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const entries = []; - return new Promise((resolve, reject) => { - const stream = this.api(root, task, options); - stream.once('error', reject); - stream.on('data', (entry) => entries.push(options.transform(entry))); - stream.once('end', () => resolve(entries)); - }); - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderAsync; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(621); +const provider_1 = __webpack_require__(648); +class ProviderAsync extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new stream_1.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const entries = []; + return new Promise((resolve, reject) => { + const stream = this.api(root, task, options); + stream.once('error', reject); + stream.on('data', (entry) => entries.push(options.transform(entry))); + stream.once('end', () => resolve(entries)); + }); + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderAsync; /***/ }), @@ -73430,61 +73430,61 @@ exports.default = ProviderAsync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(382); -const fsStat = __webpack_require__(622); -const fsWalk = __webpack_require__(627); -const reader_1 = __webpack_require__(647); -class ReaderStream extends reader_1.default { - constructor() { - super(...arguments); - this._walkStream = fsWalk.walkStream; - this._stat = fsStat.stat; - } - dynamic(root, options) { - return this._walkStream(root, options); - } - static(patterns, options) { - const filepaths = patterns.map(this._getFullEntryPath, this); - const stream = new stream_1.PassThrough({ objectMode: true }); - stream._write = (index, _enc, done) => { - return this._getEntry(filepaths[index], patterns[index], options) - .then((entry) => { - if (entry !== null && options.entryFilter(entry)) { - stream.push(entry); - } - if (index === filepaths.length - 1) { - stream.end(); - } - done(); - }) - .catch(done); - }; - for (let i = 0; i < filepaths.length; i++) { - stream.write(i); - } - return stream; - } - _getEntry(filepath, pattern, options) { - return this._getStat(filepath) - .then((stats) => this._makeEntry(stats, pattern)) - .catch((error) => { - if (options.errorFilter(error)) { - return null; - } - throw error; - }); - } - _getStat(filepath) { - return new Promise((resolve, reject) => { - this._stat(filepath, this._fsStatSettings, (error, stats) => { - error ? reject(error) : resolve(stats); - }); - }); - } -} -exports.default = ReaderStream; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(382); +const fsStat = __webpack_require__(622); +const fsWalk = __webpack_require__(627); +const reader_1 = __webpack_require__(647); +class ReaderStream extends reader_1.default { + constructor() { + super(...arguments); + this._walkStream = fsWalk.walkStream; + this._stat = fsStat.stat; + } + dynamic(root, options) { + return this._walkStream(root, options); + } + static(patterns, options) { + const filepaths = patterns.map(this._getFullEntryPath, this); + const stream = new stream_1.PassThrough({ objectMode: true }); + stream._write = (index, _enc, done) => { + return this._getEntry(filepaths[index], patterns[index], options) + .then((entry) => { + if (entry !== null && options.entryFilter(entry)) { + stream.push(entry); + } + if (index === filepaths.length - 1) { + stream.end(); + } + done(); + }) + .catch(done); + }; + for (let i = 0; i < filepaths.length; i++) { + stream.write(i); + } + return stream; + } + _getEntry(filepath, pattern, options) { + return this._getStat(filepath) + .then((stats) => this._makeEntry(stats, pattern)) + .catch((error) => { + if (options.errorFilter(error)) { + return null; + } + throw error; + }); + } + _getStat(filepath) { + return new Promise((resolve, reject) => { + this._stat(filepath, this._fsStatSettings, (error, stats) => { + error ? reject(error) : resolve(stats); + }); + }); + } +} +exports.default = ReaderStream; /***/ }), @@ -73492,30 +73492,30 @@ exports.default = ReaderStream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async = __webpack_require__(623); -const sync = __webpack_require__(624); -const settings_1 = __webpack_require__(625); -exports.Settings = settings_1.default; -function stat(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return async.read(path, getSettings(), optionsOrSettingsOrCallback); - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.stat = stat; -function statSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.statSync = statSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async = __webpack_require__(623); +const sync = __webpack_require__(624); +const settings_1 = __webpack_require__(625); +exports.Settings = settings_1.default; +function stat(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return async.read(path, getSettings(), optionsOrSettingsOrCallback); + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.stat = stat; +function statSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.statSync = statSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} /***/ }), @@ -73523,37 +73523,37 @@ function getSettings(settingsOrOptions = {}) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function read(path, settings, callback) { - settings.fs.lstat(path, (lstatError, lstat) => { - if (lstatError) { - return callFailureCallback(callback, lstatError); - } - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return callSuccessCallback(callback, lstat); - } - settings.fs.stat(path, (statError, stat) => { - if (statError) { - if (settings.throwErrorOnBrokenSymbolicLink) { - return callFailureCallback(callback, statError); - } - return callSuccessCallback(callback, lstat); - } - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - callSuccessCallback(callback, stat); - }); - }); -} -exports.read = read; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +function read(path, settings, callback) { + settings.fs.lstat(path, (lstatError, lstat) => { + if (lstatError) { + return callFailureCallback(callback, lstatError); + } + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return callSuccessCallback(callback, lstat); + } + settings.fs.stat(path, (statError, stat) => { + if (statError) { + if (settings.throwErrorOnBrokenSymbolicLink) { + return callFailureCallback(callback, statError); + } + return callSuccessCallback(callback, lstat); + } + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + callSuccessCallback(callback, stat); + }); + }); +} +exports.read = read; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} /***/ }), @@ -73561,28 +73561,28 @@ function callSuccessCallback(callback, result) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function read(path, settings) { - const lstat = settings.fs.lstatSync(path); - if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { - return lstat; - } - try { - const stat = settings.fs.statSync(path); - if (settings.markSymbolicLink) { - stat.isSymbolicLink = () => true; - } - return stat; - } - catch (error) { - if (!settings.throwErrorOnBrokenSymbolicLink) { - return lstat; - } - throw error; - } -} -exports.read = read; + +Object.defineProperty(exports, "__esModule", { value: true }); +function read(path, settings) { + const lstat = settings.fs.lstatSync(path); + if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) { + return lstat; + } + try { + const stat = settings.fs.statSync(path); + if (settings.markSymbolicLink) { + stat.isSymbolicLink = () => true; + } + return stat; + } + catch (error) { + if (!settings.throwErrorOnBrokenSymbolicLink) { + return lstat; + } + throw error; + } +} +exports.read = read; /***/ }), @@ -73590,22 +73590,22 @@ exports.read = read; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(626); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(626); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; /***/ }), @@ -73613,22 +73613,22 @@ exports.default = Settings; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(349); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync -}; -function createFileSystemAdapter(fsMethods) { - if (!fsMethods) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(349); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync +}; +function createFileSystemAdapter(fsMethods) { + if (!fsMethods) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; /***/ }), @@ -73636,38 +73636,38 @@ exports.createFileSystemAdapter = createFileSystemAdapter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = __webpack_require__(628); -const stream_1 = __webpack_require__(643); -const sync_1 = __webpack_require__(644); -const settings_1 = __webpack_require__(646); -exports.Settings = settings_1.default; -function walk(dir, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); - } - new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); -} -exports.walk = walk; -function walkSync(dir, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new sync_1.default(dir, settings); - return provider.read(); -} -exports.walkSync = walkSync; -function walkStream(dir, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - const provider = new stream_1.default(dir, settings); - return provider.read(); -} -exports.walkStream = walkStream; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = __webpack_require__(628); +const stream_1 = __webpack_require__(643); +const sync_1 = __webpack_require__(644); +const settings_1 = __webpack_require__(646); +exports.Settings = settings_1.default; +function walk(dir, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return new async_1.default(dir, getSettings()).read(optionsOrSettingsOrCallback); + } + new async_1.default(dir, getSettings(optionsOrSettingsOrCallback)).read(callback); +} +exports.walk = walk; +function walkSync(dir, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new sync_1.default(dir, settings); + return provider.read(); +} +exports.walkSync = walkSync; +function walkStream(dir, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + const provider = new stream_1.default(dir, settings); + return provider.read(); +} +exports.walkStream = walkStream; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} /***/ }), @@ -73675,36 +73675,36 @@ function getSettings(settingsOrOptions = {}) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async_1 = __webpack_require__(629); -class AsyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._storage = new Set(); - } - read(callback) { - this._reader.onError((error) => { - callFailureCallback(callback, error); - }); - this._reader.onEntry((entry) => { - this._storage.add(entry); - }); - this._reader.onEnd(() => { - callSuccessCallback(callback, Array.from(this._storage)); - }); - this._reader.read(); - } -} -exports.default = AsyncProvider; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, entries) { - callback(null, entries); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async_1 = __webpack_require__(629); +class AsyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._storage = new Set(); + } + read(callback) { + this._reader.onError((error) => { + callFailureCallback(callback, error); + }); + this._reader.onEntry((entry) => { + this._storage.add(entry); + }); + this._reader.onEnd(() => { + callSuccessCallback(callback, Array.from(this._storage)); + }); + this._reader.read(); + } +} +exports.default = AsyncProvider; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, entries) { + callback(null, entries); +} /***/ }), @@ -73712,99 +73712,99 @@ function callSuccessCallback(callback, entries) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const events_1 = __webpack_require__(373); -const fsScandir = __webpack_require__(630); -const fastq = __webpack_require__(639); -const common = __webpack_require__(641); -const reader_1 = __webpack_require__(642); -class AsyncReader extends reader_1.default { - constructor(_root, _settings) { - super(_root, _settings); - this._settings = _settings; - this._scandir = fsScandir.scandir; - this._emitter = new events_1.EventEmitter(); - this._queue = fastq(this._worker.bind(this), this._settings.concurrency); - this._isFatalError = false; - this._isDestroyed = false; - this._queue.drain = () => { - if (!this._isFatalError) { - this._emitter.emit('end'); - } - }; - } - read() { - this._isFatalError = false; - this._isDestroyed = false; - setImmediate(() => { - this._pushToQueue(this._root, this._settings.basePath); - }); - return this._emitter; - } - destroy() { - if (this._isDestroyed) { - throw new Error('The reader is already destroyed'); - } - this._isDestroyed = true; - this._queue.killAndDrain(); - } - onEntry(callback) { - this._emitter.on('entry', callback); - } - onError(callback) { - this._emitter.once('error', callback); - } - onEnd(callback) { - this._emitter.once('end', callback); - } - _pushToQueue(dir, base) { - const queueItem = { dir, base }; - this._queue.push(queueItem, (error) => { - if (error) { - this._handleError(error); - } - }); - } - _worker(item, done) { - this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { - if (error) { - return done(error, undefined); - } - for (const entry of entries) { - this._handleEntry(entry, item.base); - } - done(null, undefined); - }); - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - this._isFatalError = true; - this._isDestroyed = true; - this._emitter.emit('error', error); - } - _handleEntry(entry, base) { - if (this._isDestroyed || this._isFatalError) { - return; - } - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._emitEntry(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, entry.path); - } - } - _emitEntry(entry) { - this._emitter.emit('entry', entry); - } -} -exports.default = AsyncReader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const events_1 = __webpack_require__(373); +const fsScandir = __webpack_require__(630); +const fastq = __webpack_require__(639); +const common = __webpack_require__(641); +const reader_1 = __webpack_require__(642); +class AsyncReader extends reader_1.default { + constructor(_root, _settings) { + super(_root, _settings); + this._settings = _settings; + this._scandir = fsScandir.scandir; + this._emitter = new events_1.EventEmitter(); + this._queue = fastq(this._worker.bind(this), this._settings.concurrency); + this._isFatalError = false; + this._isDestroyed = false; + this._queue.drain = () => { + if (!this._isFatalError) { + this._emitter.emit('end'); + } + }; + } + read() { + this._isFatalError = false; + this._isDestroyed = false; + setImmediate(() => { + this._pushToQueue(this._root, this._settings.basePath); + }); + return this._emitter; + } + destroy() { + if (this._isDestroyed) { + throw new Error('The reader is already destroyed'); + } + this._isDestroyed = true; + this._queue.killAndDrain(); + } + onEntry(callback) { + this._emitter.on('entry', callback); + } + onError(callback) { + this._emitter.once('error', callback); + } + onEnd(callback) { + this._emitter.once('end', callback); + } + _pushToQueue(dir, base) { + const queueItem = { dir, base }; + this._queue.push(queueItem, (error) => { + if (error) { + this._handleError(error); + } + }); + } + _worker(item, done) { + this._scandir(item.dir, this._settings.fsScandirSettings, (error, entries) => { + if (error) { + return done(error, undefined); + } + for (const entry of entries) { + this._handleEntry(entry, item.base); + } + done(null, undefined); + }); + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + this._isFatalError = true; + this._isDestroyed = true; + this._emitter.emit('error', error); + } + _handleEntry(entry, base) { + if (this._isDestroyed || this._isFatalError) { + return; + } + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._emitEntry(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, entry.path); + } + } + _emitEntry(entry) { + this._emitter.emit('entry', entry); + } +} +exports.default = AsyncReader; /***/ }), @@ -73812,30 +73812,30 @@ exports.default = AsyncReader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const async = __webpack_require__(631); -const sync = __webpack_require__(636); -const settings_1 = __webpack_require__(637); -exports.Settings = settings_1.default; -function scandir(path, optionsOrSettingsOrCallback, callback) { - if (typeof optionsOrSettingsOrCallback === 'function') { - return async.read(path, getSettings(), optionsOrSettingsOrCallback); - } - async.read(path, getSettings(optionsOrSettingsOrCallback), callback); -} -exports.scandir = scandir; -function scandirSync(path, optionsOrSettings) { - const settings = getSettings(optionsOrSettings); - return sync.read(path, settings); -} -exports.scandirSync = scandirSync; -function getSettings(settingsOrOptions = {}) { - if (settingsOrOptions instanceof settings_1.default) { - return settingsOrOptions; - } - return new settings_1.default(settingsOrOptions); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const async = __webpack_require__(631); +const sync = __webpack_require__(636); +const settings_1 = __webpack_require__(637); +exports.Settings = settings_1.default; +function scandir(path, optionsOrSettingsOrCallback, callback) { + if (typeof optionsOrSettingsOrCallback === 'function') { + return async.read(path, getSettings(), optionsOrSettingsOrCallback); + } + async.read(path, getSettings(optionsOrSettingsOrCallback), callback); +} +exports.scandir = scandir; +function scandirSync(path, optionsOrSettings) { + const settings = getSettings(optionsOrSettings); + return sync.read(path, settings); +} +exports.scandirSync = scandirSync; +function getSettings(settingsOrOptions = {}) { + if (settingsOrOptions instanceof settings_1.default) { + return settingsOrOptions; + } + return new settings_1.default(settingsOrOptions); +} /***/ }), @@ -73843,97 +73843,97 @@ function getSettings(settingsOrOptions = {}) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(622); -const rpl = __webpack_require__(632); -const constants_1 = __webpack_require__(633); -const utils = __webpack_require__(634); -function read(dir, settings, callback) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(dir, settings, callback); - } - return readdir(dir, settings, callback); -} -exports.read = read; -function readdirWithFileTypes(dir, settings, callback) { - settings.fs.readdir(dir, { withFileTypes: true }, (readdirError, dirents) => { - if (readdirError) { - return callFailureCallback(callback, readdirError); - } - const entries = dirents.map((dirent) => ({ - dirent, - name: dirent.name, - path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` - })); - if (!settings.followSymbolicLinks) { - return callSuccessCallback(callback, entries); - } - const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); - rpl(tasks, (rplError, rplEntries) => { - if (rplError) { - return callFailureCallback(callback, rplError); - } - callSuccessCallback(callback, rplEntries); - }); - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function makeRplTaskEntry(entry, settings) { - return (done) => { - if (!entry.dirent.isSymbolicLink()) { - return done(null, entry); - } - settings.fs.stat(entry.path, (statError, stats) => { - if (statError) { - if (settings.throwErrorOnBrokenSymbolicLink) { - return done(statError); - } - return done(null, entry); - } - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - return done(null, entry); - }); - }; -} -function readdir(dir, settings, callback) { - settings.fs.readdir(dir, (readdirError, names) => { - if (readdirError) { - return callFailureCallback(callback, readdirError); - } - const filepaths = names.map((name) => `${dir}${settings.pathSegmentSeparator}${name}`); - const tasks = filepaths.map((filepath) => { - return (done) => fsStat.stat(filepath, settings.fsStatSettings, done); - }); - rpl(tasks, (rplError, results) => { - if (rplError) { - return callFailureCallback(callback, rplError); - } - const entries = []; - for (let index = 0; index < names.length; index++) { - const name = names[index]; - const stats = results[index]; - const entry = { - name, - path: filepaths[index], - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - entries.push(entry); - } - callSuccessCallback(callback, entries); - }); - }); -} -exports.readdir = readdir; -function callFailureCallback(callback, error) { - callback(error); -} -function callSuccessCallback(callback, result) { - callback(null, result); -} + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(622); +const rpl = __webpack_require__(632); +const constants_1 = __webpack_require__(633); +const utils = __webpack_require__(634); +function read(dir, settings, callback) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(dir, settings, callback); + } + return readdir(dir, settings, callback); +} +exports.read = read; +function readdirWithFileTypes(dir, settings, callback) { + settings.fs.readdir(dir, { withFileTypes: true }, (readdirError, dirents) => { + if (readdirError) { + return callFailureCallback(callback, readdirError); + } + const entries = dirents.map((dirent) => ({ + dirent, + name: dirent.name, + path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` + })); + if (!settings.followSymbolicLinks) { + return callSuccessCallback(callback, entries); + } + const tasks = entries.map((entry) => makeRplTaskEntry(entry, settings)); + rpl(tasks, (rplError, rplEntries) => { + if (rplError) { + return callFailureCallback(callback, rplError); + } + callSuccessCallback(callback, rplEntries); + }); + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function makeRplTaskEntry(entry, settings) { + return (done) => { + if (!entry.dirent.isSymbolicLink()) { + return done(null, entry); + } + settings.fs.stat(entry.path, (statError, stats) => { + if (statError) { + if (settings.throwErrorOnBrokenSymbolicLink) { + return done(statError); + } + return done(null, entry); + } + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + return done(null, entry); + }); + }; +} +function readdir(dir, settings, callback) { + settings.fs.readdir(dir, (readdirError, names) => { + if (readdirError) { + return callFailureCallback(callback, readdirError); + } + const filepaths = names.map((name) => `${dir}${settings.pathSegmentSeparator}${name}`); + const tasks = filepaths.map((filepath) => { + return (done) => fsStat.stat(filepath, settings.fsStatSettings, done); + }); + rpl(tasks, (rplError, results) => { + if (rplError) { + return callFailureCallback(callback, rplError); + } + const entries = []; + for (let index = 0; index < names.length; index++) { + const name = names[index]; + const stats = results[index]; + const entry = { + name, + path: filepaths[index], + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + entries.push(entry); + } + callSuccessCallback(callback, entries); + }); + }); +} +exports.readdir = readdir; +function callFailureCallback(callback, error) { + callback(error); +} +function callSuccessCallback(callback, result) { + callback(null, result); +} /***/ }), @@ -73995,15 +73995,15 @@ function runParallel (tasks, cb) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); -const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); -const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); -/** - * IS `true` for Node.js 10.10 and greater. - */ -exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSION === 10 && MINOR_VERSION >= 10); + +Object.defineProperty(exports, "__esModule", { value: true }); +const NODE_PROCESS_VERSION_PARTS = process.versions.node.split('.'); +const MAJOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[0], 10); +const MINOR_VERSION = parseInt(NODE_PROCESS_VERSION_PARTS[1], 10); +/** + * IS `true` for Node.js 10.10 and greater. + */ +exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSION === 10 && MINOR_VERSION >= 10); /***/ }), @@ -74011,10 +74011,10 @@ exports.IS_SUPPORT_READDIR_WITH_FILE_TYPES = MAJOR_VERSION > 10 || (MAJOR_VERSIO /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(635); -exports.fs = fs; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(635); +exports.fs = fs; /***/ }), @@ -74022,24 +74022,24 @@ exports.fs = fs; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -class DirentFromStats { - constructor(name, stats) { - this.name = name; - this.isBlockDevice = stats.isBlockDevice.bind(stats); - this.isCharacterDevice = stats.isCharacterDevice.bind(stats); - this.isDirectory = stats.isDirectory.bind(stats); - this.isFIFO = stats.isFIFO.bind(stats); - this.isFile = stats.isFile.bind(stats); - this.isSocket = stats.isSocket.bind(stats); - this.isSymbolicLink = stats.isSymbolicLink.bind(stats); - } -} -function createDirentFromStats(name, stats) { - return new DirentFromStats(name, stats); -} -exports.createDirentFromStats = createDirentFromStats; + +Object.defineProperty(exports, "__esModule", { value: true }); +class DirentFromStats { + constructor(name, stats) { + this.name = name; + this.isBlockDevice = stats.isBlockDevice.bind(stats); + this.isCharacterDevice = stats.isCharacterDevice.bind(stats); + this.isDirectory = stats.isDirectory.bind(stats); + this.isFIFO = stats.isFIFO.bind(stats); + this.isFile = stats.isFile.bind(stats); + this.isSocket = stats.isSocket.bind(stats); + this.isSymbolicLink = stats.isSymbolicLink.bind(stats); + } +} +function createDirentFromStats(name, stats) { + return new DirentFromStats(name, stats); +} +exports.createDirentFromStats = createDirentFromStats; /***/ }), @@ -74047,58 +74047,58 @@ exports.createDirentFromStats = createDirentFromStats; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(622); -const constants_1 = __webpack_require__(633); -const utils = __webpack_require__(634); -function read(dir, settings) { - if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { - return readdirWithFileTypes(dir, settings); - } - return readdir(dir, settings); -} -exports.read = read; -function readdirWithFileTypes(dir, settings) { - const dirents = settings.fs.readdirSync(dir, { withFileTypes: true }); - return dirents.map((dirent) => { - const entry = { - dirent, - name: dirent.name, - path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` - }; - if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { - try { - const stats = settings.fs.statSync(entry.path); - entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); - } - catch (error) { - if (settings.throwErrorOnBrokenSymbolicLink) { - throw error; - } - } - } - return entry; - }); -} -exports.readdirWithFileTypes = readdirWithFileTypes; -function readdir(dir, settings) { - const names = settings.fs.readdirSync(dir); - return names.map((name) => { - const entryPath = `${dir}${settings.pathSegmentSeparator}${name}`; - const stats = fsStat.statSync(entryPath, settings.fsStatSettings); - const entry = { - name, - path: entryPath, - dirent: utils.fs.createDirentFromStats(name, stats) - }; - if (settings.stats) { - entry.stats = stats; - } - return entry; - }); -} -exports.readdir = readdir; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(622); +const constants_1 = __webpack_require__(633); +const utils = __webpack_require__(634); +function read(dir, settings) { + if (!settings.stats && constants_1.IS_SUPPORT_READDIR_WITH_FILE_TYPES) { + return readdirWithFileTypes(dir, settings); + } + return readdir(dir, settings); +} +exports.read = read; +function readdirWithFileTypes(dir, settings) { + const dirents = settings.fs.readdirSync(dir, { withFileTypes: true }); + return dirents.map((dirent) => { + const entry = { + dirent, + name: dirent.name, + path: `${dir}${settings.pathSegmentSeparator}${dirent.name}` + }; + if (entry.dirent.isSymbolicLink() && settings.followSymbolicLinks) { + try { + const stats = settings.fs.statSync(entry.path); + entry.dirent = utils.fs.createDirentFromStats(entry.name, stats); + } + catch (error) { + if (settings.throwErrorOnBrokenSymbolicLink) { + throw error; + } + } + } + return entry; + }); +} +exports.readdirWithFileTypes = readdirWithFileTypes; +function readdir(dir, settings) { + const names = settings.fs.readdirSync(dir); + return names.map((name) => { + const entryPath = `${dir}${settings.pathSegmentSeparator}${name}`; + const stats = fsStat.statSync(entryPath, settings.fsStatSettings); + const entry = { + name, + path: entryPath, + dirent: utils.fs.createDirentFromStats(name, stats) + }; + if (settings.stats) { + entry.stats = stats; + } + return entry; + }); +} +exports.readdir = readdir; /***/ }), @@ -74106,30 +74106,30 @@ exports.readdir = readdir; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const fsStat = __webpack_require__(622); -const fs = __webpack_require__(638); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); - this.fs = fs.createFileSystemAdapter(this._options.fs); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.stats = this._getValue(this._options.stats, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); - this.fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this.followSymbolicLinks, - fs: this.fs, - throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const fsStat = __webpack_require__(622); +const fs = __webpack_require__(638); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false); + this.fs = fs.createFileSystemAdapter(this._options.fs); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.stats = this._getValue(this._options.stats, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true); + this.fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this.followSymbolicLinks, + fs: this.fs, + throwErrorOnBrokenSymbolicLink: this.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; /***/ }), @@ -74137,24 +74137,24 @@ exports.default = Settings; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(349); -exports.FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - stat: fs.stat, - lstatSync: fs.lstatSync, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -function createFileSystemAdapter(fsMethods) { - if (!fsMethods) { - return exports.FILE_SYSTEM_ADAPTER; - } - return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); -} -exports.createFileSystemAdapter = createFileSystemAdapter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(349); +exports.FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + stat: fs.stat, + lstatSync: fs.lstatSync, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +function createFileSystemAdapter(fsMethods) { + if (!fsMethods) { + return exports.FILE_SYSTEM_ADAPTER; + } + return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods); +} +exports.createFileSystemAdapter = createFileSystemAdapter; /***/ }), @@ -74382,30 +74382,30 @@ module.exports = reusify /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -function isFatalError(settings, error) { - if (settings.errorFilter === null) { - return true; - } - return !settings.errorFilter(error); -} -exports.isFatalError = isFatalError; -function isAppliedFilter(filter, value) { - return filter === null || filter(value); -} -exports.isAppliedFilter = isAppliedFilter; -function replacePathSegmentSeparator(filepath, separator) { - return filepath.split(/[\\\/]/).join(separator); -} -exports.replacePathSegmentSeparator = replacePathSegmentSeparator; -function joinPathSegments(a, b, separator) { - if (a === '') { - return b; - } - return a + separator + b; -} -exports.joinPathSegments = joinPathSegments; + +Object.defineProperty(exports, "__esModule", { value: true }); +function isFatalError(settings, error) { + if (settings.errorFilter === null) { + return true; + } + return !settings.errorFilter(error); +} +exports.isFatalError = isFatalError; +function isAppliedFilter(filter, value) { + return filter === null || filter(value); +} +exports.isAppliedFilter = isAppliedFilter; +function replacePathSegmentSeparator(filepath, separator) { + return filepath.split(/[\\\/]/).join(separator); +} +exports.replacePathSegmentSeparator = replacePathSegmentSeparator; +function joinPathSegments(a, b, separator) { + if (a === '') { + return b; + } + return a + separator + b; +} +exports.joinPathSegments = joinPathSegments; /***/ }), @@ -74413,17 +74413,17 @@ exports.joinPathSegments = joinPathSegments; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const common = __webpack_require__(641); -class Reader { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); - } -} -exports.default = Reader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const common = __webpack_require__(641); +class Reader { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator); + } +} +exports.default = Reader; /***/ }), @@ -74431,36 +74431,36 @@ exports.default = Reader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(382); -const async_1 = __webpack_require__(629); -class StreamProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new async_1.default(this._root, this._settings); - this._stream = new stream_1.Readable({ - objectMode: true, - read: () => { }, - destroy: this._reader.destroy.bind(this._reader) - }); - } - read() { - this._reader.onError((error) => { - this._stream.emit('error', error); - }); - this._reader.onEntry((entry) => { - this._stream.push(entry); - }); - this._reader.onEnd(() => { - this._stream.push(null); - }); - this._reader.read(); - return this._stream; - } -} -exports.default = StreamProvider; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(382); +const async_1 = __webpack_require__(629); +class StreamProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new async_1.default(this._root, this._settings); + this._stream = new stream_1.Readable({ + objectMode: true, + read: () => { }, + destroy: this._reader.destroy.bind(this._reader) + }); + } + read() { + this._reader.onError((error) => { + this._stream.emit('error', error); + }); + this._reader.onEntry((entry) => { + this._stream.push(entry); + }); + this._reader.onEnd(() => { + this._stream.push(null); + }); + this._reader.read(); + return this._stream; + } +} +exports.default = StreamProvider; /***/ }), @@ -74468,20 +74468,20 @@ exports.default = StreamProvider; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = __webpack_require__(645); -class SyncProvider { - constructor(_root, _settings) { - this._root = _root; - this._settings = _settings; - this._reader = new sync_1.default(this._root, this._settings); - } - read() { - return this._reader.read(); - } -} -exports.default = SyncProvider; + +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = __webpack_require__(645); +class SyncProvider { + constructor(_root, _settings) { + this._root = _root; + this._settings = _settings; + this._reader = new sync_1.default(this._root, this._settings); + } + read() { + return this._reader.read(); + } +} +exports.default = SyncProvider; /***/ }), @@ -74489,65 +74489,65 @@ exports.default = SyncProvider; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsScandir = __webpack_require__(630); -const common = __webpack_require__(641); -const reader_1 = __webpack_require__(642); -class SyncReader extends reader_1.default { - constructor() { - super(...arguments); - this._scandir = fsScandir.scandirSync; - this._storage = new Set(); - this._queue = new Set(); - } - read() { - this._pushToQueue(this._root, this._settings.basePath); - this._handleQueue(); - return Array.from(this._storage); - } - _pushToQueue(dir, base) { - this._queue.add({ dir, base }); - } - _handleQueue() { - for (const item of this._queue.values()) { - this._handleDirectory(item.dir, item.base); - } - } - _handleDirectory(dir, base) { - try { - const entries = this._scandir(dir, this._settings.fsScandirSettings); - for (const entry of entries) { - this._handleEntry(entry, base); - } - } - catch (error) { - this._handleError(error); - } - } - _handleError(error) { - if (!common.isFatalError(this._settings, error)) { - return; - } - throw error; - } - _handleEntry(entry, base) { - const fullpath = entry.path; - if (base !== undefined) { - entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); - } - if (common.isAppliedFilter(this._settings.entryFilter, entry)) { - this._pushToStorage(entry); - } - if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { - this._pushToQueue(fullpath, entry.path); - } - } - _pushToStorage(entry) { - this._storage.add(entry); - } -} -exports.default = SyncReader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsScandir = __webpack_require__(630); +const common = __webpack_require__(641); +const reader_1 = __webpack_require__(642); +class SyncReader extends reader_1.default { + constructor() { + super(...arguments); + this._scandir = fsScandir.scandirSync; + this._storage = new Set(); + this._queue = new Set(); + } + read() { + this._pushToQueue(this._root, this._settings.basePath); + this._handleQueue(); + return Array.from(this._storage); + } + _pushToQueue(dir, base) { + this._queue.add({ dir, base }); + } + _handleQueue() { + for (const item of this._queue.values()) { + this._handleDirectory(item.dir, item.base); + } + } + _handleDirectory(dir, base) { + try { + const entries = this._scandir(dir, this._settings.fsScandirSettings); + for (const entry of entries) { + this._handleEntry(entry, base); + } + } + catch (error) { + this._handleError(error); + } + } + _handleError(error) { + if (!common.isFatalError(this._settings, error)) { + return; + } + throw error; + } + _handleEntry(entry, base) { + const fullpath = entry.path; + if (base !== undefined) { + entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator); + } + if (common.isAppliedFilter(this._settings.entryFilter, entry)) { + this._pushToStorage(entry); + } + if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) { + this._pushToQueue(fullpath, entry.path); + } + } + _pushToStorage(entry) { + this._storage.add(entry); + } +} +exports.default = SyncReader; /***/ }), @@ -74555,32 +74555,32 @@ exports.default = SyncReader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const fsScandir = __webpack_require__(630); -class Settings { - constructor(_options = {}) { - this._options = _options; - this.basePath = this._getValue(this._options.basePath, undefined); - this.concurrency = this._getValue(this._options.concurrency, Infinity); - this.deepFilter = this._getValue(this._options.deepFilter, null); - this.entryFilter = this._getValue(this._options.entryFilter, null); - this.errorFilter = this._getValue(this._options.errorFilter, null); - this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); - this.fsScandirSettings = new fsScandir.Settings({ - followSymbolicLinks: this._options.followSymbolicLinks, - fs: this._options.fs, - pathSegmentSeparator: this._options.pathSegmentSeparator, - stats: this._options.stats, - throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink - }); - } - _getValue(option, value) { - return option === undefined ? value : option; - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const fsScandir = __webpack_require__(630); +class Settings { + constructor(_options = {}) { + this._options = _options; + this.basePath = this._getValue(this._options.basePath, undefined); + this.concurrency = this._getValue(this._options.concurrency, Infinity); + this.deepFilter = this._getValue(this._options.deepFilter, null); + this.entryFilter = this._getValue(this._options.entryFilter, null); + this.errorFilter = this._getValue(this._options.errorFilter, null); + this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path.sep); + this.fsScandirSettings = new fsScandir.Settings({ + followSymbolicLinks: this._options.followSymbolicLinks, + fs: this._options.fs, + pathSegmentSeparator: this._options.pathSegmentSeparator, + stats: this._options.stats, + throwErrorOnBrokenSymbolicLink: this._options.throwErrorOnBrokenSymbolicLink + }); + } + _getValue(option, value) { + return option === undefined ? value : option; + } +} +exports.default = Settings; /***/ }), @@ -74588,39 +74588,39 @@ exports.default = Settings; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const fsStat = __webpack_require__(622); -const utils = __webpack_require__(593); -class Reader { - constructor(_settings) { - this._settings = _settings; - this._fsStatSettings = new fsStat.Settings({ - followSymbolicLink: this._settings.followSymbolicLinks, - fs: this._settings.fs, - throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks - }); - } - _getFullEntryPath(filepath) { - return path.resolve(this._settings.cwd, filepath); - } - _makeEntry(stats, pattern) { - const entry = { - name: pattern, - path: pattern, - dirent: utils.fs.createDirentFromStats(pattern, stats) - }; - if (this._settings.stats) { - entry.stats = stats; - } - return entry; - } - _isFatalError(error) { - return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors; - } -} -exports.default = Reader; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const fsStat = __webpack_require__(622); +const utils = __webpack_require__(593); +class Reader { + constructor(_settings) { + this._settings = _settings; + this._fsStatSettings = new fsStat.Settings({ + followSymbolicLink: this._settings.followSymbolicLinks, + fs: this._settings.fs, + throwErrorOnBrokenSymbolicLink: this._settings.followSymbolicLinks + }); + } + _getFullEntryPath(filepath) { + return path.resolve(this._settings.cwd, filepath); + } + _makeEntry(stats, pattern) { + const entry = { + name: pattern, + path: pattern, + dirent: utils.fs.createDirentFromStats(pattern, stats) + }; + if (this._settings.stats) { + entry.stats = stats; + } + return entry; + } + _isFatalError(error) { + return !utils.errno.isEnoentCodeError(error) && !this._settings.suppressErrors; + } +} +exports.default = Reader; /***/ }), @@ -74628,54 +74628,54 @@ exports.default = Reader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const path = __webpack_require__(4); -const deep_1 = __webpack_require__(649); -const entry_1 = __webpack_require__(650); -const error_1 = __webpack_require__(651); -const entry_2 = __webpack_require__(652); -class Provider { - constructor(_settings) { - this._settings = _settings; - this.errorFilter = new error_1.default(this._settings); - this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions()); - this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions()); - this.entryTransformer = new entry_2.default(this._settings); - } - _getRootDirectory(task) { - return path.resolve(this._settings.cwd, task.base); - } - _getReaderOptions(task) { - const basePath = task.base === '.' ? '' : task.base; - return { - basePath, - pathSegmentSeparator: '/', - concurrency: this._settings.concurrency, - deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative), - entryFilter: this.entryFilter.getFilter(task.positive, task.negative), - errorFilter: this.errorFilter.getFilter(), - followSymbolicLinks: this._settings.followSymbolicLinks, - fs: this._settings.fs, - stats: this._settings.stats, - throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink, - transform: this.entryTransformer.getTransformer() - }; - } - _getMicromatchOptions() { - return { - dot: this._settings.dot, - matchBase: this._settings.baseNameMatch, - nobrace: !this._settings.braceExpansion, - nocase: !this._settings.caseSensitiveMatch, - noext: !this._settings.extglob, - noglobstar: !this._settings.globstar, - posix: true, - strictSlashes: false - }; - } -} -exports.default = Provider; + +Object.defineProperty(exports, "__esModule", { value: true }); +const path = __webpack_require__(4); +const deep_1 = __webpack_require__(649); +const entry_1 = __webpack_require__(650); +const error_1 = __webpack_require__(651); +const entry_2 = __webpack_require__(652); +class Provider { + constructor(_settings) { + this._settings = _settings; + this.errorFilter = new error_1.default(this._settings); + this.entryFilter = new entry_1.default(this._settings, this._getMicromatchOptions()); + this.deepFilter = new deep_1.default(this._settings, this._getMicromatchOptions()); + this.entryTransformer = new entry_2.default(this._settings); + } + _getRootDirectory(task) { + return path.resolve(this._settings.cwd, task.base); + } + _getReaderOptions(task) { + const basePath = task.base === '.' ? '' : task.base; + return { + basePath, + pathSegmentSeparator: '/', + concurrency: this._settings.concurrency, + deepFilter: this.deepFilter.getFilter(basePath, task.positive, task.negative), + entryFilter: this.entryFilter.getFilter(task.positive, task.negative), + errorFilter: this.errorFilter.getFilter(), + followSymbolicLinks: this._settings.followSymbolicLinks, + fs: this._settings.fs, + stats: this._settings.stats, + throwErrorOnBrokenSymbolicLink: this._settings.throwErrorOnBrokenSymbolicLink, + transform: this.entryTransformer.getTransformer() + }; + } + _getMicromatchOptions() { + return { + dot: this._settings.dot, + matchBase: this._settings.baseNameMatch, + nobrace: !this._settings.braceExpansion, + nocase: !this._settings.caseSensitiveMatch, + noext: !this._settings.extglob, + noglobstar: !this._settings.globstar, + posix: true, + strictSlashes: false + }; + } +} +exports.default = Provider; /***/ }), @@ -74683,65 +74683,65 @@ exports.default = Provider; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class DeepFilter { - constructor(_settings, _micromatchOptions) { - this._settings = _settings; - this._micromatchOptions = _micromatchOptions; - } - getFilter(basePath, positive, negative) { - const maxPatternDepth = this._getMaxPatternDepth(positive); - const negativeRe = this._getNegativePatternsRe(negative); - return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth); - } - _getMaxPatternDepth(patterns) { - const globstar = patterns.some(utils.pattern.hasGlobStar); - return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns); - } - _getNegativePatternsRe(patterns) { - const affectDepthOfReadingPatterns = patterns.filter(utils.pattern.isAffectDepthOfReadingPattern); - return utils.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions); - } - _filter(basePath, entry, negativeRe, maxPatternDepth) { - const depth = this._getEntryDepth(basePath, entry.path); - if (this._isSkippedByDeep(depth)) { - return false; - } - if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) { - return false; - } - if (this._isSkippedSymbolicLink(entry)) { - return false; - } - if (this._isSkippedDotDirectory(entry)) { - return false; - } - return this._isSkippedByNegativePatterns(entry, negativeRe); - } - _getEntryDepth(basePath, entryPath) { - const basePathDepth = basePath.split('/').length; - const entryPathDepth = entryPath.split('/').length; - return entryPathDepth - (basePath === '' ? 0 : basePathDepth); - } - _isSkippedByDeep(entryDepth) { - return entryDepth >= this._settings.deep; - } - _isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) { - return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth; - } - _isSkippedSymbolicLink(entry) { - return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink(); - } - _isSkippedDotDirectory(entry) { - return !this._settings.dot && entry.name.startsWith('.'); - } - _isSkippedByNegativePatterns(entry, negativeRe) { - return !utils.pattern.matchAny(entry.path, negativeRe); - } -} -exports.default = DeepFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class DeepFilter { + constructor(_settings, _micromatchOptions) { + this._settings = _settings; + this._micromatchOptions = _micromatchOptions; + } + getFilter(basePath, positive, negative) { + const maxPatternDepth = this._getMaxPatternDepth(positive); + const negativeRe = this._getNegativePatternsRe(negative); + return (entry) => this._filter(basePath, entry, negativeRe, maxPatternDepth); + } + _getMaxPatternDepth(patterns) { + const globstar = patterns.some(utils.pattern.hasGlobStar); + return globstar ? Infinity : utils.pattern.getMaxNaivePatternsDepth(patterns); + } + _getNegativePatternsRe(patterns) { + const affectDepthOfReadingPatterns = patterns.filter(utils.pattern.isAffectDepthOfReadingPattern); + return utils.pattern.convertPatternsToRe(affectDepthOfReadingPatterns, this._micromatchOptions); + } + _filter(basePath, entry, negativeRe, maxPatternDepth) { + const depth = this._getEntryDepth(basePath, entry.path); + if (this._isSkippedByDeep(depth)) { + return false; + } + if (this._isSkippedByMaxPatternDepth(depth, maxPatternDepth)) { + return false; + } + if (this._isSkippedSymbolicLink(entry)) { + return false; + } + if (this._isSkippedDotDirectory(entry)) { + return false; + } + return this._isSkippedByNegativePatterns(entry, negativeRe); + } + _getEntryDepth(basePath, entryPath) { + const basePathDepth = basePath.split('/').length; + const entryPathDepth = entryPath.split('/').length; + return entryPathDepth - (basePath === '' ? 0 : basePathDepth); + } + _isSkippedByDeep(entryDepth) { + return entryDepth >= this._settings.deep; + } + _isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth) { + return !this._settings.baseNameMatch && maxPatternDepth !== Infinity && entryDepth > maxPatternDepth; + } + _isSkippedSymbolicLink(entry) { + return !this._settings.followSymbolicLinks && entry.dirent.isSymbolicLink(); + } + _isSkippedDotDirectory(entry) { + return !this._settings.dot && entry.name.startsWith('.'); + } + _isSkippedByNegativePatterns(entry, negativeRe) { + return !utils.pattern.matchAny(entry.path, negativeRe); + } +} +exports.default = DeepFilter; /***/ }), @@ -74749,60 +74749,60 @@ exports.default = DeepFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class EntryFilter { - constructor(_settings, _micromatchOptions) { - this._settings = _settings; - this._micromatchOptions = _micromatchOptions; - this.index = new Map(); - } - getFilter(positive, negative) { - const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions); - const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions); - return (entry) => this._filter(entry, positiveRe, negativeRe); - } - _filter(entry, positiveRe, negativeRe) { - if (this._settings.unique) { - if (this._isDuplicateEntry(entry)) { - return false; - } - this._createIndexRecord(entry); - } - if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) { - return false; - } - if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { - return false; - } - const filepath = this._settings.baseNameMatch ? entry.name : entry.path; - return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe); - } - _isDuplicateEntry(entry) { - return this.index.has(entry.path); - } - _createIndexRecord(entry) { - this.index.set(entry.path, undefined); - } - _onlyFileFilter(entry) { - return this._settings.onlyFiles && !entry.dirent.isFile(); - } - _onlyDirectoryFilter(entry) { - return this._settings.onlyDirectories && !entry.dirent.isDirectory(); - } - _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) { - if (!this._settings.absolute) { - return false; - } - const fullpath = utils.path.makeAbsolute(this._settings.cwd, entry.path); - return this._isMatchToPatterns(fullpath, negativeRe); - } - _isMatchToPatterns(filepath, patternsRe) { - return utils.pattern.matchAny(filepath, patternsRe); - } -} -exports.default = EntryFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class EntryFilter { + constructor(_settings, _micromatchOptions) { + this._settings = _settings; + this._micromatchOptions = _micromatchOptions; + this.index = new Map(); + } + getFilter(positive, negative) { + const positiveRe = utils.pattern.convertPatternsToRe(positive, this._micromatchOptions); + const negativeRe = utils.pattern.convertPatternsToRe(negative, this._micromatchOptions); + return (entry) => this._filter(entry, positiveRe, negativeRe); + } + _filter(entry, positiveRe, negativeRe) { + if (this._settings.unique) { + if (this._isDuplicateEntry(entry)) { + return false; + } + this._createIndexRecord(entry); + } + if (this._onlyFileFilter(entry) || this._onlyDirectoryFilter(entry)) { + return false; + } + if (this._isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { + return false; + } + const filepath = this._settings.baseNameMatch ? entry.name : entry.path; + return this._isMatchToPatterns(filepath, positiveRe) && !this._isMatchToPatterns(entry.path, negativeRe); + } + _isDuplicateEntry(entry) { + return this.index.has(entry.path); + } + _createIndexRecord(entry) { + this.index.set(entry.path, undefined); + } + _onlyFileFilter(entry) { + return this._settings.onlyFiles && !entry.dirent.isFile(); + } + _onlyDirectoryFilter(entry) { + return this._settings.onlyDirectories && !entry.dirent.isDirectory(); + } + _isSkippedByAbsoluteNegativePatterns(entry, negativeRe) { + if (!this._settings.absolute) { + return false; + } + const fullpath = utils.path.makeAbsolute(this._settings.cwd, entry.path); + return this._isMatchToPatterns(fullpath, negativeRe); + } + _isMatchToPatterns(filepath, patternsRe) { + return utils.pattern.matchAny(filepath, patternsRe); + } +} +exports.default = EntryFilter; /***/ }), @@ -74810,21 +74810,21 @@ exports.default = EntryFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class ErrorFilter { - constructor(_settings) { - this._settings = _settings; - } - getFilter() { - return (error) => this._isNonFatalError(error); - } - _isNonFatalError(error) { - return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors; - } -} -exports.default = ErrorFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class ErrorFilter { + constructor(_settings) { + this._settings = _settings; + } + getFilter() { + return (error) => this._isNonFatalError(error); + } + _isNonFatalError(error) { + return utils.errno.isEnoentCodeError(error) || this._settings.suppressErrors; + } +} +exports.default = ErrorFilter; /***/ }), @@ -74832,32 +74832,32 @@ exports.default = ErrorFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __webpack_require__(593); -class EntryTransformer { - constructor(_settings) { - this._settings = _settings; - } - getTransformer() { - return (entry) => this._transform(entry); - } - _transform(entry) { - let filepath = entry.path; - if (this._settings.absolute) { - filepath = utils.path.makeAbsolute(this._settings.cwd, filepath); - filepath = utils.path.unixify(filepath); - } - if (this._settings.markDirectories && entry.dirent.isDirectory()) { - filepath += '/'; - } - if (!this._settings.objectMode) { - return filepath; - } - return Object.assign({}, entry, { path: filepath }); - } -} -exports.default = EntryTransformer; + +Object.defineProperty(exports, "__esModule", { value: true }); +const utils = __webpack_require__(593); +class EntryTransformer { + constructor(_settings) { + this._settings = _settings; + } + getTransformer() { + return (entry) => this._transform(entry); + } + _transform(entry) { + let filepath = entry.path; + if (this._settings.absolute) { + filepath = utils.path.makeAbsolute(this._settings.cwd, filepath); + filepath = utils.path.unixify(filepath); + } + if (this._settings.markDirectories && entry.dirent.isDirectory()) { + filepath += '/'; + } + if (!this._settings.objectMode) { + return filepath; + } + return Object.assign({}, entry, { path: filepath }); + } +} +exports.default = EntryTransformer; /***/ }), @@ -74865,35 +74865,35 @@ exports.default = EntryTransformer; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const stream_1 = __webpack_require__(382); -const stream_2 = __webpack_require__(621); -const provider_1 = __webpack_require__(648); -class ProviderStream extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new stream_2.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const source = this.api(root, task, options); - const dest = new stream_1.Readable({ objectMode: true, read: () => { } }); - source - .once('error', (error) => dest.emit('error', error)) - .on('data', (entry) => dest.emit('data', options.transform(entry))) - .once('end', () => dest.emit('end')); - return dest; - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderStream; + +Object.defineProperty(exports, "__esModule", { value: true }); +const stream_1 = __webpack_require__(382); +const stream_2 = __webpack_require__(621); +const provider_1 = __webpack_require__(648); +class ProviderStream extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new stream_2.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const source = this.api(root, task, options); + const dest = new stream_1.Readable({ objectMode: true, read: () => { } }); + source + .once('error', (error) => dest.emit('error', error)) + .on('data', (entry) => dest.emit('data', options.transform(entry))) + .once('end', () => dest.emit('end')); + return dest; + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderStream; /***/ }), @@ -74901,29 +74901,29 @@ exports.default = ProviderStream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const sync_1 = __webpack_require__(655); -const provider_1 = __webpack_require__(648); -class ProviderSync extends provider_1.default { - constructor() { - super(...arguments); - this._reader = new sync_1.default(this._settings); - } - read(task) { - const root = this._getRootDirectory(task); - const options = this._getReaderOptions(task); - const entries = this.api(root, task, options); - return entries.map(options.transform); - } - api(root, task, options) { - if (task.dynamic) { - return this._reader.dynamic(root, options); - } - return this._reader.static(task.patterns, options); - } -} -exports.default = ProviderSync; + +Object.defineProperty(exports, "__esModule", { value: true }); +const sync_1 = __webpack_require__(655); +const provider_1 = __webpack_require__(648); +class ProviderSync extends provider_1.default { + constructor() { + super(...arguments); + this._reader = new sync_1.default(this._settings); + } + read(task) { + const root = this._getRootDirectory(task); + const options = this._getReaderOptions(task); + const entries = this.api(root, task, options); + return entries.map(options.transform); + } + api(root, task, options) { + if (task.dynamic) { + return this._reader.dynamic(root, options); + } + return this._reader.static(task.patterns, options); + } +} +exports.default = ProviderSync; /***/ }), @@ -74931,49 +74931,49 @@ exports.default = ProviderSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fsStat = __webpack_require__(622); -const fsWalk = __webpack_require__(627); -const reader_1 = __webpack_require__(647); -class ReaderSync extends reader_1.default { - constructor() { - super(...arguments); - this._walkSync = fsWalk.walkSync; - this._statSync = fsStat.statSync; - } - dynamic(root, options) { - return this._walkSync(root, options); - } - static(patterns, options) { - const entries = []; - for (const pattern of patterns) { - const filepath = this._getFullEntryPath(pattern); - const entry = this._getEntry(filepath, pattern, options); - if (entry === null || !options.entryFilter(entry)) { - continue; - } - entries.push(entry); - } - return entries; - } - _getEntry(filepath, pattern, options) { - try { - const stats = this._getStat(filepath); - return this._makeEntry(stats, pattern); - } - catch (error) { - if (options.errorFilter(error)) { - return null; - } - throw error; - } - } - _getStat(filepath) { - return this._statSync(filepath, this._fsStatSettings); - } -} -exports.default = ReaderSync; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fsStat = __webpack_require__(622); +const fsWalk = __webpack_require__(627); +const reader_1 = __webpack_require__(647); +class ReaderSync extends reader_1.default { + constructor() { + super(...arguments); + this._walkSync = fsWalk.walkSync; + this._statSync = fsStat.statSync; + } + dynamic(root, options) { + return this._walkSync(root, options); + } + static(patterns, options) { + const entries = []; + for (const pattern of patterns) { + const filepath = this._getFullEntryPath(pattern); + const entry = this._getEntry(filepath, pattern, options); + if (entry === null || !options.entryFilter(entry)) { + continue; + } + entries.push(entry); + } + return entries; + } + _getEntry(filepath, pattern, options) { + try { + const stats = this._getStat(filepath); + return this._makeEntry(stats, pattern); + } + catch (error) { + if (options.errorFilter(error)) { + return null; + } + throw error; + } + } + _getStat(filepath) { + return this._statSync(filepath, this._fsStatSettings); + } +} +exports.default = ReaderSync; /***/ }), @@ -74981,59 +74981,59 @@ exports.default = ReaderSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(349); -const os = __webpack_require__(364); -const CPU_COUNT = os.cpus().length; -exports.DEFAULT_FILE_SYSTEM_ADAPTER = { - lstat: fs.lstat, - lstatSync: fs.lstatSync, - stat: fs.stat, - statSync: fs.statSync, - readdir: fs.readdir, - readdirSync: fs.readdirSync -}; -// tslint:enable no-redundant-jsdoc -class Settings { - constructor(_options = {}) { - this._options = _options; - this.absolute = this._getValue(this._options.absolute, false); - this.baseNameMatch = this._getValue(this._options.baseNameMatch, false); - this.braceExpansion = this._getValue(this._options.braceExpansion, true); - this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true); - this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT); - this.cwd = this._getValue(this._options.cwd, process.cwd()); - this.deep = this._getValue(this._options.deep, Infinity); - this.dot = this._getValue(this._options.dot, false); - this.extglob = this._getValue(this._options.extglob, true); - this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true); - this.fs = this._getFileSystemMethods(this._options.fs); - this.globstar = this._getValue(this._options.globstar, true); - this.ignore = this._getValue(this._options.ignore, []); - this.markDirectories = this._getValue(this._options.markDirectories, false); - this.objectMode = this._getValue(this._options.objectMode, false); - this.onlyDirectories = this._getValue(this._options.onlyDirectories, false); - this.onlyFiles = this._getValue(this._options.onlyFiles, true); - this.stats = this._getValue(this._options.stats, false); - this.suppressErrors = this._getValue(this._options.suppressErrors, false); - this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false); - this.unique = this._getValue(this._options.unique, true); - if (this.onlyDirectories) { - this.onlyFiles = false; - } - if (this.stats) { - this.objectMode = true; - } - } - _getValue(option, value) { - return option === undefined ? value : option; - } - _getFileSystemMethods(methods = {}) { - return Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER, methods); - } -} -exports.default = Settings; + +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = __webpack_require__(349); +const os = __webpack_require__(364); +const CPU_COUNT = os.cpus().length; +exports.DEFAULT_FILE_SYSTEM_ADAPTER = { + lstat: fs.lstat, + lstatSync: fs.lstatSync, + stat: fs.stat, + statSync: fs.statSync, + readdir: fs.readdir, + readdirSync: fs.readdirSync +}; +// tslint:enable no-redundant-jsdoc +class Settings { + constructor(_options = {}) { + this._options = _options; + this.absolute = this._getValue(this._options.absolute, false); + this.baseNameMatch = this._getValue(this._options.baseNameMatch, false); + this.braceExpansion = this._getValue(this._options.braceExpansion, true); + this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true); + this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT); + this.cwd = this._getValue(this._options.cwd, process.cwd()); + this.deep = this._getValue(this._options.deep, Infinity); + this.dot = this._getValue(this._options.dot, false); + this.extglob = this._getValue(this._options.extglob, true); + this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true); + this.fs = this._getFileSystemMethods(this._options.fs); + this.globstar = this._getValue(this._options.globstar, true); + this.ignore = this._getValue(this._options.ignore, []); + this.markDirectories = this._getValue(this._options.markDirectories, false); + this.objectMode = this._getValue(this._options.objectMode, false); + this.onlyDirectories = this._getValue(this._options.onlyDirectories, false); + this.onlyFiles = this._getValue(this._options.onlyFiles, true); + this.stats = this._getValue(this._options.stats, false); + this.suppressErrors = this._getValue(this._options.suppressErrors, false); + this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false); + this.unique = this._getValue(this._options.unique, true); + if (this.onlyDirectories) { + this.onlyFiles = false; + } + if (this.stats) { + this.objectMode = true; + } + } + _getValue(option, value) { + return option === undefined ? value : option; + } + _getFileSystemMethods(methods = {}) { + return Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER, methods); + } +} +exports.default = Settings; /***/ }), @@ -81322,77 +81322,77 @@ module.exports.generateTasks = pkg.generateTasks; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var optionsManager = __webpack_require__(713); -var taskManager = __webpack_require__(714); -var reader_async_1 = __webpack_require__(882); -var reader_stream_1 = __webpack_require__(906); -var reader_sync_1 = __webpack_require__(907); -var arrayUtils = __webpack_require__(909); -var streamUtils = __webpack_require__(910); -/** - * Synchronous API. - */ -function sync(source, opts) { - assertPatternsInput(source); - var works = getWorks(source, reader_sync_1.default, opts); - return arrayUtils.flatten(works); -} -exports.sync = sync; -/** - * Asynchronous API. - */ -function async(source, opts) { - try { - assertPatternsInput(source); - } - catch (error) { - return Promise.reject(error); - } - var works = getWorks(source, reader_async_1.default, opts); - return Promise.all(works).then(arrayUtils.flatten); -} -exports.async = async; -/** - * Stream API. - */ -function stream(source, opts) { - assertPatternsInput(source); - var works = getWorks(source, reader_stream_1.default, opts); - return streamUtils.merge(works); -} -exports.stream = stream; -/** - * Return a set of tasks based on provided patterns. - */ -function generateTasks(source, opts) { - assertPatternsInput(source); - var patterns = [].concat(source); - var options = optionsManager.prepare(opts); - return taskManager.generate(patterns, options); -} -exports.generateTasks = generateTasks; -/** - * Returns a set of works based on provided tasks and class of the reader. - */ -function getWorks(source, _Reader, opts) { - var patterns = [].concat(source); - var options = optionsManager.prepare(opts); - var tasks = taskManager.generate(patterns, options); - var reader = new _Reader(options); - return tasks.map(reader.read, reader); -} -function assertPatternsInput(source) { - if ([].concat(source).every(isString)) { - return; - } - throw new TypeError('Patterns must be a string or an array of strings'); -} -function isString(source) { - /* tslint:disable-next-line strict-type-predicates */ - return typeof source === 'string'; -} + +Object.defineProperty(exports, "__esModule", { value: true }); +var optionsManager = __webpack_require__(713); +var taskManager = __webpack_require__(714); +var reader_async_1 = __webpack_require__(882); +var reader_stream_1 = __webpack_require__(906); +var reader_sync_1 = __webpack_require__(907); +var arrayUtils = __webpack_require__(909); +var streamUtils = __webpack_require__(910); +/** + * Synchronous API. + */ +function sync(source, opts) { + assertPatternsInput(source); + var works = getWorks(source, reader_sync_1.default, opts); + return arrayUtils.flatten(works); +} +exports.sync = sync; +/** + * Asynchronous API. + */ +function async(source, opts) { + try { + assertPatternsInput(source); + } + catch (error) { + return Promise.reject(error); + } + var works = getWorks(source, reader_async_1.default, opts); + return Promise.all(works).then(arrayUtils.flatten); +} +exports.async = async; +/** + * Stream API. + */ +function stream(source, opts) { + assertPatternsInput(source); + var works = getWorks(source, reader_stream_1.default, opts); + return streamUtils.merge(works); +} +exports.stream = stream; +/** + * Return a set of tasks based on provided patterns. + */ +function generateTasks(source, opts) { + assertPatternsInput(source); + var patterns = [].concat(source); + var options = optionsManager.prepare(opts); + return taskManager.generate(patterns, options); +} +exports.generateTasks = generateTasks; +/** + * Returns a set of works based on provided tasks and class of the reader. + */ +function getWorks(source, _Reader, opts) { + var patterns = [].concat(source); + var options = optionsManager.prepare(opts); + var tasks = taskManager.generate(patterns, options); + var reader = new _Reader(options); + return tasks.map(reader.read, reader); +} +function assertPatternsInput(source) { + if ([].concat(source).every(isString)) { + return; + } + throw new TypeError('Patterns must be a string or an array of strings'); +} +function isString(source) { + /* tslint:disable-next-line strict-type-predicates */ + return typeof source === 'string'; +} /***/ }), @@ -81400,37 +81400,37 @@ function isString(source) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -function prepare(options) { - var opts = __assign({ cwd: process.cwd(), deep: true, ignore: [], dot: false, stats: false, onlyFiles: true, onlyDirectories: false, followSymlinkedDirectories: true, unique: true, markDirectories: false, absolute: false, nobrace: false, brace: true, noglobstar: false, globstar: true, noext: false, extension: true, nocase: false, case: true, matchBase: false, transform: null }, options); - if (opts.onlyDirectories) { - opts.onlyFiles = false; - } - opts.brace = !opts.nobrace; - opts.globstar = !opts.noglobstar; - opts.extension = !opts.noext; - opts.case = !opts.nocase; - if (options) { - opts.brace = ('brace' in options ? options.brace : opts.brace); - opts.globstar = ('globstar' in options ? options.globstar : opts.globstar); - opts.extension = ('extension' in options ? options.extension : opts.extension); - opts.case = ('case' in options ? options.case : opts.case); - } - return opts; -} -exports.prepare = prepare; + +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +function prepare(options) { + var opts = __assign({ cwd: process.cwd(), deep: true, ignore: [], dot: false, stats: false, onlyFiles: true, onlyDirectories: false, followSymlinkedDirectories: true, unique: true, markDirectories: false, absolute: false, nobrace: false, brace: true, noglobstar: false, globstar: true, noext: false, extension: true, nocase: false, case: true, matchBase: false, transform: null }, options); + if (opts.onlyDirectories) { + opts.onlyFiles = false; + } + opts.brace = !opts.nobrace; + opts.globstar = !opts.noglobstar; + opts.extension = !opts.noext; + opts.case = !opts.nocase; + if (options) { + opts.brace = ('brace' in options ? options.brace : opts.brace); + opts.globstar = ('globstar' in options ? options.globstar : opts.globstar); + opts.extension = ('extension' in options ? options.extension : opts.extension); + opts.case = ('case' in options ? options.case : opts.case); + } + return opts; +} +exports.prepare = prepare; /***/ }), @@ -81438,96 +81438,96 @@ exports.prepare = prepare; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var patternUtils = __webpack_require__(715); -/** - * Generate tasks based on parent directory of each pattern. - */ -function generate(patterns, options) { - var unixPatterns = patterns.map(patternUtils.unixifyPattern); - var unixIgnore = options.ignore.map(patternUtils.unixifyPattern); - var positivePatterns = getPositivePatterns(unixPatterns); - var negativePatterns = getNegativePatternsAsPositive(unixPatterns, unixIgnore); - /** - * When the `case` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath - * directly (without read directory). - */ - var staticPatterns = !options.case ? [] : positivePatterns.filter(patternUtils.isStaticPattern); - var dynamicPatterns = !options.case ? positivePatterns : positivePatterns.filter(patternUtils.isDynamicPattern); - var staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); - var dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); - return staticTasks.concat(dynamicTasks); -} -exports.generate = generate; -/** - * Convert patterns to tasks based on parent directory of each pattern. - */ -function convertPatternsToTasks(positive, negative, dynamic) { - var positivePatternsGroup = groupPatternsByBaseDirectory(positive); - // When we have a global group – there is no reason to divide the patterns into independent tasks. - // In this case, the global task covers the rest. - if ('.' in positivePatternsGroup) { - var task = convertPatternGroupToTask('.', positive, negative, dynamic); - return [task]; - } - return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); -} -exports.convertPatternsToTasks = convertPatternsToTasks; -/** - * Return only positive patterns. - */ -function getPositivePatterns(patterns) { - return patternUtils.getPositivePatterns(patterns); -} -exports.getPositivePatterns = getPositivePatterns; -/** - * Return only negative patterns. - */ -function getNegativePatternsAsPositive(patterns, ignore) { - var negative = patternUtils.getNegativePatterns(patterns).concat(ignore); - var positive = negative.map(patternUtils.convertToPositivePattern); - return positive; -} -exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; -/** - * Group patterns by base directory of each pattern. - */ -function groupPatternsByBaseDirectory(patterns) { - return patterns.reduce(function (collection, pattern) { - var base = patternUtils.getBaseDirectory(pattern); - if (base in collection) { - collection[base].push(pattern); - } - else { - collection[base] = [pattern]; - } - return collection; - }, {}); -} -exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; -/** - * Convert group of patterns to tasks. - */ -function convertPatternGroupsToTasks(positive, negative, dynamic) { - return Object.keys(positive).map(function (base) { - return convertPatternGroupToTask(base, positive[base], negative, dynamic); - }); -} -exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; -/** - * Create a task for positive and negative patterns. - */ -function convertPatternGroupToTask(base, positive, negative, dynamic) { - return { - base: base, - dynamic: dynamic, - positive: positive, - negative: negative, - patterns: [].concat(positive, negative.map(patternUtils.convertToNegativePattern)) - }; -} -exports.convertPatternGroupToTask = convertPatternGroupToTask; + +Object.defineProperty(exports, "__esModule", { value: true }); +var patternUtils = __webpack_require__(715); +/** + * Generate tasks based on parent directory of each pattern. + */ +function generate(patterns, options) { + var unixPatterns = patterns.map(patternUtils.unixifyPattern); + var unixIgnore = options.ignore.map(patternUtils.unixifyPattern); + var positivePatterns = getPositivePatterns(unixPatterns); + var negativePatterns = getNegativePatternsAsPositive(unixPatterns, unixIgnore); + /** + * When the `case` option is disabled, all patterns must be marked as dynamic, because we cannot check filepath + * directly (without read directory). + */ + var staticPatterns = !options.case ? [] : positivePatterns.filter(patternUtils.isStaticPattern); + var dynamicPatterns = !options.case ? positivePatterns : positivePatterns.filter(patternUtils.isDynamicPattern); + var staticTasks = convertPatternsToTasks(staticPatterns, negativePatterns, /* dynamic */ false); + var dynamicTasks = convertPatternsToTasks(dynamicPatterns, negativePatterns, /* dynamic */ true); + return staticTasks.concat(dynamicTasks); +} +exports.generate = generate; +/** + * Convert patterns to tasks based on parent directory of each pattern. + */ +function convertPatternsToTasks(positive, negative, dynamic) { + var positivePatternsGroup = groupPatternsByBaseDirectory(positive); + // When we have a global group – there is no reason to divide the patterns into independent tasks. + // In this case, the global task covers the rest. + if ('.' in positivePatternsGroup) { + var task = convertPatternGroupToTask('.', positive, negative, dynamic); + return [task]; + } + return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); +} +exports.convertPatternsToTasks = convertPatternsToTasks; +/** + * Return only positive patterns. + */ +function getPositivePatterns(patterns) { + return patternUtils.getPositivePatterns(patterns); +} +exports.getPositivePatterns = getPositivePatterns; +/** + * Return only negative patterns. + */ +function getNegativePatternsAsPositive(patterns, ignore) { + var negative = patternUtils.getNegativePatterns(patterns).concat(ignore); + var positive = negative.map(patternUtils.convertToPositivePattern); + return positive; +} +exports.getNegativePatternsAsPositive = getNegativePatternsAsPositive; +/** + * Group patterns by base directory of each pattern. + */ +function groupPatternsByBaseDirectory(patterns) { + return patterns.reduce(function (collection, pattern) { + var base = patternUtils.getBaseDirectory(pattern); + if (base in collection) { + collection[base].push(pattern); + } + else { + collection[base] = [pattern]; + } + return collection; + }, {}); +} +exports.groupPatternsByBaseDirectory = groupPatternsByBaseDirectory; +/** + * Convert group of patterns to tasks. + */ +function convertPatternGroupsToTasks(positive, negative, dynamic) { + return Object.keys(positive).map(function (base) { + return convertPatternGroupToTask(base, positive[base], negative, dynamic); + }); +} +exports.convertPatternGroupsToTasks = convertPatternGroupsToTasks; +/** + * Create a task for positive and negative patterns. + */ +function convertPatternGroupToTask(base, positive, negative, dynamic) { + return { + base: base, + dynamic: dynamic, + positive: positive, + negative: negative, + patterns: [].concat(positive, negative.map(patternUtils.convertToNegativePattern)) + }; +} +exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ }), @@ -81535,154 +81535,154 @@ exports.convertPatternGroupToTask = convertPatternGroupToTask; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -var globParent = __webpack_require__(716); -var isGlob = __webpack_require__(719); -var micromatch = __webpack_require__(720); -var GLOBSTAR = '**'; -/** - * Return true for static pattern. - */ -function isStaticPattern(pattern) { - return !isDynamicPattern(pattern); -} -exports.isStaticPattern = isStaticPattern; -/** - * Return true for pattern that looks like glob. - */ -function isDynamicPattern(pattern) { - return isGlob(pattern, { strict: false }); -} -exports.isDynamicPattern = isDynamicPattern; -/** - * Convert a windows «path» to a unix-style «path». - */ -function unixifyPattern(pattern) { - return pattern.replace(/\\/g, '/'); -} -exports.unixifyPattern = unixifyPattern; -/** - * Returns negative pattern as positive pattern. - */ -function convertToPositivePattern(pattern) { - return isNegativePattern(pattern) ? pattern.slice(1) : pattern; -} -exports.convertToPositivePattern = convertToPositivePattern; -/** - * Returns positive pattern as negative pattern. - */ -function convertToNegativePattern(pattern) { - return '!' + pattern; -} -exports.convertToNegativePattern = convertToNegativePattern; -/** - * Return true if provided pattern is negative pattern. - */ -function isNegativePattern(pattern) { - return pattern.startsWith('!') && pattern[1] !== '('; -} -exports.isNegativePattern = isNegativePattern; -/** - * Return true if provided pattern is positive pattern. - */ -function isPositivePattern(pattern) { - return !isNegativePattern(pattern); -} -exports.isPositivePattern = isPositivePattern; -/** - * Extracts negative patterns from array of patterns. - */ -function getNegativePatterns(patterns) { - return patterns.filter(isNegativePattern); -} -exports.getNegativePatterns = getNegativePatterns; -/** - * Extracts positive patterns from array of patterns. - */ -function getPositivePatterns(patterns) { - return patterns.filter(isPositivePattern); -} -exports.getPositivePatterns = getPositivePatterns; -/** - * Extract base directory from provided pattern. - */ -function getBaseDirectory(pattern) { - return globParent(pattern); -} -exports.getBaseDirectory = getBaseDirectory; -/** - * Return true if provided pattern has globstar. - */ -function hasGlobStar(pattern) { - return pattern.indexOf(GLOBSTAR) !== -1; -} -exports.hasGlobStar = hasGlobStar; -/** - * Return true if provided pattern ends with slash and globstar. - */ -function endsWithSlashGlobStar(pattern) { - return pattern.endsWith('/' + GLOBSTAR); -} -exports.endsWithSlashGlobStar = endsWithSlashGlobStar; -/** - * Returns «true» when pattern ends with a slash and globstar or the last partial of the pattern is static pattern. - */ -function isAffectDepthOfReadingPattern(pattern) { - var basename = path.basename(pattern); - return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); -} -exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; -/** - * Return naive depth of provided pattern without depth of the base directory. - */ -function getNaiveDepth(pattern) { - var base = getBaseDirectory(pattern); - var patternDepth = pattern.split('/').length; - var patternBaseDepth = base.split('/').length; - /** - * This is a hack for pattern that has no base directory. - * - * This is related to the `*\something\*` pattern. - */ - if (base === '.') { - return patternDepth - patternBaseDepth; - } - return patternDepth - patternBaseDepth - 1; -} -exports.getNaiveDepth = getNaiveDepth; -/** - * Return max naive depth of provided patterns without depth of the base directory. - */ -function getMaxNaivePatternsDepth(patterns) { - return patterns.reduce(function (max, pattern) { - var depth = getNaiveDepth(pattern); - return depth > max ? depth : max; - }, 0); -} -exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; -/** - * Make RegExp for provided pattern. - */ -function makeRe(pattern, options) { - return micromatch.makeRe(pattern, options); -} -exports.makeRe = makeRe; -/** - * Convert patterns to regexps. - */ -function convertPatternsToRe(patterns, options) { - return patterns.map(function (pattern) { return makeRe(pattern, options); }); -} -exports.convertPatternsToRe = convertPatternsToRe; -/** - * Returns true if the entry match any of the given RegExp's. - */ -function matchAny(entry, patternsRe) { - return patternsRe.some(function (patternRe) { return patternRe.test(entry); }); -} -exports.matchAny = matchAny; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +var globParent = __webpack_require__(716); +var isGlob = __webpack_require__(719); +var micromatch = __webpack_require__(720); +var GLOBSTAR = '**'; +/** + * Return true for static pattern. + */ +function isStaticPattern(pattern) { + return !isDynamicPattern(pattern); +} +exports.isStaticPattern = isStaticPattern; +/** + * Return true for pattern that looks like glob. + */ +function isDynamicPattern(pattern) { + return isGlob(pattern, { strict: false }); +} +exports.isDynamicPattern = isDynamicPattern; +/** + * Convert a windows «path» to a unix-style «path». + */ +function unixifyPattern(pattern) { + return pattern.replace(/\\/g, '/'); +} +exports.unixifyPattern = unixifyPattern; +/** + * Returns negative pattern as positive pattern. + */ +function convertToPositivePattern(pattern) { + return isNegativePattern(pattern) ? pattern.slice(1) : pattern; +} +exports.convertToPositivePattern = convertToPositivePattern; +/** + * Returns positive pattern as negative pattern. + */ +function convertToNegativePattern(pattern) { + return '!' + pattern; +} +exports.convertToNegativePattern = convertToNegativePattern; +/** + * Return true if provided pattern is negative pattern. + */ +function isNegativePattern(pattern) { + return pattern.startsWith('!') && pattern[1] !== '('; +} +exports.isNegativePattern = isNegativePattern; +/** + * Return true if provided pattern is positive pattern. + */ +function isPositivePattern(pattern) { + return !isNegativePattern(pattern); +} +exports.isPositivePattern = isPositivePattern; +/** + * Extracts negative patterns from array of patterns. + */ +function getNegativePatterns(patterns) { + return patterns.filter(isNegativePattern); +} +exports.getNegativePatterns = getNegativePatterns; +/** + * Extracts positive patterns from array of patterns. + */ +function getPositivePatterns(patterns) { + return patterns.filter(isPositivePattern); +} +exports.getPositivePatterns = getPositivePatterns; +/** + * Extract base directory from provided pattern. + */ +function getBaseDirectory(pattern) { + return globParent(pattern); +} +exports.getBaseDirectory = getBaseDirectory; +/** + * Return true if provided pattern has globstar. + */ +function hasGlobStar(pattern) { + return pattern.indexOf(GLOBSTAR) !== -1; +} +exports.hasGlobStar = hasGlobStar; +/** + * Return true if provided pattern ends with slash and globstar. + */ +function endsWithSlashGlobStar(pattern) { + return pattern.endsWith('/' + GLOBSTAR); +} +exports.endsWithSlashGlobStar = endsWithSlashGlobStar; +/** + * Returns «true» when pattern ends with a slash and globstar or the last partial of the pattern is static pattern. + */ +function isAffectDepthOfReadingPattern(pattern) { + var basename = path.basename(pattern); + return endsWithSlashGlobStar(pattern) || isStaticPattern(basename); +} +exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; +/** + * Return naive depth of provided pattern without depth of the base directory. + */ +function getNaiveDepth(pattern) { + var base = getBaseDirectory(pattern); + var patternDepth = pattern.split('/').length; + var patternBaseDepth = base.split('/').length; + /** + * This is a hack for pattern that has no base directory. + * + * This is related to the `*\something\*` pattern. + */ + if (base === '.') { + return patternDepth - patternBaseDepth; + } + return patternDepth - patternBaseDepth - 1; +} +exports.getNaiveDepth = getNaiveDepth; +/** + * Return max naive depth of provided patterns without depth of the base directory. + */ +function getMaxNaivePatternsDepth(patterns) { + return patterns.reduce(function (max, pattern) { + var depth = getNaiveDepth(pattern); + return depth > max ? depth : max; + }, 0); +} +exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth; +/** + * Make RegExp for provided pattern. + */ +function makeRe(pattern, options) { + return micromatch.makeRe(pattern, options); +} +exports.makeRe = makeRe; +/** + * Convert patterns to regexps. + */ +function convertPatternsToRe(patterns, options) { + return patterns.map(function (pattern) { return makeRe(pattern, options); }); +} +exports.convertPatternsToRe = convertPatternsToRe; +/** + * Returns true if the entry match any of the given RegExp's. + */ +function matchAny(entry, patternsRe) { + return patternsRe.some(function (patternRe) { return patternRe.test(entry); }); +} +exports.matchAny = matchAny; /***/ }), @@ -83474,7 +83474,7 @@ module.exports = function kindOf(val) { if (type === '[object Symbol]') { return 'symbol'; } - + if (type === '[object Map Iterator]') { return 'mapiterator'; } @@ -83487,7 +83487,7 @@ module.exports = function kindOf(val) { if (type === '[object Array Iterator]') { return 'arrayiterator'; } - + // typed arrays if (type === '[object Int8Array]') { return 'int8array'; @@ -89598,169 +89598,169 @@ module.exports.namespace = namespace; /* 769 */ /***/ (function(module, exports, __webpack_require__) { - -/** - * Expose `Emitter`. - */ - -if (true) { - module.exports = Emitter; -} - -/** - * Initialize a new `Emitter`. - * - * @api public - */ - -function Emitter(obj) { - if (obj) return mixin(obj); -}; - -/** - * Mixin the emitter properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - -function mixin(obj) { - for (var key in Emitter.prototype) { - obj[key] = Emitter.prototype[key]; - } - return obj; -} - -/** - * Listen on the given `event` with `fn`. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.on = -Emitter.prototype.addEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - (this._callbacks['$' + event] = this._callbacks['$' + event] || []) - .push(fn); - return this; -}; - -/** - * Adds an `event` listener that will be invoked a single - * time then automatically removed. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.once = function(event, fn){ - function on() { - this.off(event, on); - fn.apply(this, arguments); - } - - on.fn = fn; - this.on(event, on); - return this; -}; - -/** - * Remove the given callback for `event` or all - * registered callbacks. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - -Emitter.prototype.off = -Emitter.prototype.removeListener = -Emitter.prototype.removeAllListeners = -Emitter.prototype.removeEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - - // all - if (0 == arguments.length) { - this._callbacks = {}; - return this; - } - - // specific event - var callbacks = this._callbacks['$' + event]; - if (!callbacks) return this; - - // remove all handlers - if (1 == arguments.length) { - delete this._callbacks['$' + event]; - return this; - } - - // remove specific handler - var cb; - for (var i = 0; i < callbacks.length; i++) { - cb = callbacks[i]; - if (cb === fn || cb.fn === fn) { - callbacks.splice(i, 1); - break; - } - } - return this; -}; - -/** - * Emit `event` with the given args. - * - * @param {String} event - * @param {Mixed} ... - * @return {Emitter} - */ - -Emitter.prototype.emit = function(event){ - this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) - , callbacks = this._callbacks['$' + event]; - - if (callbacks) { - callbacks = callbacks.slice(0); - for (var i = 0, len = callbacks.length; i < len; ++i) { - callbacks[i].apply(this, args); - } - } - - return this; -}; - -/** - * Return array of callbacks for `event`. - * - * @param {String} event - * @return {Array} - * @api public - */ - -Emitter.prototype.listeners = function(event){ - this._callbacks = this._callbacks || {}; - return this._callbacks['$' + event] || []; -}; - -/** - * Check if this emitter has `event` handlers. - * - * @param {String} event - * @return {Boolean} - * @api public - */ - -Emitter.prototype.hasListeners = function(event){ - return !! this.listeners(event).length; -}; + +/** + * Expose `Emitter`. + */ + +if (true) { + module.exports = Emitter; +} + +/** + * Initialize a new `Emitter`. + * + * @api public + */ + +function Emitter(obj) { + if (obj) return mixin(obj); +}; + +/** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + +function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; + } + return obj; +} + +/** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.on = +Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks['$' + event] = this._callbacks['$' + event] || []) + .push(fn); + return this; +}; + +/** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.once = function(event, fn){ + function on() { + this.off(event, on); + fn.apply(this, arguments); + } + + on.fn = fn; + this.on(event, on); + return this; +}; + +/** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + +Emitter.prototype.off = +Emitter.prototype.removeListener = +Emitter.prototype.removeAllListeners = +Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } + + // specific event + var callbacks = this._callbacks['$' + event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks['$' + event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; + } + } + return this; +}; + +/** + * Emit `event` with the given args. + * + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} + */ + +Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; + var args = [].slice.call(arguments, 1) + , callbacks = this._callbacks['$' + event]; + + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); + } + } + + return this; +}; + +/** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ + +Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks['$' + event] || []; +}; + +/** + * Check if this emitter has `event` handlers. + * + * @param {String} event + * @return {Boolean} + * @api public + */ + +Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; +}; /***/ }), @@ -91173,7 +91173,7 @@ module.exports = function kindOf(val) { if (type === '[object Symbol]') { return 'symbol'; } - + if (type === '[object Map Iterator]') { return 'mapiterator'; } @@ -91186,7 +91186,7 @@ module.exports = function kindOf(val) { if (type === '[object Array Iterator]') { return 'arrayiterator'; } - + // typed arrays if (type === '[object Int8Array]') { return 'int8array'; @@ -96755,23 +96755,23 @@ module.exports = function (encodedURI) { /* 828 */ /***/ (function(module, exports, __webpack_require__) { -// Copyright 2014 Simon Lydell -// X11 (“MIT”) Licensed. (See LICENSE.) - -var path = __webpack_require__(4) - -"use strict" - -function urix(aPath) { - if (path.sep === "\\") { - return aPath - .replace(/\\/g, "/") - .replace(/^[a-z]:\/?/i, "/") - } - return aPath -} - -module.exports = urix +// Copyright 2014 Simon Lydell +// X11 (“MIT”) Licensed. (See LICENSE.) + +var path = __webpack_require__(4) + +"use strict" + +function urix(aPath) { + if (path.sep === "\\") { + return aPath + .replace(/\\/g, "/") + .replace(/^[a-z]:\/?/i, "/") + } + return aPath +} + +module.exports = urix /***/ }), @@ -97780,13 +97780,13 @@ var types = parse.types; module.exports = function (re, opts) { if (!opts) opts = {}; var replimit = opts.limit === undefined ? 25 : opts.limit; - + if (isRegExp(re)) re = re.source; else if (typeof re !== 'string') re = String(re); - + try { re = parse(re) } catch (err) { return false } - + var reps = 0; return (function walk (node, starHeight) { if (node.type === types.REPETITION) { @@ -97795,7 +97795,7 @@ module.exports = function (re, opts) { if (starHeight > 1) return false; if (reps > replimit) return false; } - + if (node.options) { for (var i = 0, len = node.options.length; i < len; i++) { var ok = walk({ stack: node.options[i] }, starHeight); @@ -97804,12 +97804,12 @@ module.exports = function (re, opts) { } var stack = node.stack || (node.value && node.value.stack); if (!stack) return true; - + for (var i = 0; i < stack.length; i++) { var ok = walk(stack[i], starHeight); if (!ok) return false; } - + return true; })(re, 0); }; @@ -104226,81 +104226,81 @@ function isBuffer(val) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(883); -var reader_1 = __webpack_require__(896); -var fs_stream_1 = __webpack_require__(900); -var ReaderAsync = /** @class */ (function (_super) { - __extends(ReaderAsync, _super); - function ReaderAsync() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(ReaderAsync.prototype, "fsAdapter", { - /** - * Returns FileSystem adapter. - */ - get: function () { - return new fs_stream_1.default(this.options); - }, - enumerable: true, - configurable: true - }); - /** - * Use async API to read entries for Task. - */ - ReaderAsync.prototype.read = function (task) { - var _this = this; - var root = this.getRootDirectory(task); - var options = this.getReaderOptions(task); - var entries = []; - return new Promise(function (resolve, reject) { - var stream = _this.api(root, task, options); - stream.on('error', function (err) { - _this.isEnoentCodeError(err) ? resolve([]) : reject(err); - stream.pause(); - }); - stream.on('data', function (entry) { return entries.push(_this.transform(entry)); }); - stream.on('end', function () { return resolve(entries); }); - }); - }; - /** - * Returns founded paths. - */ - ReaderAsync.prototype.api = function (root, task, options) { - if (task.dynamic) { - return this.dynamicApi(root, options); - } - return this.staticApi(task, options); - }; - /** - * Api for dynamic tasks. - */ - ReaderAsync.prototype.dynamicApi = function (root, options) { - return readdir.readdirStreamStat(root, options); - }; - /** - * Api for static tasks. - */ - ReaderAsync.prototype.staticApi = function (task, options) { - return this.fsAdapter.read(task.patterns, options.filter); - }; - return ReaderAsync; -}(reader_1.default)); -exports.default = ReaderAsync; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var readdir = __webpack_require__(883); +var reader_1 = __webpack_require__(896); +var fs_stream_1 = __webpack_require__(900); +var ReaderAsync = /** @class */ (function (_super) { + __extends(ReaderAsync, _super); + function ReaderAsync() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ReaderAsync.prototype, "fsAdapter", { + /** + * Returns FileSystem adapter. + */ + get: function () { + return new fs_stream_1.default(this.options); + }, + enumerable: true, + configurable: true + }); + /** + * Use async API to read entries for Task. + */ + ReaderAsync.prototype.read = function (task) { + var _this = this; + var root = this.getRootDirectory(task); + var options = this.getReaderOptions(task); + var entries = []; + return new Promise(function (resolve, reject) { + var stream = _this.api(root, task, options); + stream.on('error', function (err) { + _this.isEnoentCodeError(err) ? resolve([]) : reject(err); + stream.pause(); + }); + stream.on('data', function (entry) { return entries.push(_this.transform(entry)); }); + stream.on('end', function () { return resolve(entries); }); + }); + }; + /** + * Returns founded paths. + */ + ReaderAsync.prototype.api = function (root, task, options) { + if (task.dynamic) { + return this.dynamicApi(root, options); + } + return this.staticApi(task, options); + }; + /** + * Api for dynamic tasks. + */ + ReaderAsync.prototype.dynamicApi = function (root, options) { + return readdir.readdirStreamStat(root, options); + }; + /** + * Api for static tasks. + */ + ReaderAsync.prototype.staticApi = function (task, options) { + return this.fsAdapter.read(task.patterns, options.filter); + }; + return ReaderAsync; +}(reader_1.default)); +exports.default = ReaderAsync; /***/ }), @@ -105541,74 +105541,74 @@ function readdirStream (dir, options, internalOptions) { /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -var deep_1 = __webpack_require__(897); -var entry_1 = __webpack_require__(899); -var pathUtil = __webpack_require__(898); -var Reader = /** @class */ (function () { - function Reader(options) { - this.options = options; - this.micromatchOptions = this.getMicromatchOptions(); - this.entryFilter = new entry_1.default(options, this.micromatchOptions); - this.deepFilter = new deep_1.default(options, this.micromatchOptions); - } - /** - * Returns root path to scanner. - */ - Reader.prototype.getRootDirectory = function (task) { - return path.resolve(this.options.cwd, task.base); - }; - /** - * Returns options for reader. - */ - Reader.prototype.getReaderOptions = function (task) { - return { - basePath: task.base === '.' ? '' : task.base, - filter: this.entryFilter.getFilter(task.positive, task.negative), - deep: this.deepFilter.getFilter(task.positive, task.negative), - sep: '/' - }; - }; - /** - * Returns options for micromatch. - */ - Reader.prototype.getMicromatchOptions = function () { - return { - dot: this.options.dot, - nobrace: !this.options.brace, - noglobstar: !this.options.globstar, - noext: !this.options.extension, - nocase: !this.options.case, - matchBase: this.options.matchBase - }; - }; - /** - * Returns transformed entry. - */ - Reader.prototype.transform = function (entry) { - if (this.options.absolute) { - entry.path = pathUtil.makeAbsolute(this.options.cwd, entry.path); - } - if (this.options.markDirectories && entry.isDirectory()) { - entry.path += '/'; - } - var item = this.options.stats ? entry : entry.path; - if (this.options.transform === null) { - return item; - } - return this.options.transform(item); - }; - /** - * Returns true if error has ENOENT code. - */ - Reader.prototype.isEnoentCodeError = function (err) { - return err.code === 'ENOENT'; - }; - return Reader; -}()); -exports.default = Reader; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +var deep_1 = __webpack_require__(897); +var entry_1 = __webpack_require__(899); +var pathUtil = __webpack_require__(898); +var Reader = /** @class */ (function () { + function Reader(options) { + this.options = options; + this.micromatchOptions = this.getMicromatchOptions(); + this.entryFilter = new entry_1.default(options, this.micromatchOptions); + this.deepFilter = new deep_1.default(options, this.micromatchOptions); + } + /** + * Returns root path to scanner. + */ + Reader.prototype.getRootDirectory = function (task) { + return path.resolve(this.options.cwd, task.base); + }; + /** + * Returns options for reader. + */ + Reader.prototype.getReaderOptions = function (task) { + return { + basePath: task.base === '.' ? '' : task.base, + filter: this.entryFilter.getFilter(task.positive, task.negative), + deep: this.deepFilter.getFilter(task.positive, task.negative), + sep: '/' + }; + }; + /** + * Returns options for micromatch. + */ + Reader.prototype.getMicromatchOptions = function () { + return { + dot: this.options.dot, + nobrace: !this.options.brace, + noglobstar: !this.options.globstar, + noext: !this.options.extension, + nocase: !this.options.case, + matchBase: this.options.matchBase + }; + }; + /** + * Returns transformed entry. + */ + Reader.prototype.transform = function (entry) { + if (this.options.absolute) { + entry.path = pathUtil.makeAbsolute(this.options.cwd, entry.path); + } + if (this.options.markDirectories && entry.isDirectory()) { + entry.path += '/'; + } + var item = this.options.stats ? entry : entry.path; + if (this.options.transform === null) { + return item; + } + return this.options.transform(item); + }; + /** + * Returns true if error has ENOENT code. + */ + Reader.prototype.isEnoentCodeError = function (err) { + return err.code === 'ENOENT'; + }; + return Reader; +}()); +exports.default = Reader; /***/ }), @@ -105616,89 +105616,89 @@ exports.default = Reader; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(898); -var patternUtils = __webpack_require__(715); -var DeepFilter = /** @class */ (function () { - function DeepFilter(options, micromatchOptions) { - this.options = options; - this.micromatchOptions = micromatchOptions; - } - /** - * Returns filter for directories. - */ - DeepFilter.prototype.getFilter = function (positive, negative) { - var _this = this; - var maxPatternDepth = this.getMaxPatternDepth(positive); - var negativeRe = this.getNegativePatternsRe(negative); - return function (entry) { return _this.filter(entry, negativeRe, maxPatternDepth); }; - }; - /** - * Returns max depth of the provided patterns. - */ - DeepFilter.prototype.getMaxPatternDepth = function (patterns) { - var globstar = patterns.some(patternUtils.hasGlobStar); - return globstar ? Infinity : patternUtils.getMaxNaivePatternsDepth(patterns); - }; - /** - * Returns RegExp's for patterns that can affect the depth of reading. - */ - DeepFilter.prototype.getNegativePatternsRe = function (patterns) { - var affectDepthOfReadingPatterns = patterns.filter(patternUtils.isAffectDepthOfReadingPattern); - return patternUtils.convertPatternsToRe(affectDepthOfReadingPatterns, this.micromatchOptions); - }; - /** - * Returns «true» for directory that should be read. - */ - DeepFilter.prototype.filter = function (entry, negativeRe, maxPatternDepth) { - if (this.isSkippedByDeepOption(entry.depth)) { - return false; - } - if (this.isSkippedByMaxPatternDepth(entry.depth, maxPatternDepth)) { - return false; - } - if (this.isSkippedSymlinkedDirectory(entry)) { - return false; - } - if (this.isSkippedDotDirectory(entry)) { - return false; - } - return this.isSkippedByNegativePatterns(entry, negativeRe); - }; - /** - * Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value. - */ - DeepFilter.prototype.isSkippedByDeepOption = function (entryDepth) { - return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth >= this.options.deep); - }; - /** - * Returns «true» when depth parameter is not an Infinity and entry depth greater that the parameter value. - */ - DeepFilter.prototype.isSkippedByMaxPatternDepth = function (entryDepth, maxPatternDepth) { - return maxPatternDepth !== Infinity && entryDepth >= maxPatternDepth; - }; - /** - * Returns «true» for symlinked directory if the «followSymlinkedDirectories» option is disabled. - */ - DeepFilter.prototype.isSkippedSymlinkedDirectory = function (entry) { - return !this.options.followSymlinkedDirectories && entry.isSymbolicLink(); - }; - /** - * Returns «true» for a directory whose name starts with a period if «dot» option is disabled. - */ - DeepFilter.prototype.isSkippedDotDirectory = function (entry) { - return !this.options.dot && pathUtils.isDotDirectory(entry.path); - }; - /** - * Returns «true» for a directory whose path math to any negative pattern. - */ - DeepFilter.prototype.isSkippedByNegativePatterns = function (entry, negativeRe) { - return !patternUtils.matchAny(entry.path, negativeRe); - }; - return DeepFilter; -}()); -exports.default = DeepFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +var pathUtils = __webpack_require__(898); +var patternUtils = __webpack_require__(715); +var DeepFilter = /** @class */ (function () { + function DeepFilter(options, micromatchOptions) { + this.options = options; + this.micromatchOptions = micromatchOptions; + } + /** + * Returns filter for directories. + */ + DeepFilter.prototype.getFilter = function (positive, negative) { + var _this = this; + var maxPatternDepth = this.getMaxPatternDepth(positive); + var negativeRe = this.getNegativePatternsRe(negative); + return function (entry) { return _this.filter(entry, negativeRe, maxPatternDepth); }; + }; + /** + * Returns max depth of the provided patterns. + */ + DeepFilter.prototype.getMaxPatternDepth = function (patterns) { + var globstar = patterns.some(patternUtils.hasGlobStar); + return globstar ? Infinity : patternUtils.getMaxNaivePatternsDepth(patterns); + }; + /** + * Returns RegExp's for patterns that can affect the depth of reading. + */ + DeepFilter.prototype.getNegativePatternsRe = function (patterns) { + var affectDepthOfReadingPatterns = patterns.filter(patternUtils.isAffectDepthOfReadingPattern); + return patternUtils.convertPatternsToRe(affectDepthOfReadingPatterns, this.micromatchOptions); + }; + /** + * Returns «true» for directory that should be read. + */ + DeepFilter.prototype.filter = function (entry, negativeRe, maxPatternDepth) { + if (this.isSkippedByDeepOption(entry.depth)) { + return false; + } + if (this.isSkippedByMaxPatternDepth(entry.depth, maxPatternDepth)) { + return false; + } + if (this.isSkippedSymlinkedDirectory(entry)) { + return false; + } + if (this.isSkippedDotDirectory(entry)) { + return false; + } + return this.isSkippedByNegativePatterns(entry, negativeRe); + }; + /** + * Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value. + */ + DeepFilter.prototype.isSkippedByDeepOption = function (entryDepth) { + return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth >= this.options.deep); + }; + /** + * Returns «true» when depth parameter is not an Infinity and entry depth greater that the parameter value. + */ + DeepFilter.prototype.isSkippedByMaxPatternDepth = function (entryDepth, maxPatternDepth) { + return maxPatternDepth !== Infinity && entryDepth >= maxPatternDepth; + }; + /** + * Returns «true» for symlinked directory if the «followSymlinkedDirectories» option is disabled. + */ + DeepFilter.prototype.isSkippedSymlinkedDirectory = function (entry) { + return !this.options.followSymlinkedDirectories && entry.isSymbolicLink(); + }; + /** + * Returns «true» for a directory whose name starts with a period if «dot» option is disabled. + */ + DeepFilter.prototype.isSkippedDotDirectory = function (entry) { + return !this.options.dot && pathUtils.isDotDirectory(entry.path); + }; + /** + * Returns «true» for a directory whose path math to any negative pattern. + */ + DeepFilter.prototype.isSkippedByNegativePatterns = function (entry, negativeRe) { + return !patternUtils.matchAny(entry.path, negativeRe); + }; + return DeepFilter; +}()); +exports.default = DeepFilter; /***/ }), @@ -105706,30 +105706,30 @@ exports.default = DeepFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -/** - * Returns «true» if the last partial of the path starting with a period. - */ -function isDotDirectory(filepath) { - return path.basename(filepath).startsWith('.'); -} -exports.isDotDirectory = isDotDirectory; -/** - * Convert a windows-like path to a unix-style path. - */ -function normalize(filepath) { - return filepath.replace(/\\/g, '/'); -} -exports.normalize = normalize; -/** - * Returns normalized absolute path of provided filepath. - */ -function makeAbsolute(cwd, filepath) { - return normalize(path.resolve(cwd, filepath)); -} -exports.makeAbsolute = makeAbsolute; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +/** + * Returns «true» if the last partial of the path starting with a period. + */ +function isDotDirectory(filepath) { + return path.basename(filepath).startsWith('.'); +} +exports.isDotDirectory = isDotDirectory; +/** + * Convert a windows-like path to a unix-style path. + */ +function normalize(filepath) { + return filepath.replace(/\\/g, '/'); +} +exports.normalize = normalize; +/** + * Returns normalized absolute path of provided filepath. + */ +function makeAbsolute(cwd, filepath) { + return normalize(path.resolve(cwd, filepath)); +} +exports.makeAbsolute = makeAbsolute; /***/ }), @@ -105737,91 +105737,91 @@ exports.makeAbsolute = makeAbsolute; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var pathUtils = __webpack_require__(898); -var patternUtils = __webpack_require__(715); -var EntryFilter = /** @class */ (function () { - function EntryFilter(options, micromatchOptions) { - this.options = options; - this.micromatchOptions = micromatchOptions; - this.index = new Map(); - } - /** - * Returns filter for directories. - */ - EntryFilter.prototype.getFilter = function (positive, negative) { - var _this = this; - var positiveRe = patternUtils.convertPatternsToRe(positive, this.micromatchOptions); - var negativeRe = patternUtils.convertPatternsToRe(negative, this.micromatchOptions); - return function (entry) { return _this.filter(entry, positiveRe, negativeRe); }; - }; - /** - * Returns true if entry must be added to result. - */ - EntryFilter.prototype.filter = function (entry, positiveRe, negativeRe) { - // Exclude duplicate results - if (this.options.unique) { - if (this.isDuplicateEntry(entry)) { - return false; - } - this.createIndexRecord(entry); - } - // Filter files and directories by options - if (this.onlyFileFilter(entry) || this.onlyDirectoryFilter(entry)) { - return false; - } - if (this.isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { - return false; - } - return this.isMatchToPatterns(entry.path, positiveRe) && !this.isMatchToPatterns(entry.path, negativeRe); - }; - /** - * Return true if the entry already has in the cross reader index. - */ - EntryFilter.prototype.isDuplicateEntry = function (entry) { - return this.index.has(entry.path); - }; - /** - * Create record in the cross reader index. - */ - EntryFilter.prototype.createIndexRecord = function (entry) { - this.index.set(entry.path, undefined); - }; - /** - * Returns true for non-files if the «onlyFiles» option is enabled. - */ - EntryFilter.prototype.onlyFileFilter = function (entry) { - return this.options.onlyFiles && !entry.isFile(); - }; - /** - * Returns true for non-directories if the «onlyDirectories» option is enabled. - */ - EntryFilter.prototype.onlyDirectoryFilter = function (entry) { - return this.options.onlyDirectories && !entry.isDirectory(); - }; - /** - * Return true when `absolute` option is enabled and matched to the negative patterns. - */ - EntryFilter.prototype.isSkippedByAbsoluteNegativePatterns = function (entry, negativeRe) { - if (!this.options.absolute) { - return false; - } - var fullpath = pathUtils.makeAbsolute(this.options.cwd, entry.path); - return this.isMatchToPatterns(fullpath, negativeRe); - }; - /** - * Return true when entry match to provided patterns. - * - * First, just trying to apply patterns to the path. - * Second, trying to apply patterns to the path with final slash (need to micromatch to support «directory/**» patterns). - */ - EntryFilter.prototype.isMatchToPatterns = function (filepath, patternsRe) { - return patternUtils.matchAny(filepath, patternsRe) || patternUtils.matchAny(filepath + '/', patternsRe); - }; - return EntryFilter; -}()); -exports.default = EntryFilter; + +Object.defineProperty(exports, "__esModule", { value: true }); +var pathUtils = __webpack_require__(898); +var patternUtils = __webpack_require__(715); +var EntryFilter = /** @class */ (function () { + function EntryFilter(options, micromatchOptions) { + this.options = options; + this.micromatchOptions = micromatchOptions; + this.index = new Map(); + } + /** + * Returns filter for directories. + */ + EntryFilter.prototype.getFilter = function (positive, negative) { + var _this = this; + var positiveRe = patternUtils.convertPatternsToRe(positive, this.micromatchOptions); + var negativeRe = patternUtils.convertPatternsToRe(negative, this.micromatchOptions); + return function (entry) { return _this.filter(entry, positiveRe, negativeRe); }; + }; + /** + * Returns true if entry must be added to result. + */ + EntryFilter.prototype.filter = function (entry, positiveRe, negativeRe) { + // Exclude duplicate results + if (this.options.unique) { + if (this.isDuplicateEntry(entry)) { + return false; + } + this.createIndexRecord(entry); + } + // Filter files and directories by options + if (this.onlyFileFilter(entry) || this.onlyDirectoryFilter(entry)) { + return false; + } + if (this.isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) { + return false; + } + return this.isMatchToPatterns(entry.path, positiveRe) && !this.isMatchToPatterns(entry.path, negativeRe); + }; + /** + * Return true if the entry already has in the cross reader index. + */ + EntryFilter.prototype.isDuplicateEntry = function (entry) { + return this.index.has(entry.path); + }; + /** + * Create record in the cross reader index. + */ + EntryFilter.prototype.createIndexRecord = function (entry) { + this.index.set(entry.path, undefined); + }; + /** + * Returns true for non-files if the «onlyFiles» option is enabled. + */ + EntryFilter.prototype.onlyFileFilter = function (entry) { + return this.options.onlyFiles && !entry.isFile(); + }; + /** + * Returns true for non-directories if the «onlyDirectories» option is enabled. + */ + EntryFilter.prototype.onlyDirectoryFilter = function (entry) { + return this.options.onlyDirectories && !entry.isDirectory(); + }; + /** + * Return true when `absolute` option is enabled and matched to the negative patterns. + */ + EntryFilter.prototype.isSkippedByAbsoluteNegativePatterns = function (entry, negativeRe) { + if (!this.options.absolute) { + return false; + } + var fullpath = pathUtils.makeAbsolute(this.options.cwd, entry.path); + return this.isMatchToPatterns(fullpath, negativeRe); + }; + /** + * Return true when entry match to provided patterns. + * + * First, just trying to apply patterns to the path. + * Second, trying to apply patterns to the path with final slash (need to micromatch to support «directory/**» patterns). + */ + EntryFilter.prototype.isMatchToPatterns = function (filepath, patternsRe) { + return patternUtils.matchAny(filepath, patternsRe) || patternUtils.matchAny(filepath + '/', patternsRe); + }; + return EntryFilter; +}()); +exports.default = EntryFilter; /***/ }), @@ -105829,70 +105829,70 @@ exports.default = EntryFilter; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var stream = __webpack_require__(382); -var fsStat = __webpack_require__(901); -var fs_1 = __webpack_require__(905); -var FileSystemStream = /** @class */ (function (_super) { - __extends(FileSystemStream, _super); - function FileSystemStream() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Use stream API to read entries for Task. - */ - FileSystemStream.prototype.read = function (patterns, filter) { - var _this = this; - var filepaths = patterns.map(this.getFullEntryPath, this); - var transform = new stream.Transform({ objectMode: true }); - transform._transform = function (index, _enc, done) { - return _this.getEntry(filepaths[index], patterns[index]).then(function (entry) { - if (entry !== null && filter(entry)) { - transform.push(entry); - } - if (index === filepaths.length - 1) { - transform.end(); - } - done(); - }); - }; - for (var i = 0; i < filepaths.length; i++) { - transform.write(i); - } - return transform; - }; - /** - * Return entry for the provided path. - */ - FileSystemStream.prototype.getEntry = function (filepath, pattern) { - var _this = this; - return this.getStat(filepath) - .then(function (stat) { return _this.makeEntry(stat, pattern); }) - .catch(function () { return null; }); - }; - /** - * Return fs.Stats for the provided path. - */ - FileSystemStream.prototype.getStat = function (filepath) { - return fsStat.stat(filepath, { throwErrorOnBrokenSymlinks: false }); - }; - return FileSystemStream; -}(fs_1.default)); -exports.default = FileSystemStream; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var stream = __webpack_require__(382); +var fsStat = __webpack_require__(901); +var fs_1 = __webpack_require__(905); +var FileSystemStream = /** @class */ (function (_super) { + __extends(FileSystemStream, _super); + function FileSystemStream() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Use stream API to read entries for Task. + */ + FileSystemStream.prototype.read = function (patterns, filter) { + var _this = this; + var filepaths = patterns.map(this.getFullEntryPath, this); + var transform = new stream.Transform({ objectMode: true }); + transform._transform = function (index, _enc, done) { + return _this.getEntry(filepaths[index], patterns[index]).then(function (entry) { + if (entry !== null && filter(entry)) { + transform.push(entry); + } + if (index === filepaths.length - 1) { + transform.end(); + } + done(); + }); + }; + for (var i = 0; i < filepaths.length; i++) { + transform.write(i); + } + return transform; + }; + /** + * Return entry for the provided path. + */ + FileSystemStream.prototype.getEntry = function (filepath, pattern) { + var _this = this; + return this.getStat(filepath) + .then(function (stat) { return _this.makeEntry(stat, pattern); }) + .catch(function () { return null; }); + }; + /** + * Return fs.Stats for the provided path. + */ + FileSystemStream.prototype.getStat = function (filepath) { + return fsStat.stat(filepath, { throwErrorOnBrokenSymlinks: false }); + }; + return FileSystemStream; +}(fs_1.default)); +exports.default = FileSystemStream; /***/ }), @@ -106032,30 +106032,30 @@ exports.isFollowedSymlink = isFollowedSymlink; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var path = __webpack_require__(4); -var FileSystem = /** @class */ (function () { - function FileSystem(options) { - this.options = options; - } - /** - * Return full path to entry. - */ - FileSystem.prototype.getFullEntryPath = function (filepath) { - return path.resolve(this.options.cwd, filepath); - }; - /** - * Return an implementation of the Entry interface. - */ - FileSystem.prototype.makeEntry = function (stat, pattern) { - stat.path = pattern; - stat.depth = pattern.split('/').length; - return stat; - }; - return FileSystem; -}()); -exports.default = FileSystem; + +Object.defineProperty(exports, "__esModule", { value: true }); +var path = __webpack_require__(4); +var FileSystem = /** @class */ (function () { + function FileSystem(options) { + this.options = options; + } + /** + * Return full path to entry. + */ + FileSystem.prototype.getFullEntryPath = function (filepath) { + return path.resolve(this.options.cwd, filepath); + }; + /** + * Return an implementation of the Entry interface. + */ + FileSystem.prototype.makeEntry = function (stat, pattern) { + stat.path = pattern; + stat.depth = pattern.split('/').length; + return stat; + }; + return FileSystem; +}()); +exports.default = FileSystem; /***/ }), @@ -106063,89 +106063,89 @@ exports.default = FileSystem; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var stream = __webpack_require__(382); -var readdir = __webpack_require__(883); -var reader_1 = __webpack_require__(896); -var fs_stream_1 = __webpack_require__(900); -var TransformStream = /** @class */ (function (_super) { - __extends(TransformStream, _super); - function TransformStream(reader) { - var _this = _super.call(this, { objectMode: true }) || this; - _this.reader = reader; - return _this; - } - TransformStream.prototype._transform = function (entry, _encoding, callback) { - callback(null, this.reader.transform(entry)); - }; - return TransformStream; -}(stream.Transform)); -var ReaderStream = /** @class */ (function (_super) { - __extends(ReaderStream, _super); - function ReaderStream() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(ReaderStream.prototype, "fsAdapter", { - /** - * Returns FileSystem adapter. - */ - get: function () { - return new fs_stream_1.default(this.options); - }, - enumerable: true, - configurable: true - }); - /** - * Use stream API to read entries for Task. - */ - ReaderStream.prototype.read = function (task) { - var _this = this; - var root = this.getRootDirectory(task); - var options = this.getReaderOptions(task); - var transform = new TransformStream(this); - var readable = this.api(root, task, options); - return readable - .on('error', function (err) { return _this.isEnoentCodeError(err) ? null : transform.emit('error', err); }) - .pipe(transform); - }; - /** - * Returns founded paths. - */ - ReaderStream.prototype.api = function (root, task, options) { - if (task.dynamic) { - return this.dynamicApi(root, options); - } - return this.staticApi(task, options); - }; - /** - * Api for dynamic tasks. - */ - ReaderStream.prototype.dynamicApi = function (root, options) { - return readdir.readdirStreamStat(root, options); - }; - /** - * Api for static tasks. - */ - ReaderStream.prototype.staticApi = function (task, options) { - return this.fsAdapter.read(task.patterns, options.filter); - }; - return ReaderStream; -}(reader_1.default)); -exports.default = ReaderStream; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var stream = __webpack_require__(382); +var readdir = __webpack_require__(883); +var reader_1 = __webpack_require__(896); +var fs_stream_1 = __webpack_require__(900); +var TransformStream = /** @class */ (function (_super) { + __extends(TransformStream, _super); + function TransformStream(reader) { + var _this = _super.call(this, { objectMode: true }) || this; + _this.reader = reader; + return _this; + } + TransformStream.prototype._transform = function (entry, _encoding, callback) { + callback(null, this.reader.transform(entry)); + }; + return TransformStream; +}(stream.Transform)); +var ReaderStream = /** @class */ (function (_super) { + __extends(ReaderStream, _super); + function ReaderStream() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ReaderStream.prototype, "fsAdapter", { + /** + * Returns FileSystem adapter. + */ + get: function () { + return new fs_stream_1.default(this.options); + }, + enumerable: true, + configurable: true + }); + /** + * Use stream API to read entries for Task. + */ + ReaderStream.prototype.read = function (task) { + var _this = this; + var root = this.getRootDirectory(task); + var options = this.getReaderOptions(task); + var transform = new TransformStream(this); + var readable = this.api(root, task, options); + return readable + .on('error', function (err) { return _this.isEnoentCodeError(err) ? null : transform.emit('error', err); }) + .pipe(transform); + }; + /** + * Returns founded paths. + */ + ReaderStream.prototype.api = function (root, task, options) { + if (task.dynamic) { + return this.dynamicApi(root, options); + } + return this.staticApi(task, options); + }; + /** + * Api for dynamic tasks. + */ + ReaderStream.prototype.dynamicApi = function (root, options) { + return readdir.readdirStreamStat(root, options); + }; + /** + * Api for static tasks. + */ + ReaderStream.prototype.staticApi = function (task, options) { + return this.fsAdapter.read(task.patterns, options.filter); + }; + return ReaderStream; +}(reader_1.default)); +exports.default = ReaderStream; /***/ }), @@ -106153,80 +106153,80 @@ exports.default = ReaderStream; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var readdir = __webpack_require__(883); -var reader_1 = __webpack_require__(896); -var fs_sync_1 = __webpack_require__(908); -var ReaderSync = /** @class */ (function (_super) { - __extends(ReaderSync, _super); - function ReaderSync() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(ReaderSync.prototype, "fsAdapter", { - /** - * Returns FileSystem adapter. - */ - get: function () { - return new fs_sync_1.default(this.options); - }, - enumerable: true, - configurable: true - }); - /** - * Use sync API to read entries for Task. - */ - ReaderSync.prototype.read = function (task) { - var root = this.getRootDirectory(task); - var options = this.getReaderOptions(task); - try { - var entries = this.api(root, task, options); - return entries.map(this.transform, this); - } - catch (err) { - if (this.isEnoentCodeError(err)) { - return []; - } - throw err; - } - }; - /** - * Returns founded paths. - */ - ReaderSync.prototype.api = function (root, task, options) { - if (task.dynamic) { - return this.dynamicApi(root, options); - } - return this.staticApi(task, options); - }; - /** - * Api for dynamic tasks. - */ - ReaderSync.prototype.dynamicApi = function (root, options) { - return readdir.readdirSyncStat(root, options); - }; - /** - * Api for static tasks. - */ - ReaderSync.prototype.staticApi = function (task, options) { - return this.fsAdapter.read(task.patterns, options.filter); - }; - return ReaderSync; -}(reader_1.default)); -exports.default = ReaderSync; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var readdir = __webpack_require__(883); +var reader_1 = __webpack_require__(896); +var fs_sync_1 = __webpack_require__(908); +var ReaderSync = /** @class */ (function (_super) { + __extends(ReaderSync, _super); + function ReaderSync() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ReaderSync.prototype, "fsAdapter", { + /** + * Returns FileSystem adapter. + */ + get: function () { + return new fs_sync_1.default(this.options); + }, + enumerable: true, + configurable: true + }); + /** + * Use sync API to read entries for Task. + */ + ReaderSync.prototype.read = function (task) { + var root = this.getRootDirectory(task); + var options = this.getReaderOptions(task); + try { + var entries = this.api(root, task, options); + return entries.map(this.transform, this); + } + catch (err) { + if (this.isEnoentCodeError(err)) { + return []; + } + throw err; + } + }; + /** + * Returns founded paths. + */ + ReaderSync.prototype.api = function (root, task, options) { + if (task.dynamic) { + return this.dynamicApi(root, options); + } + return this.staticApi(task, options); + }; + /** + * Api for dynamic tasks. + */ + ReaderSync.prototype.dynamicApi = function (root, options) { + return readdir.readdirSyncStat(root, options); + }; + /** + * Api for static tasks. + */ + ReaderSync.prototype.staticApi = function (task, options) { + return this.fsAdapter.read(task.patterns, options.filter); + }; + return ReaderSync; +}(reader_1.default)); +exports.default = ReaderSync; /***/ }), @@ -106234,65 +106234,65 @@ exports.default = ReaderSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var fsStat = __webpack_require__(901); -var fs_1 = __webpack_require__(905); -var FileSystemSync = /** @class */ (function (_super) { - __extends(FileSystemSync, _super); - function FileSystemSync() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Use sync API to read entries for Task. - */ - FileSystemSync.prototype.read = function (patterns, filter) { - var _this = this; - var entries = []; - patterns.forEach(function (pattern) { - var filepath = _this.getFullEntryPath(pattern); - var entry = _this.getEntry(filepath, pattern); - if (entry === null || !filter(entry)) { - return; - } - entries.push(entry); - }); - return entries; - }; - /** - * Return entry for the provided path. - */ - FileSystemSync.prototype.getEntry = function (filepath, pattern) { - try { - var stat = this.getStat(filepath); - return this.makeEntry(stat, pattern); - } - catch (err) { - return null; - } - }; - /** - * Return fs.Stats for the provided path. - */ - FileSystemSync.prototype.getStat = function (filepath) { - return fsStat.statSync(filepath, { throwErrorOnBrokenSymlinks: false }); - }; - return FileSystemSync; -}(fs_1.default)); -exports.default = FileSystemSync; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var fsStat = __webpack_require__(901); +var fs_1 = __webpack_require__(905); +var FileSystemSync = /** @class */ (function (_super) { + __extends(FileSystemSync, _super); + function FileSystemSync() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Use sync API to read entries for Task. + */ + FileSystemSync.prototype.read = function (patterns, filter) { + var _this = this; + var entries = []; + patterns.forEach(function (pattern) { + var filepath = _this.getFullEntryPath(pattern); + var entry = _this.getEntry(filepath, pattern); + if (entry === null || !filter(entry)) { + return; + } + entries.push(entry); + }); + return entries; + }; + /** + * Return entry for the provided path. + */ + FileSystemSync.prototype.getEntry = function (filepath, pattern) { + try { + var stat = this.getStat(filepath); + return this.makeEntry(stat, pattern); + } + catch (err) { + return null; + } + }; + /** + * Return fs.Stats for the provided path. + */ + FileSystemSync.prototype.getStat = function (filepath) { + return fsStat.statSync(filepath, { throwErrorOnBrokenSymlinks: false }); + }; + return FileSystemSync; +}(fs_1.default)); +exports.default = FileSystemSync; /***/ }), @@ -106300,15 +106300,15 @@ exports.default = FileSystemSync; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Flatten nested arrays (max depth is 2) into a non-nested array of non-array items. - */ -function flatten(items) { - return items.reduce(function (collection, item) { return [].concat(collection, item); }, []); -} -exports.flatten = flatten; + +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Flatten nested arrays (max depth is 2) into a non-nested array of non-array items. + */ +function flatten(items) { + return items.reduce(function (collection, item) { return [].concat(collection, item); }, []); +} +exports.flatten = flatten; /***/ }), @@ -106316,20 +106316,20 @@ exports.flatten = flatten; /***/ (function(module, exports, __webpack_require__) { "use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var merge2 = __webpack_require__(585); -/** - * Merge multiple streams and propagate their errors into one stream in parallel. - */ -function merge(streams) { - var mergedStream = merge2(streams); - streams.forEach(function (stream) { - stream.on('error', function (err) { return mergedStream.emit('error', err); }); - }); - return mergedStream; -} -exports.merge = merge; + +Object.defineProperty(exports, "__esModule", { value: true }); +var merge2 = __webpack_require__(585); +/** + * Merge multiple streams and propagate their errors into one stream in parallel. + */ +function merge(streams) { + var mergedStream = merge2(streams); + streams.forEach(function (stream) { + stream.on('error', function (err) { return mergedStream.emit('error', err); }); + }); + return mergedStream; +} +exports.merge = merge; /***/ }), @@ -109916,4 +109916,4 @@ async function prepareExternalProjectDependencies(projectPath) { } /***/ }) -/******/ ]); +/******/ ]); \ No newline at end of file From 75db54e2fdbf812433b5a8d59c49b4cf39ce3337 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 12 Jun 2020 14:13:16 +0200 Subject: [PATCH 040/186] Improve performance by removing inMemory property of EuiDataGrid --- .../components/discover_grid/discover_grid.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index f451d0245a194..fa469646dce78 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -262,14 +262,6 @@ export const DiscoverGrid = function DiscoverGridInner({ return '-'; } - const createFilter = (fieldName: string, type: '-' | '+') => { - return onFilter( - indexPattern.fields.getByName(fieldName), - indexPattern.flattenHit(row)[fieldName], - type - ); - }; - const value = ( // TODO Field formatters need to be fixed // eslint-disable-next-line react/no-danger @@ -277,6 +269,13 @@ export const DiscoverGrid = function DiscoverGridInner({ ); if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { + const createFilter = (fieldName: string, type: '-' | '+') => { + return onFilter( + indexPattern.fields.getByName(fieldName), + indexPattern.flattenHit(row)[fieldName], + type + ); + }; return ( Date: Mon, 15 Jun 2020 15:38:52 +0200 Subject: [PATCH 041/186] Fix the header/EuiDataGrid overlapping --- src/core/public/chrome/ui/header/_index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/public/chrome/ui/header/_index.scss b/src/core/public/chrome/ui/header/_index.scss index 6a2842a0e4c5c..302fdd32fa614 100644 --- a/src/core/public/chrome/ui/header/_index.scss +++ b/src/core/public/chrome/ui/header/_index.scss @@ -8,7 +8,7 @@ } .euiDataGrid__restrictBody .chrHeaderWrapper { - z-index: 0; + display: none; } .chrHeaderHelpMenu__version { From 36984e26a7689747b933ce998530b53d8e0709b7 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 15 Jun 2020 16:39:28 +0200 Subject: [PATCH 042/186] Migrate flyout and popover to separate files --- .../discover_grid/discover_grid.tsx | 150 ++---------------- .../discover_grid/discover_grid_flyout.tsx | 116 ++++++++++++++ .../discover_grid/discover_grid_popover.tsx | 80 ++++++++++ 3 files changed, 213 insertions(+), 133 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index fa469646dce78..5b35e3f219378 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,34 +17,24 @@ * under the License. */ -import React, { useMemo, useState, useEffect, useCallback, ReactNode } from 'react'; +import React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'; import './discover_grid.scss'; import { isEqual } from 'lodash'; import { i18n } from '@kbn/i18n'; import { EuiDataGrid, - EuiFlexGroup, - EuiFlexItem, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiIcon, - EuiLink, - EuiPortal, - EuiTitle, - useRenderToText, - htmlIdGenerator, - EuiButtonEmpty, - EuiSpacer, - EuiDataGridColumn, EuiDataGridCellValueElementProps, + EuiDataGridColumn, + EuiIcon, EuiScreenReaderOnly, + htmlIdGenerator, } from '@elastic/eui'; -import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; -import { ElasticSearchHit, DocViewFilterFn } from '../../doc_views/doc_views_types'; +import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; import { shortenDottedString } from '../../helpers'; import { getDefaultSort } from '../../angular/doc_table/lib/get_default_sort'; +import { CellPopover } from './discover_grid_popover'; +import { DiscoverGridFlyout } from './discover_grid_flyout'; type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; @@ -74,59 +64,6 @@ interface Props { onSetColumns: (columns: string[]) => void; } -function CellPopover({ - value, - onPositiveFilterClick, - onNegativeFilterClick, -}: { - value: string | ReactNode; - onPositiveFilterClick: () => void; - onNegativeFilterClick: () => void; -}) { - const node = useMemo(() => <>{value}!, [value]); - const placeholder = i18n.translate('discover.grid.filterValuePlaceholder', { - defaultMessage: 'value', - }); - const text = useRenderToText(node, placeholder); - return ( - <> - {value} - - - - - {i18n.translate('discover.grid.filterOn', { - defaultMessage: 'Filter on value', - })} - - - - - {i18n.translate('discover.grid.filterOut', { - defaultMessage: 'Filter without value', - })} - - - - - ); -} - export const DiscoverGrid = function DiscoverGridInner({ rows, columns, @@ -440,69 +377,16 @@ export const DiscoverGrid = function DiscoverGridInner({ )} {typeof flyoutRow !== 'undefined' && ( - - setFlyoutRow(undefined)} size="m"> - - - - - - - - - -

- {i18n.translate('discover.grid.tableRow.detailHeading', { - defaultMessage: 'Expanded document', - })} -

-
-
-
-
- - - {indexPattern.isTimeBased() && ( - - - {i18n.translate( - 'discover.grid.tableRow.viewSurroundingDocumentsLinkText', - { - defaultMessage: 'View surrounding documents', - } - )} - - - )} - - - {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkText', { - defaultMessage: 'View single document', - })} - - - - -
-
- - - -
-
+ setFlyoutRow(undefined)} + onRemoveColumn={onRemoveColumn} + onAddColumn={onAddColumn} + /> )} ); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx new file mode 100644 index 0000000000000..ec3a8f4ee1521 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -0,0 +1,116 @@ +/* + * 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 React from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiIcon, + EuiLink, + EuiPortal, + EuiTitle, +} from '@elastic/eui'; +import { DocViewer } from '../doc_viewer/doc_viewer'; +import { IndexPattern } from '../../../kibana_services'; +import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; + +interface Props { + columns: string[]; + getContextAppHref: (id: string | number | Record) => string; + hit: ElasticSearchHit; + indexPattern: IndexPattern; + onAddColumn: (column: string) => void; + onClose: () => void; + onFilter: DocViewFilterFn; + onRemoveColumn: (column: string) => void; +} + +export const DiscoverGridFlyout = function DiscoverGridInner({ + hit, + indexPattern, + columns, + onFilter, + onClose, + getContextAppHref, + onRemoveColumn, + onAddColumn, +}: Props) { + if (!hit) { + return null; + } + + return ( + + onClose()} size="m"> + + + + +

+ {' '} + {i18n.translate('discover.grid.tableRow.detailHeading', { + defaultMessage: 'Expanded document', + })} +

+
+
+ + + {indexPattern.isTimeBased() && ( + + + {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkText', { + defaultMessage: 'View surrounding documents', + })} + + + )} + + + {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkText', { + defaultMessage: 'View single document', + })} + + + + +
+
+ + + +
+
+ ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx new file mode 100644 index 0000000000000..1eeb791c99233 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx @@ -0,0 +1,80 @@ +/* + * 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 React, { ReactNode, useMemo } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiButtonEmpty, + EuiFlexGroup, + EuiFlexItem, + EuiSpacer, + useRenderToText, +} from '@elastic/eui'; + +export function CellPopover({ + value, + onPositiveFilterClick, + onNegativeFilterClick, +}: { + value: string | ReactNode; + onPositiveFilterClick: () => void; + onNegativeFilterClick: () => void; +}) { + const node = useMemo(() => <>{value}!, [value]); + const placeholder = i18n.translate('discover.grid.filterValuePlaceholder', { + defaultMessage: 'value', + }); + const text = useRenderToText(node, placeholder); + return ( + <> + {value} + + + + + {i18n.translate('discover.grid.filterOn', { + defaultMessage: 'Filter on value', + })} + + + + + {i18n.translate('discover.grid.filterOut', { + defaultMessage: 'Filter without value', + })} + + + + + ); +} From 637950d175e1e4274bc44d9df91a19c06a290a80 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 15 Jun 2020 23:51:32 +0200 Subject: [PATCH 043/186] Improve performance --- .../public/application/angular/discover.js | 1 + .../create_discover_grid_directive.tsx | 38 +- .../discover_grid/discover_grid.tsx | 610 +++++++++--------- 3 files changed, 341 insertions(+), 308 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 1112777f8c3ef..3adc1b984f694 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -1016,6 +1016,7 @@ function discoverController( }; $scope.setColumns = function setColumns(columns) { + $scope.state = { ...$scope.state, columns }; setAppState({ columns }); }; diff --git a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx index 9d14998d88d5f..3190a486b6464 100644 --- a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx @@ -16,15 +16,45 @@ * specific language governing permissions and limitations * under the License. */ - +import * as React from 'react'; import { DiscoverGrid } from './discover_grid'; +interface Props

{ + [key: string]: any; +} + +/** + * TODO remove when development is finished, helper component to detect property changes + * @param WrappedComponent + */ +export function withPropsChecker

( + WrappedComponent: React.ComponentType

+): React.ComponentClass> { + // eslint-disable-next-line react/prefer-stateless-function + return class PropsChecker extends React.Component> { + /** + componentWillReceiveProps(nextProps: Props

) { + Object.keys(nextProps) + .filter((key) => nextProps[key] !== this.props[key]) + .map((key) => { + console.log('changed property:', key, 'from', this.props[key], 'to', nextProps[key]); + }); + } + **/ + + render() { + // @ts-ignore + return ; + } + }; +} + export function createDiscoverGridDirective(reactDirective: any) { - return reactDirective(DiscoverGrid, [ + return reactDirective(withPropsChecker(DiscoverGrid), [ ['columns', { watchDepth: 'collection' }], ['rows', { watchDepth: 'collection' }], ['indexPattern', { watchDepth: 'reference' }], - ['sort', { watchDepth: 'collection' }], + ['sort', { watchDepth: 'value' }], ['sampleSize', { watchDepth: 'reference' }], ['searchDescription', { watchDepth: 'reference' }], ['searchTitle', { watchDepth: 'reference' }], @@ -35,6 +65,6 @@ export function createDiscoverGridDirective(reactDirective: any) { ['onAddColumn', { watchDepth: 'reference', wrapApply: false }], ['onSetColumns', { watchDepth: 'reference', wrapApply: false }], ['getContextAppHref', { watchDepth: 'reference', wrapApply: false }], - ['onSort', { watchDepth: 'reference' }], + ['onSort', { watchDepth: 'reference', wrapApply: false }], ]); } diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 5b35e3f219378..d9f24e8963f13 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,9 +17,8 @@ * under the License. */ -import React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'; +import React, { ReactNode, useCallback, useMemo, useState } from 'react'; import './discover_grid.scss'; -import { isEqual } from 'lodash'; import { i18n } from '@kbn/i18n'; import { EuiDataGrid, @@ -64,330 +63,333 @@ interface Props { onSetColumns: (columns: string[]) => void; } -export const DiscoverGrid = function DiscoverGridInner({ - rows, - columns, - sort, - indexPattern, - ariaLabelledBy, - searchTitle, - searchDescription, - useShortDots, - onSort, - sampleSize, - onFilter, - getContextAppHref, - onRemoveColumn, - onAddColumn, - showTimeCol, - onSetColumns, -}: Props) { - const lowestPageSize = 50; - const timeString = i18n.translate('discover.timeLabel', { - defaultMessage: 'Time', - }); - const [flyoutRow, setFlyoutRow] = useState(undefined); - const buildColumns = useCallback( - (cols: any) => { - return cols.map( - (columnName: string): EuiDataGridColumn => { - const column: EuiDataGridColumn = { - id: columnName, - schema: indexPattern.getFieldByName(columnName)?.type, - }; +const pageSizeArr = [25, 50, 100]; - // Default DataGrid schemas: boolean, numeric, datetime, json, currency - // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts - switch (column.schema) { - case 'date': - column.schema = 'datetime'; - break; - case 'number': - column.schema = 'numeric'; - break; - case '_source': - case 'object': - column.schema = kibanaJSON; - break; - case 'geo_point': - column.schema = geoPoint; - break; - default: - column.schema = undefined; - break; - } +export const DiscoverGrid = React.memo( + ({ + rows, + columns, + sort, + indexPattern, + ariaLabelledBy, + searchTitle, + searchDescription, + useShortDots, + onSort, + sampleSize, + onFilter, + getContextAppHref, + onRemoveColumn, + onAddColumn, + showTimeCol, + onSetColumns, + }: Props) => { + const timeString = i18n.translate('discover.timeLabel', { + defaultMessage: 'Time', + }); + const [flyoutRow, setFlyoutRow] = useState(undefined); + const buildColumns = useCallback( + (cols: any) => { + return cols.map( + (columnName: string): EuiDataGridColumn => { + const column: EuiDataGridColumn = { + id: columnName, + schema: indexPattern.getFieldByName(columnName)?.type, + }; - if (useShortDots) { - column.display = <>{shortenDottedString(columnName)}; - } - if (column.id === indexPattern.timeFieldName) { - column.display = `${timeString} (${indexPattern.timeFieldName})`; + // Default DataGrid schemas: boolean, numeric, datetime, json, currency + // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts + switch (column.schema) { + case 'date': + column.schema = 'datetime'; + break; + case 'number': + column.schema = 'numeric'; + break; + case '_source': + case 'object': + column.schema = kibanaJSON; + break; + case 'geo_point': + column.schema = geoPoint; + break; + default: + column.schema = undefined; + break; + } + + if (useShortDots) { + column.display = <>{shortenDottedString(columnName)}; + } + if (column.id === indexPattern.timeFieldName) { + column.display = `${timeString} (${indexPattern.timeFieldName})`; + } + + return column; } + ); + }, + [indexPattern, useShortDots, timeString] + ); - return column; - } - ); - }, - [indexPattern, useShortDots, timeString] - ); + const getColumns = useCallback(() => { + const timeFieldName = indexPattern.timeFieldName; - const [dataGridColumns, setDataGridColumns] = useState( - buildColumns(columns) - ); - useEffect(() => { - const prevColumns = dataGridColumns.map((col) => col.id); - if (!isEqual(columns, prevColumns)) { - setDataGridColumns(buildColumns(columns)); - } - }, [columns, buildColumns, setDataGridColumns, dataGridColumns]); + if (showTimeCol && !columns.find((col) => col === timeFieldName)) { + return [ + { + id: indexPattern.timeFieldName, + display: `${timeString} (${indexPattern.timeFieldName})`, + schema: 'datetime', + initialWidth: 200, + } as EuiDataGridColumn, + ...buildColumns(columns), + ]; + } - const getColumns = useCallback(() => { - const timeFieldName = indexPattern.timeFieldName; + return buildColumns(columns); + }, [columns, showTimeCol, timeString, indexPattern.timeFieldName, buildColumns]); - if (showTimeCol && !dataGridColumns.find((col) => col.id === timeFieldName)) { - return [ - { - id: indexPattern.timeFieldName, - display: `${timeString} (${indexPattern.timeFieldName})`, - schema: 'datetime', - initialWidth: 200, - } as EuiDataGridColumn, - ...dataGridColumns, - ]; - } - return dataGridColumns; - }, [dataGridColumns, showTimeCol, timeString, indexPattern.timeFieldName]); + const getVisibleColumns = useCallback(() => { + const timeFieldName = indexPattern.timeFieldName; - /** - * Pagination - */ - const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: lowestPageSize }); - const onChangeItemsPerPage = useCallback( - (pageSize) => setPagination((paginationData) => ({ ...paginationData, pageSize })), - [setPagination] - ); - const onChangePage = useCallback( - (pageIndex) => setPagination((paginationData) => ({ ...paginationData, pageIndex })), - [setPagination] - ); + if (showTimeCol && !columns.find((col) => col === timeFieldName)) { + return [timeFieldName, ...columns]; + } - /** - * Sorting - */ - const sortingColumns = useMemo(() => { - return sort.length === 0 - ? getDefaultSort(indexPattern).map( - ([id, direction]) => ({ id, direction } as { id: string; direction: 'asc' | 'desc' }) - ) - : sort.map(([id, direction]) => ({ id, direction })); - }, [sort, indexPattern]); - const onTableSort = useCallback( - (sortingColumnsData) => { - onSort(sortingColumnsData.map(({ id, direction }: SortObj) => [id, direction])); - }, - [onSort] - ); + return columns; + }, [showTimeCol, columns, indexPattern.timeFieldName]); - /** - * Cell rendering - */ - const renderCellValue = useCallback( - ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { - const row = rows[rowIndex]; + /** + * Pagination + */ + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: pageSizeArr[0] }); + const onChangeItemsPerPage = useCallback( + (pageSize) => setPagination((paginationData) => ({ ...paginationData, pageSize })), + [setPagination] + ); + const onChangePage = useCallback( + (pageIndex) => setPagination((paginationData) => ({ ...paginationData, pageIndex })), + [setPagination] + ); - if (typeof row === 'undefined') { - return '-'; - } + /** + * Sorting + */ + const sortingColumns = useMemo(() => { + return sort.length === 0 + ? getDefaultSort(indexPattern).map( + ([id, direction]) => ({ id, direction } as { id: string; direction: 'asc' | 'desc' }) + ) + : sort.map(([id, direction]) => ({ id, direction })); + }, [sort, indexPattern]); + const onTableSort = useCallback( + (sortingColumnsData) => { + onSort(sortingColumnsData.map(({ id, direction }: SortObj) => [id, direction])); + }, + [onSort] + ); - const value = ( - // TODO Field formatters need to be fixed - // eslint-disable-next-line react/no-danger - - ); + /** + * Cell rendering + */ + const renderCellValue = useCallback( + ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { + const row = rows[rowIndex]; - if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { - const createFilter = (fieldName: string, type: '-' | '+') => { - return onFilter( - indexPattern.fields.getByName(fieldName), - indexPattern.flattenHit(row)[fieldName], - type - ); - }; - return ( - createFilter(columnId, '+')} - onNegativeFilterClick={() => createFilter(columnId, '-')} - /> + if (typeof row === 'undefined') { + return '-'; + } + + const value = ( + // TODO Field formatters need to be fixed + // eslint-disable-next-line react/no-danger + ); - } - return value; - }, - [rows, indexPattern, onFilter] - ); - /** - * Render variables - */ - const pageCount = Math.ceil(rows.length / pagination.pageSize); - const isOnLastPage = pagination.pageIndex === pageCount - 1; - const showDisclaimer = rows.length === sampleSize && isOnLastPage; - const randomId = useMemo(() => String(htmlIdGenerator()), []); - let searchString: ReactNode = <>; - if (searchTitle) { - if (searchDescription) { - searchString = i18n.translate('discover.searchGenerationWithDescription', { - defaultMessage: 'Table generated by search {searchTitle} ({searchDescription})', - values: { searchTitle, searchDescription }, - }); - } else { - searchString = i18n.translate('discover.searchGeneration', { - defaultMessage: 'Table generated by search {searchTitle}', - values: { searchTitle }, - }); + if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { + const createFilter = (fieldName: string, type: '-' | '+') => { + return onFilter( + indexPattern.fields.getByName(fieldName), + indexPattern.flattenHit(row)[fieldName], + type + ); + }; + return ( + createFilter(columnId, '+')} + onNegativeFilterClick={() => createFilter(columnId, '-')} + /> + ); + } + return value; + }, + [rows, indexPattern, onFilter] + ); + + /** + * Render variables + */ + const pageCount = Math.ceil(rows.length / pagination.pageSize); + const isOnLastPage = pagination.pageIndex === pageCount - 1; + const showDisclaimer = rows.length === sampleSize && isOnLastPage; + const randomId = useMemo(() => String(htmlIdGenerator()), []); + let searchString: ReactNode = <>; + if (searchTitle) { + if (searchDescription) { + searchString = i18n.translate('discover.searchGenerationWithDescription', { + defaultMessage: 'Table generated by search {searchTitle} ({searchDescription})', + values: { searchTitle, searchDescription }, + }); + } else { + searchString = i18n.translate('discover.searchGeneration', { + defaultMessage: 'Table generated by search {searchTitle}', + values: { searchTitle }, + }); + } } - } - const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); - const leadingControlControls = useMemo( - () => [ - { - id: 'openDetails', - width: 31, - headerCellRender: () => ( - - - {i18n.translate('discover.controlColumnHeader', { - defaultMessage: 'Control column', + const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); + const leadingControlControls = useMemo( + () => [ + { + id: 'openDetails', + width: 31, + headerCellRender: () => ( + + + {i18n.translate('discover.controlColumnHeader', { + defaultMessage: 'Control column', + })} + + + ), + rowCellRender: ({ rowIndex }: { rowIndex: number }) => ( + - ), - }, - ], - [flyoutRow] - ); + onClick={() => setFlyoutRow(rowIndex)} + className="dscTable__buttonToggle" + > + + + ), + }, + ], + [flyoutRow] + ); - if (!rowCount) { - return null; - } + if (!rowCount) { + return null; + } - return ( - <> - obj.id), - setVisibleColumns: (newColumns) => { - setDataGridColumns(buildColumns(newColumns)); - onSetColumns(newColumns); - }, - }} - pagination={{ - ...pagination, - onChangeItemsPerPage, - onChangePage, - pageSizeOptions: [lowestPageSize, 100, 500], - }} - toolbarVisibility={{ - showColumnSelector: { - allowHide: false, - allowReorder: true, - }, - showStyleSelector: false, - }} - gridStyle={{ - border: 'horizontal', - fontSize: 's', - cellPadding: 's', - }} - schemaDetectors={[ - { - type: kibanaJSON, - detector() { - return 0; // this schema is always explicitly defined + return ( + <> + { + onSetColumns(newColumns); }, - comparator() { - // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - return 1; + }} + pagination={{ + ...pagination, + onChangeItemsPerPage, + onChangePage, + pageSizeOptions: pageSizeArr, + }} + toolbarVisibility={{ + showColumnSelector: { + allowHide: false, + allowReorder: true, }, - sortTextAsc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - sortTextDesc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - }, - { - type: geoPoint, - detector() { - return 0; // this schema is always explicitly defined + showStyleSelector: false, + }} + gridStyle={{ + border: 'horizontal', + fontSize: 's', + cellPadding: 's', + }} + schemaDetectors={[ + { + type: kibanaJSON, + detector() { + return 0; // this schema is always explicitly defined + }, + comparator() { + // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + return 1; + }, + sortTextAsc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + sortTextDesc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 }, - comparator() { - // TODO @myasonik this column is not sortable - return 1; + { + type: geoPoint, + detector() { + return 0; // this schema is always explicitly defined + }, + comparator() { + // TODO @myasonik this column is not sortable + return 1; + }, + sortTextAsc: '', + sortTextDesc: '', + icon: 'tokenGeo', }, - sortTextAsc: '', - sortTextDesc: '', - icon: 'tokenGeo', - }, - ]} - // TODO @dsnide can make edits here per type - // Types [geoPoint], [kibanaJSON], numeric, datetime - popoverContents={{ - [geoPoint]: ({ children }) => { - return {children}; - }, - }} - /> - {showDisclaimer && ( - <> -

- {i18n.translate('discover.howToSeeOtherMatchingDocumentsDescription', { - defaultMessage: - 'These are the first {sampleSize} documents matching your search, refine your search to see others. ', - values: { sampleSize }, - })} - - {i18n.translate('discover.backToTopLinkText', { - defaultMessage: 'Back to top.', - })} - -

- - )} - {searchString && ( - -

{searchString}

-
- )} - {typeof flyoutRow !== 'undefined' && ( - setFlyoutRow(undefined)} - onRemoveColumn={onRemoveColumn} - onAddColumn={onAddColumn} + ]} + // TODO @dsnide can make edits here per type + // Types [geoPoint], [kibanaJSON], numeric, datetime + popoverContents={{ + [geoPoint]: ({ children }) => { + return {children}; + }, + }} /> - )} - - ); -}; + {showDisclaimer && ( + <> +

+ {i18n.translate('discover.howToSeeOtherMatchingDocumentsDescription', { + defaultMessage: + 'These are the first {sampleSize} documents matching your search, refine your search to see others. ', + values: { sampleSize }, + })} + + {i18n.translate('discover.backToTopLinkText', { + defaultMessage: 'Back to top.', + })} + +

+ + )} + {searchString && ( + +

{searchString}

+
+ )} + {typeof flyoutRow !== 'undefined' && ( + setFlyoutRow(undefined)} + onRemoveColumn={onRemoveColumn} + onAddColumn={onAddColumn} + /> + )} + + ); + } +); From 0b9deb023ab2612d8866ce65f9fb11d8ef6edca1 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 16 Jun 2020 09:38:21 +0200 Subject: [PATCH 044/186] Code improvements --- .../angular/discover_datagrid.html | 1 - .../discover_grid/discover_grid.tsx | 194 +++++------------- .../discover_grid/discover_grid_helpers.tsx | 134 ++++++++++++ 3 files changed, 182 insertions(+), 147 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index 6732eddd0f545..60e7f867a5009 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -125,7 +125,6 @@

{{screenTitle}}

sample-size="opts.sampleSize" search-description="opts.savedSearch.description" search-title="opts.savedSearch.lastSavedTitle" - use-short-dots="useShortDots" show-time-col="showTimeCol" get-context-app-href="getContextAppHref" on-add-column="addColumn" diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index d9f24e8963f13..18d94ecbae840 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,28 +17,31 @@ * under the License. */ -import React, { ReactNode, useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; import './discover_grid.scss'; import { i18n } from '@kbn/i18n'; import { EuiDataGrid, EuiDataGridCellValueElementProps, - EuiDataGridColumn, EuiIcon, EuiScreenReaderOnly, htmlIdGenerator, } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { shortenDottedString } from '../../helpers'; import { getDefaultSort } from '../../angular/doc_table/lib/get_default_sort'; import { CellPopover } from './discover_grid_popover'; import { DiscoverGridFlyout } from './discover_grid_flyout'; +import { + getSchemaDetectors, + getEuiGridColumns, + getPopoverContents, + getVisibleColumns, +} from './discover_grid_helpers'; type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; -const kibanaJSON = 'kibana-json'; -const geoPoint = 'geo-point'; interface SortObj { id: string; direction: Direction; @@ -54,7 +57,6 @@ interface Props { searchDescription?: string; sampleSize: number; onFilter: DocViewFilterFn; - useShortDots: boolean; showTimeCol: boolean; onSort: Function; getContextAppHref: (id: string | number | Record) => string; @@ -63,7 +65,8 @@ interface Props { onSetColumns: (columns: string[]) => void; } -const pageSizeArr = [25, 50, 100]; +const pageSizeArr = [25, 50, 100, 500]; +const defaultPageSize = 50; export const DiscoverGrid = React.memo( ({ @@ -74,7 +77,6 @@ export const DiscoverGrid = React.memo( ariaLabelledBy, searchTitle, searchDescription, - useShortDots, onSort, sampleSize, onFilter, @@ -84,86 +86,19 @@ export const DiscoverGrid = React.memo( showTimeCol, onSetColumns, }: Props) => { - const timeString = i18n.translate('discover.timeLabel', { - defaultMessage: 'Time', - }); - const [flyoutRow, setFlyoutRow] = useState(undefined); - const buildColumns = useCallback( - (cols: any) => { - return cols.map( - (columnName: string): EuiDataGridColumn => { - const column: EuiDataGridColumn = { - id: columnName, - schema: indexPattern.getFieldByName(columnName)?.type, - }; - - // Default DataGrid schemas: boolean, numeric, datetime, json, currency - // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts - switch (column.schema) { - case 'date': - column.schema = 'datetime'; - break; - case 'number': - column.schema = 'numeric'; - break; - case '_source': - case 'object': - column.schema = kibanaJSON; - break; - case 'geo_point': - column.schema = geoPoint; - break; - default: - column.schema = undefined; - break; - } - - if (useShortDots) { - column.display = <>{shortenDottedString(columnName)}; - } - if (column.id === indexPattern.timeFieldName) { - column.display = `${timeString} (${indexPattern.timeFieldName})`; - } - - return column; - } - ); - }, - [indexPattern, useShortDots, timeString] + const timeString = useMemo( + () => + i18n.translate('discover.timeLabel', { + defaultMessage: 'Time', + }), + [] ); - - const getColumns = useCallback(() => { - const timeFieldName = indexPattern.timeFieldName; - - if (showTimeCol && !columns.find((col) => col === timeFieldName)) { - return [ - { - id: indexPattern.timeFieldName, - display: `${timeString} (${indexPattern.timeFieldName})`, - schema: 'datetime', - initialWidth: 200, - } as EuiDataGridColumn, - ...buildColumns(columns), - ]; - } - - return buildColumns(columns); - }, [columns, showTimeCol, timeString, indexPattern.timeFieldName, buildColumns]); - - const getVisibleColumns = useCallback(() => { - const timeFieldName = indexPattern.timeFieldName; - - if (showTimeCol && !columns.find((col) => col === timeFieldName)) { - return [timeFieldName, ...columns]; - } - - return columns; - }, [showTimeCol, columns, indexPattern.timeFieldName]); + const [flyoutRow, setFlyoutRow] = useState(undefined); /** * Pagination */ - const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: pageSizeArr[0] }); + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize }); const onChangeItemsPerPage = useCallback( (pageSize) => setPagination((paginationData) => ({ ...paginationData, pageSize })), [setPagination] @@ -183,6 +118,7 @@ export const DiscoverGrid = React.memo( ) : sort.map(([id, direction]) => ({ id, direction })); }, [sort, indexPattern]); + const onTableSort = useCallback( (sortingColumnsData) => { onSort(sortingColumnsData.map(({ id, direction }: SortObj) => [id, direction])); @@ -235,20 +171,6 @@ export const DiscoverGrid = React.memo( const isOnLastPage = pagination.pageIndex === pageCount - 1; const showDisclaimer = rows.length === sampleSize && isOnLastPage; const randomId = useMemo(() => String(htmlIdGenerator()), []); - let searchString: ReactNode = <>; - if (searchTitle) { - if (searchDescription) { - searchString = i18n.translate('discover.searchGenerationWithDescription', { - defaultMessage: 'Table generated by search {searchTitle} ({searchDescription})', - values: { searchTitle, searchDescription }, - }); - } else { - searchString = i18n.translate('discover.searchGeneration', { - defaultMessage: 'Table generated by search {searchTitle}', - values: { searchTitle }, - }); - } - } const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const leadingControlControls = useMemo( @@ -270,7 +192,9 @@ export const DiscoverGrid = React.memo( aria-label={i18n.translate('discover.grid.viewDoc', { defaultMessage: 'Toggle dialog with details', })} - onClick={() => setFlyoutRow(rowIndex)} + onClick={() => + flyoutRow === rowIndex ? setFlyoutRow(undefined) : setFlyoutRow(rowIndex) + } className="dscTable__buttonToggle" > @@ -292,11 +216,11 @@ export const DiscoverGrid = React.memo( aria-describedby={randomId} sorting={{ columns: sortingColumns, onSort: onTableSort }} rowCount={rowCount} - columns={getColumns()} + columns={getEuiGridColumns(columns, indexPattern, showTimeCol, timeString)} renderCellValue={renderCellValue} leadingControlColumns={leadingControlControls} columnVisibility={{ - visibleColumns: getVisibleColumns() as string[], + visibleColumns: getVisibleColumns(columns, indexPattern, showTimeCol) as string[], setVisibleColumns: (newColumns) => { onSetColumns(newColumns); }, @@ -319,62 +243,40 @@ export const DiscoverGrid = React.memo( fontSize: 's', cellPadding: 's', }} - schemaDetectors={[ - { - type: kibanaJSON, - detector() { - return 0; // this schema is always explicitly defined - }, - comparator() { - // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - return 1; - }, - sortTextAsc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - sortTextDesc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - }, - { - type: geoPoint, - detector() { - return 0; // this schema is always explicitly defined - }, - comparator() { - // TODO @myasonik this column is not sortable - return 1; - }, - sortTextAsc: '', - sortTextDesc: '', - icon: 'tokenGeo', - }, - ]} - // TODO @dsnide can make edits here per type - // Types [geoPoint], [kibanaJSON], numeric, datetime - popoverContents={{ - [geoPoint]: ({ children }) => { - return {children}; - }, - }} + schemaDetectors={getSchemaDetectors()} + popoverContents={getPopoverContents()} /> {showDisclaimer && ( <>

- {i18n.translate('discover.howToSeeOtherMatchingDocumentsDescription', { - defaultMessage: - 'These are the first {sampleSize} documents matching your search, refine your search to see others. ', - values: { sampleSize }, - })} + - {i18n.translate('discover.backToTopLinkText', { - defaultMessage: 'Back to top.', - })} +

)} - {searchString && ( + {searchTitle && ( -

{searchString}

+

+ {searchDescription ? ( + + ) : ( + + )} +

)} {typeof flyoutRow !== 'undefined' && ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx new file mode 100644 index 0000000000000..0a558cdd4b975 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -0,0 +1,134 @@ +/* + * 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 React, { ReactNode } from 'react'; +import { EuiDataGridColumn } from '@elastic/eui'; +import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; + +const kibanaJSON = 'kibana-json'; +const geoPoint = 'geo-point'; + +export function getEuiGridColumns( + columns: string[], + indexPattern: IndexPattern, + showTimeCol: boolean, + timeString: string +) { + const timeFieldName = indexPattern.timeFieldName; + + if (showTimeCol && !columns.find((col) => col === timeFieldName)) { + return [ + { + id: indexPattern.timeFieldName, + display: `${timeString} (${indexPattern.timeFieldName})`, + schema: 'datetime', + initialWidth: 200, + } as EuiDataGridColumn, + ...columns.map((column) => buildEuiGridColumn(column, indexPattern, timeString)), + ]; + } + + return columns.map((column) => buildEuiGridColumn(column, indexPattern, timeString)); +} + +export function getVisibleColumns( + columns: string[], + indexPattern: IndexPattern, + showTimeCol: boolean +) { + const timeFieldName = indexPattern.timeFieldName; + + if (showTimeCol && !columns.find((col) => col === timeFieldName)) { + return [timeFieldName, ...columns]; + } + + return columns; +} + +export function buildEuiGridColumn( + columnName: string, + indexPattern: IndexPattern, + timeString: string +) { + const indexPatternField = indexPattern.getFieldByName(columnName); + const column: EuiDataGridColumn = { + id: columnName, + schema: indexPatternField?.type, + isSortable: indexPatternField?.sortable, + display: indexPatternField?.displayName, + }; + + // Default DataGrid schemas: boolean, numeric, datetime, json, currency + // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts + switch (column.schema) { + case 'date': + column.schema = 'datetime'; + break; + case 'number': + column.schema = 'numeric'; + break; + case '_source': + case 'object': + column.schema = kibanaJSON; + break; + case 'geo_point': + column.schema = geoPoint; + break; + default: + column.schema = undefined; + break; + } + if (column.id === indexPattern.timeFieldName) { + column.display = `${timeString} (${indexPattern.timeFieldName})`; + } + return column; +} + +// TODO @dsnide can make edits here per type +// Types [geoPoint], [kibanaJSON], numeric, datetime +export function getSchemaDetectors() { + return [ + { + type: kibanaJSON, + detector() { + return 0; // this schema is always explicitly defined + }, + sortTextAsc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + sortTextDesc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + }, + { + type: geoPoint, + detector() { + return 0; // this schema is always explicitly defined + }, + sortTextAsc: '', + sortTextDesc: '', + icon: 'tokenGeo', + }, + ]; +} + +export function getPopoverContents() { + return { + [geoPoint]: ({ children }: { children: ReactNode }) => { + return {children}; + }, + }; +} From 5c7b26ca00752d6234f9bfe3b4f396a0e0ad1e96 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 16 Jun 2020 12:48:11 +0200 Subject: [PATCH 045/186] Even more code improvements --- .../discover_grid/discover_grid.tsx | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 18d94ecbae840..1cd429ee54c1e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -64,7 +64,18 @@ interface Props { onAddColumn: (column: string) => void; onSetColumns: (columns: string[]) => void; } - +const toolbarVisibility = { + showColumnSelector: { + allowHide: false, + allowReorder: true, + }, + showStyleSelector: false, +}; +const gridStyle = { + border: 'horizontal', + fontSize: 's', + cellPadding: 's', +}; const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; @@ -99,14 +110,21 @@ export const DiscoverGrid = React.memo( * Pagination */ const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize }); - const onChangeItemsPerPage = useCallback( - (pageSize) => setPagination((paginationData) => ({ ...paginationData, pageSize })), - [setPagination] - ); - const onChangePage = useCallback( - (pageIndex) => setPagination((paginationData) => ({ ...paginationData, pageIndex })), - [setPagination] - ); + + const getPaginationObj = useCallback(() => { + const onChangeItemsPerPage = (pageSize) => + setPagination((paginationData) => ({ ...paginationData, pageSize })); + + const onChangePage = (pageIndex) => + setPagination((paginationData) => ({ ...paginationData, pageIndex })); + + return { + ...pagination, + onChangeItemsPerPage, + onChangePage, + pageSizeOptions: pageSizeArr, + }; + }, [pagination]); /** * Sorting @@ -225,24 +243,9 @@ export const DiscoverGrid = React.memo( onSetColumns(newColumns); }, }} - pagination={{ - ...pagination, - onChangeItemsPerPage, - onChangePage, - pageSizeOptions: pageSizeArr, - }} - toolbarVisibility={{ - showColumnSelector: { - allowHide: false, - allowReorder: true, - }, - showStyleSelector: false, - }} - gridStyle={{ - border: 'horizontal', - fontSize: 's', - cellPadding: 's', - }} + pagination={getPaginationObj()} + toolbarVisibility={toolbarVisibility} + gridStyle={gridStyle} schemaDetectors={getSchemaDetectors()} popoverContents={getPopoverContents()} /> From 3d849819c9f8ba6df2bbcc197cfa7e74e94075e3 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 16 Jun 2020 17:39:56 +0200 Subject: [PATCH 046/186] Debugging version for chandler --- .../discover_grid/discover_grid.tsx | 67 +++++++++++++++---- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 1cd429ee54c1e..20087a176196a 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -79,6 +79,32 @@ const gridStyle = { const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; +/** + * TODO remove this component just used for debugging + */ +class EuiDataGridWrapper extends React.Component> { + /** + componentWillReceiveProps(nextProps: Props

) { + Object.keys(nextProps) + .filter((key) => nextProps[key] !== this.props[key]) + .map((key) => { + console.log('changed property:', key, 'from', this.props[key], 'to', nextProps[key]); + }); + }*/ + shouldComponentUpdate( + nextProps: Readonly>, + nextState: Readonly<{}>, + nextContext: any + ): boolean { + return Object.keys(nextProps).filter((key) => nextProps[key] !== this.props[key]).length !== 0; + } + + render() { + // @ts-ignore + return ; + } +} + export const DiscoverGrid = React.memo( ({ rows, @@ -111,7 +137,7 @@ export const DiscoverGrid = React.memo( */ const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize }); - const getPaginationObj = useCallback(() => { + const paginationObj = useMemo(() => { const onChangeItemsPerPage = (pageSize) => setPagination((paginationData) => ({ ...paginationData, pageSize })); @@ -191,6 +217,26 @@ export const DiscoverGrid = React.memo( const randomId = useMemo(() => String(htmlIdGenerator()), []); const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); + const euiGridColumns = useMemo( + () => getEuiGridColumns(columns, indexPattern, showTimeCol, timeString), + [columns, indexPattern, showTimeCol, timeString] + ); + const schemaDetectors = useMemo(() => getSchemaDetectors(), []); + const popoverContents = useMemo(() => getPopoverContents(), []); + const colummsVisibility = useMemo( + () => ({ + visibleColumns: getVisibleColumns(columns, indexPattern, showTimeCol) as string[], + setVisibleColumns: (newColumns) => { + onSetColumns(newColumns); + }, + }), + [columns, indexPattern, showTimeCol, onSetColumns] + ); + const sorting = useMemo(() => ({ columns: sortingColumns, onSort: onTableSort }), [ + sortingColumns, + onTableSort, + ]); + const leadingControlControls = useMemo( () => [ { @@ -229,25 +275,20 @@ export const DiscoverGrid = React.memo( return ( <> - { - onSetColumns(newColumns); - }, - }} - pagination={getPaginationObj()} + columnVisibility={colummsVisibility} + pagination={paginationObj} toolbarVisibility={toolbarVisibility} gridStyle={gridStyle} - schemaDetectors={getSchemaDetectors()} - popoverContents={getPopoverContents()} + schemaDetectors={schemaDetectors} + popoverContents={popoverContents} /> {showDisclaimer && ( <> From 5c2cfc52e1a52d689f28ebc88528be02d8dc0e29 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 18 Jun 2020 10:26:06 +0200 Subject: [PATCH 047/186] Refactor to use context for flyout --- .../discover_grid/discover_grid.tsx | 46 +++++-------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 20087a176196a..83c62e86db777 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -27,6 +27,7 @@ import { EuiIcon, EuiScreenReaderOnly, htmlIdGenerator, + EuiDataGridStyle, } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; @@ -75,36 +76,10 @@ const gridStyle = { border: 'horizontal', fontSize: 's', cellPadding: 's', -}; +} as EuiDataGridStyle; const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; -/** - * TODO remove this component just used for debugging - */ -class EuiDataGridWrapper extends React.Component> { - /** - componentWillReceiveProps(nextProps: Props

) { - Object.keys(nextProps) - .filter((key) => nextProps[key] !== this.props[key]) - .map((key) => { - console.log('changed property:', key, 'from', this.props[key], 'to', nextProps[key]); - }); - }*/ - shouldComponentUpdate( - nextProps: Readonly>, - nextState: Readonly<{}>, - nextContext: any - ): boolean { - return Object.keys(nextProps).filter((key) => nextProps[key] !== this.props[key]).length !== 0; - } - - render() { - // @ts-ignore - return ; - } -} - export const DiscoverGrid = React.memo( ({ rows, @@ -138,10 +113,10 @@ export const DiscoverGrid = React.memo( const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize }); const paginationObj = useMemo(() => { - const onChangeItemsPerPage = (pageSize) => + const onChangeItemsPerPage = (pageSize: number) => setPagination((paginationData) => ({ ...paginationData, pageSize })); - const onChangePage = (pageIndex) => + const onChangePage = (pageIndex: number) => setPagination((paginationData) => ({ ...paginationData, pageIndex })); return { @@ -226,7 +201,7 @@ export const DiscoverGrid = React.memo( const colummsVisibility = useMemo( () => ({ visibleColumns: getVisibleColumns(columns, indexPattern, showTimeCol) as string[], - setVisibleColumns: (newColumns) => { + setVisibleColumns: (newColumns: string[]) => { onSetColumns(newColumns); }, }), @@ -256,9 +231,12 @@ export const DiscoverGrid = React.memo( aria-label={i18n.translate('discover.grid.viewDoc', { defaultMessage: 'Toggle dialog with details', })} - onClick={() => - flyoutRow === rowIndex ? setFlyoutRow(undefined) : setFlyoutRow(rowIndex) - } + onClick={(event) => { + event.stopPropagation(); + event.preventDefault(); + const newIndex = flyoutRow === rowIndex ? undefined : rowIndex; + setFlyoutRow(newIndex); + }} className="dscTable__buttonToggle" > @@ -275,7 +253,7 @@ export const DiscoverGrid = React.memo( return ( <> - Date: Thu, 18 Jun 2020 13:26:04 +0200 Subject: [PATCH 048/186] Refactor to use context for flyout II --- .../discover_grid/discover_grid.tsx | 162 +++++++++--------- 1 file changed, 83 insertions(+), 79 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 83c62e86db777..0cc0b1a7409cb 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,7 +17,7 @@ * under the License. */ -import React, { useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useMemo, useState, useContext } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import './discover_grid.scss'; import { i18n } from '@kbn/i18n'; @@ -27,7 +27,6 @@ import { EuiIcon, EuiScreenReaderOnly, htmlIdGenerator, - EuiDataGridStyle, } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; @@ -76,9 +75,30 @@ const gridStyle = { border: 'horizontal', fontSize: 's', cellPadding: 's', -} as EuiDataGridStyle; +}; const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; +// @ts-ignore +const DiscoverGridContext = React.createContext(); + +export const SelectButton = ({ rowIndex }: { rowIndex: number }) => { + // @ts-ignore + const [flyoutRow, setFlyoutRow] = useContext(DiscoverGridContext); + + return ( + + ); +}; + +export const EuiDataGridMemoized = React.memo((props: any) => ); export const DiscoverGrid = React.memo( ({ @@ -98,6 +118,8 @@ export const DiscoverGrid = React.memo( showTimeCol, onSetColumns, }: Props) => { + const flyoutRowState = useState(-1); + const [flyoutRow, setFlyoutRow] = flyoutRowState; const timeString = useMemo( () => i18n.translate('discover.timeLabel', { @@ -105,8 +127,6 @@ export const DiscoverGrid = React.memo( }), [] ); - const [flyoutRow, setFlyoutRow] = useState(undefined); - /** * Pagination */ @@ -211,9 +231,8 @@ export const DiscoverGrid = React.memo( sortingColumns, onTableSort, ]); - - const leadingControlControls = useMemo( - () => [ + const lead = useMemo(() => { + return [ { id: 'openDetails', width: 31, @@ -226,50 +245,35 @@ export const DiscoverGrid = React.memo( ), - rowCellRender: ({ rowIndex }: { rowIndex: number }) => ( - - ), + rowCellRender: SelectButton, }, - ], - [flyoutRow] - ); + ]; + }, []); if (!rowCount) { return null; } return ( - <> - - {showDisclaimer && ( - <> + + <> + + + {showDisclaimer && (

- - )} - {searchTitle && ( - -

- {searchDescription ? ( - - ) : ( - - )} -

-
- )} - {typeof flyoutRow !== 'undefined' && ( - setFlyoutRow(undefined)} - onRemoveColumn={onRemoveColumn} - onAddColumn={onAddColumn} - /> - )} - + )} + {searchTitle && ( + +

+ {searchDescription ? ( + + ) : ( + + )} +

+
+ )} + {flyoutRow >= 0 && ( + setFlyoutRow(-1)} + /> + )} + + ); } ); From 7a5db4675020830a3abe2ce341ce1c007839d82f Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 23 Jun 2020 10:09:41 +0200 Subject: [PATCH 049/186] Datagrid vision --- .../discover_grid/discover_grid.scss | 13 + .../discover_grid/discover_grid.tsx | 226 ++++++++++++++++-- .../discover_grid/discover_grid_flyout.tsx | 4 +- .../discover_grid_flyout_advanced_grid.tsx | 161 +++++++++++++ 4 files changed, 384 insertions(+), 20 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index d4babf1216c6d..40797ce0d707d 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -12,3 +12,16 @@ div[data-rbd-draggable-id="Time"] { display: none; } + + +.dscEuiDataGridRowCell .euiDataGridRowCell { + align-items: start; +} + +.dscValue { + position: relative; +} + +.dscValue .dscValueFilter{ + background: $euiColorLightShade; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 0cc0b1a7409cb..cbf661dacd269 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,7 +17,7 @@ * under the License. */ -import React, { useCallback, useMemo, useState, useContext } from 'react'; +import React, { useCallback, useMemo, useState, useContext, ReactNode } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import './discover_grid.scss'; import { i18n } from '@kbn/i18n'; @@ -26,19 +26,25 @@ import { EuiDataGridCellValueElementProps, EuiIcon, EuiScreenReaderOnly, + EuiCheckbox, htmlIdGenerator, + EuiButtonEmpty, + EuiFlexGroup, + EuiFlexItem, + EuiButtonIcon, } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; import { getDefaultSort } from '../../angular/doc_table/lib/get_default_sort'; import { CellPopover } from './discover_grid_popover'; -import { DiscoverGridFlyout } from './discover_grid_flyout'; import { getSchemaDetectors, getEuiGridColumns, getPopoverContents, getVisibleColumns, } from './discover_grid_helpers'; +import { DiscoverGridFlyoutAdvancedGrid } from './discover_grid_flyout_advanced_grid'; +import { DiscoverGridFlyout } from './discover_grid_flyout'; type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; @@ -46,6 +52,14 @@ interface SortObj { id: string; direction: Direction; } +interface GridContext { + viewed: number; + setViewed: (id: number) => void; + selected: number[]; + setSelected: (ids: number[]) => void; + showSelected: boolean; + setShowSelected: (value: boolean) => void; +} interface Props { rows: ElasticSearchHit[]; @@ -64,12 +78,28 @@ interface Props { onAddColumn: (column: string) => void; onSetColumns: (columns: string[]) => void; } + +const Selection = () => { + const { selected, showSelected, setShowSelected } = useContext(DiscoverGridContext); + return ( + setShowSelected(!showSelected)} + > + {selected.length} {selected.length === 1 ? 'hit' : 'hits'} selected + + ); +}; const toolbarVisibility = { showColumnSelector: { allowHide: false, allowReorder: true, }, showStyleSelector: false, + additionalControls: , }; const gridStyle = { border: 'horizontal', @@ -78,26 +108,141 @@ const gridStyle = { }; const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; -// @ts-ignore -const DiscoverGridContext = React.createContext(); -export const SelectButton = ({ rowIndex }: { rowIndex: number }) => { - // @ts-ignore - const [flyoutRow, setFlyoutRow] = useContext(DiscoverGridContext); +const DiscoverGridContext = React.createContext({ + viewed: -1, + setViewed: () => void 0, + selected: [], + setSelected: () => void 0, + showSelected: false, + setShowSelected: () => void 0, +}); + +export const ViewButton = ({ rowIndex }: { rowIndex: number }) => { + const { viewed, setViewed } = useContext(DiscoverGridContext); return ( ); }; +export const SelectButton = ({ col, rows }: { col: any; rows: ElasticSearchHit[] }) => { + const { selected, setSelected } = useContext(DiscoverGridContext); + const rowIndex = col.rowIndex; + const isChecked = selected.includes(rowIndex); + + return ( + { + if (e.target.checked) { + setSelected([...selected, rowIndex]); + } else { + setSelected(selected.filter((idx: number) => idx !== rowIndex)); + } + }} + /> + ); +}; + +const ValueWithFilter = ({ + value, + columnId, + row, + indexPattern, + onFilter, +}: { + value: ReactNode; + columnId: string; + row: ElasticSearchHit; + indexPattern: IndexPattern; + onFilter: DocViewFilterFn; +}) => { + const [hover, setHover] = useState(false); + const createFilter = (type: '-' | '+') => { + return onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + type + ); + }; + if (hover) { + return ( + setHover(false)} + onBlur={() => setHover(false)} + gutterSize="none" + alignItems="center" + responsive={false} + className="eui-textTruncate" + > + {value} + +
+ createFilter('+')} + style={{ + padding: 0, + minHeight: 'auto', + minWidth: 'auto', + paddingRight: 2, + paddingLeft: 2, + paddingTop: 0, + paddingBottom: 0, + }} + /> + createFilter('-')} + style={{ + padding: 0, + minHeight: 'auto', + minWidth: 'auto', + paddingRight: 2, + paddingLeft: 2, + paddingTop: 0, + paddingBottom: 0, + }} + /> +
+
+
+ ); + } else { + return ( +
setHover(true)} + onFocus={() => setHover(true)} + > + {value} +
+ ); + } +}; + export const EuiDataGridMemoized = React.memo((props: any) => ); export const DiscoverGrid = React.memo( @@ -118,8 +263,9 @@ export const DiscoverGrid = React.memo( showTimeCol, onSetColumns, }: Props) => { - const flyoutRowState = useState(-1); - const [flyoutRow, setFlyoutRow] = flyoutRowState; + const [showSelected, setShowSelected] = useState(false); + const [selected, setSelected] = useState([]); + const [viewed, setViewed] = useState(-1); const timeString = useMemo( () => i18n.translate('discover.timeLabel', { @@ -127,6 +273,7 @@ export const DiscoverGrid = React.memo( }), [] ); + /** * Pagination */ @@ -175,9 +322,8 @@ export const DiscoverGrid = React.memo( if (typeof row === 'undefined') { return '-'; } - + // TODO Field formatters need to be fixed const value = ( - // TODO Field formatters need to be fixed // eslint-disable-next-line react/no-danger ); @@ -190,6 +336,7 @@ export const DiscoverGrid = React.memo( type ); }; + return ( createFilter(columnId, '-')} /> ); + } else if (indexPattern.fields.getByName(columnId)?.filterable) { + return ( + + ); } return value; }, @@ -233,6 +390,20 @@ export const DiscoverGrid = React.memo( ]); const lead = useMemo(() => { return [ + { + id: 'checkBox', + width: 31, + headerCellRender: () => ( + + + {i18n.translate('discover.selectColumnHeader', { + defaultMessage: 'Select column', + })} + + + ), + rowCellRender: (col: number) => , + }, { id: 'openDetails', width: 31, @@ -245,17 +416,19 @@ export const DiscoverGrid = React.memo( ), - rowCellRender: SelectButton, + rowCellRender: ViewButton, }, ]; - }, []); + }, [rows]); if (!rowCount) { return null; } return ( - + <> )} - {flyoutRow >= 0 && ( + {viewed > -1 && rows[viewed] && ( { + setViewed(-1); + }} + /> + )} + {showSelected && selected.length > 0 && ( + setFlyoutRow(-1)} + onClose={() => setShowSelected(false)} /> )} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index ec3a8f4ee1521..f600ae8113a9d 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -20,6 +20,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { + EuiAccordion, EuiFlexGroup, EuiFlexItem, EuiFlyout, @@ -33,11 +34,12 @@ import { import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { JsonCodeBlock } from '../json_code_block/json_code_block'; interface Props { + hit: ElasticSearchHit; columns: string[]; getContextAppHref: (id: string | number | Record) => string; - hit: ElasticSearchHit; indexPattern: IndexPattern; onAddColumn: (column: string) => void; onClose: () => void; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx new file mode 100644 index 0000000000000..10251b5d24903 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx @@ -0,0 +1,161 @@ +/* + * 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 React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiAccordion, + EuiDataGrid, + EuiDataGridCellValueElementProps, + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiIcon, + EuiPortal, + EuiTitle, + EuiButtonGroup, +} from '@elastic/eui'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { JsonCodeBlock } from '../json_code_block/json_code_block'; +import { IndexPattern } from '../../../kibana_services'; + +interface Props { + indexPattern: IndexPattern; + rows: ElasticSearchHit[]; + selected: number[]; + onClose: () => void; +} + +export const DiscoverGridFlyoutAdvancedGrid = function DiscoverGridInner({ + indexPattern, + rows, + selected, + + onClose, +}: Props) { + const [direction, setDirection] = useState('column'); + if (!rows.length) { + return null; + } + + return ( + + onClose()} size="m"> + + + + +

+ {' '} + {i18n.translate('discover.grid.tableRow.selectedDocuments', { + defaultMessage: 'Selected hits', + })} +

+
+
+ + + + setDirection(id)} + type="multi" + /> + + + +
+
+ +

+ {i18n.translate('discover.grid.documentSelectionAriaLabel', { + defaultMessage: 'Document Selection', + })} +

+ {selected.length > 0 && ( + ({ + id: String(id), + isExpandable: false, + width: 300, + display: String(id), + })) + } + toolbarVisibility={false} + columnVisibility={{ + visibleColumns: + direction === 'column' ? ['_source'] : selected.map((id) => String(id)), + setVisibleColumns: () => void 0, + }} + rowCount={selected.length} + renderCellValue={({ + rowIndex, + columnId, + isDetails, + }: EuiDataGridCellValueElementProps) => { + return ( +
+ +
+ +
+
+
+ ); + }} + /> + )} +
+
+
+ ); +}; From 80ad99e4aab09ee697d7d8adfd026b99fb16dbe0 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 26 Jun 2020 12:28:48 +0200 Subject: [PATCH 050/186] cleanup and split of components into files --- .../discover_grid/discover_grid.tsx | 191 ++---------------- .../discover_grid/discover_grid_context.tsx | 37 ++++ .../discover_grid/discover_grid_flyout.tsx | 2 - .../discover_grid_flyout_advanced_grid.tsx | 161 --------------- .../discover_grid_flyout_selection.tsx | 99 +++++++++ .../discover_grid/discover_grid_popover.tsx | 2 +- .../discover_grid_select_button.tsx | 43 ++++ .../discover_grid_toolbar_selection.tsx | 36 ++++ .../discover_grid_view_button.tsx | 38 ++++ .../discover_value_with_filter.tsx | 125 ++++++++++++ 10 files changed, 393 insertions(+), 341 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index cbf661dacd269..fe806e19daae9 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -16,35 +16,33 @@ * specific language governing permissions and limitations * under the License. */ - -import React, { useCallback, useMemo, useState, useContext, ReactNode } from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import './discover_grid.scss'; import { i18n } from '@kbn/i18n'; import { EuiDataGrid, EuiDataGridCellValueElementProps, - EuiIcon, EuiScreenReaderOnly, - EuiCheckbox, htmlIdGenerator, - EuiButtonEmpty, - EuiFlexGroup, - EuiFlexItem, - EuiButtonIcon, } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; import { getDefaultSort } from '../../angular/doc_table/lib/get_default_sort'; -import { CellPopover } from './discover_grid_popover'; +import { DiscoverGridPopover } from './discover_grid_popover'; import { - getSchemaDetectors, getEuiGridColumns, getPopoverContents, + getSchemaDetectors, getVisibleColumns, } from './discover_grid_helpers'; -import { DiscoverGridFlyoutAdvancedGrid } from './discover_grid_flyout_advanced_grid'; +import { DiscoverGridFlyoutSelection } from './discover_grid_flyout_selection'; import { DiscoverGridFlyout } from './discover_grid_flyout'; +import { DiscoverGridValueWithFilter } from './discover_value_with_filter'; +import { DiscoverGridToolbarSelection } from './discover_grid_toolbar_selection'; +import { DiscoverGridContext } from './discover_grid_context'; +import { DiscoverGridSelectButton } from './discover_grid_select_button'; +import { ViewButton } from './discover_grid_view_button'; type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; @@ -52,14 +50,6 @@ interface SortObj { id: string; direction: Direction; } -interface GridContext { - viewed: number; - setViewed: (id: number) => void; - selected: number[]; - setSelected: (ids: number[]) => void; - showSelected: boolean; - setShowSelected: (value: boolean) => void; -} interface Props { rows: ElasticSearchHit[]; @@ -79,27 +69,13 @@ interface Props { onSetColumns: (columns: string[]) => void; } -const Selection = () => { - const { selected, showSelected, setShowSelected } = useContext(DiscoverGridContext); - return ( - setShowSelected(!showSelected)} - > - {selected.length} {selected.length === 1 ? 'hit' : 'hits'} selected - - ); -}; const toolbarVisibility = { showColumnSelector: { allowHide: false, allowReorder: true, }, showStyleSelector: false, - additionalControls: , + additionalControls: , }; const gridStyle = { border: 'horizontal', @@ -109,140 +85,6 @@ const gridStyle = { const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; -const DiscoverGridContext = React.createContext({ - viewed: -1, - setViewed: () => void 0, - selected: [], - setSelected: () => void 0, - showSelected: false, - setShowSelected: () => void 0, -}); - -export const ViewButton = ({ rowIndex }: { rowIndex: number }) => { - const { viewed, setViewed } = useContext(DiscoverGridContext); - - return ( - - ); -}; - -export const SelectButton = ({ col, rows }: { col: any; rows: ElasticSearchHit[] }) => { - const { selected, setSelected } = useContext(DiscoverGridContext); - const rowIndex = col.rowIndex; - const isChecked = selected.includes(rowIndex); - - return ( - { - if (e.target.checked) { - setSelected([...selected, rowIndex]); - } else { - setSelected(selected.filter((idx: number) => idx !== rowIndex)); - } - }} - /> - ); -}; - -const ValueWithFilter = ({ - value, - columnId, - row, - indexPattern, - onFilter, -}: { - value: ReactNode; - columnId: string; - row: ElasticSearchHit; - indexPattern: IndexPattern; - onFilter: DocViewFilterFn; -}) => { - const [hover, setHover] = useState(false); - const createFilter = (type: '-' | '+') => { - return onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - type - ); - }; - if (hover) { - return ( - setHover(false)} - onBlur={() => setHover(false)} - gutterSize="none" - alignItems="center" - responsive={false} - className="eui-textTruncate" - > - {value} - -
- createFilter('+')} - style={{ - padding: 0, - minHeight: 'auto', - minWidth: 'auto', - paddingRight: 2, - paddingLeft: 2, - paddingTop: 0, - paddingBottom: 0, - }} - /> - createFilter('-')} - style={{ - padding: 0, - minHeight: 'auto', - minWidth: 'auto', - paddingRight: 2, - paddingLeft: 2, - paddingTop: 0, - paddingBottom: 0, - }} - /> -
-
-
- ); - } else { - return ( -
setHover(true)} - onFocus={() => setHover(true)} - > - {value} -
- ); - } -}; - export const EuiDataGridMemoized = React.memo((props: any) => ); export const DiscoverGrid = React.memo( @@ -338,7 +180,7 @@ export const DiscoverGrid = React.memo( }; return ( - createFilter(columnId, '+')} onNegativeFilterClick={() => createFilter(columnId, '-')} @@ -346,7 +188,7 @@ export const DiscoverGrid = React.memo( ); } else if (indexPattern.fields.getByName(columnId)?.filterable) { return ( - ), - rowCellRender: (col: number) => , + rowCellRender: (col: number) => , }, { id: 'openDetails', @@ -481,7 +323,6 @@ export const DiscoverGrid = React.memo( )} {showSelected && selected.length > 0 && ( - setShowSelected(false)} /> )} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx new file mode 100644 index 0000000000000..db4ea05178d77 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx @@ -0,0 +1,37 @@ +/* + * 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 React from 'react'; + +export interface GridContext { + viewed: number; + setViewed: (id: number) => void; + selected: number[]; + setSelected: (ids: number[]) => void; + showSelected: boolean; + setShowSelected: (value: boolean) => void; +} + +export const DiscoverGridContext = React.createContext({ + viewed: -1, + setViewed: () => void 0, + selected: [], + setSelected: () => void 0, + showSelected: false, + setShowSelected: () => void 0, +}); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index f600ae8113a9d..378c03d02cf10 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -20,7 +20,6 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { - EuiAccordion, EuiFlexGroup, EuiFlexItem, EuiFlyout, @@ -34,7 +33,6 @@ import { import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { JsonCodeBlock } from '../json_code_block/json_code_block'; interface Props { hit: ElasticSearchHit; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx deleted file mode 100644 index 10251b5d24903..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_advanced_grid.tsx +++ /dev/null @@ -1,161 +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 React, { useState } from 'react'; -import { i18n } from '@kbn/i18n'; -import { - EuiAccordion, - EuiDataGrid, - EuiDataGridCellValueElementProps, - EuiFlexGroup, - EuiFlexItem, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiIcon, - EuiPortal, - EuiTitle, - EuiButtonGroup, -} from '@elastic/eui'; -import { ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { JsonCodeBlock } from '../json_code_block/json_code_block'; -import { IndexPattern } from '../../../kibana_services'; - -interface Props { - indexPattern: IndexPattern; - rows: ElasticSearchHit[]; - selected: number[]; - onClose: () => void; -} - -export const DiscoverGridFlyoutAdvancedGrid = function DiscoverGridInner({ - indexPattern, - rows, - selected, - - onClose, -}: Props) { - const [direction, setDirection] = useState('column'); - if (!rows.length) { - return null; - } - - return ( - - onClose()} size="m"> - - - - -

- {' '} - {i18n.translate('discover.grid.tableRow.selectedDocuments', { - defaultMessage: 'Selected hits', - })} -

-
-
- - - - setDirection(id)} - type="multi" - /> - - - -
-
- -

- {i18n.translate('discover.grid.documentSelectionAriaLabel', { - defaultMessage: 'Document Selection', - })} -

- {selected.length > 0 && ( - ({ - id: String(id), - isExpandable: false, - width: 300, - display: String(id), - })) - } - toolbarVisibility={false} - columnVisibility={{ - visibleColumns: - direction === 'column' ? ['_source'] : selected.map((id) => String(id)), - setVisibleColumns: () => void 0, - }} - rowCount={selected.length} - renderCellValue={({ - rowIndex, - columnId, - isDetails, - }: EuiDataGridCellValueElementProps) => { - return ( -
- -
- -
-
-
- ); - }} - /> - )} -
-
-
- ); -}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx new file mode 100644 index 0000000000000..56f725ddcc170 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx @@ -0,0 +1,99 @@ +/* + * 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 React from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiAccordion, + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiIcon, + EuiPortal, + EuiTitle, +} from '@elastic/eui'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { JsonCodeBlock } from '../json_code_block/json_code_block'; +import { IndexPattern } from '../../../kibana_services'; + +interface Props { + indexPattern: IndexPattern; + rows: ElasticSearchHit[]; + selected: number[]; + onClose: () => void; +} + +export function DiscoverGridFlyoutSelection({ + indexPattern, + rows, + selected, + + onClose, +}: Props) { + return ( + + onClose()} size="m"> + + + + +

+ {' '} + {i18n.translate('discover.grid.tableRow.selectedDocuments', { + defaultMessage: 'Selected hits', + })} +

+
+
+
+
+ +

+ {i18n.translate('discover.grid.documentSelectionAriaLabel', { + defaultMessage: 'Document Selection', + })} +

+ {selected.length > 0 && + selected.map((rowIndex) => ( +
+ +
+ +
+
+
+ ))} +
+
+
+ ); +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx index 1eeb791c99233..3cbb8a972ccc9 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx @@ -26,7 +26,7 @@ import { useRenderToText, } from '@elastic/eui'; -export function CellPopover({ +export function DiscoverGridPopover({ value, onPositiveFilterClick, onNegativeFilterClick, diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx new file mode 100644 index 0000000000000..858a30a7ebc7b --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx @@ -0,0 +1,43 @@ +/* + * 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 React, { useContext } from 'react'; +import { EuiCheckbox } from '@elastic/eui'; +import { GridContext, DiscoverGridContext } from './discover_grid_context'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; + +export const DiscoverGridSelectButton = ({ col, rows }: { col: any; rows: ElasticSearchHit[] }) => { + const { selected, setSelected } = useContext(DiscoverGridContext); + const rowIndex = col.rowIndex; + const isChecked = selected.includes(rowIndex); + + return ( + { + if (e.target.checked) { + setSelected([...selected, rowIndex]); + } else { + setSelected(selected.filter((idx: number) => idx !== rowIndex)); + } + }} + /> + ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx new file mode 100644 index 0000000000000..bc1d222bd7fdc --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx @@ -0,0 +1,36 @@ +/* + * 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 React, { useContext } from 'react'; +import { EuiButtonEmpty } from '@elastic/eui'; +import { DiscoverGridContext, GridContext } from './discover_grid_context'; + +export const DiscoverGridToolbarSelection = () => { + const { selected, showSelected, setShowSelected } = useContext(DiscoverGridContext); + return ( + setShowSelected(!showSelected)} + > + {selected.length} {selected.length === 1 ? 'hit' : 'hits'} selected + + ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx new file mode 100644 index 0000000000000..0608e541a1194 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx @@ -0,0 +1,38 @@ +/* + * 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 React, { useContext } from 'react'; +import { EuiIcon } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { DiscoverGridContext, GridContext } from './discover_grid_context'; + +export const ViewButton = ({ rowIndex }: { rowIndex: number }) => { + const { viewed, setViewed } = useContext(DiscoverGridContext); + + return ( + + ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx new file mode 100644 index 0000000000000..35772186bc112 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx @@ -0,0 +1,125 @@ +/* + * 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 React, { ReactNode, useState } from 'react'; +import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; + +/** + * Draft component displaying filter lens icons on hover with the possibility to add a filter + */ +export const DiscoverGridValueWithFilter = ({ + value, + columnId, + row, + indexPattern, + onFilter, +}: { + value: ReactNode; + columnId: string; + row: ElasticSearchHit; + indexPattern: IndexPattern; + onFilter: DocViewFilterFn; +}) => { + const [hover, setHover] = useState(false); + if (hover) { + return ( + setHover(false)} + onBlur={() => setHover(false)} + gutterSize="none" + alignItems="center" + responsive={false} + className="eui-textTruncate" + > + + {value} + + +
+ ) => { + ev.stopPropagation(); + ev.preventDefault(); + onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + '+' + ); + }} + style={{ + padding: 0, + minHeight: 'auto', + minWidth: 'auto', + paddingRight: 2, + paddingLeft: 2, + paddingTop: 0, + paddingBottom: 0, + }} + /> + ) => { + ev.stopPropagation(); + ev.preventDefault(); + onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + '-' + ); + }} + style={{ + padding: 0, + minHeight: 'auto', + minWidth: 'auto', + paddingRight: 2, + paddingLeft: 2, + paddingTop: 0, + paddingBottom: 0, + }} + /> +
+
+
+ ); + } else { + return ( +
setHover(true)} + onFocus={() => setHover(true)} + > + {value} +
+ ); + } +}; From 9395e51dc69d9bbf31b3a420caf1955f04ade425 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 9 Jul 2020 17:00:51 +0200 Subject: [PATCH 051/186] Migrate discover.html to discover.tsx --- .../angular/directives/{index.js => index.ts} | 9 +- .../public/application/angular/discover.html | 8 +- .../public/application/angular/discover.js | 2 +- .../angular/discover_datagrid.html | 179 ++++----------- .../components/create_discover_directive.ts | 62 +++++ .../application/components/discover.tsx | 213 ++++++++++++++++++ .../discover_grid/discover_grid.scss | 50 +++- .../discover_grid/discover_grid.tsx | 1 + .../discover_grid/discover_grid_popover.tsx | 4 +- .../discover_value_with_filter.tsx | 137 +++++------ .../components/fetch_error/fetch_error.tsx | 6 +- .../fetch_error/{index.js => index.ts} | 2 +- src/plugins/discover/public/build_services.ts | 3 + .../discover/public/get_inner_angular.ts | 14 +- 14 files changed, 445 insertions(+), 245 deletions(-) rename src/plugins/discover/public/application/angular/directives/{index.js => index.ts} (77%) create mode 100644 src/plugins/discover/public/application/components/create_discover_directive.ts create mode 100644 src/plugins/discover/public/application/components/discover.tsx rename src/plugins/discover/public/application/components/fetch_error/{index.js => index.ts} (93%) diff --git a/src/plugins/discover/public/application/angular/directives/index.js b/src/plugins/discover/public/application/angular/directives/index.ts similarity index 77% rename from src/plugins/discover/public/application/angular/directives/index.js rename to src/plugins/discover/public/application/angular/directives/index.ts index 5d8969a78f018..e42139ac95add 100644 --- a/src/plugins/discover/public/application/angular/directives/index.js +++ b/src/plugins/discover/public/application/angular/directives/index.ts @@ -17,6 +17,7 @@ * under the License. */ +// @ts-ignore import { DiscoverNoResults } from './no_results'; import { DiscoverUninitialized } from './uninitialized'; import { DiscoverHistogram } from './histogram'; @@ -24,8 +25,10 @@ import { getAngularModule } from '../../../kibana_services'; const app = getAngularModule(); -app.directive('discoverNoResults', (reactDirective) => reactDirective(DiscoverNoResults)); +app.directive('discoverNoResults', (reactDirective: any) => reactDirective(DiscoverNoResults)); -app.directive('discoverUninitialized', (reactDirective) => reactDirective(DiscoverUninitialized)); +app.directive('discoverUninitialized', (reactDirective: any) => + reactDirective(DiscoverUninitialized) +); -app.directive('discoverHistogram', (reactDirective) => reactDirective(DiscoverHistogram)); +app.directive('discoverHistogram', (reactDirective: any) => reactDirective(DiscoverHistogram)); diff --git a/src/plugins/discover/public/application/angular/discover.html b/src/plugins/discover/public/application/angular/discover.html index 48a8442b06316..1f3aa82c9d62a 100644 --- a/src/plugins/discover/public/application/angular/discover.html +++ b/src/plugins/discover/public/application/angular/discover.html @@ -79,11 +79,11 @@

{{screenTitle}}

class="dscTimechart" ng-if="opts.timefield" > - { diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index 60e7f867a5009..c91df8936c546 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -1,142 +1,47 @@ -

{{screenTitle}}

- - - - - -
- - - - -
- - - - - -
- - -
-

-
-
-
-
- -
-
-
- - -
-
- -
-
- -
-
- -
- -
-

- -
-
-
-
-
+
diff --git a/src/plugins/discover/public/application/components/create_discover_directive.ts b/src/plugins/discover/public/application/components/create_discover_directive.ts new file mode 100644 index 0000000000000..6b6c3eb289667 --- /dev/null +++ b/src/plugins/discover/public/application/components/create_discover_directive.ts @@ -0,0 +1,62 @@ +/* + * 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 { Discover } from './discover'; + +export function createDiscoverDirective(reactDirective: any) { + return reactDirective(Discover, [ + ['addColumn', { watchDepth: 'reference' }], + ['bucketInterval', { watchDepth: 'reference' }], + ['config', { watchDepth: 'reference' }], + ['fetch', { watchDepth: 'reference' }], + ['fetchCounter', { watchDepth: 'reference' }], + ['fetchError', { watchDepth: 'reference' }], + ['fieldCounts', { watchDepth: 'reference' }], + ['getContextAppHref', { watchDepth: 'reference' }], + ['histogramData', { watchDepth: 'reference' }], + ['hits', { watchDepth: 'reference' }], + ['indexPattern', { watchDepth: 'reference' }], + ['indexPatternList', { watchDepth: 'reference' }], + ['intervalOptions', { watchDepth: 'reference' }], + ['onAddFilter', { watchDepth: 'reference' }], + ['onChangeInterval', { watchDepth: 'reference' }], + ['onRemoveColumn', { watchDepth: 'reference' }], + ['onSetColumns', { watchDepth: 'reference' }], + ['onSort', { watchDepth: 'reference' }], + ['opts', { watchDepth: 'reference' }], + ['resetQuery', { watchDepth: 'reference' }], + ['resultState', { watchDepth: 'reference' }], + ['rows', { watchDepth: 'reference' }], + ['savedSearch', { watchDepth: 'reference' }], + ['screenTitle', { watchDepth: 'reference' }], + ['searchSource', { watchDepth: 'reference' }], + ['setColumns', { watchDepth: 'reference' }], + ['setIndexPattern', { watchDepth: 'reference' }], + ['setSortOrder', { watchDepth: 'reference' }], + ['showSaveQuery', { watchDepth: 'reference' }], + ['showTimeCol', { watchDepth: 'reference' }], + ['state', { watchDepth: 'reference' }], + ['timefilterUpdateHandler', { watchDepth: 'reference' }], + ['timeRange', { watchDepth: 'reference' }], + ['topNavMenu', { watchDepth: 'reference' }], + ['updateQuery', { watchDepth: 'reference' }], + ['updateSavedQueryId', { watchDepth: 'reference' }], + ['vis', { watchDepth: 'reference' }], + ]); +} diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx new file mode 100644 index 0000000000000..7d098bd400a51 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -0,0 +1,213 @@ +/* + * 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 React from 'react'; +import moment from 'moment'; +import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { HitsCounter } from './hits_counter'; +import { DiscoverGrid } from './discover_grid/discover_grid'; +import { TimechartHeader } from './timechart_header'; +import { DiscoverSidebar } from './sidebar'; +import { getServices } from '../../kibana_services'; +// @ts-ignore +import { DiscoverNoResults } from '../angular/directives/no_results'; +import { DiscoverUninitialized } from '../angular/directives/uninitialized'; +import { DiscoverHistogram } from '../angular/directives/histogram'; +import { LoadingSpinner } from './loading_spinner/loading_spinner'; +import { DiscoverFetchError } from './fetch_error/fetch_error'; + +export function Discover({ + addColumn, + bucketInterval, + config, + fetch, + fetchError, + fetchCounter, + fieldCounts, + getContextAppHref, + histogramData, + hits, + indexPattern, + indexPatternList, + intervalOptions, + onAddFilter, + onChangeInterval, + onRemoveColumn, + onSetColumns, + onSort, + opts, + resetQuery, + resultState, + rows, + screenTitle, + searchSource, + setIndexPattern, + showTimeCol, + showSaveQuery, + state, + timefilterUpdateHandler, + timeRange, + topNavMenu, + vis, + updateQuery, + updateSavedQueryId, +}: any) { + const toMoment = function (datetime: string) { + if (!datetime) { + return ''; + } + return moment(datetime).format(config.get('dateFormat')); + }; + if (!timeRange) { + return
Loading
; + } + const { TopNavMenu } = getServices().navigation.ui; + const { savedSearch } = opts; + + return ( + +
+

{screenTitle}

+ + +
+
+ +
+
+ {resultState === 'none' && ( + + )} + {resultState === 'uninitialized' && } + + {resultState === 'loading' && ( + <> + {fetchError && } + {!fetchError && ( +
+ +
+ )} + + )} + + {resultState === 'ready' && ( +
+
+
+ 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> +
+
+ +
+
+ +
+ {opts.timefield && ( +
+ {vis && rows.length !== 0 && ( +
+ +
+ )} +
+ )} +
+

+ +

+ {rows && rows.length && ( +
+ +
+ )} +
+
+
+ )} +
+
+
+
+ ); +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index 40797ce0d707d..066f6e6cfc0c6 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -9,19 +9,63 @@ white-space: nowrap; } // this is a hack than needs to be improved -div[data-rbd-draggable-id="Time"] { +div[data-rbd-draggable-id='Time'] { display: none; } - .dscEuiDataGridRowCell .euiDataGridRowCell { align-items: start; } + +.dscEuiDataGridRowCellFilter { + display: none; + text-align: right; +} + +.dscEuiDataGridRowCellBtn { + text-align: right; + padding: 0 2px; + min-height: auto; + min-width: auto; + transition: none; + -webkit-transition: none; + -o-transition: none; +} + .dscValue { position: relative; } -.dscValue .dscValueFilter{ +.dscValue .dscValueFilter { background: $euiColorLightShade; } + +.euiDataGridRowCell:hover .dscEuiDataGridRowCellFilter { + display: flex; +} + +// hack to show expand icon on hover +.euiDataGridRowCell:hover { + border: 1px solid transparent; + margin-top: -1px; + -webkit-box-shadow: 0 0 0 2px rgba(0, 107, 180, 0.3); + box-shadow: 0 0 0 2px rgba(0, 107, 180, 0.3); + border-radius: 1px; + z-index: 2; +} +.euiDataGridRowCell:hover .euiDataGridRowCell__expandButton { + margin-left: 6px; +} +.euiDataGridRowCell:hover .euiDataGridRowCell__expandButtonIcon { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + width: inherit; + visibility: visible; +} +.euiDataGridRowCell__expandButtonIcon { + transition: none; + -webkit-transition: none; + -o-transition: none; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index fe806e19daae9..4d4a796d432dc 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -81,6 +81,7 @@ const gridStyle = { border: 'horizontal', fontSize: 's', cellPadding: 's', + rowHover: 'none', }; const pageSizeArr = [25, 50, 100, 500]; const defaultPageSize = 50; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx index 3cbb8a972ccc9..13afa61472f1e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx @@ -47,7 +47,7 @@ export function DiscoverGridPopover({ { - const [hover, setHover] = useState(false); - if (hover) { - return ( - setHover(false)} - onBlur={() => setHover(false)} - gutterSize="none" - alignItems="center" - responsive={false} - className="eui-textTruncate" - > - - {value} - - -
- ) => { - ev.stopPropagation(); - ev.preventDefault(); - onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - '+' - ); - }} - style={{ - padding: 0, - minHeight: 'auto', - minWidth: 'auto', - paddingRight: 2, - paddingLeft: 2, - paddingTop: 0, - paddingBottom: 0, - }} - /> - ) => { - ev.stopPropagation(); - ev.preventDefault(); - onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - '-' - ); - }} - style={{ - padding: 0, - minHeight: 'auto', - minWidth: 'auto', - paddingRight: 2, - paddingLeft: 2, - paddingTop: 0, - paddingBottom: 0, - }} - /> -
-
-
- ); - } else { - return ( -
setHover(true)} - onFocus={() => setHover(true)} - > + return ( + + {value} -
- ); - } +
+ +
+ ) => { + ev.stopPropagation(); + ev.preventDefault(); + onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + '+' + ); + }} + /> + ) => { + ev.stopPropagation(); + ev.preventDefault(); + onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + '-' + ); + }} + /> +
+
+
+ ); }; diff --git a/src/plugins/discover/public/application/components/fetch_error/fetch_error.tsx b/src/plugins/discover/public/application/components/fetch_error/fetch_error.tsx index 880a493983adf..d9cad8e30bac0 100644 --- a/src/plugins/discover/public/application/components/fetch_error/fetch_error.tsx +++ b/src/plugins/discover/public/application/components/fetch_error/fetch_error.tsx @@ -20,7 +20,7 @@ import './fetch_error.scss'; import React, { Fragment } from 'react'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiCallOut, EuiCodeBlock, EuiSpacer } from '@elastic/eui'; -import { getAngularModule, getServices } from '../../../kibana_services'; +import { getServices } from '../../../kibana_services'; interface Props { fetchError: { @@ -31,7 +31,7 @@ interface Props { }; } -const DiscoverFetchError = ({ fetchError }: Props) => { +export const DiscoverFetchError = ({ fetchError }: Props) => { if (!fetchError) { return null; } @@ -96,5 +96,3 @@ const DiscoverFetchError = ({ fetchError }: Props) => { export function createFetchErrorDirective(reactDirective: any) { return reactDirective(DiscoverFetchError); } - -getAngularModule().directive('discoverFetchError', createFetchErrorDirective); diff --git a/src/plugins/discover/public/application/components/fetch_error/index.js b/src/plugins/discover/public/application/components/fetch_error/index.ts similarity index 93% rename from src/plugins/discover/public/application/components/fetch_error/index.js rename to src/plugins/discover/public/application/components/fetch_error/index.ts index 0206bc48257ac..79a9f11e6cb50 100644 --- a/src/plugins/discover/public/application/components/fetch_error/index.js +++ b/src/plugins/discover/public/application/components/fetch_error/index.ts @@ -17,4 +17,4 @@ * under the License. */ -import './fetch_error'; +export { DiscoverFetchError } from './fetch_error'; diff --git a/src/plugins/discover/public/build_services.ts b/src/plugins/discover/public/build_services.ts index 75c83e30d80ad..2f9c58c5ab84c 100644 --- a/src/plugins/discover/public/build_services.ts +++ b/src/plugins/discover/public/build_services.ts @@ -43,6 +43,7 @@ import { DiscoverStartPlugins } from './plugin'; import { createSavedSearchesLoader, SavedSearch } from './saved_searches'; import { getHistory } from './kibana_services'; import { KibanaLegacyStart } from '../../kibana_legacy/public'; +import { NavigationPublicPluginStart } from '../../navigation/public'; export interface DiscoverServices { addBasePath: (path: string) => string; @@ -57,6 +58,7 @@ export interface DiscoverServices { indexPatterns: IndexPatternsContract; inspector: InspectorPublicPluginStart; metadata: { branch: string }; + navigation: NavigationPublicPluginStart; share?: SharePluginStart; kibanaLegacy: KibanaLegacyStart; timefilter: TimefilterContract; @@ -98,6 +100,7 @@ export async function buildServices( metadata: { branch: context.env.packageInfo.branch, }, + navigation: plugins.navigation, share: plugins.share, kibanaLegacy: plugins.kibanaLegacy, timefilter: plugins.data.query.timefilter.timefilter, diff --git a/src/plugins/discover/public/get_inner_angular.ts b/src/plugins/discover/public/get_inner_angular.ts index 0b03220329d0c..a204f0be626e8 100644 --- a/src/plugins/discover/public/get_inner_angular.ts +++ b/src/plugins/discover/public/get_inner_angular.ts @@ -59,13 +59,15 @@ import { createTopNavHelper, } from '../../kibana_legacy/public'; import { createDiscoverSidebarDirective } from './application/components/sidebar'; -import { createHitsCounterDirective } from '././application/components/hits_counter'; -import { createLoadingSpinnerDirective } from '././application/components/loading_spinner/loading_spinner'; +import { createHitsCounterDirective } from './application/components/hits_counter'; +import { createLoadingSpinnerDirective } from './application/components/loading_spinner/loading_spinner'; import { createTimechartHeaderDirective } from './application/components/timechart_header'; import { createContextErrorMessageDirective } from './application/components/context_error_message'; import { DiscoverStartPlugins } from './plugin'; import { getScopedHistory } from './kibana_services'; import { createSkipBottomButtonDirective } from './application/components/skip_bottom_button'; +import { createDiscoverDirective } from './application/components/create_discover_directive'; +import { createFetchErrorDirective } from './application/components/fetch_error/fetch_error'; /** * returns the main inner angular module, it contains all the parts of Angular Discover @@ -89,11 +91,9 @@ export function getInnerAngularModule( export function getInnerAngularModuleEmbeddable( name: string, core: CoreStart, - deps: DiscoverStartPlugins, - context: PluginInitializerContext + deps: DiscoverStartPlugins ) { - const module = initializeInnerAngularModule(name, core, deps.navigation, deps.data, true); - return module; + return initializeInnerAngularModule(name, core, deps.navigation, deps.data, true); } let initialized = false; @@ -158,11 +158,13 @@ export function initializeInnerAngularModule( .directive('fixedScroll', FixedScrollProvider) .directive('renderComplete', createRenderCompleteDirective) .directive('discoverSidebar', createDiscoverSidebarDirective) + .directive('discover', createDiscoverDirective) .directive('skipBottomButton', createSkipBottomButtonDirective) .directive('hitsCounter', createHitsCounterDirective) .directive('loadingSpinner', createLoadingSpinnerDirective) .directive('timechartHeader', createTimechartHeaderDirective) .directive('contextErrorMessage', createContextErrorMessageDirective) + .directive('discoverFetchError', createFetchErrorDirective) .service('debounce', ['$timeout', DebounceProviderTimeout]); } From be0dcb740ed68f38fcbe92b95c23fb7d0b799ceb Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 9 Jul 2020 18:17:16 +0200 Subject: [PATCH 052/186] Fix filters --- src/plugins/discover/public/application/components/discover.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 7d098bd400a51..d2001de0905a1 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -86,7 +86,7 @@ export function Discover({ Date: Sat, 11 Jul 2020 12:11:19 +0200 Subject: [PATCH 053/186] Improve CSS --- src/plugins/discover/public/application/_discover.scss | 6 +----- .../public/application/angular/discover_datagrid.html | 2 +- .../components/discover_grid/discover_grid.scss | 10 ++++++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 2a3b12342165b..4751a1d760d3e 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -48,11 +48,6 @@ discover-app { overflow: hidden; } - -.dscDiscoverGrid { - width: 100%; - max-width: 100%; -} .dscHistogram { display: flex; height: $euiSize * 8; @@ -139,6 +134,7 @@ discover-app { .dscTable { overflow: auto; + //will-change: transform; // SASSTODO: add a monospace modifier to the doc-table component .kbnDocTable__row { diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index c91df8936c546..fbcb9cd7edd1a 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -1,4 +1,4 @@ - + Date: Wed, 15 Jul 2020 09:14:10 +0200 Subject: [PATCH 054/186] Add column header actions - this is a draft to implement it in EUI later on --- .../discover_grid/discover_grid.scss | 18 +++++ .../discover_grid/discover_grid.tsx | 6 +- .../discover_grid_header_col.tsx | 55 ++++++++++++++ .../discover_grid/discover_grid_helpers.tsx | 73 +++++++++++++++---- 4 files changed, 136 insertions(+), 16 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_header_col.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index 746966b754f32..68954fb32c056 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -79,3 +79,21 @@ div[data-rbd-draggable-id='Time'] { .euiDataGrid__verticalScroll { will-change: transform; } + +// We only truncate if the cell is not a control column. +.euiDataGridHeader { + + .euiDataGridHeaderCell__content { + @include euiTextTruncate; + overflow: hidden; + white-space: nowrap; + flex-grow: 1; + } + + .euiDataGridHeaderCell__popover { + flex-grow: 0; + flex-basis: auto; + width: auto; + padding-left: $euiSizeXS; + } +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 4d4a796d432dc..1bc6bc20785b1 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -62,7 +62,7 @@ interface Props { sampleSize: number; onFilter: DocViewFilterFn; showTimeCol: boolean; - onSort: Function; + onSort: (props: any) => void; getContextAppHref: (id: string | number | Record) => string; onRemoveColumn: (column: string) => void; onAddColumn: (column: string) => void; @@ -213,8 +213,8 @@ export const DiscoverGrid = React.memo( const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( - () => getEuiGridColumns(columns, indexPattern, showTimeCol, timeString), - [columns, indexPattern, showTimeCol, timeString] + () => getEuiGridColumns(columns, indexPattern, showTimeCol, timeString, onSetColumns, onSort), + [columns, indexPattern, showTimeCol, timeString, onSetColumns, onSort] ); const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const popoverContents = useMemo(() => getPopoverContents(), []); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_header_col.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_header_col.tsx new file mode 100644 index 0000000000000..87cb5c9099330 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_header_col.tsx @@ -0,0 +1,55 @@ +/* + * 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 { EuiIcon, EuiListGroup, EuiPopover } from '@elastic/eui'; +import React, { useState } from 'react'; + +export const DiscoverGridHeader = ({ title, listItems }: any) => { + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + const usedListItems = listItems.map((listItem: any) => { + return { + ...listItem, + onClick: () => { + setIsPopoverOpen(false); + listItem.onClick(); + }, + }; + }); + return ( +
+
{title}
+ setIsPopoverOpen(false)} + button={ + + } + > +
+ +
+
+
+ ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 0a558cdd4b975..2f442fcac3934 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -19,6 +19,8 @@ import React, { ReactNode } from 'react'; import { EuiDataGridColumn } from '@elastic/eui'; import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; +import { DiscoverGridHeader } from './discover_grid_header_col'; +import { moveColumn } from '../../angular/doc_table/actions/columns'; const kibanaJSON = 'kibana-json'; const geoPoint = 'geo-point'; @@ -27,23 +29,22 @@ export function getEuiGridColumns( columns: string[], indexPattern: IndexPattern, showTimeCol: boolean, - timeString: string + timeString: string, + onSetColumns: (columns: string[]) => void, + onSort: (props: any) => void ) { const timeFieldName = indexPattern.timeFieldName; - if (showTimeCol && !columns.find((col) => col === timeFieldName)) { - return [ - { - id: indexPattern.timeFieldName, - display: `${timeString} (${indexPattern.timeFieldName})`, - schema: 'datetime', - initialWidth: 200, - } as EuiDataGridColumn, - ...columns.map((column) => buildEuiGridColumn(column, indexPattern, timeString)), - ]; + if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { + const usedColumns = [indexPattern.timeFieldName, ...columns]; + return usedColumns.map((column) => + buildEuiGridColumn(column, indexPattern, timeString, usedColumns, onSetColumns, onSort) + ); } - return columns.map((column) => buildEuiGridColumn(column, indexPattern, timeString)); + return columns.map((column) => + buildEuiGridColumn(column, indexPattern, timeString, columns, onSetColumns, onSort) + ); } export function getVisibleColumns( @@ -63,7 +64,10 @@ export function getVisibleColumns( export function buildEuiGridColumn( columnName: string, indexPattern: IndexPattern, - timeString: string + timeString: string, + columns: string[], + onSetColumns: (columns: string[]) => void, + onSort: (props: any) => void ) { const indexPatternField = indexPattern.getFieldByName(columnName); const column: EuiDataGridColumn = { @@ -96,6 +100,49 @@ export function buildEuiGridColumn( if (column.id === indexPattern.timeFieldName) { column.display = `${timeString} (${indexPattern.timeFieldName})`; } + const listItems = [ + { + label: 'Sort ASC', + onClick: () => onSort([[column.id, 'asc']]), + iconType: 'sortUp', + size: 'xs', + color: 'text', + isDisabled: !indexPatternField?.sortable, + }, + { + label: 'Sort DESC', + onClick: () => onSort([[column.id, 'desc']]), + iconType: 'sortDown', + size: 'xs', + color: 'text', + isDisabled: !indexPatternField?.sortable, + }, + { + label: 'Move left', + onClick: () => onSetColumns(moveColumn(columns, column.id, columns.indexOf(column.id) - 1)), + iconType: 'sortLeft', + size: 'xs', + color: 'text', + isDisabled: columns.indexOf(column.id) === 0, + }, + { + label: 'Move right', + onClick: () => onSetColumns(moveColumn(columns, column.id, columns.indexOf(column.id) + 1)), + iconType: 'sortRight', + size: 'xs', + color: 'text', + isDisabled: columns.indexOf(column.id) === columns.length - 1, + }, + { + label: 'Remove column', + onClick: () => onSetColumns(columns.filter((col: string) => col !== column.id)), + iconType: 'cross', + size: 'xs', + color: 'text', + isDisabled: columns.length === 1, + }, + ]; + column.display = ; return column; } From 096a81dfe5631d71971da29fe2d02e36a3a38aa8 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 21 Jul 2020 18:21:00 +0200 Subject: [PATCH 055/186] Fix tests --- .../styles/_legacy/components/_table.scss | 5 +-- .../common/field_formats/converters/source.ts | 6 +-- .../public/application/_discover.scss | 5 +++ .../application/components/discover.tsx | 2 +- .../discover_grid/discover_grid.tsx | 40 +++++++++++++++++-- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/legacy/ui/public/styles/_legacy/components/_table.scss b/src/legacy/ui/public/styles/_legacy/components/_table.scss index 43eee31999e62..d0ac9d6f79862 100644 --- a/src/legacy/ui/public/styles/_legacy/components/_table.scss +++ b/src/legacy/ui/public/styles/_legacy/components/_table.scss @@ -7,9 +7,8 @@ } } -kbn-table, -.kbn-table, -tbody[kbn-rows] { +kbn-table, .kbn-table, tbody[kbn-rows] { + @include dscDocSourceStyle; // sub tables should not have a leading border .table .table { margin-bottom: 0; diff --git a/src/plugins/data/common/field_formats/converters/source.ts b/src/plugins/data/common/field_formats/converters/source.ts index b7c7736201dd7..f00261e00971a 100644 --- a/src/plugins/data/common/field_formats/converters/source.ts +++ b/src/plugins/data/common/field_formats/converters/source.ts @@ -43,10 +43,10 @@ function noWhiteSpace(html: string) { } const templateHtml = ` -
+
<% defPairs.forEach(function (def) { %> -
<%- def[0] %>:
-
<%= def[1] %>
+
<%- def[0] %>:
+
<%= def[1] %>
<%= ' ' %> <% }); %>
`; diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 4751a1d760d3e..6789ef0d33de9 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -49,6 +49,11 @@ discover-app { } .dscHistogram { + display: flex; + height: 200px; +} +// new slimmer layout for data grid +.dscHistogramGrid { display: flex; height: $euiSize * 8; padding: $euiSizeS $euiSizeS 0 $euiSizeS; diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index d2001de0905a1..ba5a881b7affa 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -164,7 +164,7 @@ export function Discover({ className="dscTimechart" > {vis && rows.length !== 0 && ( -
+
{ + const highlights = (row && row.highlight) || {}; + const formatted = indexPattern.formatHit(row); + const highlightPairs: any[] = []; + const sourcePairs: any[] = []; + + Object.keys(formatted).forEach((key) => { + const pairs = highlights[key] ? highlightPairs : sourcePairs; + const newField = key; + const val = formatted[key]; + pairs.push([newField, val]); + }, []); + + return ( +
+ {sourcePairs.map((pair) => ( + +
{pair[0]}
+
+ + ))} +
+ ); + }; // TODO Field formatters need to be fixed - const value = ( - // eslint-disable-next-line react/no-danger - - ); + const value = + field.type === '_source' ? ( + formatSource(row, columnId) + ) : ( + // eslint-disable-next-line react/no-danger + + ); if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { const createFilter = (fieldName: string, type: '-' | '+') => { From 76822825ad5271f774a7165b441323be97e45438 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 21 Jul 2020 11:10:49 -0700 Subject: [PATCH 056/186] adding toggle of chart --- .../public/application/_discover.scss | 33 +++++----- .../application/components/discover.tsx | 63 ++++++++++++------- .../discover_grid/discover_grid.scss | 2 - .../discover_grid/discover_grid_popover.tsx | 1 - 4 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 4751a1d760d3e..42ae41898ec49 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -88,28 +88,27 @@ discover-app { } .dscResultCount { - display: flex; - justify-content: space-between; + // display: flex; + // justify-content: space-between; padding: 0 $euiSizeS; - flex-grow: 0; + // flex-grow: 0; } -.dscResultCount__title { - flex-grow: 0; - flex-basis: auto; -} +// .dscResultCount__title { +// flex-grow: 0; +// flex-basis: auto; +// } -.dscResultCount__actions { - flex-grow: 0; - flex-basis: auto; - display: flex; - align-items: center; - - > *:not(:first-child) { - margin-left: $euiSizeS; - } -} +// .dscResultCount__actions { +// flex-grow: 0; +// flex-basis: auto; +// display: flex; +// align-items: center; +// > *:not(:first-child) { +// margin-left: $euiSizeS; +// } +// } .dscTimechart__header { display: flex; diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index d2001de0905a1..ad7d2e0bbbc1f 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React from 'react'; +import React, { useState } from 'react'; import moment from 'moment'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { HitsCounter } from './hits_counter'; @@ -30,6 +30,7 @@ import { DiscoverUninitialized } from '../angular/directives/uninitialized'; import { DiscoverHistogram } from '../angular/directives/histogram'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; import { DiscoverFetchError } from './fetch_error/fetch_error'; +import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; export function Discover({ addColumn, @@ -78,6 +79,11 @@ export function Discover({ } const { TopNavMenu } = getServices().navigation.ui; const { savedSearch } = opts; + const [toggle4On, setToggle4On] = useState(true); + + const onToggle4Change = (e) => { + setToggle4On(e.target.checked); + }; return ( @@ -136,29 +142,42 @@ export function Discover({ {resultState === 'ready' && (
-
- 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> -
-
- -
+ + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + + +
-
- {opts.timefield && ( + {opts.timefield && toggle4On && (
{i18n.translate('discover.grid.filterOut', { From 62b480ff9105b676bb605163410bad269ec94fa5 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 22 Jul 2020 08:52:15 +0200 Subject: [PATCH 057/186] Fix tests --- .../discover_grid/discover_grid.tsx | 22 +++++-------------- .../discover_grid/discover_grid_helpers.tsx | 1 + src/plugins/discover/public/plugin.ts | 7 +----- test/functional/apps/discover/_data_grid.ts | 10 ++++----- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 3f1dc9385971c..4bb6839525981 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -167,27 +167,17 @@ export const DiscoverGrid = React.memo( } const field = indexPattern.fields.getByName(columnId); const formatSource = () => { - const highlights = (row && row.highlight) || {}; const formatted = indexPattern.formatHit(row); - const highlightPairs: any[] = []; - const sourcePairs: any[] = []; - - Object.keys(formatted).forEach((key) => { - const pairs = highlights[key] ? highlightPairs : sourcePairs; - const newField = key; - const val = formatted[key]; - pairs.push([newField, val]); - }, []); return (
- {sourcePairs.map((pair) => ( - -
{pair[0]}
+ {Object.keys(formatted).map((key) => ( + +
{key}
))} @@ -196,8 +186,8 @@ export const DiscoverGrid = React.memo( }; // TODO Field formatters need to be fixed const value = - field.type === '_source' ? ( - formatSource(row, columnId) + field && field.type === '_source' ? ( + formatSource() ) : ( // eslint-disable-next-line react/no-danger diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 2f442fcac3934..9eef5dadb2160 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -99,6 +99,7 @@ export function buildEuiGridColumn( } if (column.id === indexPattern.timeFieldName) { column.display = `${timeString} (${indexPattern.timeFieldName})`; + column.initialWidth = 180; } const listItems = [ { diff --git a/src/plugins/discover/public/plugin.ts b/src/plugins/discover/public/plugin.ts index 20e13d204e0e9..5b1d8840518f3 100644 --- a/src/plugins/discover/public/plugin.ts +++ b/src/plugins/discover/public/plugin.ts @@ -371,12 +371,7 @@ export class DiscoverPlugin const { core, plugins } = await this.initializeServices(); getServices().kibanaLegacy.loadFontAwesome(); const { getInnerAngularModuleEmbeddable } = await import('./get_inner_angular'); - getInnerAngularModuleEmbeddable( - embeddableAngularName, - core, - plugins, - this.initializerContext - ); + getInnerAngularModuleEmbeddable(embeddableAngularName, core, plugins); const mountpoint = document.createElement('div'); this.embeddableInjector = angular.bootstrap(mountpoint, [embeddableAngularName]); } diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts index 45ab0a62b03b3..b754c34b490bf 100644 --- a/test/functional/apps/discover/_data_grid.ts +++ b/test/functional/apps/discover/_data_grid.ts @@ -49,19 +49,19 @@ export default function ({ const getTitles = async () => (await testSubjects.getVisibleText('dataGridHeader')).replace(/\s|\r?\n|\r/g, ' '); - expect(await getTitles()).to.be('Time _source'); + expect(await getTitles()).to.be('Time (@timestamp) _source'); await PageObjects.discover.clickFieldListItemAdd('bytes'); - expect(await getTitles()).to.be('Time bytes'); + expect(await getTitles()).to.be('Time (@timestamp) bytes'); await PageObjects.discover.clickFieldListItemAdd('agent'); - expect(await getTitles()).to.be('Time bytes agent'); + expect(await getTitles()).to.be('Time (@timestamp) bytes agent'); await PageObjects.discover.clickFieldListItemAdd('bytes'); - expect(await getTitles()).to.be('Time agent'); + expect(await getTitles()).to.be('Time (@timestamp) agent'); await PageObjects.discover.clickFieldListItemAdd('agent'); - expect(await getTitles()).to.be('Time _source'); + expect(await getTitles()).to.be('Time (@timestamp) _source'); }); }); } From 9a26fcfff7f5ec98d5bca0a5e7fb53edd0f3108b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 22 Jul 2020 12:21:28 +0200 Subject: [PATCH 058/186] Fix i18n --- .../application/components/discover_grid/discover_grid.tsx | 6 +++--- .../components/discover_grid/discover_grid_popover.tsx | 2 +- .../components/discover_grid/discover_value_with_filter.tsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 4bb6839525981..283ce007683b0 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -314,12 +314,12 @@ export const DiscoverGrid = React.memo( {showDisclaimer && (

- +

)} @@ -328,7 +328,7 @@ export const DiscoverGrid = React.memo(

{searchDescription ? ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx index 13afa61472f1e..2d98c9a5b6df0 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx @@ -63,7 +63,7 @@ export function DiscoverGridPopover({ Date: Thu, 23 Jul 2020 12:03:19 +0200 Subject: [PATCH 059/186] Use EuiResizableContainer to make columns resizeable --- .../application/components/discover.tsx | 223 ++++++++++-------- 1 file changed, 122 insertions(+), 101 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index ba5a881b7affa..a8f591a563358 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -18,6 +18,7 @@ */ import React from 'react'; import moment from 'moment'; +import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; @@ -97,115 +98,135 @@ export function Discover({ showSearchBar={true} useDefaultBehaviors={true} /> -

-
- -
-
- {resultState === 'none' && ( - - )} - {resultState === 'uninitialized' && } - - {resultState === 'loading' && ( + + {(EuiResizablePanel, EuiResizableButton) => ( <> - {fetchError && } - {!fetchError && ( -
- -
- )} - - )} + + + - {resultState === 'ready' && ( -
-
-
- 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> -
-
- -
-
+ -
- {opts.timefield && ( -
- {vis && rows.length !== 0 && ( -
- -
- )} -
- )} -
-

- + <> + {resultState === 'none' && ( + -

- {rows && rows.length && ( -
- + )} + {resultState === 'uninitialized' && } + + {resultState === 'loading' && ( + <> + {fetchError && } + {!fetchError && ( +
+ +
+ )} + + )} + + {resultState === 'ready' && ( +
+
+
+ 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> +
+
+ +
+
+ +
+ {opts.timefield && ( +
+ {vis && rows.length !== 0 && ( +
+ +
+ )} +
+ )} +
+

+ +

+ {rows && rows.length && ( +
+ +
+ )} +
+
)} -
-
-
+ + + )} -
+
From d9c999756c4c0a205a35a49f5ed0d69884f85353 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 27 Jul 2020 19:03:56 -0700 Subject: [PATCH 060/186] merged from kertal's branch --- .../application/components/discover.tsx | 60 ++++++++++++------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index a5d1de681e2e5..b280ebcdc7801 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -80,10 +80,10 @@ export function Discover({ } const { TopNavMenu } = getServices().navigation.ui; const { savedSearch } = opts; - const [toggle4On, setToggle4On] = useState(true); + const [toggleOn, setToggleOn] = useState(true); - const onToggle4Change = (e) => { - setToggle4On(e.target.checked); + const onToggleChange = (e) => { + setToggleOn(e.target.checked); }; return ( @@ -159,29 +159,43 @@ export function Discover({ {resultState === 'ready' && (
-
- 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> -
-
- -
+ + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + + +
- {opts.timefield && ( + {opts.timefield && toggleOn && (
Date: Tue, 28 Jul 2020 16:32:46 -0700 Subject: [PATCH 061/186] clean sass file --- .../public/application/_discover.scss | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 7b2e26395808c..4189d13b55cff 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -94,28 +94,9 @@ discover-app { } .dscResultCount { - // display: flex; - // justify-content: space-between; padding: 0 $euiSizeS; - // flex-grow: 0; } -// .dscResultCount__title { -// flex-grow: 0; -// flex-basis: auto; -// } - -// .dscResultCount__actions { -// flex-grow: 0; -// flex-basis: auto; -// display: flex; -// align-items: center; - -// > *:not(:first-child) { -// margin-left: $euiSizeS; -// } -// } - .dscTimechart__header { display: flex; justify-content: center; From 539b1acbabe783882ae4eaccc374b28bbc8688d0 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 29 Jul 2020 18:07:28 -0700 Subject: [PATCH 062/186] improve dscResultCount in smaller screens --- .../discover/public/application/_discover.scss | 1 + .../public/application/components/discover.scss | 13 +++++++++++++ .../public/application/components/discover.tsx | 11 ++++++----- .../timechart_header/timechart_header.scss | 3 +++ .../timechart_header/timechart_header.tsx | 5 +++-- 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover.scss create mode 100644 src/plugins/discover/public/application/components/timechart_header/timechart_header.scss diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 4189d13b55cff..10272ca748e32 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -46,6 +46,7 @@ discover-app { flex-direction: column; display: flex; overflow: hidden; + padding-right: $euiSizeS; } .dscHistogram { diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss new file mode 100644 index 0000000000000..ec6a213694a4b --- /dev/null +++ b/src/plugins/discover/public/application/components/discover.scss @@ -0,0 +1,13 @@ +.dscResultCount { + @include euiBreakpoint('xs', 's') { + .dscResultCount__toggle { + align-items: flex-end; + margin-top: 0 !important; + } + + .dscResuntCount__title, + .dscResultCount__actions { + margin-bottom: 0 !important; + } + } +} diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index b280ebcdc7801..6b09fe705905e 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -20,6 +20,7 @@ import React, { useState } from 'react'; import moment from 'moment'; import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; @@ -31,7 +32,7 @@ import { DiscoverUninitialized } from '../angular/directives/uninitialized'; import { DiscoverHistogram } from '../angular/directives/histogram'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; import { DiscoverFetchError } from './fetch_error/fetch_error'; -import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; +import './discover.scss'; export function Discover({ addColumn, @@ -69,6 +70,7 @@ export function Discover({ updateQuery, updateSavedQueryId, }: any) { + const [toggleOn, toggleChart] = useState(true); const toMoment = function (datetime: string) { if (!datetime) { return ''; @@ -80,10 +82,9 @@ export function Discover({ } const { TopNavMenu } = getServices().navigation.ui; const { savedSearch } = opts; - const [toggleOn, setToggleOn] = useState(true); const onToggleChange = (e) => { - setToggleOn(e.target.checked); + toggleChart(e.target.checked); }; return ( @@ -170,7 +171,7 @@ export function Discover({ onResetQuery={resetQuery} /> - + - + - + {`${from} - ${to} ${ interval !== 'auto' ? i18n.translate('discover.timechartHeader.timeIntervalSelect.per', { @@ -105,7 +106,7 @@ export function TimechartHeader({ - + Date: Wed, 19 Aug 2020 09:22:08 +0200 Subject: [PATCH 063/186] Fix type error --- .../discover/public/application/components/discover.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 6b09fe705905e..4c000759c8182 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -83,10 +83,6 @@ export function Discover({ const { TopNavMenu } = getServices().navigation.ui; const { savedSearch } = opts; - const onToggleChange = (e) => { - toggleChart(e.target.checked); - }; - return (
@@ -187,7 +183,9 @@ export function Discover({ { + toggleChart(e.target.checked); + }} isSelected={toggleOn} isEmpty /> From 2cde541e1cee7c7d4f69a109a93aebf84ef890d0 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 24 Aug 2020 15:14:35 +0200 Subject: [PATCH 064/186] Rename doc_table:legacyTable to doc_table:legacy for eslint --- docs/management/advanced-options.asciidoc | 2 +- src/plugins/discover/common/index.ts | 2 +- src/plugins/discover/public/application/angular/discover.js | 4 ++-- .../public/application/embeddable/search_embeddable.ts | 4 +--- test/accessibility/apps/discover.ts | 2 +- test/functional/apps/discover/_data_grid.ts | 4 ++-- test/functional/apps/discover/_date_nanos.js | 2 +- test/functional/apps/discover/_date_nanos_mixed.js | 2 +- test/functional/apps/discover/_discover.js | 2 +- test/functional/apps/discover/_doc_navigation.js | 2 +- test/functional/apps/discover/_field_data.js | 2 +- test/functional/apps/discover/_large_string.js | 2 +- test/functional/apps/management/_scripted_fields.js | 2 +- x-pack/test/functional/apps/security/secure_roles_perm.js | 2 +- 14 files changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/management/advanced-options.asciidoc b/docs/management/advanced-options.asciidoc index 0367cbe6bae26..22aaa5b2b69c6 100644 --- a/docs/management/advanced-options.asciidoc +++ b/docs/management/advanced-options.asciidoc @@ -144,7 +144,7 @@ This setting does not have an effect when loading a saved search. `doc_table:highlight`:: Highlights results in Discover and saved searches on dashboards. Highlighting slows requests when working on big documents. -`doc_table:legacyTable`:: Control the way the Discover's table looks and works. Set this property to `true` to revert to the legacy implementation. +`doc_table:legacy`:: Control the way the Discover's table looks and works. Set this property to `true` to revert to the legacy implementation. [float] [[kibana-ml-settings]] diff --git a/src/plugins/discover/common/index.ts b/src/plugins/discover/common/index.ts index e348ee7e24f49..5f239a6034652 100644 --- a/src/plugins/discover/common/index.ts +++ b/src/plugins/discover/common/index.ts @@ -27,4 +27,4 @@ export const FIELDS_LIMIT_SETTING = 'fields:popularLimit'; export const CONTEXT_DEFAULT_SIZE_SETTING = 'context:defaultSize'; export const CONTEXT_STEP_SETTING = 'context:step'; export const CONTEXT_TIE_BREAKER_FIELDS_SETTING = 'context:tieBreakerFields'; -export const DOC_TABLE_LEGACY_TABLE = 'doc_table:legacyTable'; +export const DOC_TABLE_LEGACY_TABLE = 'doc_table:legacy'; diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index d470e13d493d8..a37da1b2dccdc 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -115,7 +115,7 @@ app.config(($routeProvider) => { }; const discoverRoute = { ...defaults, - template: getServices().uiSettings.get('doc_table:legacyTable', true) + template: getServices().uiSettings.get('doc_table:legacy', true) ? indexTemplate : indexTemplateGrid, reloadOnSearch: false, @@ -315,7 +315,7 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; $scope.useShortDots = config.get('shortDots:enable', false); - $scope.useNewGrid = config.get('doc_table:legacyTable', false); + $scope.useNewGrid = config.get('doc_table:legacy', false); $scope.showTimeCol = !config.get('doc_table:hideTimeColumn', false) && $scope.indexPattern.timeFieldName; diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 867ef297cb76f..98cf36efe94d5 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -166,9 +166,7 @@ export class SearchEmbeddable extends Embeddable throw new Error('Search scope not defined'); } this.searchInstance = this.$compile( - getServices().uiSettings.get('doc_table:legacyTable', true) - ? searchTemplate - : searchTemplateGrid + getServices().uiSettings.get('doc_table:legacy', true) ? searchTemplate : searchTemplateGrid )(this.searchScope); const rootNode = angular.element(domNode); rootNode.append(this.searchInstance); diff --git a/test/accessibility/apps/discover.ts b/test/accessibility/apps/discover.ts index 0a03b868f6a1e..95f3c8dad886f 100644 --- a/test/accessibility/apps/discover.ts +++ b/test/accessibility/apps/discover.ts @@ -40,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('logstash_functional'); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); diff --git a/test/functional/apps/discover/_data_grid.ts b/test/functional/apps/discover/_data_grid.ts index b754c34b490bf..8f62e03518253 100644 --- a/test/functional/apps/discover/_data_grid.ts +++ b/test/functional/apps/discover/_data_grid.ts @@ -30,7 +30,7 @@ export default function ({ const esArchiver = getService('esArchiver'); const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); const kibanaServer = getService('kibanaServer'); - const defaultSettings = { defaultIndex: 'logstash-*', 'doc_table:legacyTable': false }; + const defaultSettings = { defaultIndex: 'logstash-*', 'doc_table:legacy': false }; const testSubjects = getService('testSubjects'); before(async function () { @@ -42,7 +42,7 @@ export default function ({ }); after(async function () { - await kibanaServer.uiSettings.replace({ 'doc_table:legacyTable': true }); + await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); }); it('can add fields to the table', async function () { diff --git a/test/functional/apps/discover/_date_nanos.js b/test/functional/apps/discover/_date_nanos.js index 03d794e16ea56..b44859137ee37 100644 --- a/test/functional/apps/discover/_date_nanos.js +++ b/test/functional/apps/discover/_date_nanos.js @@ -32,7 +32,7 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('date_nanos'); await kibanaServer.uiSettings.replace({ defaultIndex: 'date-nanos', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos']); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_date_nanos_mixed.js b/test/functional/apps/discover/_date_nanos_mixed.js index 8387c6dd6bcf6..415df99244aef 100644 --- a/test/functional/apps/discover/_date_nanos_mixed.js +++ b/test/functional/apps/discover/_date_nanos_mixed.js @@ -32,7 +32,7 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('date_nanos_mixed'); await kibanaServer.uiSettings.replace({ defaultIndex: 'timestamp-*', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos_mixed']); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 516a2618140d8..3aa68e790b57a 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }; describe('discover test', function describeIndexTests() { diff --git a/test/functional/apps/discover/_doc_navigation.js b/test/functional/apps/discover/_doc_navigation.js index 53eb93a075f71..16391ff9b4be2 100644 --- a/test/functional/apps/discover/_doc_navigation.js +++ b/test/functional/apps/discover/_doc_navigation.js @@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('discover'); await esArchiver.loadIfNeeded('logstash_functional'); - await kibanaServer.uiSettings.replace({ 'doc_table:legacyTable': true }); + await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); await PageObjects.discover.waitForDocTableLoadingComplete(); diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js index 7011c8eac0c8b..d9fe308be6c74 100644 --- a/test/functional/apps/discover/_field_data.js +++ b/test/functional/apps/discover/_field_data.js @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }) { // delete .kibana index and update configDoc await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_large_string.js b/test/functional/apps/discover/_large_string.js index 5b163aaacf3fe..dfcfa40df9f0f 100644 --- a/test/functional/apps/discover/_large_string.js +++ b/test/functional/apps/discover/_large_string.js @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('hamlet'); await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }); }); diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 35c1c255d3f33..f6c6aac636309 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -60,7 +60,7 @@ export default function ({ getService, getPageObjects }) { await browser.setWindowSize(1200, 800); await esArchiver.load('discover'); // delete .kibana index and then wait for Kibana to re-create it - await kibanaServer.uiSettings.replace({ 'doc_table:legacyTable': true }); + await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); await PageObjects.settings.createIndexPattern(); await kibanaServer.uiSettings.update({}); }); diff --git a/x-pack/test/functional/apps/security/secure_roles_perm.js b/x-pack/test/functional/apps/security/secure_roles_perm.js index 5ea759f11912a..f453345bedbf6 100644 --- a/x-pack/test/functional/apps/security/secure_roles_perm.js +++ b/x-pack/test/functional/apps/security/secure_roles_perm.js @@ -32,7 +32,7 @@ export default function ({ getService, getPageObjects }) { await esArchiver.load('security/discover'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', - 'doc_table:legacyTable': true, + 'doc_table:legacy': true, }); await PageObjects.settings.navigateTo(); }); From 70fb429a6dbec3d535efe6b245c17c0f9c61adc0 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 25 Aug 2020 11:18:27 +0200 Subject: [PATCH 065/186] Use records instead of hits as wording --- .../discover_grid/discover_grid_flyout_selection.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx index 56f725ddcc170..6730e2c0762c1 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx @@ -58,7 +58,7 @@ export function DiscoverGridFlyoutSelection({

{' '} {i18n.translate('discover.grid.tableRow.selectedDocuments', { - defaultMessage: 'Selected hits', + defaultMessage: 'Selected records', })}

@@ -68,7 +68,7 @@ export function DiscoverGridFlyoutSelection({

{i18n.translate('discover.grid.documentSelectionAriaLabel', { - defaultMessage: 'Document Selection', + defaultMessage: 'Records selection', })}

{selected.length > 0 && From 381e3bfa56df707f7378c5e436441e04d25969a8 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 25 Aug 2020 13:16:34 +0200 Subject: [PATCH 066/186] Enable persistence of data grid columns width --- .../public/application/angular/discover.js | 13 +++++++ .../angular/discover_datagrid.html | 1 + .../components/create_discover_directive.ts | 1 + .../application/components/discover.tsx | 3 ++ .../create_discover_grid_directive.tsx | 35 ++----------------- .../discover_grid/discover_grid.tsx | 20 +++++++++-- .../discover_grid/discover_grid_helpers.tsx | 25 +++++++++++-- .../embeddable/search_embeddable.ts | 3 ++ .../public/saved_searches/_saved_search.ts | 3 ++ .../discover/public/saved_searches/types.ts | 1 + .../discover/server/saved_objects/search.ts | 1 + 11 files changed, 70 insertions(+), 36 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index a37da1b2dccdc..82ad363748157 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -615,6 +615,10 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise savedSearch.columns.length > 0 ? savedSearch.columns : config.get(DEFAULT_COLUMNS_SETTING).slice(), + columnsWidth: + savedSearch.grid && savedSearch.grid.columnsWidth + ? savedSearch.grid.columnsWidth + : undefined, index: $scope.indexPattern.id, interval: 'auto', filters: _.cloneDeep($scope.searchSource.getOwnField('filter')), @@ -738,6 +742,9 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise await $scope.updateDataSource(); savedSearch.columns = $scope.state.columns; + savedSearch.grid = { + columnsWidth: $scope.state.columnsWidth, + }; savedSearch.sort = $scope.state.sort; try { @@ -1032,6 +1039,12 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise setAppState({ columns }); }; + $scope.setColumnsResize = (col) => { + const colSize = $scope.state.columnsWidth ? { ...$scope.state.columnsWidth } : {}; + colSize[col.columnId] = Math.round(col.width); + setAppState({ columnsWidth: colSize }); + }; + $scope.scrollToTop = function () { $window.scrollTo(0, 0); }; diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index fbcb9cd7edd1a..9d347a7741428 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -20,6 +20,7 @@ on-remove-column="removeColumn" on-set-columns="setColumns" on-sort="setSortOrder" + on-resize="setColumnsResize" opts="opts" reset-query="resetQuery" result-state="resultState" diff --git a/src/plugins/discover/public/application/components/create_discover_directive.ts b/src/plugins/discover/public/application/components/create_discover_directive.ts index 6b6c3eb289667..091951b44a176 100644 --- a/src/plugins/discover/public/application/components/create_discover_directive.ts +++ b/src/plugins/discover/public/application/components/create_discover_directive.ts @@ -39,6 +39,7 @@ export function createDiscoverDirective(reactDirective: any) { ['onRemoveColumn', { watchDepth: 'reference' }], ['onSetColumns', { watchDepth: 'reference' }], ['onSort', { watchDepth: 'reference' }], + ['onResize', { watchDepth: 'reference' }], ['opts', { watchDepth: 'reference' }], ['resetQuery', { watchDepth: 'reference' }], ['resultState', { watchDepth: 'reference' }], diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 4c000759c8182..a1c47a5704429 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -53,6 +53,7 @@ export function Discover({ onRemoveColumn, onSetColumns, onSort, + onResize, opts, resetQuery, resultState, @@ -221,6 +222,7 @@ export function Discover({
)} diff --git a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx index 3190a486b6464..5d03511b9c8ac 100644 --- a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx @@ -16,41 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -import * as React from 'react'; -import { DiscoverGrid } from './discover_grid'; - -interface Props

{ - [key: string]: any; -} -/** - * TODO remove when development is finished, helper component to detect property changes - * @param WrappedComponent - */ -export function withPropsChecker

( - WrappedComponent: React.ComponentType

-): React.ComponentClass> { - // eslint-disable-next-line react/prefer-stateless-function - return class PropsChecker extends React.Component> { - /** - componentWillReceiveProps(nextProps: Props

) { - Object.keys(nextProps) - .filter((key) => nextProps[key] !== this.props[key]) - .map((key) => { - console.log('changed property:', key, 'from', this.props[key], 'to', nextProps[key]); - }); - } - **/ - - render() { - // @ts-ignore - return ; - } - }; -} +import { DiscoverGrid } from './discover_grid'; export function createDiscoverGridDirective(reactDirective: any) { - return reactDirective(withPropsChecker(DiscoverGrid), [ + return reactDirective(DiscoverGrid, [ ['columns', { watchDepth: 'collection' }], ['rows', { watchDepth: 'collection' }], ['indexPattern', { watchDepth: 'reference' }], @@ -66,5 +36,6 @@ export function createDiscoverGridDirective(reactDirective: any) { ['onSetColumns', { watchDepth: 'reference', wrapApply: false }], ['getContextAppHref', { watchDepth: 'reference', wrapApply: false }], ['onSort', { watchDepth: 'reference', wrapApply: false }], + ['onResize', { watchDepth: 'reference', wrapApply: false }], ]); } diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 283ce007683b0..f65d4e64c9398 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -54,6 +54,7 @@ interface SortObj { interface Props { rows: ElasticSearchHit[]; columns: string[]; + columnsWidth: any; sort: SortArr[]; ariaLabelledBy: string; indexPattern: IndexPattern; @@ -67,6 +68,7 @@ interface Props { onRemoveColumn: (column: string) => void; onAddColumn: (column: string) => void; onSetColumns: (columns: string[]) => void; + onResize: (colSettings: { columnId: string; width: number }) => void; } const toolbarVisibility = { @@ -92,12 +94,14 @@ export const DiscoverGrid = React.memo( ({ rows, columns, + columnsWidth, sort, indexPattern, ariaLabelledBy, searchTitle, searchDescription, onSort, + onResize, sampleSize, onFilter, getContextAppHref, @@ -235,8 +239,17 @@ export const DiscoverGrid = React.memo( const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( - () => getEuiGridColumns(columns, indexPattern, showTimeCol, timeString, onSetColumns, onSort), - [columns, indexPattern, showTimeCol, timeString, onSetColumns, onSort] + () => + getEuiGridColumns( + columns, + columnsWidth, + indexPattern, + showTimeCol, + timeString, + onSetColumns, + onSort + ), + [columns, indexPattern, showTimeCol, timeString, onSetColumns, onSort, columnsWidth] ); const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const popoverContents = useMemo(() => getPopoverContents(), []); @@ -309,6 +322,9 @@ export const DiscoverGrid = React.memo( gridStyle={gridStyle} schemaDetectors={schemaDetectors} popoverContents={popoverContents} + onColumnResize={(col: { columnId: string; width: number }) => { + onResize(col); + }} /> {showDisclaimer && ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 9eef5dadb2160..6619fd414103e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -27,6 +27,7 @@ const geoPoint = 'geo-point'; export function getEuiGridColumns( columns: string[], + columnsWidth: any = {}, indexPattern: IndexPattern, showTimeCol: boolean, timeString: string, @@ -38,12 +39,28 @@ export function getEuiGridColumns( if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { const usedColumns = [indexPattern.timeFieldName, ...columns]; return usedColumns.map((column) => - buildEuiGridColumn(column, indexPattern, timeString, usedColumns, onSetColumns, onSort) + buildEuiGridColumn( + column, + columnsWidth ? columnsWidth[column] : 0, + indexPattern, + timeString, + usedColumns, + onSetColumns, + onSort + ) ); } return columns.map((column) => - buildEuiGridColumn(column, indexPattern, timeString, columns, onSetColumns, onSort) + buildEuiGridColumn( + column, + columnsWidth ? columnsWidth[column] : 0, + indexPattern, + timeString, + columns, + onSetColumns, + onSort + ) ); } @@ -63,6 +80,7 @@ export function getVisibleColumns( export function buildEuiGridColumn( columnName: string, + columnWidth: any, indexPattern: IndexPattern, timeString: string, columns: string[], @@ -101,6 +119,9 @@ export function buildEuiGridColumn( column.display = `${timeString} (${indexPattern.timeFieldName})`; column.initialWidth = 180; } + if (columnWidth > 0) { + column.initialWidth = Number(columnWidth); + } const listItems = [ { label: 'Sort ASC', diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 98cf36efe94d5..db41651048d39 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -66,6 +66,7 @@ interface SearchScope extends ng.IScope { indexPattern?: IndexPattern; totalHitCount?: number; isLoading?: boolean; + grid?: any; } interface SearchEmbeddableConfig { @@ -244,6 +245,8 @@ export class SearchEmbeddable extends Embeddable this.updateInput({ columns }); }; + searchScope.grid = this.savedSearch.grid ? this.savedSearch.grid : {}; + searchScope.filter = async (field, value, operator) => { let filters = esFilters.generateFilters( this.filterManager, diff --git a/src/plugins/discover/public/saved_searches/_saved_search.ts b/src/plugins/discover/public/saved_searches/_saved_search.ts index 2b8574a8fa118..685bb1860c700 100644 --- a/src/plugins/discover/public/saved_searches/_saved_search.ts +++ b/src/plugins/discover/public/saved_searches/_saved_search.ts @@ -32,6 +32,7 @@ export function createSavedSearchClass(services: SavedObjectKibanaServices) { description: 'text', hits: 'integer', columns: 'keyword', + grid: 'object', sort: 'keyword', version: 'integer', }; @@ -51,6 +52,7 @@ export function createSavedSearchClass(services: SavedObjectKibanaServices) { description: 'text', hits: 'integer', columns: 'keyword', + grid: 'object', sort: 'keyword', version: 'integer', }, @@ -59,6 +61,7 @@ export function createSavedSearchClass(services: SavedObjectKibanaServices) { title: '', description: '', columns: [], + grid: {}, hits: 0, sort: [], version: 1, diff --git a/src/plugins/discover/public/saved_searches/types.ts b/src/plugins/discover/public/saved_searches/types.ts index d601d087afcee..397d2ec85afaf 100644 --- a/src/plugins/discover/public/saved_searches/types.ts +++ b/src/plugins/discover/public/saved_searches/types.ts @@ -27,6 +27,7 @@ export interface SavedSearch { description?: string; columns: string[]; sort: SortOrder[]; + grid: any; destroy: () => void; } export interface SavedSearchLoader { diff --git a/src/plugins/discover/server/saved_objects/search.ts b/src/plugins/discover/server/saved_objects/search.ts index c13550e543ab6..c001552110662 100644 --- a/src/plugins/discover/server/saved_objects/search.ts +++ b/src/plugins/discover/server/saved_objects/search.ts @@ -53,6 +53,7 @@ export const searchSavedObjectType: SavedObjectsType = { }, sort: { type: 'keyword', index: false, doc_values: false }, title: { type: 'text' }, + grid: { type: 'object', enabled: false }, version: { type: 'integer' }, }, }, From 8a780b942e2d0044b38220ec7f336afce594392f Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Sun, 30 Aug 2020 17:40:34 -0700 Subject: [PATCH 067/186] improve expanded doc flyout design --- .../discover_grid/discover_grid_flyout.tsx | 55 ++++++++++--------- .../discover_grid_view_button.tsx | 2 +- .../components/table/table_row.tsx | 40 +++++++------- .../table/table_row_btn_filter_add.tsx | 2 +- .../table/table_row_btn_filter_exists.tsx | 2 +- .../table/table_row_btn_filter_remove.tsx | 2 +- .../table/table_row_btn_toggle_column.tsx | 4 +- 7 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 378c03d02cf10..0d81584ba4ce7 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -29,6 +29,7 @@ import { EuiLink, EuiPortal, EuiTitle, + EuiButtonEmpty, } from '@elastic/eui'; import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; @@ -67,40 +68,44 @@ export const DiscoverGridFlyout = function DiscoverGridInner({

- {' '} + {' '} {i18n.translate('discover.grid.tableRow.detailHeading', { defaultMessage: 'Expanded document', })}

- - - {indexPattern.isTimeBased() && ( - - - {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkText', { - defaultMessage: 'View surrounding documents', - })} - - - )} - - - {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkText', { - defaultMessage: 'View single document', - })} - - - - + + {indexPattern.isTimeBased() && ( + + + {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkText', { + defaultMessage: 'View surrounding documents', + })} + + + )} + + + {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkText', { + defaultMessage: 'View single document', + })} + + + { onClick={() => setViewed(rowIndex)} className="dscTable__buttonToggle" > - + ); }; diff --git a/src/plugins/discover/public/application/components/table/table_row.tsx b/src/plugins/discover/public/application/components/table/table_row.tsx index 5f7dd9f37dcd3..699197e90b994 100644 --- a/src/plugins/discover/public/application/components/table/table_row.tsx +++ b/src/plugins/discover/public/application/components/table/table_row.tsx @@ -67,26 +67,6 @@ export function DocViewTableRow({ return ( - {typeof onFilter === 'function' && ( - - onFilter(fieldMapping, valueRaw, '+')} - /> - onFilter(fieldMapping, valueRaw, '-')} - /> - {typeof onToggleColumn === 'function' && ( - - )} - onFilter('_exists_', field, '+')} - scripted={fieldMapping && fieldMapping.scripted} - /> - - )} + {typeof onFilter === 'function' && ( + + onFilter(fieldMapping, valueRaw, '+')} + /> + onFilter(fieldMapping, valueRaw, '-')} + /> + {typeof onToggleColumn === 'function' && ( + + )} + onFilter('_exists_', field, '+')} + scripted={fieldMapping && fieldMapping.scripted} + /> + + )} ); } diff --git a/src/plugins/discover/public/application/components/table/table_row_btn_filter_add.tsx b/src/plugins/discover/public/application/components/table/table_row_btn_filter_add.tsx index bd842eb5c6f72..142761768b472 100644 --- a/src/plugins/discover/public/application/components/table/table_row_btn_filter_add.tsx +++ b/src/plugins/discover/public/application/components/table/table_row_btn_filter_add.tsx @@ -49,7 +49,7 @@ export function DocViewTableRowBtnFilterAdd({ onClick, disabled = false }: Props data-test-subj="addInclusiveFilterButton" disabled={disabled} onClick={onClick} - iconType={'magnifyWithPlus'} + iconType={'plusInCircle'} iconSize={'s'} /> diff --git a/src/plugins/discover/public/application/components/table/table_row_btn_filter_exists.tsx b/src/plugins/discover/public/application/components/table/table_row_btn_filter_exists.tsx index dab22c103bc48..43a711fc72da5 100644 --- a/src/plugins/discover/public/application/components/table/table_row_btn_filter_exists.tsx +++ b/src/plugins/discover/public/application/components/table/table_row_btn_filter_exists.tsx @@ -61,7 +61,7 @@ export function DocViewTableRowBtnFilterExists({ className="kbnDocViewer__actionButton" data-test-subj="addExistsFilterButton" disabled={disabled} - iconType={'indexOpen'} + iconType={'filter'} iconSize={'s'} /> diff --git a/src/plugins/discover/public/application/components/table/table_row_btn_filter_remove.tsx b/src/plugins/discover/public/application/components/table/table_row_btn_filter_remove.tsx index bbef54cb4ecc7..878088ae0a6d8 100644 --- a/src/plugins/discover/public/application/components/table/table_row_btn_filter_remove.tsx +++ b/src/plugins/discover/public/application/components/table/table_row_btn_filter_remove.tsx @@ -49,7 +49,7 @@ export function DocViewTableRowBtnFilterRemove({ onClick, disabled = false }: Pr data-test-subj="removeInclusiveFilterButton" disabled={disabled} onClick={onClick} - iconType={'magnifyWithMinus'} + iconType={'minusInCircle'} iconSize={'s'} /> diff --git a/src/plugins/discover/public/application/components/table/table_row_btn_toggle_column.tsx b/src/plugins/discover/public/application/components/table/table_row_btn_toggle_column.tsx index 3e5a057929701..1a32ba3be1712 100644 --- a/src/plugins/discover/public/application/components/table/table_row_btn_toggle_column.tsx +++ b/src/plugins/discover/public/application/components/table/table_row_btn_toggle_column.tsx @@ -37,7 +37,7 @@ export function DocViewTableRowBtnToggleColumn({ onClick, active, disabled = fal className="kbnDocViewer__actionButton" data-test-subj="toggleColumnButton" disabled - iconType={'tableOfContents'} + iconType={'listAdd'} iconSize={'s'} /> ); @@ -59,7 +59,7 @@ export function DocViewTableRowBtnToggleColumn({ onClick, active, disabled = fal onClick={onClick} className="kbnDocViewer__actionButton" data-test-subj="toggleColumnButton" - iconType={'tableOfContents'} + iconType={'listAdd'} iconSize={'s'} /> From 72bdf33dd1d16d9180d5f748f11180a1a5b90a31 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Sun, 30 Aug 2020 18:21:53 -0700 Subject: [PATCH 068/186] remove EuiLink --- .../components/discover_grid/discover_grid_flyout.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 0d81584ba4ce7..f2987fcec7fe9 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -26,7 +26,6 @@ import { EuiFlyoutBody, EuiFlyoutHeader, EuiIcon, - EuiLink, EuiPortal, EuiTitle, EuiButtonEmpty, From f4bac9c28684631e2f89a3791fa6136874174627 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 1 Sep 2020 14:16:07 +0200 Subject: [PATCH 069/186] Fix legacy embeddable --- .../create_discover_grid_directive.tsx | 35 +++++++++++++++++-- .../embeddable/search_embeddable.ts | 4 ++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx index 5d03511b9c8ac..db7ce7b4e1484 100644 --- a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx @@ -16,11 +16,42 @@ * specific language governing permissions and limitations * under the License. */ - +import * as React from 'react'; import { DiscoverGrid } from './discover_grid'; +interface Props

{ + [key: string]: any; +} + +/** + * TODO remove when development is finished, helper component to detect property changes + * TODO when this is removed there is a problem with the reactDirective that has to be solved + * @param WrappedComponent + */ +export function withPropsChecker

( + WrappedComponent: React.ComponentType

+): React.ComponentClass> { + // eslint-disable-next-line react/prefer-stateless-function + return class PropsChecker extends React.Component> { + /** + componentWillReceiveProps(nextProps: Props

) { + Object.keys(nextProps) + .filter((key) => nextProps[key] !== this.props[key]) + .map((key) => { + console.log('changed property:', key, 'from', this.props[key], 'to', nextProps[key]); + }); + } + **/ + + render() { + // @ts-ignore + return ; + } + }; +} + export function createDiscoverGridDirective(reactDirective: any) { - return reactDirective(DiscoverGrid, [ + return reactDirective(withPropsChecker(DiscoverGrid), [ ['columns', { watchDepth: 'collection' }], ['rows', { watchDepth: 'collection' }], ['indexPattern', { watchDepth: 'reference' }], diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index b38b931068d98..6de904c000dd9 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -246,7 +246,9 @@ export class SearchEmbeddable this.updateInput({ columns }); }; - searchScope.grid = this.savedSearch.grid ? this.savedSearch.grid : {}; + if (this.savedSearch.grid) { + searchScope.grid = this.savedSearch.grid; + } searchScope.filter = async (field, value, operator) => { let filters = esFilters.generateFilters( From 638d0e7b710eb0aa2ba67618ba8e4bbcaa6bcf08 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sat, 5 Sep 2020 18:27:15 +0200 Subject: [PATCH 070/186] Enable columnsWidth in embeddable, remove filters from cell --- .../create_discover_grid_directive.tsx | 1 + .../discover_grid/discover_grid.scss | 4 + .../discover_grid/discover_grid.tsx | 11 +-- .../discover_grid/discover_grid_cell.tsx | 94 +++++++++++++++++++ .../discover_grid/discover_grid_helpers.tsx | 1 + .../embeddable/search_embeddable.ts | 5 + .../embeddable/search_template_datagrid.html | 1 + 7 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx index db7ce7b4e1484..548d8f0e76867 100644 --- a/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/create_discover_grid_directive.tsx @@ -53,6 +53,7 @@ export function withPropsChecker

( export function createDiscoverGridDirective(reactDirective: any) { return reactDirective(withPropsChecker(DiscoverGrid), [ ['columns', { watchDepth: 'collection' }], + ['columnsWidth', { watchDepth: 'collection' }], ['rows', { watchDepth: 'collection' }], ['indexPattern', { watchDepth: 'reference' }], ['sort', { watchDepth: 'value' }], diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index 91060c4d3db83..c109cbfb68f1c 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -95,3 +95,7 @@ div[data-rbd-draggable-id='Time'] { padding-left: $euiSizeXS; } } + +.euiDataGridRowCell--numeric { + text-align: right; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index f65d4e64c9398..841c3b54acb25 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -38,7 +38,6 @@ import { } from './discover_grid_helpers'; import { DiscoverGridFlyoutSelection } from './discover_grid_flyout_selection'; import { DiscoverGridFlyout } from './discover_grid_flyout'; -import { DiscoverGridValueWithFilter } from './discover_value_with_filter'; import { DiscoverGridToolbarSelection } from './discover_grid_toolbar_selection'; import { DiscoverGridContext } from './discover_grid_context'; import { DiscoverGridSelectButton } from './discover_grid_select_button'; @@ -214,15 +213,7 @@ export const DiscoverGrid = React.memo( /> ); } else if (indexPattern.fields.getByName(columnId)?.filterable) { - return ( - - ); + return value; } return value; }, diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx new file mode 100644 index 0000000000000..a38632874ab04 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx @@ -0,0 +1,94 @@ +/* + * 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 React, { ReactNode } from 'react'; +import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; + +/** + * Draft component displaying filter lens icons on hover with the possibility to add a filter + */ +export const DiscoverGridValueWithFilter = ({ + value, + columnId, + row, + indexPattern, + onFilter, +}: { + value: ReactNode; + columnId: string; + row: ElasticSearchHit; + indexPattern: IndexPattern; + onFilter: DocViewFilterFn; +}) => { + return ( + + + {value} + + +

+ ) => { + ev.stopPropagation(); + ev.preventDefault(); + onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + '+' + ); + }} + /> + ) => { + ev.stopPropagation(); + ev.preventDefault(); + onFilter( + indexPattern.fields.getByName(columnId), + indexPattern.flattenHit(row)[columnId], + '-' + ); + }} + /> +
+
+ + ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 6619fd414103e..3907ff23e63fe 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -115,6 +115,7 @@ export function buildEuiGridColumn( column.schema = undefined; break; } + if (column.id === indexPattern.timeFieldName) { column.display = `${timeString} (${indexPattern.timeFieldName})`; column.initialWidth = 180; diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 6de904c000dd9..89c09141bb307 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -53,6 +53,7 @@ import { SAMPLE_SIZE_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../common interface SearchScope extends ng.IScope { columns?: string[]; + columnsWidth?: any; description?: string; sort?: SortOrder[]; sharedItemTitle?: string; @@ -248,6 +249,10 @@ export class SearchEmbeddable if (this.savedSearch.grid) { searchScope.grid = this.savedSearch.grid; + searchScope.columnsWidth = + this.savedSearch.grid && this.savedSearch.grid.columnsWidth + ? this.savedSearch.grid.columnsWidth + : undefined; } searchScope.filter = async (field, value, operator) => { diff --git a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html index 84187c48370eb..93fe85a7a3d38 100644 --- a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html +++ b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html @@ -1,5 +1,6 @@ Date: Tue, 8 Sep 2020 15:32:01 +0200 Subject: [PATCH 071/186] Fix types --- src/plugins/discover/public/application/components/discover.tsx | 1 - test/functional/apps/management/_scripted_fields.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index a1c47a5704429..02d61092ce064 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -122,7 +122,6 @@ export function Discover({ onRemoveField={onRemoveColumn} selectedIndexPattern={searchSource && searchSource.getField('index')} setIndexPattern={setIndexPattern} - state={state} /> diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 800b9d334caa8..76b25a6548833 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -61,7 +61,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.load('discover'); // delete .kibana index and then wait for Kibana to re-create it await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); - await PageObjects.settings.createIndexPattern(); await kibanaServer.uiSettings.update({}); }); From d0709493c411c3cba25f671adfd0c72938f6d6f6 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 8 Sep 2020 16:01:49 +0200 Subject: [PATCH 072/186] Fix context href --- .../public/application/angular/discover.js | 15 +++++++++-- .../angular/discover_datagrid.html | 1 - .../components/create_discover_directive.ts | 1 - .../application/components/discover.tsx | 27 +++++++++++++++++-- .../discover_grid/discover_grid.tsx | 2 +- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 82ad363748157..5062c823bcacb 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -453,13 +453,23 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise }; $scope.getContextAppHref = (anchorId) => { - const path = `#/discover/context/${$scope.indexPattern}/${anchorId}`; + const path = `#/discover/context/${encodeURIComponent( + $scope.indexPattern.id + )}/${encodeURIComponent(anchorId)}`; const urlSearchParams = new URLSearchParams(); + + urlSearchParams.set( + 'g', + rison.encode({ + filters: filterManager.getGlobalFilters() || [], + }) + ); + urlSearchParams.set( '_a', rison.encode({ columns: $scope.state.columns, - filters: ($scope.filters || []).map(esFilters.disableFilter), + filters: (filterManager.getAppFilters() || []).map(esFilters.disableFilter), }) ); return `${path}?${urlSearchParams.toString()}`; @@ -635,6 +645,7 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise savedSearch: savedSearch, indexPatternList: $route.current.locals.savedObjects.ip.list, config: config, + filterManager, }; const shouldSearchOnPageLoad = () => { diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index 9d347a7741428..2be87c7b7ab83 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -8,7 +8,6 @@ fetchCounter="fetchCounter" fetchError="fetchError" field-counts="fieldCounts" - get-context-app-href="getContextAppHref" hits="hits" histogram-data="histogramData" index-pattern-list="opts.indexPatternList" diff --git a/src/plugins/discover/public/application/components/create_discover_directive.ts b/src/plugins/discover/public/application/components/create_discover_directive.ts index 091951b44a176..4c26231a2ba06 100644 --- a/src/plugins/discover/public/application/components/create_discover_directive.ts +++ b/src/plugins/discover/public/application/components/create_discover_directive.ts @@ -28,7 +28,6 @@ export function createDiscoverDirective(reactDirective: any) { ['fetchCounter', { watchDepth: 'reference' }], ['fetchError', { watchDepth: 'reference' }], ['fieldCounts', { watchDepth: 'reference' }], - ['getContextAppHref', { watchDepth: 'reference' }], ['histogramData', { watchDepth: 'reference' }], ['hits', { watchDepth: 'reference' }], ['indexPattern', { watchDepth: 'reference' }], diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 02d61092ce064..ff64dc29109d5 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -18,6 +18,7 @@ */ import React, { useState } from 'react'; import moment from 'moment'; +import rison from 'rison-node'; import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; @@ -26,6 +27,7 @@ import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; import { DiscoverSidebar } from './sidebar'; import { getServices } from '../../kibana_services'; + // @ts-ignore import { DiscoverNoResults } from '../angular/directives/no_results'; import { DiscoverUninitialized } from '../angular/directives/uninitialized'; @@ -33,6 +35,7 @@ import { DiscoverHistogram } from '../angular/directives/histogram'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; import { DiscoverFetchError } from './fetch_error/fetch_error'; import './discover.scss'; +import { esFilters } from '../../../../data/public'; export function Discover({ addColumn, @@ -42,7 +45,6 @@ export function Discover({ fetchError, fetchCounter, fieldCounts, - getContextAppHref, histogramData, hits, indexPattern, @@ -82,7 +84,28 @@ export function Discover({ return
Loading
; } const { TopNavMenu } = getServices().navigation.ui; - const { savedSearch } = opts; + const { savedSearch, filterManager } = opts; + + const getContextAppHref = (anchorId: string) => { + const path = `#/context/${encodeURIComponent(indexPattern.id)}/${encodeURIComponent(anchorId)}`; + const urlSearchParams = new URLSearchParams(); + + urlSearchParams.set( + 'g', + rison.encode({ + filters: filterManager.getGlobalFilters() || [], + }) + ); + + urlSearchParams.set( + '_a', + rison.encode({ + columns: state.columns, + filters: (filterManager.getAppFilters() || []).map(esFilters.disableFilter), + }) + ); + return `${path}?${urlSearchParams.toString()}`; + }; return ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 841c3b54acb25..ef93d2af92e87 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -63,7 +63,7 @@ interface Props { onFilter: DocViewFilterFn; showTimeCol: boolean; onSort: (props: any) => void; - getContextAppHref: (id: string | number | Record) => string; + getContextAppHref: (id: string) => string; onRemoveColumn: (column: string) => void; onAddColumn: (column: string) => void; onSetColumns: (columns: string[]) => void; From c52931deada8c47f61bce578899c755ce2d6a099 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 14 Sep 2020 17:16:42 +0200 Subject: [PATCH 073/186] Improve dashboard code, add no results rendering --- .../discover_grid/discover_grid.scss | 10 + .../discover_grid/discover_grid.tsx | 189 ++++++++++-------- .../discover_grid/discover_grid_flyout.tsx | 2 +- .../discover_grid_select_button.tsx | 11 +- 4 files changed, 126 insertions(+), 86 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index c109cbfb68f1c..b14775a36832b 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -99,3 +99,13 @@ div[data-rbd-draggable-id='Time'] { .euiDataGridRowCell--numeric { text-align: right; } + +.euiDataGrid__noResults { + display: flex; + flex-direction: column; + justify-content: center; + flex: 1 0 100%; + text-align: center; + height: 100%; + width: 100%; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index ef93d2af92e87..5315f9578a9fd 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,13 +17,16 @@ * under the License. */ import React, { useCallback, useMemo, useState } from 'react'; -import { FormattedMessage } from '@kbn/i18n/react'; +import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import './discover_grid.scss'; import { i18n } from '@kbn/i18n'; import { EuiDataGrid, EuiDataGridCellValueElementProps, EuiScreenReaderOnly, + EuiSpacer, + EuiText, + EuiIcon, htmlIdGenerator, } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; @@ -51,7 +54,7 @@ interface SortObj { } interface Props { - rows: ElasticSearchHit[]; + rows?: ElasticSearchHit[]; columns: string[]; columnsWidth: any; sort: SortArr[]; @@ -67,7 +70,7 @@ interface Props { onRemoveColumn: (column: string) => void; onAddColumn: (column: string) => void; onSetColumns: (columns: string[]) => void; - onResize: (colSettings: { columnId: string; width: number }) => void; + onResize?: (colSettings: { columnId: string; width: number }) => void; } const toolbarVisibility = { @@ -163,7 +166,7 @@ export const DiscoverGrid = React.memo( */ const renderCellValue = useCallback( ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { - const row = rows[rowIndex]; + const row = rows ? rows[rowIndex] : undefined; if (typeof row === 'undefined') { return '-'; @@ -223,9 +226,10 @@ export const DiscoverGrid = React.memo( /** * Render variables */ - const pageCount = Math.ceil(rows.length / pagination.pageSize); + const rowsLength = rows ? rows.length : 0; + const pageCount = Math.ceil(rowsLength / pagination.pageSize); const isOnLastPage = pagination.pageIndex === pageCount - 1; - const showDisclaimer = rows.length === sampleSize && isOnLastPage; + const showDisclaimer = rowsLength === sampleSize && isOnLastPage; const randomId = useMemo(() => String(htmlIdGenerator()), []); const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); @@ -258,6 +262,9 @@ export const DiscoverGrid = React.memo( onTableSort, ]); const lead = useMemo(() => { + if (!rows) { + return []; + } return [ { id: 'checkBox', @@ -290,89 +297,103 @@ export const DiscoverGrid = React.memo( ]; }, [rows]); - if (!rowCount) { - return null; + if (!rowCount || !rows) { + return ( + +
+ + + + + +
+
+ ); } return ( - - <> - { - onResize(col); - }} - /> - - {showDisclaimer && ( -

- - - - -

- )} - {searchTitle && ( - -

- {searchDescription ? ( - - ) : ( - - )} -

-
- )} - {viewed > -1 && rows[viewed] && ( - { - setViewed(-1); + + + <> + { + if (onResize) { + onResize(col); + } }} /> - )} - {showSelected && selected.length > 0 && ( - setShowSelected(false)} - /> - )} - - + + {showDisclaimer && ( +

+ + + + +

+ )} + {searchTitle && ( + +

+ {searchDescription ? ( + + ) : ( + + )} +

+
+ )} + {viewed > -1 && rows[viewed] && ( + { + setViewed(-1); + }} + /> + )} + {showSelected && selected && selected.length > 0 && ( + setShowSelected(false)} + /> + )} + +
+
); } ); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index f2987fcec7fe9..b070b2846c268 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -37,7 +37,7 @@ import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_typ interface Props { hit: ElasticSearchHit; columns: string[]; - getContextAppHref: (id: string | number | Record) => string; + getContextAppHref: (id: string) => string; indexPattern: IndexPattern; onAddColumn: (column: string) => void; onClose: () => void; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx index 858a30a7ebc7b..7c1069bea2f17 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx @@ -21,10 +21,19 @@ import { EuiCheckbox } from '@elastic/eui'; import { GridContext, DiscoverGridContext } from './discover_grid_context'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; -export const DiscoverGridSelectButton = ({ col, rows }: { col: any; rows: ElasticSearchHit[] }) => { +export const DiscoverGridSelectButton = ({ + col, + rows, +}: { + col: any; + rows?: ElasticSearchHit[]; +}) => { const { selected, setSelected } = useContext(DiscoverGridContext); const rowIndex = col.rowIndex; const isChecked = selected.includes(rowIndex); + if (!rows) { + return null; + } return ( Date: Mon, 14 Sep 2020 16:51:38 -0700 Subject: [PATCH 074/186] temporarily remove EuiResizableContainer --- .../application/components/discover.tsx | 296 +++++++++--------- .../components/sidebar/discover_sidebar.scss | 20 +- 2 files changed, 172 insertions(+), 144 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index ff64dc29109d5..715b12f887849 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import moment from 'moment'; import rison from 'rison-node'; -import { EuiResizableContainer } from '@elastic/eui'; +// import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; @@ -37,6 +37,38 @@ import { DiscoverFetchError } from './fetch_error/fetch_error'; import './discover.scss'; import { esFilters } from '../../../../data/public'; +// Hook +function useWindowSize() { + // Initialize state with undefined width/height so server and client renders match + // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/ + const [windowSize, setWindowSize] = useState({ + width: undefined, + height: undefined, + }); + + useEffect(() => { + // Handler to call on window resize + function handleResize() { + // Set window width/height to state + setWindowSize({ + width: window.innerWidth, + height: window.innerHeight, + }); + } + + // Add event listener + window.addEventListener('resize', handleResize); + + // Call handler right away so state gets updated with initial window size + handleResize(); + + // Remove event listener on cleanup + return () => window.removeEventListener('resize', handleResize); + }, []); // Empty array ensures that effect is only run on mount + + return windowSize; +} + export function Discover({ addColumn, bucketInterval, @@ -85,6 +117,7 @@ export function Discover({ } const { TopNavMenu } = getServices().navigation.ui; const { savedSearch, filterManager } = opts; + const size = useWindowSize(); const getContextAppHref = (anchorId: string) => { const path = `#/context/${encodeURIComponent(indexPattern.id)}/${encodeURIComponent(anchorId)}`; @@ -126,151 +159,134 @@ export function Discover({ useDefaultBehaviors={true} />
- - {(EuiResizablePanel, EuiResizableButton) => ( - <> - - - + <> +
+ {size.width}px / {size.height}px +
+ - + <> + {resultState === 'none' && ( + + )} + {resultState === 'uninitialized' && } - - <> - {resultState === 'none' && ( - - )} - {resultState === 'uninitialized' && } + {resultState === 'loading' && ( + <> + {fetchError && } + {!fetchError && ( +
+ +
+ )} + + )} - {resultState === 'loading' && ( - <> - {fetchError && } - {!fetchError && ( -
- + {resultState === 'ready' && ( +
+
+ + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + { + toggleChart(e.target.checked); + }} + isSelected={toggleOn} + isEmpty + /> + + +
+ +
+ {opts.timefield && toggleOn && ( +
+ {vis && rows.length !== 0 && ( +
+
)} - +
)} - - {resultState === 'ready' && ( -
-
- - - 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> - - - - - - { - toggleChart(e.target.checked); - }} - isSelected={toggleOn} - isEmpty - /> - - +
+

+ +

+ {rows && rows.length && ( +
+
- -
- {opts.timefield && toggleOn && ( -
- {vis && rows.length !== 0 && ( -
- -
- )} -
- )} -
-

- -

- {rows && rows.length && ( -
- -
- )} -
-
-
- )} - - - - )} - + )} +
+
+
+ )} + +
diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index f6d4751e81438..2b0c55e696c11 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -12,10 +12,10 @@ display: -webkit-flex; display: -ms-flexbox; display: flex; - overflow: hidden; + // overflow: hidden; } -.dscApp .dscSidebar__sectionStatic { +.dscApp .dscSidebar__sectionStatic { padding: 0 16px; } @@ -26,8 +26,20 @@ flex-grow: 1; overflow-x: hidden; scrollbar-width: thin; - -webkit-mask-image: linear-gradient(to bottom, rgba(255, 0, 0, 0.1) 0%, red 7.5px, red calc(100% - 7.5px), rgba(255, 0, 0, 0.1) 100%); - mask-image: linear-gradient(to bottom, rgba(255, 0, 0, 0.1) 0%, red 7.5px, red calc(100% - 7.5px), rgba(255, 0, 0, 0.1) 100%); + -webkit-mask-image: linear-gradient( + to bottom, + rgba(255, 0, 0, 0.1) 0%, + red 7.5px, + red calc(100% - 7.5px), + rgba(255, 0, 0, 0.1) 100% + ); + mask-image: linear-gradient( + to bottom, + rgba(255, 0, 0, 0.1) 0%, + red 7.5px, + red calc(100% - 7.5px), + rgba(255, 0, 0, 0.1) 100% + ); height: 100%; overflow-y: auto; padding: 0 16px; From 760b84ab45516a5c0d13e336f2495d590cbb1f5c Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 14 Sep 2020 19:09:09 -0700 Subject: [PATCH 075/186] need to move button to the right section --- .../public/application/_discover.scss | 5 + .../application/components/discover.tsx | 81 ++++- .../sidebar/discover_mobile_flyout.tsx | 313 ++++++++++++++++++ .../sidebar/discover_sidebar_mobile.tsx | 144 ++++++++ .../application/components/sidebar/index.ts | 2 + 5 files changed, 529 insertions(+), 16 deletions(-) create mode 100644 src/plugins/discover/public/application/components/sidebar/discover_mobile_flyout.tsx create mode 100644 src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 10272ca748e32..142c604c34c07 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -31,6 +31,11 @@ discover-app { flex-grow: 1; display: flex; overflow: hidden; + @include euiBreakpoint('xs', 's') { + flex-wrap: wrap; + margin-left: 0; + margin-right: 0; + } } .dscApp__sidebar { diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 715b12f887849..598dc309f2fa5 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -21,11 +21,21 @@ import moment from 'moment'; import rison from 'rison-node'; // import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; +import { + EuiFlexItem, + EuiFlexGroup, + EuiButton, + EuiButtonToggle, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, +} from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; import { DiscoverSidebar } from './sidebar'; +import { DiscoverSidebarMobile } from './sidebar'; +import { DiscoverMobileFlyout } from './sidebar'; import { getServices } from '../../kibana_services'; // @ts-ignore @@ -118,6 +128,32 @@ export function Discover({ const { TopNavMenu } = getServices().navigation.ui; const { savedSearch, filterManager } = opts; const size = useWindowSize(); + const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); + + let flyout; + + if (isFlyoutVisible) { + flyout = ( + setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> + +

Field list

+
+ + + +
+ ); + } const getContextAppHref = (anchorId: string) => { const path = `#/context/${encodeURIComponent(indexPattern.id)}/${encodeURIComponent(anchorId)}`; @@ -160,20 +196,32 @@ export function Discover({ />
<> -
- {size.width}px / {size.height}px -
- + {flyout} + {size && size.width > 575 ? ( + + ) : ( + + )} <> {resultState === 'none' && ( @@ -197,6 +245,8 @@ export function Discover({ {resultState === 'ready' && (
+ {size.width}px / {size.height}px + setIsFlyoutVisible(true)}>Fields
-
{opts.timefield && toggleOn && (
; + /** + * hits fetched from ES, displayed in the doc table + */ + hits: Array>; + /** + * List of available index patterns + */ + indexPatternList: Array>; + /** + * Callback function when selecting a field + */ + onAddField: (fieldName: string) => void; + /** + * Callback function when adding a filter from sidebar + */ + onAddFilter: (field: IndexPatternField | string, value: string, type: '+' | '-') => void; + /** + * Callback function when removing a field + * @param fieldName + */ + onRemoveField: (fieldName: string) => void; + /** + * Currently selected index pattern + */ + selectedIndexPattern: IndexPattern; + /** + * Callback function to select another index pattern + */ + setIndexPattern: (id: string) => void; +} + +export function DiscoverMobileFlyout({ + columns, + fieldCounts, + hits, + indexPatternList, + onAddField, + onAddFilter, + onRemoveField, + selectedIndexPattern, + setIndexPattern, +}: DiscoverMobileFlyoutProps) { + const [showFields, setShowFields] = useState(false); + const [fields, setFields] = useState(null); + const [fieldFilterState, setFieldFilterState] = useState(getDefaultFieldFilter()); + const services = useMemo(() => getServices(), []); + + useEffect(() => { + const newFields = getIndexPatternFieldList(selectedIndexPattern, fieldCounts); + setFields(newFields); + }, [selectedIndexPattern, fieldCounts, hits, services]); + + const onChangeFieldSearch = useCallback( + (field: string, value: string | boolean | undefined) => { + const newState = setFieldFilterProp(fieldFilterState, field, value); + setFieldFilterState(newState); + }, + [fieldFilterState] + ); + + const getDetailsByField = useCallback( + (ipField: IndexPatternField) => getDetails(ipField, hits, columns, selectedIndexPattern), + [hits, columns, selectedIndexPattern] + ); + + const popularLimit = services.uiSettings.get(FIELDS_LIMIT_SETTING); + const useShortDots = services.uiSettings.get(UI_SETTINGS.SHORT_DOTS_ENABLE); + + const { + selected: selectedFields, + popular: popularFields, + unpopular: unpopularFields, + } = useMemo(() => groupFields(fields, columns, popularLimit, fieldCounts, fieldFilterState), [ + fields, + columns, + popularLimit, + fieldCounts, + fieldFilterState, + ]); + + const fieldTypes = useMemo(() => { + const result = ['any']; + if (Array.isArray(fields)) { + for (const field of fields) { + if (result.indexOf(field.type) === -1) { + result.push(field.type); + } + } + } + return result; + }, [fields]); + + if (!selectedIndexPattern || !fields) { + return null; + } + + return ( + +
+
+ o.attributes.title)} + /> +
+
+ + +
+
+
+ {fields.length > 0 && ( + <> + +

+ +

+
+ +
    + {selectedFields.map((field: IndexPatternField) => { + return ( +
  • + +
  • + ); + })} +
+
+ +

+ +

+
+
+ setShowFields(!showFields)} + aria-label={ + showFields + ? i18n.translate( + 'discover.fieldChooser.filter.indexAndFieldsSectionHideAriaLabel', + { + defaultMessage: 'Hide fields', + } + ) + : i18n.translate( + 'discover.fieldChooser.filter.indexAndFieldsSectionShowAriaLabel', + { + defaultMessage: 'Show fields', + } + ) + } + /> +
+
+ + )} + {popularFields.length > 0 && ( +
+ + + +
    + {popularFields.map((field: IndexPatternField) => { + return ( +
  • + +
  • + ); + })} +
+
+ )} + +
    + {unpopularFields.map((field: IndexPatternField) => { + return ( +
  • + +
  • + ); + })} +
+
+
+
+ ); +} diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx new file mode 100644 index 0000000000000..9afc3d86b94ea --- /dev/null +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx @@ -0,0 +1,144 @@ +/* + * 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 './discover_sidebar.scss'; +import React, { useEffect, useState, useMemo, useCallback } from 'react'; +import { i18n } from '@kbn/i18n'; +import { sortBy } from 'lodash'; +import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { DiscoverField } from './discover_field'; +import { DiscoverIndexPattern } from './discover_index_pattern'; +import { DiscoverFieldSearch } from './discover_field_search'; +import { IndexPatternAttributes } from '../../../../../data/common'; +import { SavedObject } from '../../../../../../core/types'; +import { FIELDS_LIMIT_SETTING } from '../../../../common'; +import { groupFields } from './lib/group_fields'; +import { IndexPatternField, IndexPattern, UI_SETTINGS } from '../../../../../data/public'; +import { getDetails } from './lib/get_details'; +import { getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter'; +import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list'; +import { getServices } from '../../../kibana_services'; + +export interface DiscoverSidebarMobileProps { + /** + * the selected columns displayed in the doc table in discover + */ + columns: string[]; + /** + * a statistics of the distribution of fields in the given hits + */ + fieldCounts: Record; + /** + * hits fetched from ES, displayed in the doc table + */ + hits: Array>; + /** + * List of available index patterns + */ + indexPatternList: Array>; + /** + * Callback function when selecting a field + */ + onAddField: (fieldName: string) => void; + /** + * Callback function when adding a filter from sidebar + */ + onAddFilter: (field: IndexPatternField | string, value: string, type: '+' | '-') => void; + /** + * Callback function when removing a field + * @param fieldName + */ + onRemoveField: (fieldName: string) => void; + /** + * Currently selected index pattern + */ + selectedIndexPattern: IndexPattern; + /** + * Callback function to select another index pattern + */ + setIndexPattern: (id: string) => void; +} + +export function DiscoverSidebarMobile({ + columns, + fieldCounts, + hits, + indexPatternList, + onAddField, + onAddFilter, + onRemoveField, + selectedIndexPattern, + setIndexPattern, +}: DiscoverSidebarMobileProps) { + const [fields, setFields] = useState(null); + const [fieldFilterState, setFieldFilterState] = useState(getDefaultFieldFilter()); + const services = useMemo(() => getServices(), []); + + useEffect(() => { + const newFields = getIndexPatternFieldList(selectedIndexPattern, fieldCounts); + setFields(newFields); + }, [selectedIndexPattern, fieldCounts, hits, services]); + + const onChangeFieldSearch = useCallback( + (field: string, value: string | boolean | undefined) => { + const newState = setFieldFilterProp(fieldFilterState, field, value); + setFieldFilterState(newState); + }, + [fieldFilterState] + ); + + const popularLimit = services.uiSettings.get(FIELDS_LIMIT_SETTING); + + const { + selected: selectedFields, + popular: popularFields, + unpopular: unpopularFields, + } = useMemo(() => groupFields(fields, columns, popularLimit, fieldCounts, fieldFilterState), [ + fields, + columns, + popularLimit, + fieldCounts, + fieldFilterState, + ]); + + if (!selectedIndexPattern || !fields) { + return null; + } + + console.log(selectedFields, 'selectedFields'); + + return ( + +
+ {selectedFields.length} +
+ o.attributes.title)} + /> +
+
+
+ ); +} diff --git a/src/plugins/discover/public/application/components/sidebar/index.ts b/src/plugins/discover/public/application/components/sidebar/index.ts index 1b837840b52f6..414ce56a6e4fd 100644 --- a/src/plugins/discover/public/application/components/sidebar/index.ts +++ b/src/plugins/discover/public/application/components/sidebar/index.ts @@ -18,4 +18,6 @@ */ export { DiscoverSidebar } from './discover_sidebar'; +export { DiscoverSidebarMobile } from './discover_sidebar_mobile'; +export { DiscoverMobileFlyout } from './discover_mobile_flyout'; export { createDiscoverSidebarDirective } from './discover_sidebar_directive'; From 39cb3b212de39b071dd79e8c7a732ef4d02fb395 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 16 Sep 2020 13:32:26 -0700 Subject: [PATCH 076/186] working on Fields mobile button --- .../application/components/discover.scss | 8 ++++ .../application/components/discover.tsx | 39 +++++++++++++------ .../sidebar/discover_sidebar_mobile.tsx | 1 - 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index ec6a213694a4b..d7c54dbec8599 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -11,3 +11,11 @@ } } } + +.dscSidebar__mobile { + width: 100%; + padding: 0 $euiSize $euiSizeL $euiSize; + .dscSidebar__sectionStatic { + padding: 0; + } +} diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 598dc309f2fa5..acd76921e82bd 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -22,6 +22,7 @@ import rison from 'rison-node'; // import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { + EuiBadge, EuiFlexItem, EuiFlexGroup, EuiButton, @@ -29,6 +30,7 @@ import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, + EuiIcon, } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; @@ -210,17 +212,31 @@ export function Discover({ setIndexPattern={setIndexPattern} /> ) : ( - +
+ + setIsFlyoutVisible(true)}> + + Fields + Selected + + 5 + + + 5 + + + +
)} <> @@ -246,7 +262,6 @@ export function Discover({ {resultState === 'ready' && (
{size.width}px / {size.height}px - setIsFlyoutVisible(true)}>Fields
- {selectedFields.length}
Date: Mon, 21 Sep 2020 00:02:48 -0700 Subject: [PATCH 077/186] improve Fields button in mobile --- .../public/application/_discover.scss | 4 +++ .../application/components/discover.scss | 12 ++++++- .../application/components/discover.tsx | 33 +++++++++++-------- .../components/sidebar/discover_field.tsx | 13 ++++++-- .../sidebar/discover_mobile_flyout.tsx | 5 ++- .../components/sidebar/discover_sidebar.scss | 4 +++ .../sidebar/discover_sidebar_mobile.tsx | 2 -- 7 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 142c604c34c07..f72bf9f0ed3d1 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -83,6 +83,10 @@ discover-app { display: flex; overflow: hidden; + @include euiBreakpoint('xs', 's') { + margin: $euiSizeS; + } + .kbn-table { margin-bottom: 0; } diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index d7c54dbec8599..a0a5e7884a3e6 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -14,8 +14,18 @@ .dscSidebar__mobile { width: 100%; - padding: 0 $euiSize $euiSizeL $euiSize; + padding: 0 $euiSizeS $euiSizeL $euiSizeS; .dscSidebar__sectionStatic { padding: 0; } + .dscSidebar__mobileButton { + justify-content: space-between; + } + .dscSidebar__mobileBadge { + margin-left: $euiSizeXS; + } +} + +.dscSidebarFlyout__header { + align-items: center; } diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index acd76921e82bd..070dfdd3d777d 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -30,7 +30,7 @@ import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, - EuiIcon, + EuiButtonIcon, } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; @@ -138,7 +138,14 @@ export function Discover({ flyout = ( setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> -

Field list

+ + + setIsFlyoutVisible(false)} iconType="arrowLeft" /> + + +

Field list

+
+
- setIsFlyoutVisible(true)}> - - Fields - Selected - - 5 - - - 5 - - + setIsFlyoutVisible(true)} + > + Fields + + 5 +
)} diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx index bb330cba68e2e..7930c337e5ba3 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx @@ -61,6 +61,10 @@ export interface DiscoverFieldProps { * Determines whether the field name is shortened test.sub1.sub2 = t.s.sub2 */ useShortDots?: boolean; + /** + * Shows Add button at all times and not only on focus + */ + mobile?: boolean; } export function DiscoverField({ @@ -72,6 +76,7 @@ export function DiscoverField({ getDetails, selected, useShortDots, + mobile = false, }: DiscoverFieldProps) { const addLabelAria = i18n.translate('discover.fieldChooser.discoverField.addButtonAriaLabel', { defaultMessage: 'Add {field} to table', @@ -131,7 +136,9 @@ export function DiscoverField({ > ) => { if (ev.type === 'click') { ev.currentTarget.focus(); @@ -156,7 +163,9 @@ export function DiscoverField({ ) => { if (ev.type === 'click') { ev.currentTarget.focus(); diff --git a/src/plugins/discover/public/application/components/sidebar/discover_mobile_flyout.tsx b/src/plugins/discover/public/application/components/sidebar/discover_mobile_flyout.tsx index 9b33af526b5df..9bf1c71a8505e 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_mobile_flyout.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_mobile_flyout.tsx @@ -86,7 +86,7 @@ export function DiscoverMobileFlyout({ selectedIndexPattern, setIndexPattern, }: DiscoverMobileFlyoutProps) { - const [showFields, setShowFields] = useState(false); + const [showFields, setShowFields] = useState(true); const [fields, setFields] = useState(null); const [fieldFilterState, setFieldFilterState] = useState(getDefaultFieldFilter()); const services = useMemo(() => getServices(), []); @@ -190,6 +190,7 @@ export function DiscoverMobileFlyout({ >
Date: Wed, 23 Sep 2020 11:02:01 -0700 Subject: [PATCH 078/186] didn't really need an extra component --- .../discover/public/application/components/discover.tsx | 5 +++-- .../components/discover_grid/discover_grid_helpers.tsx | 2 +- .../application/components/sidebar/discover_field.tsx | 2 +- .../application/components/sidebar/discover_sidebar.tsx | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 070dfdd3d777d..2ae5fbbd7e80a 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -37,7 +37,7 @@ import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; import { DiscoverSidebar } from './sidebar'; import { DiscoverSidebarMobile } from './sidebar'; -import { DiscoverMobileFlyout } from './sidebar'; +// import { DiscoverMobileFlyout } from './sidebar'; import { getServices } from '../../kibana_services'; // @ts-ignore @@ -148,7 +148,7 @@ export function Discover({ - diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 3907ff23e63fe..c4f17643eb981 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -198,7 +198,7 @@ export function getSchemaDetectors() { export function getPopoverContents() { return { [geoPoint]: ({ children }: { children: ReactNode }) => { - return {children}; + return {children}xx; }, }; } diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx index 7930c337e5ba3..99f03cea28a1b 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx @@ -76,7 +76,7 @@ export function DiscoverField({ getDetails, selected, useShortDots, - mobile = false, + mobile, }: DiscoverFieldProps) { const addLabelAria = i18n.translate('discover.fieldChooser.discoverField.addButtonAriaLabel', { defaultMessage: 'Add {field} to table', diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index 0a3855f9cd776..10e92f7a5a8ff 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -73,6 +73,10 @@ export interface DiscoverSidebarProps { * Callback function to select another index pattern */ setIndexPattern: (id: string) => void; + /** + * Shows Add button at all times and not only on focus + */ + mobile?: boolean; } export function DiscoverSidebar({ @@ -85,6 +89,7 @@ export function DiscoverSidebar({ onRemoveField, selectedIndexPattern, setIndexPattern, + mobile = false, }: DiscoverSidebarProps) { const [showFields, setShowFields] = useState(false); const [fields, setFields] = useState(null); @@ -197,6 +202,7 @@ export function DiscoverSidebar({ getDetails={getDetailsByField} selected={true} useShortDots={useShortDots} + mobile={mobile} /> ); @@ -271,6 +277,7 @@ export function DiscoverSidebar({ onAddFilter={onAddFilter} getDetails={getDetailsByField} useShortDots={useShortDots} + mobile={mobile} /> ); @@ -301,6 +308,7 @@ export function DiscoverSidebar({ onAddFilter={onAddFilter} getDetails={getDetailsByField} useShortDots={useShortDots} + mobile={mobile} /> ); From 9e74d0c4eaf7f12cc2f8ab90ef6550c8361e5140 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 23 Sep 2020 14:01:37 -0700 Subject: [PATCH 079/186] available fields accordion --- .../application/components/discover.tsx | 6 +- .../components/sidebar/discover_sidebar.scss | 4 + .../components/sidebar/discover_sidebar.tsx | 193 ++++++++---------- 3 files changed, 98 insertions(+), 105 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 2ae5fbbd7e80a..fc0f3a0a734e8 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -136,7 +136,11 @@ export function Discover({ if (isFlyoutVisible) { flyout = ( - setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> + setIsFlyoutVisible(false)} + aria-labelledby="flyoutTitle" + > diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index da8646383003a..a4d7c449d8a7e 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -65,6 +65,10 @@ line-height: $euiSizeXXL; } +.dscFieldList__popularSection { + margin-top: $euiSizeXS; +} + .dscFieldList { list-style: none; margin-bottom: 0; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index 10e92f7a5a8ff..5a243639b29fc 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -19,7 +19,7 @@ import './discover_sidebar.scss'; import React, { useCallback, useEffect, useState, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiButtonIcon, EuiTitle, EuiSpacer } from '@elastic/eui'; +import { EuiAccordion, EuiButtonIcon, EuiText, EuiTitle, EuiSpacer } from '@elastic/eui'; import { sortBy } from 'lodash'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { DiscoverField } from './discover_field'; @@ -208,112 +208,97 @@ export function DiscoverSidebar({ ); })} -
- -

- -

-
-
- setShowFields(!showFields)} - aria-label={ - showFields - ? i18n.translate( - 'discover.fieldChooser.filter.indexAndFieldsSectionHideAriaLabel', - { - defaultMessage: 'Hide fields', - } - ) - : i18n.translate( - 'discover.fieldChooser.filter.indexAndFieldsSectionShowAriaLabel', - { - defaultMessage: 'Show fields', - } - ) - } - /> -
-
- - )} - {popularFields.length > 0 && ( -
- - - -
    + + + + + } > - {popularFields.map((field: IndexPatternField) => { - return ( -
  • 0 && ( +
    + - -
  • - ); - })} -
-
- )} - -
    - {unpopularFields.map((field: IndexPatternField) => { - return ( -
+ )} +
    - - - ); - })} -
+ {unpopularFields.map((field: IndexPatternField) => { + return ( +
  • + +
  • + ); + })} + + + + )}
    From 38acb0155ed6891cc54145918f5fd9c03b8eb6b2 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Thu, 24 Sep 2020 19:29:01 -0700 Subject: [PATCH 080/186] lots of cleanup --- .../public/application/_discover.scss | 6 + .../application/components/discover.scss | 2 +- .../application/components/discover.tsx | 91 ++--- .../sidebar/discover_mobile_flyout.tsx | 316 ------------------ .../components/sidebar/discover_sidebar.scss | 88 ++--- .../components/sidebar/discover_sidebar.tsx | 295 ++++++++-------- .../application/components/sidebar/index.ts | 1 - 7 files changed, 237 insertions(+), 562 deletions(-) delete mode 100644 src/plugins/discover/public/application/components/sidebar/discover_mobile_flyout.tsx diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index f72bf9f0ed3d1..d4b3fca169948 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -35,6 +35,7 @@ discover-app { flex-wrap: wrap; margin-left: 0; margin-right: 0; + overflow-y: auto; } } @@ -83,6 +84,11 @@ discover-app { display: flex; overflow: hidden; + @include euiBreakpoint('m', 'l', 'xl') { + margin-right: $euiSize; + margin-bottom: $euiSize; + } + @include euiBreakpoint('xs', 's') { margin: $euiSizeS; } diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index a0a5e7884a3e6..50ede048e72d0 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -14,7 +14,7 @@ .dscSidebar__mobile { width: 100%; - padding: 0 $euiSizeS $euiSizeL $euiSizeS; + padding: 0 $euiSizeS $euiSizeS; .dscSidebar__sectionStatic { padding: 0; } diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index fc0f3a0a734e8..adba018831ff5 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -49,38 +49,6 @@ import { DiscoverFetchError } from './fetch_error/fetch_error'; import './discover.scss'; import { esFilters } from '../../../../data/public'; -// Hook -function useWindowSize() { - // Initialize state with undefined width/height so server and client renders match - // Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/ - const [windowSize, setWindowSize] = useState({ - width: undefined, - height: undefined, - }); - - useEffect(() => { - // Handler to call on window resize - function handleResize() { - // Set window width/height to state - setWindowSize({ - width: window.innerWidth, - height: window.innerHeight, - }); - } - - // Add event listener - window.addEventListener('resize', handleResize); - - // Call handler right away so state gets updated with initial window size - handleResize(); - - // Remove event listener on cleanup - return () => window.removeEventListener('resize', handleResize); - }, []); // Empty array ensures that effect is only run on mount - - return windowSize; -} - export function Discover({ addColumn, bucketInterval, @@ -129,7 +97,6 @@ export function Discover({ } const { TopNavMenu } = getServices().navigation.ui; const { savedSearch, filterManager } = opts; - const size = useWindowSize(); const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); let flyout; @@ -208,10 +175,10 @@ export function Discover({ showSearchBar={true} useDefaultBehaviors={true} /> + {flyout}
    <> - {flyout} - {size && size.width > 575 ? ( +
    - ) : ( -
    - - setIsFlyoutVisible(true)} - > - Fields - - 5 - - -
    - )} +
    +
    + + setIsFlyoutVisible(true)} + > + Fields + + 5 + + +
    <> {resultState === 'none' && ( @@ -273,7 +239,6 @@ export function Discover({ {resultState === 'ready' && (
    - {size.width}px / {size.height}px
    ; - /** - * hits fetched from ES, displayed in the doc table - */ - hits: Array>; - /** - * List of available index patterns - */ - indexPatternList: Array>; - /** - * Callback function when selecting a field - */ - onAddField: (fieldName: string) => void; - /** - * Callback function when adding a filter from sidebar - */ - onAddFilter: (field: IndexPatternField | string, value: string, type: '+' | '-') => void; - /** - * Callback function when removing a field - * @param fieldName - */ - onRemoveField: (fieldName: string) => void; - /** - * Currently selected index pattern - */ - selectedIndexPattern: IndexPattern; - /** - * Callback function to select another index pattern - */ - setIndexPattern: (id: string) => void; -} - -export function DiscoverMobileFlyout({ - columns, - fieldCounts, - hits, - indexPatternList, - onAddField, - onAddFilter, - onRemoveField, - selectedIndexPattern, - setIndexPattern, -}: DiscoverMobileFlyoutProps) { - const [showFields, setShowFields] = useState(true); - const [fields, setFields] = useState(null); - const [fieldFilterState, setFieldFilterState] = useState(getDefaultFieldFilter()); - const services = useMemo(() => getServices(), []); - - useEffect(() => { - const newFields = getIndexPatternFieldList(selectedIndexPattern, fieldCounts); - setFields(newFields); - }, [selectedIndexPattern, fieldCounts, hits, services]); - - const onChangeFieldSearch = useCallback( - (field: string, value: string | boolean | undefined) => { - const newState = setFieldFilterProp(fieldFilterState, field, value); - setFieldFilterState(newState); - }, - [fieldFilterState] - ); - - const getDetailsByField = useCallback( - (ipField: IndexPatternField) => getDetails(ipField, hits, columns, selectedIndexPattern), - [hits, columns, selectedIndexPattern] - ); - - const popularLimit = services.uiSettings.get(FIELDS_LIMIT_SETTING); - const useShortDots = services.uiSettings.get(UI_SETTINGS.SHORT_DOTS_ENABLE); - - const { - selected: selectedFields, - popular: popularFields, - unpopular: unpopularFields, - } = useMemo(() => groupFields(fields, columns, popularLimit, fieldCounts, fieldFilterState), [ - fields, - columns, - popularLimit, - fieldCounts, - fieldFilterState, - ]); - - const fieldTypes = useMemo(() => { - const result = ['any']; - if (Array.isArray(fields)) { - for (const field of fields) { - if (result.indexOf(field.type) === -1) { - result.push(field.type); - } - } - } - return result; - }, [fields]); - - if (!selectedIndexPattern || !fields) { - return null; - } - - return ( - -
    -
    - o.attributes.title)} - /> -
    -
    - - -
    -
    -
    - {fields.length > 0 && ( - <> - -

    - -

    -
    - -
      - {selectedFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    -
    - -

    - -

    -
    -
    - setShowFields(!showFields)} - aria-label={ - showFields - ? i18n.translate( - 'discover.fieldChooser.filter.indexAndFieldsSectionHideAriaLabel', - { - defaultMessage: 'Hide fields', - } - ) - : i18n.translate( - 'discover.fieldChooser.filter.indexAndFieldsSectionShowAriaLabel', - { - defaultMessage: 'Show fields', - } - ) - } - /> -
    -
    - - )} - {popularFields.length > 0 && ( -
    - - - -
      - {popularFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    -
    - )} - -
      - {unpopularFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    -
    -
    -
    - ); -} diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index a4d7c449d8a7e..7b233fb5e0d5a 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -1,48 +1,53 @@ -.dscApp .dscSidebar__section { - -webkit-box-flex: 1; - -webkit-flex-grow: 1; - -ms-flex-positive: 1; - flex-grow: 1; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; +.dscSidebar { + margin: 0; + min-width: 304px; display: flex; - // overflow: hidden; + flex-direction: column; + position: relative; } -.dscApp .dscSidebar__sectionStatic { - padding: 0 16px; +.dscSidebar__contentWrapper { + flex: 1 0 100%; + overflow: hidden; + @include euiBreakpoint('xs', 's') { + padding-bottom: $euiSize * 4; + } + + .dscSidebar__content { + @include euiBreakpoint('xs', 's') { + padding-top: 0; + } + width: 100%; + height: 100%; + padding: $euiSize $euiSize 0; + } } -.dscApp .dscSidebar__sectionScroll { - -webkit-box-flex: 1; - -webkit-flex-grow: 1; - -ms-flex-positive: 1; +/** + * 1. Don't cut off the shadow of the field items + */ + +.dscSidebar__scrollSection { + @include euiBreakpoint('xs', 's') { + padding-left: $euiSize; + padding-top: $euiSize; + } + @include euiOverflowShadow; + @include euiScrollBar; + margin-left: -$euiSize; /* 1 */ + position: relative; flex-grow: 1; - overflow-x: hidden; - scrollbar-width: thin; - -webkit-mask-image: linear-gradient( - to bottom, - rgba(255, 0, 0, 0.1) 0%, - red 7.5px, - red calc(100% - 7.5px), - rgba(255, 0, 0, 0.1) 100% - ); - mask-image: linear-gradient( - to bottom, - rgba(255, 0, 0, 0.1) 0%, - red 7.5px, - red calc(100% - 7.5px), - rgba(255, 0, 0, 0.1) 100% - ); - height: 100%; - overflow-y: auto; - padding: 0 16px; + overflow: auto; +} + +.dscSidebar__scrollSectionList { + @include euiBreakpoint('m', 'l', 'xl') { + padding-top: $euiSizeS; + position: absolute; + top: 0; + left: $euiSize; /* 1 */ + right: $euiSizeXS; /* 1 */ + } } .dscSidebar__container { @@ -65,13 +70,10 @@ line-height: $euiSizeXXL; } -.dscFieldList__popularSection { - margin-top: $euiSizeXS; -} - .dscFieldList { list-style: none; margin-bottom: 0; + padding: 0 $euiSizeXS $euiSizeXS; } .dscFieldListHeader { diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index 5a243639b29fc..6c7f06cc8aa05 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -19,7 +19,14 @@ import './discover_sidebar.scss'; import React, { useCallback, useEffect, useState, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiAccordion, EuiButtonIcon, EuiText, EuiTitle, EuiSpacer } from '@elastic/eui'; +import { + EuiAccordion, + EuiFlexItem, + EuiFlexGroup, + EuiText, + EuiTitle, + EuiSpacer, +} from '@elastic/eui'; import { sortBy } from 'lodash'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { DiscoverField } from './discover_field'; @@ -148,18 +155,26 @@ export function DiscoverSidebar({ return (
    -
    - o.attributes.title)} - /> -
    + + + {' '} + o.attributes.title)} + /> + +
    -
    -
    -
    - {fields.length > 0 && ( - <> - -

    - -

    -
    - -
      - {selectedFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    - - - - - - } - > - {popularFields.length > 0 && ( -
    - + +
    +
    + {fields.length > 0 && ( + <> + + + + + + } > - - -
      +
        + {selectedFields.map((field: IndexPatternField) => { + return ( +
      • + +
      • + ); + })} +
      + + {selectedFields && selectedFields.length > 0 ? : null} + + + + + + } > - {popularFields.map((field: IndexPatternField) => { - return ( -
    • + {popularFields.length > 0 && ( + <> + + + +
        - - - ); - })} -
      -
    - )} -
      - {unpopularFields.map((field: IndexPatternField) => { - return ( -
    • { + return ( +
    • + +
    • + ); + })} +
    + + )} +
      - - - ); - })} -
    - - - )} -
    + {unpopularFields.map((field: IndexPatternField) => { + return ( +
  • + +
  • + ); + })} + + + + + )} +
    +
    + +
    ); diff --git a/src/plugins/discover/public/application/components/sidebar/index.ts b/src/plugins/discover/public/application/components/sidebar/index.ts index 414ce56a6e4fd..15781236541fb 100644 --- a/src/plugins/discover/public/application/components/sidebar/index.ts +++ b/src/plugins/discover/public/application/components/sidebar/index.ts @@ -19,5 +19,4 @@ export { DiscoverSidebar } from './discover_sidebar'; export { DiscoverSidebarMobile } from './discover_sidebar_mobile'; -export { DiscoverMobileFlyout } from './discover_mobile_flyout'; export { createDiscoverSidebarDirective } from './discover_sidebar_directive'; From 28f88974c0dcfca68ca9ac572b09b038865c0ed3 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sat, 26 Sep 2020 17:41:49 +0200 Subject: [PATCH 081/186] Fix functional test --- .../discover/public/application/angular/discover.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index d20f0ad079e00..834a708ab8688 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -608,21 +608,21 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise function getStateDefaults() { const query = $scope.searchSource.getField('query') || data.query.queryString.getDefaultQuery(); - return { + const defaultState = { query, sort: getSortArray(savedSearch.sort, $scope.indexPattern), columns: savedSearch.columns.length > 0 ? savedSearch.columns : config.get(DEFAULT_COLUMNS_SETTING).slice(), - columnsWidth: - savedSearch.grid && savedSearch.grid.columnsWidth - ? savedSearch.grid.columnsWidth - : undefined, index: $scope.indexPattern.id, interval: 'auto', filters: _.cloneDeep($scope.searchSource.getOwnField('filter')), }; + if (savedSearch.grid && savedSearch.grid.columnsWidth) { + defaultState.columnsWidth = savedSearch.grid.columnsWidth; + } + return defaultState; } $scope.state.index = $scope.indexPattern.id; @@ -637,7 +637,6 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise config: config, fixedScroll: createFixedScroll($scope, $timeout), setHeaderActionMenu: getHeaderActionMenuMounter(), - config: config, filterManager, }; From a04bc8df3c2e53d15d50974425050a6d0de07e92 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 27 Sep 2020 22:38:42 +0200 Subject: [PATCH 082/186] Refactor getDefaultState --- .../public/application/angular/discover.js | 39 +++++++---------- .../application/angular/discover_state.ts | 42 +++++++++++++++++-- .../angular/doc_table/lib/get_sort.ts | 10 ++++- 3 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 834a708ab8688..5691d1010f4d0 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -24,7 +24,7 @@ import { debounceTime } from 'rxjs/operators'; import moment from 'moment'; import dateMath from '@elastic/datemath'; import { i18n } from '@kbn/i18n'; -import { getState, splitState } from './discover_state'; +import { getState, splitState, getStateDefaults } from './discover_state'; import { RequestAdapter } from '../../../../inspector/public'; import { SavedObjectSaveModal, showSaveModal } from '../../../../saved_objects/public'; @@ -76,7 +76,6 @@ import { getIndexPatternId } from '../helpers/get_index_pattern_id'; import { addFatalError } from '../../../../kibana_legacy/public'; import rison from 'rison-node'; import { - DEFAULT_COLUMNS_SETTING, SAMPLE_SIZE_SETTING, SORT_DEFAULT_ORDER_SETTING, SEARCH_ON_PAGE_LOAD_SETTING, @@ -220,7 +219,12 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise getPreviousAppState, resetInitialAppState, } = getState({ - defaultAppState: getStateDefaults(), + defaultAppState: getStateDefaults( + savedSearch, + $scope.indexPattern, + config, + data.query.queryString.getDefaultQuery() + ), storeInSessionStorage: config.get('state:storeInSessionStorage'), history, toasts: core.notifications.toasts, @@ -605,26 +609,6 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise indexPatternId: searchSource.getField('index').id, }; }; - - function getStateDefaults() { - const query = $scope.searchSource.getField('query') || data.query.queryString.getDefaultQuery(); - const defaultState = { - query, - sort: getSortArray(savedSearch.sort, $scope.indexPattern), - columns: - savedSearch.columns.length > 0 - ? savedSearch.columns - : config.get(DEFAULT_COLUMNS_SETTING).slice(), - index: $scope.indexPattern.id, - interval: 'auto', - filters: _.cloneDeep($scope.searchSource.getOwnField('filter')), - }; - if (savedSearch.grid && savedSearch.grid.columnsWidth) { - defaultState.columnsWidth = savedSearch.grid.columnsWidth; - } - return defaultState; - } - $scope.state.index = $scope.indexPattern.id; $scope.state.sort = getSortArray($scope.state.sort, $scope.indexPattern); @@ -768,7 +752,14 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise history.push(`/view/${encodeURIComponent(savedSearch.id)}`); } else { // Update defaults so that "reload saved query" functions correctly - setAppState(getStateDefaults()); + setAppState( + getStateDefaults( + savedSearch, + $scope.indexPattern, + config, + data.query.queryString.getDefaultQuery() + ) + ); chrome.docTitle.change(savedSearch.lastSavedTitle); chrome.setBreadcrumbs([ { diff --git a/src/plugins/discover/public/application/angular/discover_state.ts b/src/plugins/discover/public/application/angular/discover_state.ts index 5ddb6a92b5fd4..a759bf3c627cd 100644 --- a/src/plugins/discover/public/application/angular/discover_state.ts +++ b/src/plugins/discover/public/application/angular/discover_state.ts @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import { isEqual } from 'lodash'; +import _, { isEqual } from 'lodash'; import { History } from 'history'; -import { NotificationsStart } from 'kibana/public'; +import { IUiSettingsClient, NotificationsStart } from 'kibana/public'; import { createStateContainer, createKbnUrlStateStorage, @@ -27,14 +27,21 @@ import { IKbnUrlStateStorage, withNotifyOnErrors, } from '../../../../kibana_utils/public'; -import { esFilters, Filter, Query } from '../../../../data/public'; +import { esFilters, Filter, IndexPattern, Query } from '../../../../data/public'; import { migrateLegacyQuery } from '../helpers/migrate_legacy_query'; +import { getSortArray } from './doc_table'; +import { DEFAULT_COLUMNS_SETTING } from '../../../common'; +import { SavedSearch } from '../../saved_searches'; export interface AppState { /** * Columns displayed in the table */ columns?: string[]; + /** + * Width of data grid columns + */ + columnsWidth?: { [key: string]: number }; /** * Array of applied filters */ @@ -54,7 +61,7 @@ export interface AppState { /** * Array of the used sorting [[field,direction],...] */ - sort?: string[][]; + sort?: Array<[string, string]>; /** * id of the used saved query */ @@ -191,6 +198,33 @@ export function getState({ }; } +export function getStateDefaults( + savedSearch: SavedSearch, + indexPattern: IndexPattern, + config: IUiSettingsClient, + defaultQuery: { + query: string; + language: string; + } +): AppState { + const { searchSource } = savedSearch; + const defaultState: AppState = { + query: searchSource.getField('query') || defaultQuery, + sort: getSortArray(savedSearch.sort, indexPattern), + columns: + savedSearch.columns.length > 0 + ? savedSearch.columns + : config.get(DEFAULT_COLUMNS_SETTING).slice(), + index: indexPattern.id, + interval: 'auto', + filters: _.cloneDeep(searchSource.getOwnField('filter')) as Filter[], + }; + if (savedSearch.grid && savedSearch.grid.columnsWidth) { + defaultState.columnsWidth = savedSearch.grid.columnsWidth; + } + return defaultState; +} + /** * Helper function to merge a given new state with the existing state and to set the given state * container diff --git a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.ts b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.ts index 73ae691529e2b..2605ec5bf6745 100644 --- a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.ts +++ b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort.ts @@ -76,6 +76,12 @@ export function getSort(sort: SortPair[] | SortPair, indexPattern: IndexPattern) * compared to getSort it doesn't return an array of objects, it returns an array of arrays * [[fieldToSort: directionToSort]] */ -export function getSortArray(sort: SortPair[], indexPattern: IndexPattern) { - return getSort(sort, indexPattern).map((sortPair) => Object.entries(sortPair).pop()); +export function getSortArray(sort: SortPair[], indexPattern: IndexPattern): SortPairArr[] { + return getSort(sort, indexPattern).reduce((acc: SortPairArr[], sortPair) => { + const entries = Object.entries(sortPair); + if (entries && entries[0]) { + acc.push(entries[0]); + } + return acc; + }, []); } From 0f8bc2fe1400cb201344d4333c458ad8f13d8ef8 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Sun, 27 Sep 2020 17:22:12 -0700 Subject: [PATCH 083/186] i18n for fields --- .../discover/public/application/components/discover.tsx | 5 ++++- .../components/discover_grid/discover_grid_helpers.tsx | 2 +- .../application/components/sidebar/discover_sidebar.scss | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index adba018831ff5..b0e5271f5fb79 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -210,7 +210,10 @@ export function Discover({ fullWidth onClick={() => setIsFlyoutVisible(true)} > - Fields + 5 diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index c4f17643eb981..3907ff23e63fe 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -198,7 +198,7 @@ export function getSchemaDetectors() { export function getPopoverContents() { return { [geoPoint]: ({ children }: { children: ReactNode }) => { - return {children}xx; + return {children}; }, }; } diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index 7b233fb5e0d5a..0a083ef38aee8 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -19,7 +19,7 @@ } width: 100%; height: 100%; - padding: $euiSize $euiSize 0; + padding: 0 $euiSize; } } From 8793fb46af4b0c449aad6ed02252f5477ecd1fef Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 28 Sep 2020 13:47:31 -0700 Subject: [PATCH 084/186] fix No Results screen on mobile --- src/plugins/discover/public/application/_discover.scss | 3 ++- .../public/application/angular/directives/_no_results.scss | 3 +++ .../discover/public/application/components/discover.tsx | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 729c4cdd9d49c..0306466b700cf 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -37,6 +37,7 @@ discover-app { display: flex; overflow: hidden; @include euiBreakpoint('xs', 's') { + flex-grow: 0; flex-wrap: wrap; margin-left: 0; margin-right: 0; @@ -223,7 +224,7 @@ discover-app { z-index: -1; min-height: $euiSizeM; min-width: $euiSizeM; - padding: $euiSizeXS * .5; + padding: $euiSizeXS * 0.5; } &.closed { diff --git a/src/plugins/discover/public/application/angular/directives/_no_results.scss b/src/plugins/discover/public/application/angular/directives/_no_results.scss index 7ea945e820bf9..85b23ffc79767 100644 --- a/src/plugins/discover/public/application/angular/directives/_no_results.scss +++ b/src/plugins/discover/public/application/angular/directives/_no_results.scss @@ -1,3 +1,6 @@ .dscNoResults { + @include euiBreakpoint('xs', 's') { + padding: 0 $euiSizeS; + } max-width: 1000px; } diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index f4dcb8ae3844e..ea90a950bbc38 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -172,7 +172,7 @@ export function Discover({ {flyout}
    <> -
    +
    -
    +
    Date: Mon, 28 Sep 2020 17:22:01 -0700 Subject: [PATCH 085/186] improve Expanded Document flyout in mobile --- .../public/application/components/discover.tsx | 13 ++++++++++--- .../discover_grid/discover_grid_flyout.tsx | 9 +++++++-- .../components/doc_viewer/doc_viewer.scss | 17 ++++++++++++----- .../components/field_name/field_name.tsx | 4 +++- .../components/sidebar/discover_sidebar.scss | 1 - .../application/components/table/table_row.tsx | 1 + 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index ea90a950bbc38..039f10939abb9 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -19,6 +19,7 @@ import React, { useState } from 'react'; import rison from 'rison-node'; // import { EuiResizableContainer } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { EuiBadge, @@ -30,13 +31,13 @@ import { EuiFlyoutBody, EuiFlyoutHeader, EuiButtonIcon, + EuiTitle, } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; import { DiscoverSidebar } from './sidebar'; import { DiscoverSidebarMobile } from './sidebar'; -// import { DiscoverMobileFlyout } from './sidebar'; import { getServices } from '../../kibana_services'; // @ts-ignore @@ -97,7 +98,7 @@ export function Discover({ if (isFlyoutVisible) { flyout = ( setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle" > @@ -107,7 +108,13 @@ export function Discover({ setIsFlyoutVisible(false)} iconType="arrowLeft" /> -

    Field list

    + +

    + {i18n.translate('discover.fieldList.flyoutHeading', { + defaultMessage: 'Field list', + })} +

    +
    diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index b070b2846c268..1ba17f6936ac9 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -65,7 +65,7 @@ export const DiscoverGridFlyout = function DiscoverGridInner({ - +

    {' '} {i18n.translate('discover.grid.tableRow.detailHeading', { @@ -77,7 +77,12 @@ export const DiscoverGridFlyout = function DiscoverGridInner({ - + {indexPattern.isTimeBased() && ( ; scripted?: boolean; + className?: string; } export function FieldName({ @@ -38,13 +39,14 @@ export function FieldName({ fieldType, useShortDots, fieldIconProps, + className, scripted = false, }: Props) { const typeName = getFieldTypeName(fieldType); const displayName = useShortDots ? shortenDottedString(fieldName) : fieldName; return ( - + diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index 0a083ef38aee8..8c04aa70e818a 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -1,6 +1,5 @@ .dscSidebar { margin: 0; - min-width: 304px; display: flex; flex-direction: column; position: relative; diff --git a/src/plugins/discover/public/application/components/table/table_row.tsx b/src/plugins/discover/public/application/components/table/table_row.tsx index 699197e90b994..f121b5f5a553e 100644 --- a/src/plugins/discover/public/application/components/table/table_row.tsx +++ b/src/plugins/discover/public/application/components/table/table_row.tsx @@ -69,6 +69,7 @@ export function DocViewTableRow({ Date: Mon, 28 Sep 2020 19:00:53 -0700 Subject: [PATCH 086/186] give tokens color --- .../discover/public/application/components/table/table_row.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/table/table_row.tsx b/src/plugins/discover/public/application/components/table/table_row.tsx index f121b5f5a553e..95ed759501389 100644 --- a/src/plugins/discover/public/application/components/table/table_row.tsx +++ b/src/plugins/discover/public/application/components/table/table_row.tsx @@ -69,10 +69,8 @@ export function DocViewTableRow({ From 8830406de6a795a5e341fd555b2c40612beb4880 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 29 Sep 2020 15:19:22 -0700 Subject: [PATCH 087/186] add NotificationBadge to accordions --- .../application/components/discover.tsx | 2 +- .../components/sidebar/discover_sidebar.tsx | 105 ++++++++++-------- 2 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 039f10939abb9..b7987dbe4cb8d 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -216,7 +216,7 @@ export function Discover({ defaultMessage="Fields" /> - 5 + {state.columns[0] === '_source' ? 0 : state.columns.length}

    diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index d1f8440dfa009..79390d1417ae0 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -26,6 +26,7 @@ import { EuiText, EuiTitle, EuiSpacer, + EuiNotificationBadge, } from '@elastic/eui'; import { sortBy } from 'lodash'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; @@ -188,50 +189,61 @@ export function DiscoverSidebar({
    {fields.length > 0 && ( <> - - - - - - } - > - -
      - {selectedFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    -
    - {selectedFields && selectedFields.length > 0 ? : null} + {selectedFields && + selectedFields.length > 0 && + selectedFields[0].displayName !== '_source' ? ( + <> + + + + + + } + extraAction={ + + {selectedFields.length} + + } + > + +
      + {selectedFields.map((field: IndexPatternField) => { + return ( +
    • + +
    • + ); + })} +
    +
    + {' '} + + ) : null} } + extraAction={ + + {popularFields.length + unpopularFields.length} + + } > {popularFields.length > 0 && ( From e62952485ba58608b2bd8359727f94a8285f5525 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 29 Sep 2020 15:39:20 -0700 Subject: [PATCH 088/186] add EuiShowFor and EuiHideFor --- .../application/components/discover.tsx | 157 +++++++++--------- 1 file changed, 80 insertions(+), 77 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index b7987dbe4cb8d..c8917c4098918 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -32,6 +32,8 @@ import { EuiFlyoutHeader, EuiButtonIcon, EuiTitle, + EuiShowFor, + EuiHideFor, } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; @@ -97,42 +99,40 @@ export function Discover({ if (isFlyoutVisible) { flyout = ( - setIsFlyoutVisible(false)} - aria-labelledby="flyoutTitle" - > - - - - setIsFlyoutVisible(false)} iconType="arrowLeft" /> - - - -

    - {i18n.translate('discover.fieldList.flyoutHeading', { - defaultMessage: 'Field list', - })} -

    -
    -
    -
    -
    - - - -
    + + setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> + + + + setIsFlyoutVisible(false)} iconType="arrowLeft" /> + + + +

    + {i18n.translate('discover.fieldList.flyoutHeading', { + defaultMessage: 'Field list', + })} +

    +
    +
    +
    +
    + + + +
    +
    ); } @@ -179,48 +179,51 @@ export function Discover({ {flyout}
    <> -
    - -
    -
    - - setIsFlyoutVisible(true)} - > - +
    + - - {state.columns[0] === '_source' ? 0 : state.columns.length} - - -
    - +
    + + +
    + + setIsFlyoutVisible(true)} + > + + + {state.columns[0] === '_source' ? 0 : state.columns.length} + + +
    +
    <> {resultState === 'none' && ( Date: Wed, 30 Sep 2020 10:18:40 -0700 Subject: [PATCH 089/186] make NotificationBadges in sidebar consider filters --- .../components/sidebar/discover_sidebar.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index 79390d1417ae0..2e770302f2bd0 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +import { isEqual } from 'lodash'; import './discover_sidebar.scss'; import React, { useCallback, useEffect, useState, useMemo } from 'react'; import { i18n } from '@kbn/i18n'; @@ -153,6 +154,8 @@ export function DiscoverSidebar({ return null; } + const filterChanged = isEqual(fieldFilterState, getDefaultFieldFilter()); + return (
    } extraAction={ - + {selectedFields.length} } @@ -258,7 +264,7 @@ export function DiscoverSidebar({ } extraAction={ - + {popularFields.length + unpopularFields.length} } From e4f3e8978703c0520894cab179f6a8f26267f5c6 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 30 Sep 2020 14:42:32 -0700 Subject: [PATCH 090/186] update Filter button on sidebar --- .../sidebar/discover_field_search.tsx | 30 +++++++++++-------- .../components/sidebar/discover_sidebar.scss | 11 +++---- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx index 99dad418c04bd..57c71a2bd6a55 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.tsx @@ -19,11 +19,10 @@ import React, { OptionHTMLAttributes, ReactNode, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { - EuiFacetButton, EuiFieldSearch, + EuiFilterGroup, EuiFlexGroup, EuiFlexItem, - EuiIcon, EuiPopover, EuiPopoverFooter, EuiPopoverTitle, @@ -34,6 +33,8 @@ import { EuiFormRow, EuiButtonGroup, EuiOutsideClickDetector, + EuiFilterButton, + EuiSpacer, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; @@ -108,7 +109,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { defaultMessage: 'Show field filter settings', }); - const handleFacetButtonClicked = () => { + const handleFilterButtonClicked = () => { setPopoverOpen(!isPopoverOpen); }; @@ -162,20 +163,22 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { }; const buttonContent = ( - } + iconType="arrowDown" isSelected={activeFiltersCount > 0} - quantity={activeFiltersCount} - onClick={handleFacetButtonClicked} + numFilters={0} + hasActiveFilters={activeFiltersCount > 0} + numActiveFilters={activeFiltersCount} + onClick={handleFilterButtonClicked} > - + ); const select = ( @@ -263,8 +266,9 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { /> -
    - {}} isDisabled={!isPopoverOpen}> + + {}} isDisabled={!isPopoverOpen}> + - -
    + + ); } diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss index 8c04aa70e818a..4cdee4d4dd1e0 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -132,14 +132,15 @@ } .dscFieldSearch__toggleButton { - width: calc(100% - #{$euiSizeS}); - color: $euiColorPrimary; - padding-left: $euiSizeXS; - margin-left: $euiSizeXS; + // width: calc(100% - #{$euiSizeS}); + // color: $euiColorPrimary; + // padding-left: $euiSizeXS; + // margin-left: $euiSizeXS; + // borde } .dscFieldSearch__filterWrapper { - flex-grow: 0; + width: 100%; } .dscFieldSearch__formWrapper { From 2e30b1e85c2d98e0904ff8c86b708af5bed3eb10 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 30 Sep 2020 17:41:56 -0700 Subject: [PATCH 091/186] removed some boostrap and did some cleanup in legacy --- .../public/application/_discover.scss | 39 +- .../components/discover_legacy.tsx | 357 +++++++++++------- 2 files changed, 227 insertions(+), 169 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 0306466b700cf..41f5caaa0977c 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -45,14 +45,6 @@ discover-app { } } -.dscApp__sidebar { - flex-grow: 0; - flex-basis: auto; - min-width: 250px; - display: flex; - flex-direction: column; -} - .dscApp__content { flex-grow: 1; flex-direction: column; @@ -63,7 +55,7 @@ discover-app { .dscHistogram { display: flex; - height: 200px; + height: $euiSize * 12.5; padding: $euiSizeS; } // new slimmer layout for data grid @@ -154,10 +146,9 @@ discover-app { } } -// SASSTODO: replace the padding value with a variable .dscTable__footer { background-color: $euiColorLightShade; - padding: 5px 10px; + padding: $euiSizeXS $euiSizeS; text-align: center; } @@ -166,10 +157,6 @@ discover-app { flex-direction: column; display: flex; overflow: hidden; - h3 { - margin: -20px 0 10px 0; - text-align: center; - } } .dscResults__interval { @@ -212,28 +199,22 @@ discover-app { } } +.dscCollapsibleSidebar__collapseButton { + align-self: flex-start; + &:not(.closed) { + position: relative; + left: -$euiSizeS; + } +} + .dscCollapsibleSidebar { position: relative; z-index: $euiZLevel1; - .dscCollapsibleSidebar__collapseButton { - position: absolute; - top: 0; - right: -$euiSizeXL + 4; - cursor: pointer; - z-index: -1; - min-height: $euiSizeM; - min-width: $euiSizeM; - padding: $euiSizeXS * 0.5; - } - &.closed { width: 0 !important; border-right-width: 0; border-left-width: 0; - .dscCollapsibleSidebar__collapseButton { - right: -$euiSizeL + 4; - } } } diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 9c3d833d73b23..aa341de1d113e 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -18,13 +18,27 @@ */ import React, { useState, useCallback, useEffect } from 'react'; import classNames from 'classnames'; -import { EuiButtonEmpty, EuiButtonIcon } from '@elastic/eui'; +import { + EuiButtonEmpty, + EuiButtonIcon, + EuiHideFor, + EuiShowFor, + EuiButton, + EuiBadge, + EuiFlexItem, + EuiFlexGroup, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiTitle, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { IUiSettingsClient, MountPoint } from 'kibana/public'; import { HitsCounter } from './hits_counter'; import { TimechartHeader } from './timechart_header'; import { DiscoverSidebar } from './sidebar'; +import { DiscoverSidebarMobile } from './sidebar'; import { getServices, IndexPattern } from '../../kibana_services'; // @ts-ignore import { DiscoverNoResults } from '../angular/directives/no_results'; @@ -123,6 +137,7 @@ export function DiscoverLegacy({ vis, }: DiscoverLegacyProps) { const [isSidebarClosed, setIsSidebarClosed] = useState(false); + const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); const { TopNavMenu } = getServices().navigation.ui; const { savedSearch, indexPatternList } = opts; const bucketAggConfig = vis?.data?.aggs?.aggs[1]; @@ -148,10 +163,46 @@ export function DiscoverLegacy({ closed: isSidebarClosed, }); - const mainSectionClassName = classNames({ - 'col-md-10': !isSidebarClosed, - 'col-md-12': isSidebarClosed, - }); + let flyout; + + if (isFlyoutVisible) { + flyout = ( + + setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> + + + + setIsFlyoutVisible(false)} iconType="arrowLeft" /> + + + +

    + {i18n.translate('discover.fieldList.flyoutHeading', { + defaultMessage: 'Field list', + })} +

    +
    +
    +
    +
    + + + +
    +
    + ); + } return ( @@ -172,152 +223,178 @@ export function DiscoverLegacy({ showSearchBar={true} useDefaultBehaviors={true} /> -
    -
    -
    - {!isSidebarClosed && ( -
    - -
    - )} - setIsSidebarClosed(!isSidebarClosed)} - data-test-subj="collapseSideBarButton" - aria-controls="discover-sidebar" - aria-expanded={isSidebarClosed ? 'false' : 'true'} - aria-label="Toggle sidebar" - className="dscCollapsibleSidebar__collapseButton" +
    + + {!isSidebarClosed && ( +
    + +
    + )} +
    + +
    + + setIsFlyoutVisible(true)} + > + + + {state.columns[0] === '_source' ? 0 : state.columns.length} + +
    -
    - {resultState === 'none' && ( - + {/*
    */} + + setIsSidebarClosed(!isSidebarClosed)} + data-test-subj="collapseSideBarButton" + aria-controls="discover-sidebar" + aria-expanded={isSidebarClosed ? 'false' : 'true'} + aria-label="Toggle sidebar" + className={`dscCollapsibleSidebar__collapseButton ${sidebarClassName}`} + /> + +
    + {resultState === 'none' && ( + + )} + {resultState === 'uninitialized' && } + {/* @TODO: Solved in the Angular way to satisfy functional test - should be improved*/} + + {fetchError && } +
    + +
    +
    + {resultState === 'ready' && ( +
    + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} /> - )} - {resultState === 'uninitialized' && } - {/* @TODO: Solved in the Angular way to satisfy functional test - should be improved*/} - - {fetchError && } -
    - -
    -
    - {resultState === 'ready' && ( -
    - - 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} + {opts.timefield && ( + - {opts.timefield && ( - - )} + )} - {opts.timefield && ( -
    - {vis && rows.length !== 0 && ( -
    - -
    - )} -
    - )} + {opts.timefield && ( +
    + {vis && rows.length !== 0 && ( +
    + +
    + )} +
    + )} -
    -
    -

    - +
    +

    + +

    + {rows && rows.length && ( +
    + -

    - {rows && rows.length && ( -
    - - - ​ - - {rows.length === opts.sampleSize && ( -
    - + ​ + + {rows.length === opts.sampleSize && ( +
    + + values={{ sampleSize: opts.sampleSize }} + /> - window.scrollTo(0, 0)}> - - -
    - )} -
    - )} -
    -
    + window.scrollTo(0, 0)}> + + +
    + )} +
    + )} +
    - )} -
    +
    + )}
    -
    +
    ); From 567b6f2e830b96d294bc625ff4ac8cd09a406ddf Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Thu, 1 Oct 2020 16:43:23 -0700 Subject: [PATCH 092/186] show the flyout in legacy --- .../discover/public/application/components/discover_legacy.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index aa341de1d113e..b11faf85d303f 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -223,6 +223,7 @@ export function DiscoverLegacy({ showSearchBar={true} useDefaultBehaviors={true} /> + {flyout}
    {!isSidebarClosed && ( From 03af0ce0347b57061b1b87c59989f6476ef4a963 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 2 Oct 2020 18:05:45 +0200 Subject: [PATCH 093/186] Shared state refactoring --- .../application/components/discover.tsx | 115 ++--------- .../components/discover_legacy.tsx | 123 ++---------- .../sidebar/discover_sidebar.test.tsx | 3 + .../components/sidebar/discover_sidebar.tsx | 52 ++++- .../sidebar/discover_sidebar_mobile.tsx | 141 ------------- .../sidebar/discover_sidebar_responsive.tsx | 188 ++++++++++++++++++ .../application/components/sidebar/index.ts | 2 +- 7 files changed, 262 insertions(+), 362 deletions(-) delete mode 100644 src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx create mode 100644 src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index c8917c4098918..d92414708cd86 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -19,27 +19,11 @@ import React, { useState } from 'react'; import rison from 'rison-node'; // import { EuiResizableContainer } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { - EuiBadge, - EuiFlexItem, - EuiFlexGroup, - EuiButton, - EuiButtonToggle, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiButtonIcon, - EuiTitle, - EuiShowFor, - EuiHideFor, -} from '@elastic/eui'; +import { EuiFlexItem, EuiFlexGroup, EuiButtonToggle } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; -import { DiscoverSidebar } from './sidebar'; -import { DiscoverSidebarMobile } from './sidebar'; import { getServices } from '../../kibana_services'; // @ts-ignore @@ -50,6 +34,7 @@ import { LoadingSpinner } from './loading_spinner/loading_spinner'; import { DiscoverFetchError } from './fetch_error'; import './discover.scss'; import { esFilters, search } from '../../../../data/public'; +import { DiscoverSidebarResponsive } from './sidebar/discover_sidebar_responsive'; export function Discover({ addColumn, @@ -83,7 +68,6 @@ export function Discover({ updateSavedQueryId, }: any) { const [toggleOn, toggleChart] = useState(true); - const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); if (!timeRange) { return
    Loading
    ; } @@ -97,45 +81,6 @@ export function Discover({ let flyout; - if (isFlyoutVisible) { - flyout = ( - - setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> - - - - setIsFlyoutVisible(false)} iconType="arrowLeft" /> - - - -

    - {i18n.translate('discover.fieldList.flyoutHeading', { - defaultMessage: 'Field list', - })} -

    -
    -
    -
    -
    - - - -
    -
    - ); - } - const getContextAppHref = (anchorId: string) => { const path = `#/context/${encodeURIComponent(indexPattern.id)}/${encodeURIComponent(anchorId)}`; const urlSearchParams = new URLSearchParams(); @@ -179,51 +124,17 @@ export function Discover({ {flyout}
    <> - -
    - -
    -
    - -
    - - setIsFlyoutVisible(true)} - > - - - {state.columns[0] === '_source' ? 0 : state.columns.length} - - -
    -
    + <> {resultState === 'none' && ( void; @@ -137,7 +123,6 @@ export function DiscoverLegacy({ vis, }: DiscoverLegacyProps) { const [isSidebarClosed, setIsSidebarClosed] = useState(false); - const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); const { TopNavMenu } = getServices().navigation.ui; const { savedSearch, indexPatternList } = opts; const bucketAggConfig = vis?.data?.aggs?.aggs[1]; @@ -163,47 +148,6 @@ export function DiscoverLegacy({ closed: isSidebarClosed, }); - let flyout; - - if (isFlyoutVisible) { - flyout = ( - - setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> - - - - setIsFlyoutVisible(false)} iconType="arrowLeft" /> - - - -

    - {i18n.translate('discover.fieldList.flyoutHeading', { - defaultMessage: 'Field list', - })} -

    -
    -
    -
    -
    - - - -
    -
    - ); - } - return (
    @@ -223,57 +167,20 @@ export function DiscoverLegacy({ showSearchBar={true} useDefaultBehaviors={true} /> - {flyout}
    - - {!isSidebarClosed && ( -
    - -
    - )} -
    - -
    - - setIsFlyoutVisible(true)} - > - - - {state.columns[0] === '_source' ? 0 : state.columns.length} - - -
    -
    + {/*
    */} ({ getServices: () => ({ @@ -101,6 +102,8 @@ function getCompProps() { selectedIndexPattern: indexPattern, setIndexPattern: jest.fn(), state: {}, + fieldFilter: {} as FieldFilterState, + setFieldFilter: jest.fn(), }; } diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index 2e770302f2bd0..a3977f16bf79f 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -40,7 +40,7 @@ import { FIELDS_LIMIT_SETTING } from '../../../../common'; import { groupFields } from './lib/group_fields'; import { IndexPatternField, IndexPattern, UI_SETTINGS } from '../../../../../data/public'; import { getDetails } from './lib/get_details'; -import { getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter'; +import { FieldFilterState, getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter'; import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list'; import { getServices } from '../../../kibana_services'; @@ -86,6 +86,18 @@ export interface DiscoverSidebarProps { * Shows Add button at all times and not only on focus */ mobile?: boolean; + /** + * Shows index pattern and a button that displays the sidebar in a flyout + */ + useFlyout?: boolean; + /** + * Current state of the field filter, filtering fields by name, type, ... + */ + fieldFilter: FieldFilterState; + /** + * Change current state of fieldFilter + */ + setFieldFilter: (next: FieldFilterState) => void; } export function DiscoverSidebar({ @@ -99,10 +111,11 @@ export function DiscoverSidebar({ selectedIndexPattern, setIndexPattern, mobile = false, + useFlyout = false, + fieldFilter, + setFieldFilter, }: DiscoverSidebarProps) { - const [showFields, setShowFields] = useState(false); const [fields, setFields] = useState(null); - const [fieldFilterState, setFieldFilterState] = useState(getDefaultFieldFilter()); const services = useMemo(() => getServices(), []); useEffect(() => { @@ -112,10 +125,10 @@ export function DiscoverSidebar({ const onChangeFieldSearch = useCallback( (field: string, value: string | boolean | undefined) => { - const newState = setFieldFilterProp(fieldFilterState, field, value); - setFieldFilterState(newState); + const newState = setFieldFilterProp(fieldFilter, field, value); + setFieldFilter(newState); }, - [fieldFilterState] + [fieldFilter, setFieldFilter] ); const getDetailsByField = useCallback( @@ -130,12 +143,12 @@ export function DiscoverSidebar({ selected: selectedFields, popular: popularFields, unpopular: unpopularFields, - } = useMemo(() => groupFields(fields, columns, popularLimit, fieldCounts, fieldFilterState), [ + } = useMemo(() => groupFields(fields, columns, popularLimit, fieldCounts, fieldFilter), [ fields, columns, popularLimit, fieldCounts, - fieldFilterState, + fieldFilter, ]); const fieldTypes = useMemo(() => { @@ -154,7 +167,26 @@ export function DiscoverSidebar({ return null; } - const filterChanged = isEqual(fieldFilterState, getDefaultFieldFilter()); + const filterChanged = isEqual(fieldFilter, getDefaultFieldFilter()); + + if (useFlyout) { + return ( +
    +
    + o.attributes.title)} + /> +
    +
    + ); + } return ( @@ -182,7 +214,7 @@ export function DiscoverSidebar({
    diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx deleted file mode 100644 index b75e2980c7876..0000000000000 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_mobile.tsx +++ /dev/null @@ -1,141 +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 './discover_sidebar.scss'; -import React, { useEffect, useState, useMemo, useCallback } from 'react'; -import { i18n } from '@kbn/i18n'; -import { sortBy } from 'lodash'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { DiscoverField } from './discover_field'; -import { DiscoverIndexPattern } from './discover_index_pattern'; -import { DiscoverFieldSearch } from './discover_field_search'; -import { IndexPatternAttributes } from '../../../../../data/common'; -import { SavedObject } from '../../../../../../core/types'; -import { FIELDS_LIMIT_SETTING } from '../../../../common'; -import { groupFields } from './lib/group_fields'; -import { IndexPatternField, IndexPattern, UI_SETTINGS } from '../../../../../data/public'; -import { getDetails } from './lib/get_details'; -import { getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter'; -import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list'; -import { getServices } from '../../../kibana_services'; - -export interface DiscoverSidebarMobileProps { - /** - * the selected columns displayed in the doc table in discover - */ - columns: string[]; - /** - * a statistics of the distribution of fields in the given hits - */ - fieldCounts: Record; - /** - * hits fetched from ES, displayed in the doc table - */ - hits: Array>; - /** - * List of available index patterns - */ - indexPatternList: Array>; - /** - * Callback function when selecting a field - */ - onAddField: (fieldName: string) => void; - /** - * Callback function when adding a filter from sidebar - */ - onAddFilter: (field: IndexPatternField | string, value: string, type: '+' | '-') => void; - /** - * Callback function when removing a field - * @param fieldName - */ - onRemoveField: (fieldName: string) => void; - /** - * Currently selected index pattern - */ - selectedIndexPattern: IndexPattern; - /** - * Callback function to select another index pattern - */ - setIndexPattern: (id: string) => void; -} - -export function DiscoverSidebarMobile({ - columns, - fieldCounts, - hits, - indexPatternList, - onAddField, - onAddFilter, - onRemoveField, - selectedIndexPattern, - setIndexPattern, -}: DiscoverSidebarMobileProps) { - const [fields, setFields] = useState(null); - const [fieldFilterState, setFieldFilterState] = useState(getDefaultFieldFilter()); - const services = useMemo(() => getServices(), []); - - useEffect(() => { - const newFields = getIndexPatternFieldList(selectedIndexPattern, fieldCounts); - setFields(newFields); - }, [selectedIndexPattern, fieldCounts, hits, services]); - - const onChangeFieldSearch = useCallback( - (field: string, value: string | boolean | undefined) => { - const newState = setFieldFilterProp(fieldFilterState, field, value); - setFieldFilterState(newState); - }, - [fieldFilterState] - ); - - const popularLimit = services.uiSettings.get(FIELDS_LIMIT_SETTING); - - const { - selected: selectedFields, - popular: popularFields, - unpopular: unpopularFields, - } = useMemo(() => groupFields(fields, columns, popularLimit, fieldCounts, fieldFilterState), [ - fields, - columns, - popularLimit, - fieldCounts, - fieldFilterState, - ]); - - if (!selectedIndexPattern || !fields) { - return null; - } - - return ( - -
    -
    - o.attributes.title)} - /> -
    -
    -
    - ); -} diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx new file mode 100644 index 0000000000000..a3d04ed425493 --- /dev/null +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx @@ -0,0 +1,188 @@ +/* + * 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 './discover_sidebar.scss'; +import React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiFlexItem, + EuiFlexGroup, + EuiTitle, + EuiHideFor, + EuiShowFor, + EuiButton, + EuiBadge, + EuiFlyoutHeader, + EuiButtonIcon, + EuiFlyoutBody, + EuiFlyout, +} from '@elastic/eui'; +import { sortBy } from 'lodash'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DiscoverIndexPattern } from './discover_index_pattern'; +import { IndexPatternAttributes } from '../../../../../data/common'; +import { SavedObject } from '../../../../../../core/types'; +import { IndexPatternField, IndexPattern } from '../../../../../data/public'; +import { getDefaultFieldFilter } from './lib/field_filter'; +import { DiscoverSidebar } from './discover_sidebar'; + +export interface DiscoverSidebarResponsiveProps { + /** + * the selected columns displayed in the doc table in discover + */ + columns: string[]; + /** + * a statistics of the distribution of fields in the given hits + */ + fieldCounts: Record; + /** + * hits fetched from ES, displayed in the doc table + */ + hits: Array>; + /** + * List of available index patterns + */ + indexPatternList: Array>; + /** + * Callback function when selecting a field + */ + onAddField: (fieldName: string) => void; + /** + * Callback function when adding a filter from sidebar + */ + onAddFilter: (field: IndexPatternField | string, value: string, type: '+' | '-') => void; + /** + * Callback function when removing a field + * @param fieldName + */ + onRemoveField: (fieldName: string) => void; + /** + * Currently selected index pattern + */ + selectedIndexPattern?: IndexPattern; + /** + * Callback function to select another index pattern + */ + setIndexPattern: (id: string) => void; + /** + * Shows Add button at all times and not only on focus + */ + mobile?: boolean; + /** + * Shows index pattern and a button that displays the sidebar in a flyout + */ + useFlyout?: boolean; + /** + * Adapt to legacy layout + */ + legacy?: boolean; + /** + * Additional classname used for legacy + */ + sidebarClassName?: string; +} + +export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) { + const [fieldFilter, setFieldFilter] = useState(getDefaultFieldFilter()); + const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); + + if (!props.selectedIndexPattern) { + return null; + } + + const className = props.legacy + ? `dscSidebar dscSidebar__desktop dscCollapsibleSidebar ${props.sidebarClassName}` + : `dscSidebar dscSidebar__desktop`; + + return ( + <> + +
    + +
    +
    + +
    +
    +
    + o.attributes.title)} + /> +
    +
    + setIsFlyoutVisible(true)} + > + + + {props.columns[0] === '_source' ? 0 : props.columns.length} + + +
    + {isFlyoutVisible && ( + setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> + + + + setIsFlyoutVisible(false)} iconType="arrowLeft" /> + + + +

    + {i18n.translate('discover.fieldList.flyoutHeading', { + defaultMessage: 'Field list', + })} +

    +
    +
    +
    +
    + + + +
    + )} +
    + + ); +} diff --git a/src/plugins/discover/public/application/components/sidebar/index.ts b/src/plugins/discover/public/application/components/sidebar/index.ts index dced08d5a3c31..7575b5691a95a 100644 --- a/src/plugins/discover/public/application/components/sidebar/index.ts +++ b/src/plugins/discover/public/application/components/sidebar/index.ts @@ -18,4 +18,4 @@ */ export { DiscoverSidebar } from './discover_sidebar'; -export { DiscoverSidebarMobile } from './discover_sidebar_mobile'; +export { DiscoverSidebarResponsive } from './discover_sidebar_responsive'; From 789e469761892092a0d10d9b4a4ae124b2c126e8 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 2 Oct 2020 18:13:38 +0200 Subject: [PATCH 094/186] Fix flyover not showing icons permanetly --- .../components/sidebar/discover_sidebar_responsive.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx index a3d04ed425493..b6622e168ba05 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx @@ -178,6 +178,7 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) {...props} fieldFilter={fieldFilter} setFieldFilter={setFieldFilter} + mobile={true} /> From b6d3a935738b01cdc233ae710d7c5705d14be948 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Fri, 2 Oct 2020 15:36:02 -0700 Subject: [PATCH 095/186] update loading screens --- .../public/application/_discover.scss | 13 +- .../application/components/discover.scss | 5 + .../application/components/discover.tsx | 188 +++++++++--------- .../components/discover_legacy.tsx | 2 +- 4 files changed, 103 insertions(+), 105 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 41f5caaa0977c..4907a67dfa1d7 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -121,18 +121,9 @@ discover-app { padding: $euiSizeXS 0; } -.dscOverlay { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 20; - padding-top: $euiSizeM; - - opacity: 0.75; +.dscLoading { text-align: center; - background-color: transparent; + padding: $euiSizeL 0; } .dscTable { diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index 50ede048e72d0..e633c30bcfddc 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -29,3 +29,8 @@ .dscSidebarFlyout__header { align-items: center; } + +.dscLoading { + text-align: center; + padding: $euiSizeL 0; +} diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index d92414708cd86..976c066cae2b2 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -144,105 +144,107 @@ export function Discover({ )} {resultState === 'uninitialized' && } - {resultState === 'loading' && ( - <> - {fetchError && } - {!fetchError && ( -
    - -
    - )} - - )} +
    + {resultState === 'loading' && ( + <> + {fetchError && } + {!fetchError && ( +
    + +
    + )} + + )} - {resultState === 'ready' && ( -
    -
    - - - 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> - - - - - - { - toggleChart(e.target.checked); - }} - isSelected={toggleOn} - isEmpty - /> - - -
    + {resultState === 'ready' && ( + <> +
    + + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + { + toggleChart(e.target.checked); + }} + isSelected={toggleOn} + isEmpty + /> + + +
    -
    - {opts.timefield && toggleOn && ( -
    - {vis && rows.length !== 0 && ( -
    - + {opts.timefield && toggleOn && ( +
    + {vis && rows.length !== 0 && ( +
    + +
    + )} +
    + )} +
    +

    + +

    + {rows && rows.length && ( +
    +
    )}
    - )} -
    -

    - -

    - {rows && rows.length && ( -
    - -
    - )} -
    -
    -
    - )} +
    + + )} +
    diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index b9318d83ef70b..8c27416fee367 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -206,7 +206,7 @@ export function DiscoverLegacy({ {/* @TODO: Solved in the Angular way to satisfy functional test - should be improved*/} {fetchError && } -
    +
    From 8127b20147054d7d71c44e6aceb584a39c60dab3 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 5 Oct 2020 11:00:39 -0700 Subject: [PATCH 096/186] fix empty state --- .../discover/public/application/_discover.scss | 1 + .../angular/directives/_no_results.scss | 2 +- .../public/application/components/discover.tsx | 15 +++++++-------- .../application/components/discover_legacy.tsx | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 4907a67dfa1d7..1fa54471d9ebe 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -84,6 +84,7 @@ discover-app { flex-direction: column; display: flex; overflow: hidden; + height: calc(100vh - #{$euiSizeXL * 6.5}); @include euiBreakpoint('m', 'l', 'xl') { margin-right: $euiSize; diff --git a/src/plugins/discover/public/application/angular/directives/_no_results.scss b/src/plugins/discover/public/application/angular/directives/_no_results.scss index 85b23ffc79767..5778cbfa3ba7f 100644 --- a/src/plugins/discover/public/application/angular/directives/_no_results.scss +++ b/src/plugins/discover/public/application/angular/directives/_no_results.scss @@ -2,5 +2,5 @@ @include euiBreakpoint('xs', 's') { padding: 0 $euiSizeS; } - max-width: 1000px; + padding: 0 $euiSize; } diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 976c066cae2b2..a99a5228af7e4 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -136,15 +136,14 @@ export function Discover({ setIndexPattern={setIndexPattern} /> <> - {resultState === 'none' && ( - - )} - {resultState === 'uninitialized' && } -
    + {resultState === 'none' && ( + + )} + {resultState === 'uninitialized' && } {resultState === 'loading' && ( <> {fetchError && } diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 8c27416fee367..1e87c29c0b2e4 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -181,7 +181,6 @@ export function DiscoverLegacy({ legacy={true} sidebarClassName={sidebarClassName} /> - {/*
    */} {resultState === 'ready' && ( -
    + <> 0 ? hits : 0} @@ -299,7 +298,7 @@ export function DiscoverLegacy({ )}
    -
    + )}
    From 4ad36d93e0a8d14adcdf4ab8e0cd2595b7f7c7f9 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 6 Oct 2020 12:58:08 -0700 Subject: [PATCH 097/186] remove fixed height --- .../discover/public/application/_discover.scss | 14 +++++++++++++- .../components/hits_counter/hits_counter.tsx | 8 +++++++- .../timechart_header/timechart_header.tsx | 8 +++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 1fa54471d9ebe..ad8d3b88d5a11 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -6,14 +6,27 @@ } .dscAppContainer { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + display: flex; + flex-direction: column; > * { position: relative; } } + discover-app { flex-grow: 1; } +.dscHitsCounter, +.dscTimeChartHeader { + flex-grow: 0; +} + .dscApp { position: absolute; top: 0; @@ -84,7 +97,6 @@ discover-app { flex-direction: column; display: flex; overflow: hidden; - height: calc(100vh - #{$euiSizeXL * 6.5}); @include euiBreakpoint('m', 'l', 'xl') { margin-right: $euiSize; diff --git a/src/plugins/discover/public/application/components/hits_counter/hits_counter.tsx b/src/plugins/discover/public/application/components/hits_counter/hits_counter.tsx index 73e2062b3ee9d..c132e8c863f36 100644 --- a/src/plugins/discover/public/application/components/hits_counter/hits_counter.tsx +++ b/src/plugins/discover/public/application/components/hits_counter/hits_counter.tsx @@ -40,7 +40,13 @@ export interface HitsCounterProps { export function HitsCounter({ hits, showResetButton, onResetQuery }: HitsCounterProps) { return ( - + {formatNumWithCommas(hits)}{' '} diff --git a/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx b/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx index 9074de1b5b3d1..ecbc6a48ea816 100644 --- a/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx +++ b/src/plugins/discover/public/application/components/timechart_header/timechart_header.tsx @@ -101,7 +101,13 @@ export function TimechartHeader({ return ( - + Date: Wed, 7 Oct 2020 12:19:34 +0200 Subject: [PATCH 098/186] Fix infinite scrolling --- .../angular/doc_table/infinite_scroll.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts b/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts index 1d38d0fc534d1..e91e15497f64c 100644 --- a/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts +++ b/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts @@ -30,16 +30,15 @@ export function createInfiniteScrollDirective() { more: '=', }, link: ($scope: LazyScope, $element: JQuery) => { - const $window = $(window); let checkTimer: any; + const scrollDiv = $element.parents('.dscTable'); function onScroll() { if (!$scope.more) return; - const winHeight = Number($window.height()); - const winBottom = Number(winHeight) + Number($window.scrollTop()); - const offset = $element.offset(); - const elTop = offset ? offset.top : 0; + const winHeight = Number(scrollDiv.height()); + const winBottom = Number(winHeight) + Number(scrollDiv.scrollTop()); + const elTop = $element.get(0).offsetTop || 0; const remaining = elTop - winBottom; if (remaining <= winHeight * 0.5) { @@ -57,10 +56,10 @@ export function createInfiniteScrollDirective() { }, 50); } - $window.on('scroll', scheduleCheck); + scrollDiv.on('scroll', scheduleCheck); $scope.$on('$destroy', function () { clearTimeout(checkTimer); - $window.off('scroll', scheduleCheck); + $(scrollDiv).off('scroll', scheduleCheck); }); scheduleCheck(); }, From 429e4a4bdaacb468be0035c029ccab8504ce2547 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 7 Oct 2020 15:41:31 +0200 Subject: [PATCH 099/186] Adapt infinite scrolling, allow user to hide chart in legacy --- .../public/application/angular/discover.js | 6 +- .../angular/doc_table/infinite_scroll.ts | 16 ++++- .../components/discover_legacy.tsx | 70 ++++++++++++++----- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 5691d1010f4d0..5c6877107a258 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -191,7 +191,7 @@ app.directive('discoverApp', function () { }; }); -function discoverController($element, $route, $scope, $timeout, $window, Promise, uiCapabilities) { +function discoverController($element, $route, $scope, $timeout, Promise, uiCapabilities) { const { isDefault: isDefaultType } = indexPatternsUtils; const subscriptions = new Subscription(); const $fetchObservable = new Subject(); @@ -1037,10 +1037,6 @@ function discoverController($element, $route, $scope, $timeout, $window, Promise setAppState({ columnsWidth: colSize }); }; - $scope.scrollToTop = function () { - $window.scrollTo(0, 0); - }; - async function setupVisualization() { // If no timefield has been specified we don't create a histogram of messages if (!getTimeField()) return; diff --git a/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts b/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts index e91e15497f64c..d8fa990d0701a 100644 --- a/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts +++ b/src/plugins/discover/public/application/angular/doc_table/infinite_scroll.ts @@ -31,13 +31,21 @@ export function createInfiniteScrollDirective() { }, link: ($scope: LazyScope, $element: JQuery) => { let checkTimer: any; + /** + * depending on which version of Discover is displayed, different elements are scrolling + * and have therefore to be considered for calculation of infinite scrolling + */ const scrollDiv = $element.parents('.dscTable'); + const scrollDivMobile = $element.parents('.dscApp__frame'); function onScroll() { if (!$scope.more) return; + const usedScrollDiv = document.getElementsByClassName('dscSidebar__mobile').length + ? scrollDivMobile + : scrollDiv; - const winHeight = Number(scrollDiv.height()); - const winBottom = Number(winHeight) + Number(scrollDiv.scrollTop()); + const winHeight = Number(usedScrollDiv.height()); + const winBottom = Number(winHeight) + Number(usedScrollDiv.scrollTop()); const elTop = $element.get(0).offsetTop || 0; const remaining = elTop - winBottom; @@ -57,9 +65,11 @@ export function createInfiniteScrollDirective() { } scrollDiv.on('scroll', scheduleCheck); + scrollDivMobile.on('scroll', scheduleCheck); $scope.$on('$destroy', function () { clearTimeout(checkTimer); - $(scrollDiv).off('scroll', scheduleCheck); + scrollDiv.off('scroll', scheduleCheck); + scrollDivMobile.off('scroll', scheduleCheck); }); scheduleCheck(); }, diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 1e87c29c0b2e4..d71d4169e3e8e 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -18,7 +18,14 @@ */ import React, { useState, useCallback, useEffect } from 'react'; import classNames from 'classnames'; -import { EuiButtonEmpty, EuiButtonIcon, EuiHideFor } from '@elastic/eui'; +import { + EuiButtonEmpty, + EuiButtonIcon, + EuiButtonToggle, + EuiFlexGroup, + EuiFlexItem, + EuiHideFor, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { IUiSettingsClient, MountPoint } from 'kibana/public'; @@ -48,7 +55,7 @@ import { SavedSearch } from '../../saved_searches'; import { SavedObject } from '../../../../../core/types'; import { Vis } from '../../../../visualizations/public'; import { TopNavMenuData } from '../../../../navigation/public'; -import { DiscoverSidebarResponsive } from './sidebar/discover_sidebar_responsive'; +import { DiscoverSidebarResponsive } from './sidebar'; export interface DiscoverLegacyProps { addColumn: (column: string) => void; @@ -122,6 +129,7 @@ export function DiscoverLegacy({ updateSavedQueryId, vis, }: DiscoverLegacyProps) { + const [toggleOn, toggleChart] = useState(true); const [isSidebarClosed, setIsSidebarClosed] = useState(false); const { TopNavMenu } = getServices().navigation.ui; const { savedSearch, indexPatternList } = opts; @@ -212,23 +220,43 @@ export function DiscoverLegacy({ {resultState === 'ready' && ( <> - 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> - {opts.timefield && ( - - )} +
    + + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + { + toggleChart(e.target.checked); + }} + isSelected={toggleOn} + isEmpty + /> + + +
    - {opts.timefield && ( + {toggleOn && opts.timefield && (
    - window.scrollTo(0, 0)}> + { + ev.currentTarget.parentNode.parentNode.parentNode.scrollTo(0, 0); + }} + > Date: Wed, 7 Oct 2020 08:28:31 -0700 Subject: [PATCH 100/186] couple of tiny styling fixes --- src/plugins/discover/public/application/_discover.scss | 3 +++ .../discover/public/application/components/discover_legacy.tsx | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index ad8d3b88d5a11..2c71886ab3d6f 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -148,6 +148,9 @@ discover-app { font-family: $euiCodeFontFamily; font-size: $euiFontSizeXS; } + tr:first-child { + border-bottom: 1px solid $euiColorLightShade; + } } .dscTable__footer { diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index d71d4169e3e8e..6450b9933a795 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -221,7 +221,7 @@ export function DiscoverLegacy({ <>
    - + Date: Wed, 7 Oct 2020 08:35:32 -0700 Subject: [PATCH 101/186] revert --- src/plugins/discover/public/application/_discover.scss | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 2c71886ab3d6f..ad8d3b88d5a11 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -148,9 +148,6 @@ discover-app { font-family: $euiCodeFontFamily; font-size: $euiFontSizeXS; } - tr:first-child { - border-bottom: 1px solid $euiColorLightShade; - } } .dscTable__footer { From e8a9b08968e8d75b8d1143f4f86f42620e1ca964 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 15 Oct 2020 13:40:28 +0200 Subject: [PATCH 102/186] Fix jest test + type errors + unused variables --- .../discover_grid/discover_grid_helpers.tsx | 30 +++---------------- .../sidebar/discover_field_search.test.tsx | 9 +++--- src/plugins/discover/public/build_services.ts | 2 +- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 14d2a96d609cc..c64b4fcd3a79f 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -19,7 +19,6 @@ import React, { ReactNode } from 'react'; import { EuiDataGridColumn } from '@elastic/eui'; import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; -import { moveColumn } from '../../angular/doc_table/actions/columns'; const kibanaJSON = 'kibana-json'; const geoPoint = 'geo-point'; @@ -29,37 +28,19 @@ export function getEuiGridColumns( columnsWidth: any = {}, indexPattern: IndexPattern, showTimeCol: boolean, - timeString: string, - onSetColumns: (columns: string[]) => void, - onSort: (props: any) => void + timeString: string ) { const timeFieldName = indexPattern.timeFieldName; if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { const usedColumns = [indexPattern.timeFieldName, ...columns]; return usedColumns.map((column) => - buildEuiGridColumn( - column, - columnsWidth ? columnsWidth[column] : 0, - indexPattern, - timeString, - usedColumns, - onSetColumns, - onSort - ) + buildEuiGridColumn(column, columnsWidth ? columnsWidth[column] : 0, indexPattern, timeString) ); } return columns.map((column) => - buildEuiGridColumn( - column, - columnsWidth ? columnsWidth[column] : 0, - indexPattern, - timeString, - columns, - onSetColumns, - onSort - ) + buildEuiGridColumn(column, columnsWidth ? columnsWidth[column] : 0, indexPattern, timeString) ); } @@ -81,10 +62,7 @@ export function buildEuiGridColumn( columnName: string, columnWidth: any, indexPattern: IndexPattern, - timeString: string, - columns: string[], - onSetColumns: (columns: string[]) => void, - onSort: (props: any) => void + timeString: string ) { const indexPatternField = indexPattern.getFieldByName(columnName); const column: EuiDataGridColumn = { diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx index 625d6833406eb..ab8a720ef6b12 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.test.tsx @@ -50,17 +50,18 @@ describe('DiscoverFieldSearch', () => { test('change in active filters should change facet selection and call onChange', () => { const onChange = jest.fn(); const component = mountComponent({ ...defaultProps, ...{ onChange } }); - let btn = findTestSubject(component, 'toggleFieldFilterButton'); - expect(btn.hasClass('euiFacetButton--isSelected')).toBeFalsy(); + const btn = findTestSubject(component, 'toggleFieldFilterButton'); + const badge = btn.find('.euiNotificationBadge'); + expect(badge.text()).toEqual('0'); btn.simulate('click'); const aggregatableButtonGroup = findButtonGroup(component, 'aggregatable'); + act(() => { // @ts-ignore (aggregatableButtonGroup.props() as EuiButtonGroupProps).onChange('aggregatable-true', null); }); component.update(); - btn = findTestSubject(component, 'toggleFieldFilterButton'); - expect(btn.hasClass('euiFacetButton--isSelected')).toBe(true); + expect(badge.text()).toEqual('1'); expect(onChange).toBeCalledWith('aggregatable', true); }); diff --git a/src/plugins/discover/public/build_services.ts b/src/plugins/discover/public/build_services.ts index 4a3b2b75cdc45..63a0a89700420 100644 --- a/src/plugins/discover/public/build_services.ts +++ b/src/plugins/discover/public/build_services.ts @@ -78,7 +78,7 @@ export async function buildServices( plugins: DiscoverStartPlugins, context: PluginInitializerContext, getEmbeddableInjector: any, - enhanced: false + enhanced: boolean ): Promise { const services: SavedObjectKibanaServices = { savedObjectsClient: core.savedObjects.client, From e56455c909166bad34192a09b74a42a522ff3288 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 15 Oct 2020 15:31:36 +0200 Subject: [PATCH 103/186] Fix a11y test --- .../components/discover_grid/discover_grid.tsx | 13 ++----------- .../components/sidebar/discover_sidebar.tsx | 2 ++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 6575a9f935bee..50d8525c3fb64 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -183,17 +183,8 @@ export const DiscoverGrid = React.memo( const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( - () => - getEuiGridColumns( - columns, - columnsWidth, - indexPattern, - showTimeCol, - timeString, - onSetColumns, - onSort - ), - [columns, indexPattern, showTimeCol, timeString, onSetColumns, onSort, columnsWidth] + () => getEuiGridColumns(columns, columnsWidth, indexPattern, showTimeCol, timeString), + [columns, indexPattern, showTimeCol, timeString, columnsWidth] ); const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const popoverContents = useMemo(() => getPopoverContents(), []); diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index a3977f16bf79f..c6f289889bee2 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -195,6 +195,8 @@ export function DiscoverSidebar({ aria-label={i18n.translate('discover.fieldChooser.filter.indexAndFieldsSectionAriaLabel', { defaultMessage: 'Index and fields', })} + id="discover-sidebar" + data-test-subj="discover-sidebar" > Date: Thu, 15 Oct 2020 21:29:09 +0200 Subject: [PATCH 104/186] Fix skipToBottom button --- src/plugins/discover/public/application/_discover.scss | 1 + src/plugins/discover/public/plugin.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index ad8d3b88d5a11..a86972d29ae2f 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -172,6 +172,7 @@ discover-app { position: absolute; right: $euiSizeM; top: $euiSizeXS; + z-index: $euiZLevel1; } .dscApp .dscFormatSource { diff --git a/src/plugins/discover/public/plugin.ts b/src/plugins/discover/public/plugin.ts index 05be5bef79852..c8bb0082a9881 100644 --- a/src/plugins/discover/public/plugin.ts +++ b/src/plugins/discover/public/plugin.ts @@ -89,6 +89,7 @@ export interface DiscoverSetup { */ addDocView(docViewRaw: DocViewInput | DocViewInputFn): void; }; + setEnhanced: (value: boolean) => void; } export interface DiscoverStart { From 5b5385a3301cfda8fca12d5fd7f79ea3787e7862 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 16 Oct 2020 12:39:16 +0200 Subject: [PATCH 105/186] Adapt mocks --- src/plugins/discover/public/mocks.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/discover/public/mocks.ts b/src/plugins/discover/public/mocks.ts index e4314426bfce5..7ec0a6027474d 100644 --- a/src/plugins/discover/public/mocks.ts +++ b/src/plugins/discover/public/mocks.ts @@ -27,6 +27,7 @@ const createSetupContract = (): Setup => { docViews: { addDocView: jest.fn(), }, + setEnhanced: jest.fn(), }; return setupContract; }; From 7b74b094b8825bdd65e6ccf07cd423b0457a8ba5 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 16 Oct 2020 18:57:37 +0200 Subject: [PATCH 106/186] Add JSON schema rendering --- .../discover_grid/discover_grid_helpers.tsx | 2 +- .../discover_grid/get_render_cell_value.tsx | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index c64b4fcd3a79f..dc28e0e3564aa 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -88,7 +88,7 @@ export function buildEuiGridColumn( break; case '_source': case 'object': - column.schema = kibanaJSON; + column.schema = 'object'; break; case 'geo_point': column.schema = geoPoint; diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx index 0d61b6ae2750d..52b08c8234b37 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx @@ -17,7 +17,7 @@ * under the License. */ import React from 'react'; -import { EuiDataGridCellValueElementProps } from '@elastic/eui'; +import { EuiCodeBlock, EuiDataGridCellValueElementProps } from '@elastic/eui'; import { DiscoverGridPopover } from './discover_grid_popover'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; @@ -27,7 +27,7 @@ export const getRenderCellValueFn = ( rows: ElasticSearchHit[] | undefined, onFilter: DocViewFilterFn ) => ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { - const row = rows ? rows[rowIndex] : undefined; + const row = rows ? (rows[rowIndex] as Record) : undefined; if (typeof row === 'undefined') { return '-'; @@ -60,6 +60,13 @@ export const getRenderCellValueFn = ( ); + if (isDetails && field && (field.type === '_source' || typeof row[columnId] === 'object')) { + return ( + + {JSON.stringify(row[columnId], null, 2)} + + ); + } if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { const createFilter = (fieldName: string, type: '-' | '+') => { return onFilter( From d6f89ac1fef2643c509094d1925d43e656dad781 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 18 Oct 2020 10:09:09 +0200 Subject: [PATCH 107/186] Fix _source schema --- .../discover_grid/discover_grid.tsx | 3 +- .../discover_grid/discover_grid_cell.tsx | 94 ------------------- .../discover_grid/discover_grid_helpers.tsx | 16 +++- .../discover_grid/get_render_cell_value.tsx | 37 ++------ 4 files changed, 19 insertions(+), 131 deletions(-) delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 50d8525c3fb64..50f6abbd941ea 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -157,10 +157,9 @@ export const DiscoverGrid = React.memo( /** * Cell rendering */ - const renderCellValue = useMemo(() => getRenderCellValueFn(indexPattern, rows, onFilter), [ + const renderCellValue = useMemo(() => getRenderCellValueFn(indexPattern, rows), [ rows, indexPattern, - onFilter, ]); const toolbarVisibility = { diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx deleted file mode 100644 index a38632874ab04..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell.tsx +++ /dev/null @@ -1,94 +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 React, { ReactNode } from 'react'; -import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; - -/** - * Draft component displaying filter lens icons on hover with the possibility to add a filter - */ -export const DiscoverGridValueWithFilter = ({ - value, - columnId, - row, - indexPattern, - onFilter, -}: { - value: ReactNode; - columnId: string; - row: ElasticSearchHit; - indexPattern: IndexPattern; - onFilter: DocViewFilterFn; -}) => { - return ( - - - {value} - - -
    - ) => { - ev.stopPropagation(); - ev.preventDefault(); - onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - '+' - ); - }} - /> - ) => { - ev.stopPropagation(); - ev.preventDefault(); - onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - '-' - ); - }} - /> -
    -
    -
    - ); -}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index dc28e0e3564aa..cfdbe16576eff 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { ReactNode } from 'react'; -import { EuiDataGridColumn } from '@elastic/eui'; +import { EuiCodeBlock, EuiDataGridColumn } from '@elastic/eui'; import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; const kibanaJSON = 'kibana-json'; @@ -87,14 +87,16 @@ export function buildEuiGridColumn( column.schema = 'numeric'; break; case '_source': + column.schema = kibanaJSON; + break; case 'object': - column.schema = 'object'; + column.schema = 'json'; break; case 'geo_point': column.schema = geoPoint; break; default: - column.schema = undefined; + column.schema = 'json'; break; } @@ -108,7 +110,6 @@ export function buildEuiGridColumn( return column; } -// TODO @dsnide can make edits here per type // Types [geoPoint], [kibanaJSON], numeric, datetime export function getSchemaDetectors() { return [ @@ -139,5 +140,12 @@ export function getPopoverContents() { [geoPoint]: ({ children }: { children: ReactNode }) => { return {children}; }, + [kibanaJSON]: ({ children }: { children: ReactNode }) => { + return ( + + {children} + + ); + }, }; } diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx index 52b08c8234b37..6f96e2f77ed38 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx @@ -17,15 +17,13 @@ * under the License. */ import React from 'react'; -import { EuiCodeBlock, EuiDataGridCellValueElementProps } from '@elastic/eui'; -import { DiscoverGridPopover } from './discover_grid_popover'; +import { EuiDataGridCellValueElementProps } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; -import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; export const getRenderCellValueFn = ( indexPattern: IndexPattern, - rows: ElasticSearchHit[] | undefined, - onFilter: DocViewFilterFn + rows: ElasticSearchHit[] | undefined ) => ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { const row = rows ? (rows[rowIndex] as Record) : undefined; @@ -51,7 +49,7 @@ export const getRenderCellValueFn = ( ); }; - // TODO Field formatters need to be fixed + const value = field && field.type === '_source' ? ( formatSource() @@ -60,31 +58,8 @@ export const getRenderCellValueFn = ( ); - if (isDetails && field && (field.type === '_source' || typeof row[columnId] === 'object')) { - return ( - - {JSON.stringify(row[columnId], null, 2)} - - ); - } - if (isDetails && indexPattern.fields.getByName(columnId)?.filterable) { - const createFilter = (fieldName: string, type: '-' | '+') => { - return onFilter( - indexPattern.fields.getByName(fieldName), - indexPattern.flattenHit(row)[fieldName], - type - ); - }; - - return ( - createFilter(columnId, '+')} - onNegativeFilterClick={() => createFilter(columnId, '-')} - /> - ); - } else if (indexPattern.fields.getByName(columnId)?.filterable) { - return value; + if (isDetails && field && field.type === '_source') { + return JSON.stringify(row[columnId], null, 2); } return value; }; From 4ca957d7a5f72bd6682ab3c12a5996daa5629fd4 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 19 Oct 2020 13:27:23 +0200 Subject: [PATCH 108/186] Fix a11y tests --- .../application/components/sidebar/discover_sidebar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx index c6f289889bee2..22a1f6e4354ab 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -234,7 +234,7 @@ export function DiscoverSidebar({ id="dscSelectedFields" initialIsOpen={true} buttonContent={ - + + Date: Mon, 19 Oct 2020 13:32:07 +0200 Subject: [PATCH 109/186] Improve loading spinner for legacy --- .../public/application/components/discover.tsx | 12 ++---------- .../components/loading_spinner/loading_spinner.tsx | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 7feaeef39653b..d86f7f2eefe6b 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -33,7 +33,7 @@ import { DiscoverHistogram } from '../angular/directives/histogram'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; import './discover.scss'; import { esFilters, search } from '../../../../data/public'; -import { DiscoverSidebarResponsive } from './sidebar/discover_sidebar_responsive'; +import { DiscoverSidebarResponsive } from './sidebar'; export function Discover({ addColumn, @@ -142,15 +142,7 @@ export function Discover({ /> )} {resultState === 'uninitialized' && } - {resultState === 'loading' && ( - <> - {!fetchError && ( -
    - -
    - )} - - )} + {resultState === 'loading' && <>{!fetchError && }} {resultState === 'ready' && ( <> diff --git a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx index e3cc396783628..b5a863aec4a0a 100644 --- a/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx +++ b/src/plugins/discover/public/application/components/loading_spinner/loading_spinner.tsx @@ -22,7 +22,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; export function LoadingSpinner() { return ( -
    +

    From 7fa93ee4392b26044690dd161f53502c349bfb98 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 19 Oct 2020 15:33:13 +0200 Subject: [PATCH 110/186] Fix functional tests --- test/functional/apps/discover/_doc_table.ts | 15 ++++++++------- test/functional/page_objects/discover_page.ts | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test/functional/apps/discover/_doc_table.ts b/test/functional/apps/discover/_doc_table.ts index 7fc120f9ea474..dae83e8f41552 100644 --- a/test/functional/apps/discover/_doc_table.ts +++ b/test/functional/apps/discover/_doc_table.ts @@ -133,13 +133,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should add more columns to the table', async function () { - const [column] = extraColumns; - await PageObjects.discover.findFieldByName(column); - log.debug(`add a ${column} column`); - await PageObjects.discover.clickFieldListItemAdd(column); - await PageObjects.header.waitUntilLoadingHasFinished(); - // test the header now - expect(await PageObjects.discover.getDocHeader()).to.have.string(column); + for (const column of extraColumns) { + await PageObjects.discover.clearFieldSearchInput(); + await PageObjects.discover.findFieldByName(column); + await PageObjects.discover.clickFieldListItemAdd(column); + await PageObjects.header.waitUntilLoadingHasFinished(); + // test the header now + expect(await PageObjects.discover.getDocHeader()).to.have.string(column); + } }); it('should remove columns from the table', async function () { diff --git a/test/functional/page_objects/discover_page.ts b/test/functional/page_objects/discover_page.ts index 60532c81493f9..503a9158c1072 100644 --- a/test/functional/page_objects/discover_page.ts +++ b/test/functional/page_objects/discover_page.ts @@ -284,6 +284,9 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider } public async clickFieldListItemRemove(field: string) { + if (!(await testSubjects.exists('fieldList-selected'))) { + return; + } const selectedList = await testSubjects.find('fieldList-selected'); if (await testSubjects.descendantExists(`field-${field}`, selectedList)) { await this.clickFieldListItemToggle(field); From bce5d487ae4bf9bee54e6c7344dfa3a94f7e534e Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 20 Oct 2020 12:36:57 +0200 Subject: [PATCH 111/186] Fix dashboard rendering, refactor col width persistence --- .../public/application/angular/discover.js | 11 +-- .../angular/discover_datagrid.html | 1 - .../application/angular/discover_state.ts | 13 ++-- .../components/create_discover_directive.ts | 1 - .../create_discover_grid_directive.tsx | 74 +++++++++++++++++++ .../application/components/discover.tsx | 13 +++- .../discover_grid/discover_grid.tsx | 9 ++- .../discover_grid/discover_grid_helpers.tsx | 21 ++++-- .../components/discover_grid/types.ts | 29 ++++++++ .../components/discover_legacy.tsx | 1 + .../embeddable/search_embeddable.ts | 29 ++++---- .../embeddable/search_embeddable_factory.ts | 1 + .../embeddable/search_template_datagrid.html | 2 +- .../discover/public/get_inner_angular.ts | 4 +- .../discover/public/saved_searches/types.ts | 3 +- 15 files changed, 166 insertions(+), 46 deletions(-) create mode 100644 src/plugins/discover/public/application/components/create_discover_grid_directive.tsx create mode 100644 src/plugins/discover/public/application/components/discover_grid/types.ts diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 8a39d9df5eba5..5930af880a0bf 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -638,6 +638,7 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab config: config, setHeaderActionMenu: getHeaderActionMenuMounter(), filterManager, + setAppState, }; const shouldSearchOnPageLoad = () => { @@ -751,9 +752,7 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab await $scope.updateDataSource(); savedSearch.columns = $scope.state.columns; - savedSearch.grid = { - columnsWidth: $scope.state.columnsWidth, - }; + savedSearch.grid = $scope.state.grid; savedSearch.sort = $scope.state.sort; try { @@ -1052,12 +1051,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab setAppState({ columns }); }; - $scope.setColumnsResize = (col) => { - const colSize = $scope.state.columnsWidth ? { ...$scope.state.columnsWidth } : {}; - colSize[col.columnId] = Math.round(col.width); - setAppState({ columnsWidth: colSize }); - }; - async function setupVisualization() { // If no timefield has been specified we don't create a histogram of messages if (!getTimeField()) return; diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index 2be87c7b7ab83..5569dc01dab1a 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -19,7 +19,6 @@ on-remove-column="removeColumn" on-set-columns="setColumns" on-sort="setSortOrder" - on-resize="setColumnsResize" opts="opts" reset-query="resetQuery" result-state="resultState" diff --git a/src/plugins/discover/public/application/angular/discover_state.ts b/src/plugins/discover/public/application/angular/discover_state.ts index a759bf3c627cd..95f38274e158a 100644 --- a/src/plugins/discover/public/application/angular/discover_state.ts +++ b/src/plugins/discover/public/application/angular/discover_state.ts @@ -32,20 +32,21 @@ import { migrateLegacyQuery } from '../helpers/migrate_legacy_query'; import { getSortArray } from './doc_table'; import { DEFAULT_COLUMNS_SETTING } from '../../../common'; import { SavedSearch } from '../../saved_searches'; +import { DiscoverGridSettings } from '../components/discover_grid/types'; export interface AppState { /** * Columns displayed in the table */ columns?: string[]; - /** - * Width of data grid columns - */ - columnsWidth?: { [key: string]: number }; /** * Array of applied filters */ filters?: Filter[]; + /** + * Data Grid related state + */ + grid?: DiscoverGridSettings; /** * id of the used index pattern */ @@ -219,8 +220,8 @@ export function getStateDefaults( interval: 'auto', filters: _.cloneDeep(searchSource.getOwnField('filter')) as Filter[], }; - if (savedSearch.grid && savedSearch.grid.columnsWidth) { - defaultState.columnsWidth = savedSearch.grid.columnsWidth; + if (savedSearch.grid && savedSearch.grid) { + defaultState.grid = savedSearch.grid; } return defaultState; } diff --git a/src/plugins/discover/public/application/components/create_discover_directive.ts b/src/plugins/discover/public/application/components/create_discover_directive.ts index 4c26231a2ba06..4bce2a1e917e2 100644 --- a/src/plugins/discover/public/application/components/create_discover_directive.ts +++ b/src/plugins/discover/public/application/components/create_discover_directive.ts @@ -38,7 +38,6 @@ export function createDiscoverDirective(reactDirective: any) { ['onRemoveColumn', { watchDepth: 'reference' }], ['onSetColumns', { watchDepth: 'reference' }], ['onSort', { watchDepth: 'reference' }], - ['onResize', { watchDepth: 'reference' }], ['opts', { watchDepth: 'reference' }], ['resetQuery', { watchDepth: 'reference' }], ['resultState', { watchDepth: 'reference' }], diff --git a/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx new file mode 100644 index 0000000000000..c526319f884a1 --- /dev/null +++ b/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx @@ -0,0 +1,74 @@ +/* + * 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 * as React from 'react'; +import { DiscoverGrid } from './discover_grid/discover_grid'; + +interface Props

    { + [key: string]: any; +} + +/** + * TODO remove when development is finished, helper component to detect property changes + * @param WrappedComponent + */ +export function withPropsChecker

    ( + WrappedComponent: React.ComponentType

    +): React.ComponentClass> { + // eslint-disable-next-line react/prefer-stateless-function + return class PropsChecker extends React.Component> { + /** + componentWillReceiveProps(nextProps: Props

    ) { + Object.keys(nextProps) + .filter((key) => nextProps[key] !== this.props[key]) + .map((key) => { + console.log('changed property:', key, 'from', this.props[key], 'to', nextProps[key]); + }); + } + **/ + + render() { + // @ts-ignore + return ; + } + }; +} + +/** + * this is just needed for the embeddable + */ +export function createDiscoverGridDirective(reactDirective: any) { + return reactDirective(withPropsChecker(DiscoverGrid), [ + ['columns', { watchDepth: 'collection' }], + ['rows', { watchDepth: 'collection' }], + ['indexPattern', { watchDepth: 'reference' }], + ['sort', { watchDepth: 'value' }], + ['sampleSize', { watchDepth: 'reference' }], + ['searchDescription', { watchDepth: 'reference' }], + ['searchTitle', { watchDepth: 'reference' }], + ['useShortDots', { watchDepth: 'value' }], + ['showTimeCol', { watchDepth: 'value' }], + ['settings', { watchDepth: 'reference' }], + ['onFilter', { watchDepth: 'reference', wrapApply: false }], + ['onRemoveColumn', { watchDepth: 'reference', wrapApply: false }], + ['onAddColumn', { watchDepth: 'reference', wrapApply: false }], + ['onSetColumns', { watchDepth: 'reference', wrapApply: false }], + ['getContextAppHref', { watchDepth: 'reference', wrapApply: false }], + ['onSort', { watchDepth: 'reference', wrapApply: false }], + ]); +} diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index d86f7f2eefe6b..6653957800548 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -49,7 +49,6 @@ export function Discover({ onRemoveColumn, onSetColumns, onSort, - onResize, opts, resetQuery, resultState, @@ -210,7 +209,6 @@ export function Discover({ { + const grid = { ...state.grid } || {}; + const newColumns = { ...grid.columns } || {}; + newColumns[colSettings.columnId] = { + width: colSettings.width, + }; + const newGrid = { ...grid, columns: newColumns }; + opts.setAppState({ grid: newGrid }); + }} useDocSelector={enhanced} />

    diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 50f6abbd941ea..c413601862dc6 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -44,6 +44,7 @@ import { DiscoverGridContext } from './discover_grid_context'; import { DiscoverGridSelectButton } from './discover_grid_select_button'; import { ViewButton } from './discover_grid_view_button'; import { getRenderCellValueFn } from './get_render_cell_value'; +import { DiscoverGridSettings } from './types'; type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; @@ -55,7 +56,6 @@ interface SortObj { interface Props { ariaLabelledBy: string; columns: string[]; - columnsWidth: any; getContextAppHref: (id: string) => string; indexPattern: IndexPattern; onAddColumn: (column: string) => void; @@ -66,6 +66,7 @@ interface Props { onSort: (props: any) => void; rows?: ElasticSearchHit[]; sampleSize: number; + settings?: DiscoverGridSettings; searchDescription?: string; searchTitle?: string; showTimeCol: boolean; @@ -88,8 +89,8 @@ export const DiscoverGrid = React.memo( ({ rows, columns, - columnsWidth, sort, + settings, indexPattern, ariaLabelledBy, searchTitle, @@ -182,8 +183,8 @@ export const DiscoverGrid = React.memo( const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( - () => getEuiGridColumns(columns, columnsWidth, indexPattern, showTimeCol, timeString), - [columns, indexPattern, showTimeCol, timeString, columnsWidth] + () => getEuiGridColumns(columns, settings, indexPattern, showTimeCol, timeString), + [columns, indexPattern, showTimeCol, timeString, settings] ); const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const popoverContents = useMemo(() => getPopoverContents(), []); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index cfdbe16576eff..18f68ea627690 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -19,28 +19,39 @@ import React, { ReactNode } from 'react'; import { EuiCodeBlock, EuiDataGridColumn } from '@elastic/eui'; import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; +import { DiscoverGridSettings } from './types'; const kibanaJSON = 'kibana-json'; const geoPoint = 'geo-point'; export function getEuiGridColumns( columns: string[], - columnsWidth: any = {}, + settings: DiscoverGridSettings | undefined, indexPattern: IndexPattern, showTimeCol: boolean, timeString: string ) { const timeFieldName = indexPattern.timeFieldName; + const getColWidth = (column: string) => { + if (settings?.columns && settings.columns[column]) { + return settings.columns[column].width || 0; + } + return 0; + }; - if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { + if ( + showTimeCol !== false && + indexPattern.timeFieldName && + !columns.find((col) => col === timeFieldName) + ) { const usedColumns = [indexPattern.timeFieldName, ...columns]; return usedColumns.map((column) => - buildEuiGridColumn(column, columnsWidth ? columnsWidth[column] : 0, indexPattern, timeString) + buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) ); } return columns.map((column) => - buildEuiGridColumn(column, columnsWidth ? columnsWidth[column] : 0, indexPattern, timeString) + buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) ); } @@ -60,7 +71,7 @@ export function getVisibleColumns( export function buildEuiGridColumn( columnName: string, - columnWidth: any, + columnWidth: number | undefined = 0, indexPattern: IndexPattern, timeString: string ) { diff --git a/src/plugins/discover/public/application/components/discover_grid/types.ts b/src/plugins/discover/public/application/components/discover_grid/types.ts new file mode 100644 index 0000000000000..c5783c7f07194 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/types.ts @@ -0,0 +1,29 @@ +/* + * 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. + */ + +/** + * User configureable state of data grid, persisted in saved search + */ +export interface DiscoverGridSettings { + columns?: Record; +} + +export interface DiscoverGridSettingsColumn { + width?: number; +} diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 2b39b8569e558..08d04fb82dae1 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -79,6 +79,7 @@ export interface DiscoverLegacyProps { timefield: string; sampleSize: number; setHeaderActionMenu: (menuMount: MountPoint | undefined) => void; + setAppState: (state: Partial) => void; }; resetQuery: () => void; resultState: string; diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 48684cc614d91..444e34bec5691 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -43,17 +43,18 @@ import { getSortForSearchSource } from '../angular/doc_table'; import { getRequestInspectorStats, getResponseInspectorStats, - getServices, IndexPattern, ISearchSource, } from '../../kibana_services'; import { SEARCH_EMBEDDABLE_TYPE } from './constants'; import { SavedSearch } from '../..'; import { SAMPLE_SIZE_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../common'; +import { DiscoverGridSettings } from '../components/discover_grid/types'; +import { DiscoverServices } from '../../build_services'; interface SearchScope extends ng.IScope { columns?: string[]; - columnsWidth?: any; + settings?: DiscoverGridSettings; description?: string; sort?: SortOrder[]; sharedItemTitle?: string; @@ -67,7 +68,7 @@ interface SearchScope extends ng.IScope { indexPattern?: IndexPattern; totalHitCount?: number; isLoading?: boolean; - grid?: any; + showTimeCol?: boolean; } interface SearchEmbeddableConfig { @@ -79,6 +80,7 @@ interface SearchEmbeddableConfig { indexPatterns?: IndexPattern[]; editable: boolean; filterManager: FilterManager; + services: DiscoverServices; } export class SearchEmbeddable @@ -97,6 +99,7 @@ export class SearchEmbeddable public readonly type = SEARCH_EMBEDDABLE_TYPE; private filterManager: FilterManager; private abortController?: AbortController; + private services: DiscoverServices; private prevTimeRange?: TimeRange; private prevFilters?: Filter[]; @@ -112,6 +115,7 @@ export class SearchEmbeddable indexPatterns, editable, filterManager, + services, }: SearchEmbeddableConfig, initialInput: SearchInput, private readonly executeTriggerActions: UiActionsStart['executeTriggerActions'], @@ -129,7 +133,7 @@ export class SearchEmbeddable }, parent ); - + this.services = services; this.filterManager = filterManager; this.savedSearch = savedSearch; this.$rootScope = $rootScope; @@ -139,8 +143,8 @@ export class SearchEmbeddable }; this.initializeSearchScope(); - this.autoRefreshFetchSubscription = getServices() - .timefilter.getAutoRefreshFetch$() + this.autoRefreshFetchSubscription = this.services.timefilter + .getAutoRefreshFetch$() .subscribe(this.fetch); this.subscription = Rx.merge(this.getOutput$(), this.getInput$()).subscribe(() => { @@ -169,7 +173,7 @@ export class SearchEmbeddable throw new Error('Search scope not defined'); } this.searchInstance = this.$compile( - getServices().uiSettings.get('doc_table:legacy', true) ? searchTemplate : searchTemplateGrid + this.services.uiSettings.get('doc_table:legacy', true) ? searchTemplate : searchTemplateGrid )(this.searchScope); const rootNode = angular.element(domNode); rootNode.append(this.searchInstance); @@ -247,12 +251,9 @@ export class SearchEmbeddable }; if (this.savedSearch.grid) { - searchScope.grid = this.savedSearch.grid; - searchScope.columnsWidth = - this.savedSearch.grid && this.savedSearch.grid.columnsWidth - ? this.savedSearch.grid.columnsWidth - : undefined; + searchScope.settings = this.savedSearch.grid; } + searchScope.showTimeCol = !this.services.uiSettings.get('doc_table:hideTimeColumn', false); searchScope.filter = async (field, value, operator) => { let filters = esFilters.generateFilters( @@ -287,13 +288,13 @@ export class SearchEmbeddable if (this.abortController) this.abortController.abort(); this.abortController = new AbortController(); - searchSource.setField('size', getServices().uiSettings.get(SAMPLE_SIZE_SETTING)); + searchSource.setField('size', this.services.uiSettings.get(SAMPLE_SIZE_SETTING)); searchSource.setField( 'sort', getSortForSearchSource( this.searchScope.sort, this.searchScope.indexPattern, - getServices().uiSettings.get(SORT_DEFAULT_ORDER_SETTING) + this.services.uiSettings.get(SORT_DEFAULT_ORDER_SETTING) ) ); diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts index f61fa361f0c0e..d85476568201f 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts @@ -103,6 +103,7 @@ export class SearchEmbeddableFactory filterManager, editable: getServices().capabilities.discover.save as boolean, indexPatterns: indexPattern ? [indexPattern] : [], + services: getServices(), }, input, executeTriggerActions, diff --git a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html index 93fe85a7a3d38..ff48a815e64d0 100644 --- a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html +++ b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html @@ -1,6 +1,6 @@ void; lastSavedTitle?: string; } From b89e980f3ce5b82f1c4ce586860b8f54ac19c30b Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Wed, 21 Oct 2020 15:33:37 -0700 Subject: [PATCH 112/186] fix datagrid in fullscreen --- src/plugins/discover/public/application/_discover.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index a86972d29ae2f..b39072e224923 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -1,3 +1,9 @@ +body.euiDataGrid__restrictBody { + .application { + z-index: $euiZLevel1; + } +} + .dscAppWrapper { display: flex; flex-direction: column; From cca4d3e2fa5ca325e6220aec0bc468a056dd4902 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 22 Oct 2020 10:47:28 +0200 Subject: [PATCH 113/186] Improve document selection code --- .../discover_grid/discover_grid.tsx | 14 +- .../discover_grid/discover_grid_context.tsx | 7 +- .../discover_grid_doc_selection.tsx | 148 ++++++++++++++++++ .../discover_grid_flyout_selection.tsx | 18 +-- .../discover_grid_select_button.tsx | 52 ------ .../discover_grid_toolbar_selection.tsx | 4 +- .../application/components/table/table.tsx | 7 +- .../application/doc_views/doc_views_types.ts | 2 +- .../components/agg_params_helper.test.ts | 4 + .../public/components/agg_params_helper.ts | 2 +- .../public/components/controls/field.tsx | 2 +- .../vis_default_editor/public/utils.ts | 15 +- 12 files changed, 191 insertions(+), 84 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index c413601862dc6..34e0019ab5170 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -37,14 +37,13 @@ import { getSchemaDetectors, getVisibleColumns, } from './discover_grid_helpers'; -import { DiscoverGridFlyoutSelection } from './discover_grid_flyout_selection'; import { DiscoverGridFlyout } from './discover_grid_flyout'; import { DiscoverGridToolbarSelection } from './discover_grid_toolbar_selection'; import { DiscoverGridContext } from './discover_grid_context'; -import { DiscoverGridSelectButton } from './discover_grid_select_button'; import { ViewButton } from './discover_grid_view_button'; import { getRenderCellValueFn } from './get_render_cell_value'; import { DiscoverGridSettings } from './types'; +import { DiscoverGridSelectButton, DiscoverGridSelection } from './discover_grid_doc_selection'; type Direction = 'asc' | 'desc'; type SortArr = [string, Direction]; @@ -107,7 +106,7 @@ export const DiscoverGrid = React.memo( useDocSelector, }: Props) => { const [showSelected, setShowSelected] = useState(false); - const [selected, setSelected] = useState([]); + const [selected, setSelected] = useState(new Map()); const [viewed, setViewed] = useState(-1); const timeString = useMemo( () => @@ -325,13 +324,8 @@ export const DiscoverGrid = React.memo( }} /> )} - {showSelected && selected && selected.length > 0 && ( - setShowSelected(false)} - /> + {showSelected && selected && selected.size && ( + setShowSelected(false)} /> )} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx index db4ea05178d77..ccd247de1bfe4 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx @@ -17,12 +17,13 @@ * under the License. */ import React from 'react'; +import { DiscoverGridSelection } from './discover_grid_doc_selection'; export interface GridContext { viewed: number; setViewed: (id: number) => void; - selected: number[]; - setSelected: (ids: number[]) => void; + selected: DiscoverGridSelection; + setSelected: (map: DiscoverGridSelection) => void; showSelected: boolean; setShowSelected: (value: boolean) => void; } @@ -30,7 +31,7 @@ export interface GridContext { export const DiscoverGridContext = React.createContext({ viewed: -1, setViewed: () => void 0, - selected: [], + selected: new Map(), setSelected: () => void 0, showSelected: false, setShowSelected: () => void 0, diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx new file mode 100644 index 0000000000000..2add74ae7ab28 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx @@ -0,0 +1,148 @@ +/* + * 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 React, { useContext } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiAccordion, + EuiCheckbox, + EuiFlexGroup, + EuiFlexItem, + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiIcon, + EuiPortal, + EuiTitle, +} from '@elastic/eui'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { JsonCodeBlock } from '../json_code_block/json_code_block'; +import { DiscoverGridContext, GridContext } from './discover_grid_context'; + +export type DiscoverGridSelection = Map; + +export interface DiscoverGridSelectionDoc { + id: string; + added: string; + record: ElasticSearchHit; +} + +export function getSelectedId(record: ElasticSearchHit) { + return `${record._index}-${record._id}`; +} + +export const DiscoverGridSelectButton = ({ + col, + rows, +}: { + col: any; + rows?: ElasticSearchHit[]; +}) => { + const { selected, setSelected } = useContext(DiscoverGridContext); + const rowIndex = col.rowIndex; + if (!rows || !rows[rowIndex]) { + return null; + } + const record = rows[rowIndex]; + const id = getSelectedId(record); + const isChecked = selected.has(id); + if (!rows) { + return null; + } + + return ( + { + if (e.target.checked) { + selected.set(id, { + id, + added: new Date().toJSON(), + record: record as ElasticSearchHit, + }); + } else { + selected.delete(id); + } + setSelected(new Map(selected)); + }} + /> + ); +}; + +export function DiscoverGridSelection({ + selected, + onClose, +}: { + selected: DiscoverGridSelection; + onClose: () => void; +}) { + const rows = [...selected.values()].map((entry) => { + return entry.record; + }); + return ( + + onClose()} size="m"> + + + + +

    + {' '} + {i18n.translate('discover.grid.tableRow.selectedDocuments', { + defaultMessage: 'Selected records', + })} +

    +
    +
    +
    +
    + +

    + {i18n.translate('discover.grid.documentSelectionAriaLabel', { + defaultMessage: 'Records selection', + })} +

    + {rows.length > 0 && + rows.map((row) => ( +
    + +
    + +
    +
    +
    + ))} +
    +
    +
    + ); +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx index 4b903a2f2d5c1..b729244b5bf33 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx @@ -36,12 +36,12 @@ import { IndexPattern } from '../../../kibana_services'; interface Props { indexPattern: IndexPattern; - rows: ElasticSearchHit[]; - selected: number[]; + selected: Record; onClose: () => void; } -export function DiscoverGridFlyoutSelection({ indexPattern, rows, selected, onClose }: Props) { +export function DiscoverGridFlyoutSelection({ indexPattern, selected, onClose }: Props) { + const rows = Object.values(selected); return ( onClose()} size="m"> @@ -65,12 +65,12 @@ export function DiscoverGridFlyoutSelection({ indexPattern, rows, selected, onCl defaultMessage: 'Records selection', })} - {selected.length > 0 && - selected.map((rowIndex) => ( -
    + {rows.length > 0 && + rows.map((row) => ( +
    - +
    diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx deleted file mode 100644 index 7c1069bea2f17..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_select_button.tsx +++ /dev/null @@ -1,52 +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 React, { useContext } from 'react'; -import { EuiCheckbox } from '@elastic/eui'; -import { GridContext, DiscoverGridContext } from './discover_grid_context'; -import { ElasticSearchHit } from '../../doc_views/doc_views_types'; - -export const DiscoverGridSelectButton = ({ - col, - rows, -}: { - col: any; - rows?: ElasticSearchHit[]; -}) => { - const { selected, setSelected } = useContext(DiscoverGridContext); - const rowIndex = col.rowIndex; - const isChecked = selected.includes(rowIndex); - if (!rows) { - return null; - } - - return ( - { - if (e.target.checked) { - setSelected([...selected, rowIndex]); - } else { - setSelected(selected.filter((idx: number) => idx !== rowIndex)); - } - }} - /> - ); -}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx index 996a0175227fc..17e2e07817b1f 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx @@ -28,9 +28,9 @@ export const DiscoverGridToolbarSelection = () => { iconType="arrowDown" color="primary" className="euiDataGrid__controlBtn" - onClick={() => setShowSelected(!showSelected)} + onClick={() => (selected.size ? setShowSelected(!showSelected) : void 0)} > - {selected.length} {selected.length === 1 ? 'record' : 'records'} selected + {selected.size} {selected.size === 1 ? 'record' : 'records'} selected ); }; diff --git a/src/plugins/discover/public/application/components/table/table.tsx b/src/plugins/discover/public/application/components/table/table.tsx index 628045bd32f61..34a64dd765274 100644 --- a/src/plugins/discover/public/application/components/table/table.tsx +++ b/src/plugins/discover/public/application/components/table/table.tsx @@ -32,13 +32,16 @@ export function DocViewTable({ onAddColumn, onRemoveColumn, }: DocViewRenderProps) { + const [fieldRowOpen, setFieldRowOpen] = useState({} as Record); + if (!indexPattern) { + return null; + } const mapping = indexPattern.fields.getByName; const flattened = indexPattern.flattenHit(hit); const formatted = indexPattern.formatHit(hit, 'html'); - const [fieldRowOpen, setFieldRowOpen] = useState({} as Record); function toggleValueCollapse(field: string) { - fieldRowOpen[field] = fieldRowOpen[field] !== true; + fieldRowOpen[field] = !fieldRowOpen[field]; setFieldRowOpen({ ...fieldRowOpen }); } diff --git a/src/plugins/discover/public/application/doc_views/doc_views_types.ts b/src/plugins/discover/public/application/doc_views/doc_views_types.ts index 6c90861e26727..016788870cb96 100644 --- a/src/plugins/discover/public/application/doc_views/doc_views_types.ts +++ b/src/plugins/discover/public/application/doc_views/doc_views_types.ts @@ -48,7 +48,7 @@ export interface DocViewRenderProps { columns?: string[]; filter?: DocViewFilterFn; hit: ElasticSearchHit; - indexPattern: IndexPattern; + indexPattern?: IndexPattern; onAddColumn?: (columnName: string) => void; onRemoveColumn?: (columnName: string) => void; } diff --git a/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts b/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts index 834ad8b70ad0d..a56155db02f6b 100644 --- a/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts +++ b/src/plugins/vis_default_editor/public/components/agg_params_helper.test.ts @@ -33,6 +33,7 @@ import { FieldParamEditor, OrderByParamEditor } from './controls'; import { EditorConfig } from './utils'; import { Schema } from '../schemas'; import { EditorVisState } from './sidebar/state/reducers'; +import { groupAndSortBy } from '../utils'; jest.mock('../utils', () => ({ groupAndSortBy: jest.fn(() => ['indexedFields']), @@ -169,6 +170,9 @@ describe('DefaultEditorAggParams helpers', () => { ], advanced: [], }); + + // Should be grouped using displayName as label + expect(groupAndSortBy).toHaveBeenCalledWith(expect.anything(), 'type', 'displayName', 'name'); }); }); diff --git a/src/plugins/vis_default_editor/public/components/agg_params_helper.ts b/src/plugins/vis_default_editor/public/components/agg_params_helper.ts index b13ca32601aa9..271fc75a0853e 100644 --- a/src/plugins/vis_default_editor/public/components/agg_params_helper.ts +++ b/src/plugins/vis_default_editor/public/components/agg_params_helper.ts @@ -93,7 +93,7 @@ function getAggParamsToRender({ } } fields = filterAggTypeFields(availableFields, agg); - indexedFields = groupAndSortBy(fields, 'type', 'name'); + indexedFields = groupAndSortBy(fields, 'type', 'displayName', 'name'); if (fields && !indexedFields.length && index > 0) { // don't draw the rest of the options if there are no indexed fields and it's an extra param (index > 0). diff --git a/src/plugins/vis_default_editor/public/components/controls/field.tsx b/src/plugins/vis_default_editor/public/components/controls/field.tsx index bfc4f881f8458..41d6db25da5e2 100644 --- a/src/plugins/vis_default_editor/public/components/controls/field.tsx +++ b/src/plugins/vis_default_editor/public/components/controls/field.tsx @@ -52,7 +52,7 @@ function FieldParamEditor({ }: FieldParamEditorProps) { const [isDirty, setIsDirty] = useState(false); const selectedOptions: ComboBoxGroupedOptions = value - ? [{ label: value.displayName || value.name, target: value }] + ? [{ label: value.displayName, target: value, key: value.name }] : []; const onChange = (options: EuiComboBoxOptionOption[]) => { diff --git a/src/plugins/vis_default_editor/public/utils.ts b/src/plugins/vis_default_editor/public/utils.ts index d0a9c067e9da2..11b7c07acc2c2 100644 --- a/src/plugins/vis_default_editor/public/utils.ts +++ b/src/plugins/vis_default_editor/public/utils.ts @@ -18,10 +18,12 @@ */ interface ComboBoxOption { + key?: string; label: string; target: T; } interface ComboBoxGroupedOption { + key?: string; label: string; options: Array>; } @@ -40,15 +42,22 @@ export type ComboBoxGroupedOptions = Array>; * @returns An array of grouped and sorted alphabetically `objects` that are compatible with EuiComboBox options. */ export function groupAndSortBy< - T extends Record, + T extends Record, TGroupBy extends string = 'type', - TLabelName extends string = 'title' ->(objects: T[], groupBy: TGroupBy, labelName: TLabelName): ComboBoxGroupedOptions { + TLabelName extends string = 'title', + TKeyName extends string = never +>( + objects: T[], + groupBy: TGroupBy, + labelName: TLabelName, + keyName?: TKeyName +): ComboBoxGroupedOptions { const groupedOptions = objects.reduce((array, obj) => { const group = array.find((element) => element.label === obj[groupBy]); const option = { label: obj[labelName], target: obj, + ...(keyName ? { key: obj[keyName] } : {}), }; if (group && group.options) { From 5099bedac647c468f20aa8b7904e87fcd54b73ee Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Thu, 22 Oct 2020 13:16:23 -0700 Subject: [PATCH 114/186] better fix --- src/core/public/chrome/ui/header/_index.scss | 6 ++++-- src/plugins/discover/public/application/_discover.scss | 6 ------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/public/chrome/ui/header/_index.scss b/src/core/public/chrome/ui/header/_index.scss index ae455c26fc5d3..58cc61bbce96a 100644 --- a/src/core/public/chrome/ui/header/_index.scss +++ b/src/core/public/chrome/ui/header/_index.scss @@ -1,7 +1,9 @@ @include euiHeaderAffordForFixed; -.euiDataGrid__restrictBody .chrHeaderWrapper { - display: none; +.euiDataGrid__restrictBody { + .headerGlobalNav { + display: none; + } } .chrHeaderHelpMenu__version { diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index b39072e224923..a86972d29ae2f 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -1,9 +1,3 @@ -body.euiDataGrid__restrictBody { - .application { - z-index: $euiZLevel1; - } -} - .dscAppWrapper { display: flex; flex-direction: column; From 679bee96fa14fcc52325145a7df14263574fc8a4 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 2 Nov 2020 15:09:01 +0100 Subject: [PATCH 115/186] Fix get_inner_angular.ts --- src/plugins/discover/public/application/components/discover.tsx | 2 +- src/plugins/discover/public/get_inner_angular.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 71c74ee0f30ad..082fd8fd1734a 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -170,7 +170,7 @@ export function Discover({ { + onClick={() => { toggleChart(!toggleOn); }} > diff --git a/src/plugins/discover/public/get_inner_angular.ts b/src/plugins/discover/public/get_inner_angular.ts index 3d40f7b178dc5..2ace65c31cc03 100644 --- a/src/plugins/discover/public/get_inner_angular.ts +++ b/src/plugins/discover/public/get_inner_angular.ts @@ -192,7 +192,6 @@ function createDocTableModule() { .directive('kbnTableRow', createTableRowDirective) .directive('toolBarPagerButtons', createToolBarPagerButtonsDirective) .directive('kbnInfiniteScroll', createInfiniteScrollDirective) - .directive('docViewer', createDocViewerDirective) .directive('discoverGrid', createDiscoverGridDirective) .directive('docViewer', createDocViewerDirective) .directive('contextAppLegacy', createContextAppLegacy); From f9fe460cfcd967832b3466c5cf761148d4a1c866 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 4 Nov 2020 18:48:13 +0100 Subject: [PATCH 116/186] Simplify code and cleanup CSS --- .../discover_grid/discover_grid.scss | 25 ------- .../discover_grid/discover_grid.tsx | 12 +++- .../discover_grid/discover_grid_context.tsx | 16 ++--- .../discover_grid/discover_grid_helpers.tsx | 71 +++++++++++++++++-- 4 files changed, 83 insertions(+), 41 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index b14775a36832b..821445655d2cf 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -50,31 +50,6 @@ div[data-rbd-draggable-id='Time'] { display: flex; } -// hack to show expand icon on hover -.euiDataGridRowCell:hover { - border: 1px solid transparent; - margin-top: -1px; - -webkit-box-shadow: 0 0 0 2px rgba(0, 107, 180, 0.3); - box-shadow: 0 0 0 2px rgba(0, 107, 180, 0.3); - border-radius: 1px; - z-index: 2; -} -.euiDataGridRowCell:hover .euiDataGridRowCell__expandButton { - margin-left: 6px; -} -.euiDataGridRowCell:hover .euiDataGridRowCell__expandButtonIcon { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - width: inherit; - visibility: visible; -} -.euiDataGridRowCell__expandButtonIcon { - transition: none; - -webkit-transition: none; - -o-transition: none; -} - .euiDataGrid__verticalScroll { will-change: transform; } diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 34e0019ab5170..6cb59a3d36444 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -255,7 +255,17 @@ export const DiscoverGrid = React.memo( return ( <> void; showSelected: boolean; setShowSelected: (value: boolean) => void; + rows: ElasticSearchHit[]; + onFilter: DocViewFilterFn; + indexPattern: IndexPattern; } -export const DiscoverGridContext = React.createContext({ - viewed: -1, - setViewed: () => void 0, - selected: new Map(), - setSelected: () => void 0, - showSelected: false, - setShowSelected: () => void 0, -}); +const defaultContext = ({} as unknown) as GridContext; + +export const DiscoverGridContext = React.createContext(defaultContext); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index 18f68ea627690..d94b51db2fce2 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -16,10 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -import React, { ReactNode } from 'react'; +import React, { ReactNode, useContext } from 'react'; import { EuiCodeBlock, EuiDataGridColumn } from '@elastic/eui'; -import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; +import { i18n } from '@kbn/i18n'; +import { IndexPattern, IndexPatternField } from '../../../../../data/common'; import { DiscoverGridSettings } from './types'; +import { DiscoverGridContext } from './discover_grid_context'; const kibanaJSON = 'kibana-json'; const geoPoint = 'geo-point'; @@ -39,11 +41,7 @@ export function getEuiGridColumns( return 0; }; - if ( - showTimeCol !== false && - indexPattern.timeFieldName && - !columns.find((col) => col === timeFieldName) - ) { + if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { const usedColumns = [indexPattern.timeFieldName, ...columns]; return usedColumns.map((column) => buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) @@ -69,6 +67,64 @@ export function getVisibleColumns( return columns; } +const FilterInBtn = ({ Component, rowIndex, columnId }: any) => { + const context = useContext(DiscoverGridContext); + return ( + { + const row = context.rows[rowIndex]; + const flattened = context.indexPattern.flattenHit(row); + + if (flattened) { + context.onFilter(columnId, flattened[columnId], '+'); + } + }} + iconType="plusInCircle" + aria-label={i18n.translate('discover.grid.filterForAria', { + defaultMessage: 'Filter for {value}', + values: { value: columnId }, + })} + > + {i18n.translate('discover.grid.filterFor', { + defaultMessage: 'Filter for', + })} + + ); +}; + +const FilterOutBtn = ({ Component, rowIndex, columnId }: any) => { + const context = useContext(DiscoverGridContext); + return ( + { + const row = context.rows[rowIndex]; + const flattened = context.indexPattern.flattenHit(row); + + if (flattened) { + context.onFilter(columnId, flattened[columnId], '-'); + } + }} + iconType="minusInCircle" + aria-label={i18n.translate('discover.grid.filterOutAria', { + defaultMessage: 'Filter out {value}', + values: { value: columnId }, + })} + > + {i18n.translate('discover.grid.filterOut', { + defaultMessage: 'Filter out', + })} + + ); +}; + +export function buildCellActions(field: IndexPatternField) { + if (!field.aggregatable) { + return []; + } + + return [FilterInBtn, FilterOutBtn]; +} + export function buildEuiGridColumn( columnName: string, columnWidth: number | undefined = 0, @@ -86,6 +142,7 @@ export function buildEuiGridColumn( showSortAsc: { label: 'Sort ASC' }, showSortDesc: { label: 'Sort DESC' }, }, + cellActions: indexPatternField ? buildCellActions(indexPatternField) : [], }; // Default DataGrid schemas: boolean, numeric, datetime, json, currency From 06239d7f042f79bf85641a7a3276f9acf7d84482 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 6 Nov 2020 14:37:45 +0100 Subject: [PATCH 117/186] Fix types --- .../components/sidebar/discover_sidebar_responsive.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx index b6622e168ba05..45da33cdbd5c1 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx @@ -19,6 +19,7 @@ import './discover_sidebar.scss'; import React, { useState } from 'react'; import { i18n } from '@kbn/i18n'; +import { UiStatsMetricType } from '@kbn/analytics'; import { EuiFlexItem, EuiFlexGroup, @@ -95,6 +96,12 @@ export interface DiscoverSidebarResponsiveProps { * Additional classname used for legacy */ sidebarClassName?: string; + /** + * Metric tracking function + * @param metricType + * @param eventName + */ + trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void; } export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) { From 1e64917c293914304d79aba73de2aee7f712b56e Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 6 Nov 2020 15:36:26 +0100 Subject: [PATCH 118/186] Fix types --- .../application/angular/discover_state.ts | 3 +- .../application/components/discover.tsx | 275 ++++++++++-------- .../discover_grid/discover_grid.tsx | 7 +- .../components/discover_legacy.tsx | 12 +- 4 files changed, 160 insertions(+), 137 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover_state.ts b/src/plugins/discover/public/application/angular/discover_state.ts index 95f38274e158a..f8960c38e990f 100644 --- a/src/plugins/discover/public/application/angular/discover_state.ts +++ b/src/plugins/discover/public/application/angular/discover_state.ts @@ -33,6 +33,7 @@ import { getSortArray } from './doc_table'; import { DEFAULT_COLUMNS_SETTING } from '../../../common'; import { SavedSearch } from '../../saved_searches'; import { DiscoverGridSettings } from '../components/discover_grid/types'; +import { SortPairArr } from './doc_table/lib/get_sort'; export interface AppState { /** @@ -62,7 +63,7 @@ export interface AppState { /** * Array of the used sorting [[field,direction],...] */ - sort?: Array<[string, string]>; + sort?: SortPairArr[]; /** * id of the used saved query */ diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 082fd8fd1734a..9ffbf2f3c2ee2 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -18,20 +18,22 @@ */ import React, { useState } from 'react'; import rison from 'rison-node'; +import classNames from 'classnames'; + // import { EuiResizableContainer } from '@elastic/eui'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { EuiFlexItem, EuiFlexGroup, EuiButtonEmpty } from '@elastic/eui'; +import { EuiFlexItem, EuiFlexGroup, EuiButtonEmpty, EuiHideFor, EuiButtonIcon } from '@elastic/eui'; import { HitsCounter } from './hits_counter'; import { DiscoverGrid } from './discover_grid/discover_grid'; import { TimechartHeader } from './timechart_header'; import { getServices } from '../../kibana_services'; -import { DiscoverUninitialized } from '../angular/directives/uninitialized'; -import { DiscoverHistogram } from '../angular/directives/histogram'; +import { DiscoverUninitialized, DiscoverHistogram } from '../angular/directives'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; import './discover.scss'; import { esFilters, search } from '../../../../data/public'; import { DiscoverSidebarResponsive } from './sidebar'; import { DiscoverNoResults } from './no_results'; +import { DiscoverProps } from './discover_legacy'; export function Discover({ addColumn, @@ -53,32 +55,34 @@ export function Discover({ rows, searchSource, setIndexPattern, - showTimeCol, showSaveQuery, state, timefilterUpdateHandler, timeRange, topNavMenu, - vis, updateQuery, updateSavedQueryId, -}: any) { +}: DiscoverProps) { const [toggleOn, toggleChart] = useState(true); + const [isSidebarClosed, setIsSidebarClosed] = useState(false); + const { trackUiMetric } = getServices(); if (!timeRange) { return
    Loading
    ; } const { TopNavMenu } = getServices().navigation.ui; const enhanced = getServices().enhanced; - - const { savedSearch, filterManager, indexPatternList } = opts; - const bucketAggConfig = vis?.data?.aggs?.aggs[1]; + const { savedSearch, filterManager, indexPatternList, config } = opts; + const showTimeCol = !config.get('doc_table:hideTimeColumn', false) && indexPattern.timeFieldName; + const bucketAggConfig = opts.chartAggConfigs?.aggs[1]; const bucketInterval = bucketAggConfig && search.aggs.isDateHistogramBucketAggConfig(bucketAggConfig) ? bucketAggConfig.buckets?.getInterval() : undefined; const getContextAppHref = (anchorId: string) => { - const path = `#/context/${encodeURIComponent(indexPattern.id)}/${encodeURIComponent(anchorId)}`; + const path = `#/context/${encodeURIComponent(String(indexPattern.id))}/${encodeURIComponent( + anchorId + )}`; const urlSearchParams = new URLSearchParams(); urlSearchParams.set( @@ -97,7 +101,9 @@ export function Discover({ ); return `${path}?${urlSearchParams.toString()}`; }; - + const sidebarClassName = classNames({ + closed: isSidebarClosed, + }); return (
    @@ -119,128 +125,143 @@ export function Discover({ />
    <> - - <> -
    - {resultState === 'none' && ( - - )} - {resultState === 'uninitialized' && } - {resultState === 'loading' && <>{!fetchError && }} - - {resultState === 'ready' && ( - <> -
    - - + )} + + setIsSidebarClosed(!isSidebarClosed)} + data-test-subj="collapseSideBarButton" + aria-controls="discover-sidebar" + aria-expanded={isSidebarClosed ? 'false' : 'true'} + aria-label="Toggle sidebar" + className={`dscCollapsibleSidebar__collapseButton ${sidebarClassName}`} + /> + +
    + {resultState === 'none' && ( + + )} + {resultState === 'uninitialized' && } + {resultState === 'loading' && } + {resultState === 'ready' && ( + <> +
    + + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + { + toggleChart(!toggleOn); + }} > - 0 ? hits : 0} - showResetButton={!!(savedSearch && savedSearch.id)} - onResetQuery={resetQuery} - /> - - - - - - { - toggleChart(!toggleOn); - }} - > - {toggleOn ? 'Hide chart' : 'Show chart'} - - - -
    + {toggleOn ? 'Hide chart' : 'Show chart'} + + + +
    -
    - {opts.timefield && toggleOn && ( -
    - {vis && rows.length !== 0 && ( -
    - -
    - )} -
    - )} -
    -

    - -

    - {rows && rows.length && ( -
    - { - const grid = { ...state.grid } || {}; - const newColumns = { ...grid.columns } || {}; - newColumns[colSettings.columnId] = { - width: colSettings.width, - }; - const newGrid = { ...grid, columns: newColumns }; - opts.setAppState({ grid: newGrid }); - }} - useDocSelector={enhanced} +
    + {opts.timefield && toggleOn && ( +
    + {opts.chartAggConfigs && rows.length !== 0 && ( +
    +
    )}
    -
    - - )} -
    - + )} +
    +

    + +

    + {rows && rows.length && ( +
    + { + const grid = { ...state.grid } || {}; + const newColumns = { ...grid.columns } || {}; + newColumns[colSettings.columnId] = { + width: colSettings.width, + }; + const newGrid = { ...grid, columns: newColumns }; + opts.setAppState({ grid: newGrid }); + }} + useDocSelector={enhanced} + /> +
    + )} +
    +
    + + )} +
    diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 6cb59a3d36444..f691f9b7c21b5 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -44,12 +44,11 @@ import { ViewButton } from './discover_grid_view_button'; import { getRenderCellValueFn } from './get_render_cell_value'; import { DiscoverGridSettings } from './types'; import { DiscoverGridSelectButton, DiscoverGridSelection } from './discover_grid_doc_selection'; +import { SortPairArr } from '../../angular/doc_table/lib/get_sort'; -type Direction = 'asc' | 'desc'; -type SortArr = [string, Direction]; interface SortObj { id: string; - direction: Direction; + direction: string; } interface Props { @@ -69,7 +68,7 @@ interface Props { searchDescription?: string; searchTitle?: string; showTimeCol: boolean; - sort: SortArr[]; + sort: SortPairArr[]; useDocSelector: boolean; } diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 1bc1d969fe528..416c65f271301 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -31,7 +31,6 @@ import { LoadingSpinner } from './loading_spinner/loading_spinner'; import { DocTableLegacy } from '../angular/doc_table/create_doc_table_react'; import { SkipBottomButton } from './skip_bottom_button'; import { - IndexPatternField, search, ISearchSource, TimeRange, @@ -39,6 +38,7 @@ import { IndexPatternAttributes, DataPublicPluginStart, AggConfigs, + FilterManager, } from '../../../../data/public'; import { Chart } from '../angular/helpers/point_series'; import { AppState } from '../angular/discover_state'; @@ -47,8 +47,9 @@ import { SavedSearch } from '../../saved_searches'; import { SavedObject } from '../../../../../core/types'; import { TopNavMenuData } from '../../../../navigation/public'; import { DiscoverSidebarResponsive } from './sidebar'; +import { DocViewFilterFn, ElasticSearchHit } from '../doc_views/doc_views_types'; -export interface DiscoverLegacyProps { +export interface DiscoverProps { addColumn: (column: string) => void; fetch: () => void; fetchCounter: number; @@ -58,7 +59,7 @@ export interface DiscoverLegacyProps { hits: number; indexPattern: IndexPattern; minimumVisibleRows: number; - onAddFilter: (field: IndexPatternField | string, value: string, type: '+' | '-') => void; + onAddFilter: DocViewFilterFn; onChangeInterval: (interval: string) => void; onMoveColumn: (columns: string, newIdx: number) => void; onRemoveColumn: (column: string) => void; @@ -70,6 +71,7 @@ export interface DiscoverLegacyProps { config: IUiSettingsClient; data: DataPublicPluginStart; fixedScroll: (el: HTMLElement) => void; + filterManager: FilterManager; indexPatternList: Array>; sampleSize: number; savedSearch: SavedSearch; @@ -79,7 +81,7 @@ export interface DiscoverLegacyProps { }; resetQuery: () => void; resultState: string; - rows: Array>; + rows: ElasticSearchHit[]; searchSource: ISearchSource; setIndexPattern: (id: string) => void; showSaveQuery: boolean; @@ -120,7 +122,7 @@ export function DiscoverLegacy({ topNavMenu, updateQuery, updateSavedQueryId, -}: DiscoverLegacyProps) { +}: DiscoverProps) { const [toggleOn, toggleChart] = useState(true); const [isSidebarClosed, setIsSidebarClosed] = useState(false); const { TopNavMenu } = getServices().navigation.ui; From c66dca50051ccb01589483af1ec19bbbdab50ef7 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 6 Nov 2020 15:56:06 +0100 Subject: [PATCH 119/186] Cleanup --- .../discover_grid/discover_grid_popover.tsx | 79 ---------------- .../discover_value_with_filter.tsx | 94 ------------------- 2 files changed, 173 deletions(-) delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx deleted file mode 100644 index 9ca2bf6abf795..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_popover.tsx +++ /dev/null @@ -1,79 +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 React, { ReactNode, useMemo } from 'react'; -import { i18n } from '@kbn/i18n'; -import { - EuiButtonEmpty, - EuiFlexGroup, - EuiFlexItem, - EuiSpacer, - useRenderToText, -} from '@elastic/eui'; - -export function DiscoverGridPopover({ - value, - onPositiveFilterClick, - onNegativeFilterClick, -}: { - value: string | ReactNode; - onPositiveFilterClick: () => void; - onNegativeFilterClick: () => void; -}) { - const node = useMemo(() => <>{value}!, [value]); - const placeholder = i18n.translate('discover.grid.filterValuePlaceholder', { - defaultMessage: 'value', - }); - const text = useRenderToText(node, placeholder); - return ( - <> - {value} - - - - - {i18n.translate('discover.grid.filterOn', { - defaultMessage: 'Filter on value', - })} - - - - - {i18n.translate('discover.grid.filterOut', { - defaultMessage: 'Filter without value', - })} - - - - - ); -} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx deleted file mode 100644 index a38632874ab04..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_value_with_filter.tsx +++ /dev/null @@ -1,94 +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 React, { ReactNode } from 'react'; -import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; - -/** - * Draft component displaying filter lens icons on hover with the possibility to add a filter - */ -export const DiscoverGridValueWithFilter = ({ - value, - columnId, - row, - indexPattern, - onFilter, -}: { - value: ReactNode; - columnId: string; - row: ElasticSearchHit; - indexPattern: IndexPattern; - onFilter: DocViewFilterFn; -}) => { - return ( - - - {value} - - -
    - ) => { - ev.stopPropagation(); - ev.preventDefault(); - onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - '+' - ); - }} - /> - ) => { - ev.stopPropagation(); - ev.preventDefault(); - onFilter( - indexPattern.fields.getByName(columnId), - indexPattern.flattenHit(row)[columnId], - '-' - ); - }} - /> -
    -
    -
    - ); -}; From fa36978f1170ac2c36e2f2819e1a3a0da6d0da0e Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 9 Nov 2020 17:24:57 -0800 Subject: [PATCH 120/186] simple cleanup to Selected Records flyout --- .../discover_grid/discover_grid_doc_selection.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx index 2add74ae7ab28..989121de6706e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx @@ -30,6 +30,7 @@ import { EuiIcon, EuiPortal, EuiTitle, + EuiSpacer, } from '@elastic/eui'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; import { JsonCodeBlock } from '../json_code_block/json_code_block'; @@ -103,9 +104,9 @@ export function DiscoverGridSelection({ - +

    - {' '} + {' '} {i18n.translate('discover.grid.tableRow.selectedDocuments', { defaultMessage: 'Selected records', })} @@ -125,7 +126,7 @@ export function DiscoverGridSelection({
    +
    ))} From 40c8419423c4669a31d6f30416948a553ce268ac Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 12 Nov 2020 17:33:06 +0100 Subject: [PATCH 121/186] Fix column actions displayed in expand column --- .../components/discover_grid/discover_grid_helpers.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index d94b51db2fce2..a6333b37af7c2 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -119,7 +119,7 @@ const FilterOutBtn = ({ Component, rowIndex, columnId }: any) => { export function buildCellActions(field: IndexPatternField) { if (!field.aggregatable) { - return []; + return undefined; } return [FilterInBtn, FilterOutBtn]; From 495500a6e847c156d488ead2bf49ca4ae766b08d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 16 Nov 2020 09:01:34 +0100 Subject: [PATCH 122/186] Cleanup code --- .../discover_grid/discover_grid.tsx | 47 +--------- .../discover_grid/discover_grid_columns.tsx | 64 +++++++++++++ .../discover_grid_doc_selection.tsx | 16 ++++ .../discover_grid_flyout_selection.tsx | 93 ------------------- .../discover_grid_toolbar_selection.tsx | 36 ------- .../discover_grid_view_button.tsx | 2 +- 6 files changed, 86 insertions(+), 172 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index f691f9b7c21b5..0efb34fbbb39b 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -38,13 +38,12 @@ import { getVisibleColumns, } from './discover_grid_helpers'; import { DiscoverGridFlyout } from './discover_grid_flyout'; -import { DiscoverGridToolbarSelection } from './discover_grid_toolbar_selection'; import { DiscoverGridContext } from './discover_grid_context'; -import { ViewButton } from './discover_grid_view_button'; import { getRenderCellValueFn } from './get_render_cell_value'; import { DiscoverGridSettings } from './types'; -import { DiscoverGridSelectButton, DiscoverGridSelection } from './discover_grid_doc_selection'; +import { DiscoverGridSelection, DiscoverGridToolbarSelection } from './discover_grid_doc_selection'; import { SortPairArr } from '../../angular/doc_table/lib/get_sort'; +import { leadControlColumns } from './discover_grid_columns'; interface SortObj { id: string; @@ -186,7 +185,7 @@ export const DiscoverGrid = React.memo( ); const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const popoverContents = useMemo(() => getPopoverContents(), []); - const colummsVisibility = useMemo( + const columnsVisibility = useMemo( () => ({ visibleColumns: getVisibleColumns(columns, indexPattern, showTimeCol) as string[], setVisibleColumns: (newColumns: string[]) => { @@ -199,43 +198,7 @@ export const DiscoverGrid = React.memo( sortingColumns, onTableSort, ]); - const lead = useMemo(() => { - if (!rows) { - return []; - } - return [ - useDocSelector - ? { - id: 'checkBox', - width: 31, - headerCellRender: () => ( - - - {i18n.translate('discover.selectColumnHeader', { - defaultMessage: 'Select column', - })} - - - ), - rowCellRender: (col: number) => , - } - : null, - { - id: 'openDetails', - width: 31, - headerCellRender: () => ( - - - {i18n.translate('discover.controlColumnHeader', { - defaultMessage: 'Control column', - })} - - - ), - rowCellRender: ViewButton, - }, - ].filter((obj) => !!obj); - }, [rows, useDocSelector]); + const lead = useMemo(() => leadControlColumns(rows, useDocSelector), [rows, useDocSelector]); if (!rowCount || !rows) { return ( @@ -275,7 +238,7 @@ export const DiscoverGrid = React.memo( columns={euiGridColumns} renderCellValue={renderCellValue} leadingControlColumns={lead} - columnVisibility={colummsVisibility} + columnVisibility={columnsVisibility} pagination={paginationObj} toolbarVisibility={toolbarVisibility} gridStyle={gridStyle} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx new file mode 100644 index 0000000000000..ef4befcf8dbeb --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -0,0 +1,64 @@ +/* + * 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 React from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiScreenReaderOnly } from '@elastic/eui'; +import { DiscoverGridSelectButton } from './discover_grid_doc_selection'; +import { ViewButton } from './discover_grid_view_button'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; + +export function leadControlColumns(rows: ElasticSearchHit[] | undefined, useDocSelector: boolean) { + if (!rows) { + return []; + } + return [ + useDocSelector + ? { + id: 'checkBox', + width: 31, + headerCellRender: () => ( + + + {i18n.translate('discover.selectColumnHeader', { + defaultMessage: 'Select column', + })} + + + ), + rowCellRender: (col: number) => , + cellActions: [], + } + : null, + { + id: 'openDetails', + width: 31, + headerCellRender: () => ( + + + {i18n.translate('discover.controlColumnHeader', { + defaultMessage: 'Control column', + })} + + + ), + rowCellRender: ViewButton, + cellActions: [], + }, + ].filter((obj) => !!obj); +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx index 989121de6706e..32c10be6014da 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx @@ -31,6 +31,7 @@ import { EuiPortal, EuiTitle, EuiSpacer, + EuiButtonEmpty, } from '@elastic/eui'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; import { JsonCodeBlock } from '../json_code_block/json_code_block'; @@ -148,3 +149,18 @@ export function DiscoverGridSelection({ ); } + +export const DiscoverGridToolbarSelection = () => { + const { selected, showSelected, setShowSelected } = useContext(DiscoverGridContext); + return ( + (selected.size ? setShowSelected(!showSelected) : void 0)} + > + {selected.size} {selected.size === 1 ? 'record' : 'records'} selected + + ); +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx deleted file mode 100644 index b729244b5bf33..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout_selection.tsx +++ /dev/null @@ -1,93 +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 React from 'react'; -import { i18n } from '@kbn/i18n'; -import { - EuiAccordion, - EuiFlexGroup, - EuiFlexItem, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiIcon, - EuiPortal, - EuiTitle, -} from '@elastic/eui'; -import { ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { JsonCodeBlock } from '../json_code_block/json_code_block'; -import { IndexPattern } from '../../../kibana_services'; - -interface Props { - indexPattern: IndexPattern; - selected: Record; - onClose: () => void; -} - -export function DiscoverGridFlyoutSelection({ indexPattern, selected, onClose }: Props) { - const rows = Object.values(selected); - return ( - - onClose()} size="m"> - - - - -

    - {' '} - {i18n.translate('discover.grid.tableRow.selectedDocuments', { - defaultMessage: 'Selected records', - })} -

    -
    -
    -
    -
    - -

    - {i18n.translate('discover.grid.documentSelectionAriaLabel', { - defaultMessage: 'Records selection', - })} -

    - {rows.length > 0 && - rows.map((row) => ( -
    - -
    - -
    -
    -
    - ))} -
    -
    -
    - ); -} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx deleted file mode 100644 index 17e2e07817b1f..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_toolbar_selection.tsx +++ /dev/null @@ -1,36 +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 React, { useContext } from 'react'; -import { EuiButtonEmpty } from '@elastic/eui'; -import { DiscoverGridContext, GridContext } from './discover_grid_context'; - -export const DiscoverGridToolbarSelection = () => { - const { selected, showSelected, setShowSelected } = useContext(DiscoverGridContext); - return ( - (selected.size ? setShowSelected(!showSelected) : void 0)} - > - {selected.size} {selected.size === 1 ? 'record' : 'records'} selected - - ); -}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx index e823b1bde01fe..4afd75a5096cb 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx @@ -29,7 +29,7 @@ export const ViewButton = ({ rowIndex }: { rowIndex: number }) => { aria-label={i18n.translate('discover.grid.viewDoc', { defaultMessage: 'Toggle dialog with details', })} - onClick={() => setViewed(rowIndex)} + onClick={() => setViewed(rowIndex === viewed ? -1 : rowIndex)} className="dscTable__buttonToggle" > From daf9939e72505a43d3584b43499e14812022a32a Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 17 Nov 2020 21:58:00 +0100 Subject: [PATCH 123/186] Remove selection code (to restore in a different PR) --- .../application/components/discover.tsx | 2 - .../discover_grid/discover_grid.tsx | 12 +- .../discover_grid/discover_grid_columns.tsx | 22 +-- .../discover_grid/discover_grid_context.tsx | 3 - .../discover_grid_doc_selection.tsx | 166 ------------------ src/plugins/discover/public/build_services.ts | 5 +- src/plugins/discover/public/mocks.ts | 1 - src/plugins/discover/public/plugin.ts | 6 +- .../discover_enhanced/public/plugin.ts | 1 - 9 files changed, 5 insertions(+), 213 deletions(-) delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 9ffbf2f3c2ee2..e25e70c73e62b 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -70,7 +70,6 @@ export function Discover({ return
    Loading
    ; } const { TopNavMenu } = getServices().navigation.ui; - const enhanced = getServices().enhanced; const { savedSearch, filterManager, indexPatternList, config } = opts; const showTimeCol = !config.get('doc_table:hideTimeColumn', false) && indexPattern.timeFieldName; const bucketAggConfig = opts.chartAggConfigs?.aggs[1]; @@ -253,7 +252,6 @@ export function Discover({ const newGrid = { ...grid, columns: newColumns }; opts.setAppState({ grid: newGrid }); }} - useDocSelector={enhanced} />

    )} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 0efb34fbbb39b..7bcfc70c0350d 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -41,7 +41,6 @@ import { DiscoverGridFlyout } from './discover_grid_flyout'; import { DiscoverGridContext } from './discover_grid_context'; import { getRenderCellValueFn } from './get_render_cell_value'; import { DiscoverGridSettings } from './types'; -import { DiscoverGridSelection, DiscoverGridToolbarSelection } from './discover_grid_doc_selection'; import { SortPairArr } from '../../angular/doc_table/lib/get_sort'; import { leadControlColumns } from './discover_grid_columns'; @@ -68,7 +67,6 @@ interface Props { searchTitle?: string; showTimeCol: boolean; sort: SortPairArr[]; - useDocSelector: boolean; } const gridStyle = { @@ -101,10 +99,8 @@ export const DiscoverGrid = React.memo( onAddColumn, showTimeCol, onSetColumns, - useDocSelector, }: Props) => { const [showSelected, setShowSelected] = useState(false); - const [selected, setSelected] = useState(new Map()); const [viewed, setViewed] = useState(-1); const timeString = useMemo( () => @@ -166,7 +162,6 @@ export const DiscoverGrid = React.memo( allowReorder: true, }, showStyleSelector: false, - additionalControls: useDocSelector ? : undefined, }; /** @@ -198,7 +193,7 @@ export const DiscoverGrid = React.memo( sortingColumns, onTableSort, ]); - const lead = useMemo(() => leadControlColumns(rows, useDocSelector), [rows, useDocSelector]); + const lead = useMemo(() => leadControlColumns(rows), [rows]); if (!rowCount || !rows) { return ( @@ -218,8 +213,6 @@ export const DiscoverGrid = React.memo( )} - {showSelected && selected && selected.size && ( - setShowSelected(false)} /> - )} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index ef4befcf8dbeb..24a68de085095 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -19,32 +19,14 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiScreenReaderOnly } from '@elastic/eui'; -import { DiscoverGridSelectButton } from './discover_grid_doc_selection'; import { ViewButton } from './discover_grid_view_button'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; -export function leadControlColumns(rows: ElasticSearchHit[] | undefined, useDocSelector: boolean) { +export function leadControlColumns(rows: ElasticSearchHit[] | undefined) { if (!rows) { return []; } return [ - useDocSelector - ? { - id: 'checkBox', - width: 31, - headerCellRender: () => ( - - - {i18n.translate('discover.selectColumnHeader', { - defaultMessage: 'Select column', - })} - - - ), - rowCellRender: (col: number) => , - cellActions: [], - } - : null, { id: 'openDetails', width: 31, @@ -60,5 +42,5 @@ export function leadControlColumns(rows: ElasticSearchHit[] | undefined, useDocS rowCellRender: ViewButton, cellActions: [], }, - ].filter((obj) => !!obj); + ]; } diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx index 437cfde95306b..1bdb0b8e607bc 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx @@ -17,15 +17,12 @@ * under the License. */ import React from 'react'; -import { DiscoverGridSelection } from './discover_grid_doc_selection'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; import { IndexPattern } from '../../../kibana_services'; export interface GridContext { viewed: number; setViewed: (id: number) => void; - selected: DiscoverGridSelection; - setSelected: (map: DiscoverGridSelection) => void; showSelected: boolean; setShowSelected: (value: boolean) => void; rows: ElasticSearchHit[]; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx deleted file mode 100644 index 32c10be6014da..0000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_doc_selection.tsx +++ /dev/null @@ -1,166 +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 React, { useContext } from 'react'; -import { i18n } from '@kbn/i18n'; -import { - EuiAccordion, - EuiCheckbox, - EuiFlexGroup, - EuiFlexItem, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiIcon, - EuiPortal, - EuiTitle, - EuiSpacer, - EuiButtonEmpty, -} from '@elastic/eui'; -import { ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { JsonCodeBlock } from '../json_code_block/json_code_block'; -import { DiscoverGridContext, GridContext } from './discover_grid_context'; - -export type DiscoverGridSelection = Map; - -export interface DiscoverGridSelectionDoc { - id: string; - added: string; - record: ElasticSearchHit; -} - -export function getSelectedId(record: ElasticSearchHit) { - return `${record._index}-${record._id}`; -} - -export const DiscoverGridSelectButton = ({ - col, - rows, -}: { - col: any; - rows?: ElasticSearchHit[]; -}) => { - const { selected, setSelected } = useContext(DiscoverGridContext); - const rowIndex = col.rowIndex; - if (!rows || !rows[rowIndex]) { - return null; - } - const record = rows[rowIndex]; - const id = getSelectedId(record); - const isChecked = selected.has(id); - if (!rows) { - return null; - } - - return ( - { - if (e.target.checked) { - selected.set(id, { - id, - added: new Date().toJSON(), - record: record as ElasticSearchHit, - }); - } else { - selected.delete(id); - } - setSelected(new Map(selected)); - }} - /> - ); -}; - -export function DiscoverGridSelection({ - selected, - onClose, -}: { - selected: DiscoverGridSelection; - onClose: () => void; -}) { - const rows = [...selected.values()].map((entry) => { - return entry.record; - }); - return ( - - onClose()} size="m"> - - - - -

    - {' '} - {i18n.translate('discover.grid.tableRow.selectedDocuments', { - defaultMessage: 'Selected records', - })} -

    -
    -
    -
    -
    - -

    - {i18n.translate('discover.grid.documentSelectionAriaLabel', { - defaultMessage: 'Records selection', - })} -

    - {rows.length > 0 && - rows.map((row) => ( -
    - -
    - -
    -
    - -
    - ))} -
    -
    -
    - ); -} - -export const DiscoverGridToolbarSelection = () => { - const { selected, showSelected, setShowSelected } = useContext(DiscoverGridContext); - return ( - (selected.size ? setShowSelected(!showSelected) : void 0)} - > - {selected.size} {selected.size === 1 ? 'record' : 'records'} selected - - ); -}; diff --git a/src/plugins/discover/public/build_services.ts b/src/plugins/discover/public/build_services.ts index 50bdafef0d33e..b8e8bb314dd55 100644 --- a/src/plugins/discover/public/build_services.ts +++ b/src/plugins/discover/public/build_services.ts @@ -52,7 +52,6 @@ export interface DiscoverServices { core: CoreStart; data: DataPublicPluginStart; docLinks: DocLinksStart; - enhanced: boolean; history: () => History; theme: ChartsPluginStart['theme']; filterManager: FilterManager; @@ -76,8 +75,7 @@ export async function buildServices( core: CoreStart, plugins: DiscoverStartPlugins, context: PluginInitializerContext, - getEmbeddableInjector: any, - enhanced: boolean + getEmbeddableInjector: any ): Promise { const services = { savedObjectsClient: core.savedObjects.client, @@ -93,7 +91,6 @@ export async function buildServices( core, data: plugins.data, docLinks: core.docLinks, - enhanced, theme: plugins.charts.theme, filterManager: plugins.data.query.filterManager, getEmbeddableInjector, diff --git a/src/plugins/discover/public/mocks.ts b/src/plugins/discover/public/mocks.ts index 7ec0a6027474d..e4314426bfce5 100644 --- a/src/plugins/discover/public/mocks.ts +++ b/src/plugins/discover/public/mocks.ts @@ -27,7 +27,6 @@ const createSetupContract = (): Setup => { docViews: { addDocView: jest.fn(), }, - setEnhanced: jest.fn(), }; return setupContract; }; diff --git a/src/plugins/discover/public/plugin.ts b/src/plugins/discover/public/plugin.ts index 9663b9faf7b52..647746b98cbd1 100644 --- a/src/plugins/discover/public/plugin.ts +++ b/src/plugins/discover/public/plugin.ts @@ -89,7 +89,6 @@ export interface DiscoverSetup { */ addDocView(docViewRaw: DocViewInput | DocViewInputFn): void; }; - setEnhanced: (value: boolean) => void; } export interface DiscoverStart { @@ -163,7 +162,6 @@ export class DiscoverPlugin private servicesInitialized: boolean = false; private innerAngularInitialized: boolean = false; private urlGenerator?: DiscoverStart['urlGenerator']; - private enhanced: boolean = true; /** * why are those functions public? they are needed for some mocha tests @@ -304,7 +302,6 @@ export class DiscoverPlugin this.registerEmbeddable(core, plugins); return { - setEnhanced: (value: boolean) => (this.enhanced = value), docViews: { addDocView: this.docViewsRegistry.addDocView.bind(this.docViewsRegistry), }, @@ -342,8 +339,7 @@ export class DiscoverPlugin core, plugins, this.initializerContext, - this.getEmbeddableInjector, - this.enhanced + this.getEmbeddableInjector ); setServices(services); this.servicesInitialized = true; diff --git a/x-pack/plugins/discover_enhanced/public/plugin.ts b/x-pack/plugins/discover_enhanced/public/plugin.ts index 3a6a5e66d7f95..beff9944a975f 100644 --- a/x-pack/plugins/discover_enhanced/public/plugin.ts +++ b/x-pack/plugins/discover_enhanced/public/plugin.ts @@ -68,7 +68,6 @@ export class DiscoverEnhancedPlugin ) { const start = createStartServicesGetter(core.getStartServices); const isSharePluginInstalled = !!share; - discover.setEnhanced(true); if (isSharePluginInstalled) { const params = { start }; From dec46096039c220aa90dfb70eca3d6fcba6b97a9 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 23 Nov 2020 07:10:07 +0100 Subject: [PATCH 124/186] Add functional tests --- .../discover_grid/discover_grid.tsx | 1 + .../discover_grid/discover_grid_flyout.tsx | 4 +- .../discover_grid_view_button.tsx | 1 + .../apps/discover/_data_grid_context.ts | 90 +++++++++++++++++++ test/functional/apps/discover/index.js | 1 + test/functional/services/doc_table.ts | 46 +++++++++- 6 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 test/functional/apps/discover/_data_grid_context.ts diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 7bcfc70c0350d..32704e54180e3 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -226,6 +226,7 @@ export const DiscoverGrid = React.memo( - onClose()} size="m"> + onClose()} size="m" data-test-subj="docTableDetailsFlyout"> @@ -89,6 +89,7 @@ export const DiscoverGridFlyout = function DiscoverGridInner({ size="xs" iconType="documents" href={getContextAppHref ? getContextAppHref(hit._id) : ''} + data-test-subj="docTableRowAction" > {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkText', { defaultMessage: 'View surrounding documents', @@ -103,6 +104,7 @@ export const DiscoverGridFlyout = function DiscoverGridInner({ href={`#/doc/${indexPattern.id}/${hit._index}?id=${encodeURIComponent( hit._id as string )}`} + data-test-subj="docTableRowAction" > {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkText', { defaultMessage: 'View single document', diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx index 4afd75a5096cb..1be6e8ce5c17e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx @@ -31,6 +31,7 @@ export const ViewButton = ({ rowIndex }: { rowIndex: number }) => { })} onClick={() => setViewed(rowIndex === viewed ? -1 : rowIndex)} className="dscTable__buttonToggle" + data-test-subj="docTableExpandToggleColumn" > diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts new file mode 100644 index 0000000000000..d8d2ac0d31e8d --- /dev/null +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -0,0 +1,90 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +const TEST_COLUMN_NAMES = ['@message']; +const TEST_FILTER_COLUMN_NAMES = [ + ['extension', 'jpg'], + ['geo.src', 'IN'], +]; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const retry = getService('retry'); + const docTable = getService('docTable'); + const filterBar = getService('filterBar'); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings']); + const defaultSettings = { defaultIndex: 'logstash-*', 'doc_table:legacy': false }; + const kibanaServer = getService('kibanaServer'); + const esArchiver = getService('esArchiver'); + + describe('discover data grid context tests', () => { + before(async () => { + await esArchiver.loadIfNeeded('logstash_functional'); + await PageObjects.settings.setLegacyDiscoverTable(); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await kibanaServer.uiSettings.update(defaultSettings); + await PageObjects.common.navigateToApp('discover'); + + for (const columnName of TEST_COLUMN_NAMES) { + await PageObjects.discover.clickFieldListItemAdd(columnName); + } + + for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { + await PageObjects.discover.clickFieldListItem(columnName); + await PageObjects.discover.clickFieldListPlusFilter(columnName, value); + } + }); + after(async () => { + await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + }); + + it('should open the context view with the selected document as anchor', async () => { + // check the anchor timestamp in the context view + await retry.waitFor('selected document timestamp matches anchor timestamp ', async () => { + // get the timestamp of the first row + const discoverFields = await docTable.getFields(); + const firstTimestamp = discoverFields[0][0]; + + // navigate to the context view + await docTable.clickRowToggle({ rowIndex: 0 }); + const rowActions = await docTable.getRowActions({ rowIndex: 0 }); + await rowActions[0].click(); + const contextFields = await docTable.getFields({ isAnchorRow: true }); + const anchorTimestamp = contextFields[0][0]; + return anchorTimestamp === firstTimestamp; + }); + }); + + it('should open the context view with the same columns', async () => { + const columnNames = await docTable.getHeaderFields(); + expect(columnNames).to.eql(['Time', ...TEST_COLUMN_NAMES]); + }); + + it('should open the context view with the filters disabled', async () => { + let disabledFilterCounter = 0; + for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { + if (await filterBar.hasFilter(columnName, value, false)) { + disabledFilterCounter++; + } + } + expect(disabledFilterCounter).to.be(TEST_FILTER_COLUMN_NAMES.length); + }); + }); +} diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index cff40774d0681..345aeb59358cf 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -50,5 +50,6 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_date_nanos_mixed')); loadTestFile(require.resolve('./_indexpattern_without_timefield')); loadTestFile(require.resolve('./_data_grid')); + loadTestFile(require.resolve('./_data_grid_context')); }); } diff --git a/test/functional/services/doc_table.ts b/test/functional/services/doc_table.ts index 1ac8de69ee5f4..262c273ee51e7 100644 --- a/test/functional/services/doc_table.ts +++ b/test/functional/services/doc_table.ts @@ -21,17 +21,23 @@ import { WebElementWrapper } from './lib/web_element_wrapper'; export function DocTableProvider({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); + const find = getService('find'); const retry = getService('retry'); const PageObjects = getPageObjects(['common', 'header']); interface SelectOptions { - isAnchorRow: boolean; + isAnchorRow?: boolean; rowIndex: number; } class DocTable { - public async getTable(selector?: string) { - return await testSubjects.find(selector ? selector : 'docTable'); + private async isLegacy(selector: string = 'docTable') { + const table = await this.getTable(selector); + const hasEuiClass = await table.elementHasClass('euiDataGrid__verticalScroll'); + return !hasEuiClass; + } + public async getTable(selector: string = 'docTable') { + return await testSubjects.find(selector); } public async getRowsText() { @@ -44,7 +50,10 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont public async getBodyRows(): Promise { const table = await this.getTable(); - return await table.findAllByTestSubject('~docTableRow'); + if (!(await this.isLegacy())) { + return await table.findAllByTestSubject('dataGridRow'); + } + return await table.findAllByTestSubject('docTableRow'); } public async getAnchorRow(): Promise { @@ -79,6 +88,9 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont } public async getDetailsRows(): Promise { + if (!(await this.isLegacy())) { + return [await testSubjects.find('docTableDetailsFlyout')]; + } const table = await this.getTable(); return await table.findAllByCssSelector( '[data-test-subj~="docTableRow"] + [data-test-subj~="docTableDetailsRow"]' @@ -95,6 +107,24 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont } public async getFields(options: { isAnchorRow: boolean } = { isAnchorRow: false }) { + if (!(await this.isLegacy())) { + const rows = await find.allByCssSelector('.euiDataGridRow'); + + const result = []; + for (const row of rows) { + const cells = await row.findAllByClassName('euiDataGridRowCell__truncate'); + const cellsText = []; + let cellIdx = 0; + for (const cell of cells) { + if (cellIdx > 0) { + cellsText.push(await cell.getVisibleText()); + } + cellIdx++; + } + result.push(cellsText); + } + return result; + } const table = await this.getTable(); const $ = await table.parseDomContent(); const rowLocator = options.isAnchorRow ? '~docTableAnchorRow' : '~docTableRow'; @@ -110,6 +140,14 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont public async getHeaderFields(selector?: string): Promise { const table = await this.getTable(selector); const $ = await table.parseDomContent(); + if (!(await this.isLegacy())) { + const result = await find.allByCssSelector('.euiDataGridHeaderCell__content'); + const textArr = []; + for (const cell of result) { + textArr.push(await cell.getVisibleText()); + } + return Promise.resolve(textArr); + } return $.findTestSubjects('~docTableHeaderField') .toArray() .map((field: any) => $(field).text().trim()); From 34ed605049a4bf0271af3ee82edac15b15cc82ed Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 23 Nov 2020 11:18:47 +0100 Subject: [PATCH 125/186] Refactor functional tests --- .../apps/discover/_data_grid_context.ts | 12 ++-- test/functional/services/data_grid.ts | 72 +++++++++++++++++++ test/functional/services/doc_table.ts | 46 ++---------- 3 files changed, 83 insertions(+), 47 deletions(-) diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts index d8d2ac0d31e8d..b3854ea54e315 100644 --- a/test/functional/apps/discover/_data_grid_context.ts +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -27,8 +27,9 @@ const TEST_FILTER_COLUMN_NAMES = [ export default function ({ getService, getPageObjects }: FtrProviderContext) { const retry = getService('retry'); - const docTable = getService('docTable'); const filterBar = getService('filterBar'); + const dataGrid = getService('dataGrid'); + const docTable = getService('docTable'); const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings']); const defaultSettings = { defaultIndex: 'logstash-*', 'doc_table:legacy': false }; const kibanaServer = getService('kibanaServer'); @@ -59,14 +60,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // check the anchor timestamp in the context view await retry.waitFor('selected document timestamp matches anchor timestamp ', async () => { // get the timestamp of the first row - const discoverFields = await docTable.getFields(); + const discoverFields = await dataGrid.getFields(); const firstTimestamp = discoverFields[0][0]; // navigate to the context view - await docTable.clickRowToggle({ rowIndex: 0 }); - const rowActions = await docTable.getRowActions({ rowIndex: 0 }); + await dataGrid.clickRowToggle({ rowIndex: 0 }); + const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); await rowActions[0].click(); - const contextFields = await docTable.getFields({ isAnchorRow: true }); + // entering the context view (contains the legacy type) + const contextFields = await docTable.getFields(); const anchorTimestamp = contextFields[0][0]; return anchorTimestamp === firstTimestamp; }); diff --git a/test/functional/services/data_grid.ts b/test/functional/services/data_grid.ts index 40157caab5756..1d0f9c1c31f3d 100644 --- a/test/functional/services/data_grid.ts +++ b/test/functional/services/data_grid.ts @@ -18,14 +18,20 @@ */ import { FtrProviderContext } from '../ftr_provider_context'; +import { WebElementWrapper } from './lib/web_element_wrapper'; interface TabbedGridData { columns: string[]; rows: string[][]; } +interface SelectOptions { + isAnchorRow?: boolean; + rowIndex: number; +} export function DataGridProvider({ getService }: FtrProviderContext) { const find = getService('find'); + const testSubjects = getService('testSubjects'); class DataGrid { async getDataGridTableData(): Promise { @@ -49,6 +55,72 @@ export function DataGridProvider({ getService }: FtrProviderContext) { rows, }; } + public async getFields() { + const rows = await find.allByCssSelector('.euiDataGridRow'); + + const result = []; + for (const row of rows) { + const cells = await row.findAllByClassName('euiDataGridRowCell__truncate'); + const cellsText = []; + let cellIdx = 0; + for (const cell of cells) { + if (cellIdx > 0) { + cellsText.push(await cell.getVisibleText()); + } + cellIdx++; + } + result.push(cellsText); + } + return result; + } + + public async getTable(selector: string = 'docTable') { + return await testSubjects.find(selector); + } + + public async getBodyRows(): Promise { + const table = await this.getTable(); + return await table.findAllByTestSubject('dataGridRow'); + } + + public async getAnchorRow(): Promise { + const table = await this.getTable(); + return await table.findByTestSubject('~docTableAnchorRow'); + } + + public async getRow(options: SelectOptions): Promise { + return options.isAnchorRow + ? await this.getAnchorRow() + : (await this.getBodyRows())[options.rowIndex]; + } + + public async clickRowToggle( + options: SelectOptions = { isAnchorRow: false, rowIndex: 0 } + ): Promise { + const row = await this.getRow(options); + const toggle = await row.findByTestSubject('~docTableExpandToggleColumn'); + await toggle.click(); + } + + public async getDetailsRows(): Promise { + return [await testSubjects.find('docTableDetailsFlyout')]; + } + + public async getHeaderFields(): Promise { + const result = await find.allByCssSelector('.euiDataGridHeaderCell__content'); + const textArr = []; + for (const cell of result) { + textArr.push(await cell.getVisibleText()); + } + return Promise.resolve(textArr); + } + + public async getRowActions( + options: SelectOptions = { isAnchorRow: false, rowIndex: 0 } + ): Promise { + const detailsRow = (await this.getDetailsRows())[options.rowIndex]; + return await detailsRow.findAllByTestSubject('~docTableRowAction'); + } } return new DataGrid(); diff --git a/test/functional/services/doc_table.ts b/test/functional/services/doc_table.ts index 262c273ee51e7..1ac8de69ee5f4 100644 --- a/test/functional/services/doc_table.ts +++ b/test/functional/services/doc_table.ts @@ -21,23 +21,17 @@ import { WebElementWrapper } from './lib/web_element_wrapper'; export function DocTableProvider({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); - const find = getService('find'); const retry = getService('retry'); const PageObjects = getPageObjects(['common', 'header']); interface SelectOptions { - isAnchorRow?: boolean; + isAnchorRow: boolean; rowIndex: number; } class DocTable { - private async isLegacy(selector: string = 'docTable') { - const table = await this.getTable(selector); - const hasEuiClass = await table.elementHasClass('euiDataGrid__verticalScroll'); - return !hasEuiClass; - } - public async getTable(selector: string = 'docTable') { - return await testSubjects.find(selector); + public async getTable(selector?: string) { + return await testSubjects.find(selector ? selector : 'docTable'); } public async getRowsText() { @@ -50,10 +44,7 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont public async getBodyRows(): Promise { const table = await this.getTable(); - if (!(await this.isLegacy())) { - return await table.findAllByTestSubject('dataGridRow'); - } - return await table.findAllByTestSubject('docTableRow'); + return await table.findAllByTestSubject('~docTableRow'); } public async getAnchorRow(): Promise { @@ -88,9 +79,6 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont } public async getDetailsRows(): Promise { - if (!(await this.isLegacy())) { - return [await testSubjects.find('docTableDetailsFlyout')]; - } const table = await this.getTable(); return await table.findAllByCssSelector( '[data-test-subj~="docTableRow"] + [data-test-subj~="docTableDetailsRow"]' @@ -107,24 +95,6 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont } public async getFields(options: { isAnchorRow: boolean } = { isAnchorRow: false }) { - if (!(await this.isLegacy())) { - const rows = await find.allByCssSelector('.euiDataGridRow'); - - const result = []; - for (const row of rows) { - const cells = await row.findAllByClassName('euiDataGridRowCell__truncate'); - const cellsText = []; - let cellIdx = 0; - for (const cell of cells) { - if (cellIdx > 0) { - cellsText.push(await cell.getVisibleText()); - } - cellIdx++; - } - result.push(cellsText); - } - return result; - } const table = await this.getTable(); const $ = await table.parseDomContent(); const rowLocator = options.isAnchorRow ? '~docTableAnchorRow' : '~docTableRow'; @@ -140,14 +110,6 @@ export function DocTableProvider({ getService, getPageObjects }: FtrProviderCont public async getHeaderFields(selector?: string): Promise { const table = await this.getTable(selector); const $ = await table.parseDomContent(); - if (!(await this.isLegacy())) { - const result = await find.allByCssSelector('.euiDataGridHeaderCell__content'); - const textArr = []; - for (const cell of result) { - textArr.push(await cell.getVisibleText()); - } - return Promise.resolve(textArr); - } return $.findTestSubjects('~docTableHeaderField') .toArray() .map((field: any) => $(field).text().trim()); From caf50b657c3198d3cce2f4cdc31bc33dd2e3c67d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 23 Nov 2020 12:06:15 +0100 Subject: [PATCH 126/186] Add field data tests --- .../apps/discover/_data_grid_field_data.ts | 99 +++++++++++++++++++ test/functional/apps/discover/index.js | 1 + test/functional/services/data_grid.ts | 16 ++- 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 test/functional/apps/discover/_data_grid_field_data.ts diff --git a/test/functional/apps/discover/_data_grid_field_data.ts b/test/functional/apps/discover/_data_grid_field_data.ts new file mode 100644 index 0000000000000..dd2f5cfa3ca53 --- /dev/null +++ b/test/functional/apps/discover/_data_grid_field_data.ts @@ -0,0 +1,99 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const retry = getService('retry'); + const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); + const toasts = getService('toasts'); + const queryBar = getService('queryBar'); + const PageObjects = getPageObjects(['common', 'header', 'discover', 'visualize', 'timePicker']); + const defaultSettings = { defaultIndex: 'logstash-*', 'doc_table:legacy': false }; + const dataGrid = getService('dataGrid'); + + describe('discover data grid field data tests', function describeIndexTests() { + this.tags('includeFirefox'); + before(async function () { + await esArchiver.load('discover'); + await esArchiver.loadIfNeeded('logstash_functional'); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await kibanaServer.uiSettings.update(defaultSettings); + await PageObjects.common.navigateToApp('discover'); + }); + describe('field data', function () { + it('search php should show the correct hit count', async function () { + const expectedHitCount = '445'; + await retry.try(async function () { + await queryBar.setQuery('php'); + await queryBar.submitQuery(); + const hitCount = await PageObjects.discover.getHitCount(); + expect(hitCount).to.be(expectedHitCount); + }); + }); + + it('the search term should be highlighted in the field data', async function () { + // marks is the style that highlights the text in yellow + const marks = await PageObjects.discover.getMarks(); + expect(marks.length).to.be(50); + expect(marks.indexOf('php')).to.be(0); + }); + + it('search type:apache should show the correct hit count', async function () { + const expectedHitCount = '11,156'; + await queryBar.setQuery('type:apache'); + await queryBar.submitQuery(); + await retry.try(async function tryingForTime() { + const hitCount = await PageObjects.discover.getHitCount(); + expect(hitCount).to.be(expectedHitCount); + }); + }); + + it('doc view should show Time and _source columns', async function () { + const expectedHeader = 'Time (@timestamp) _source'; + const DocHeader = await dataGrid.getHeaderFields(); + expect(DocHeader.join(' ')).to.be(expectedHeader); + }); + + it('doc view should sort ascending', async function () { + const expectedTimeStamp = 'Sep 20, 2015 @ 00:00:00.000'; + await dataGrid.clickDocSortAsc(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + await retry.try(async function tryingForTime() { + const rowData = await dataGrid.getFields(); + expect(rowData[0][0].startsWith(expectedTimeStamp)).to.be.ok(); + }); + }); + + it('a bad syntax query should show an error message', async function () { + const expectedError = + 'Expected ":", "<", "<=", ">", ">=", AND, OR, end of input, ' + + 'whitespace but "(" found.'; + await queryBar.setQuery('xxx('); + await queryBar.submitQuery(); + const { message } = await toasts.getErrorToast(); + expect(message).to.contain(expectedError); + await toasts.dismissToast(); + }); + }); + }); +} diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index 345aeb59358cf..ee6e7fcdc1303 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -51,5 +51,6 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_indexpattern_without_timefield')); loadTestFile(require.resolve('./_data_grid')); loadTestFile(require.resolve('./_data_grid_context')); + loadTestFile(require.resolve('./_data_grid_field_data')); }); } diff --git a/test/functional/services/data_grid.ts b/test/functional/services/data_grid.ts index 1d0f9c1c31f3d..927afe509aa6e 100644 --- a/test/functional/services/data_grid.ts +++ b/test/functional/services/data_grid.ts @@ -109,8 +109,12 @@ export function DataGridProvider({ getService }: FtrProviderContext) { public async getHeaderFields(): Promise { const result = await find.allByCssSelector('.euiDataGridHeaderCell__content'); const textArr = []; + let idx = 0; for (const cell of result) { - textArr.push(await cell.getVisibleText()); + if (idx > 0) { + textArr.push(await cell.getVisibleText()); + } + idx++; } return Promise.resolve(textArr); } @@ -121,6 +125,16 @@ export function DataGridProvider({ getService }: FtrProviderContext) { const detailsRow = (await this.getDetailsRows())[options.rowIndex]; return await detailsRow.findAllByTestSubject('~docTableRowAction'); } + + public async clickDocSortAsc() { + await find.clickByCssSelector('.euiDataGridHeaderCell__button'); + await find.clickByButtonText('Sort ASC'); + } + + public async clickDocSortDesc() { + await find.clickByCssSelector('.euiDataGridHeaderCell__button'); + await find.clickByButtonText('Sort Desc'); + } } return new DataGrid(); From f76e4a2f0303ed0b2f82051f8c58f02ab33c7045 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 24 Nov 2020 12:00:58 +0100 Subject: [PATCH 127/186] Fix bad syntax test - seems this doesn't work locally but on jenkins? --- test/functional/apps/discover/_data_grid_field_data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_data_grid_field_data.ts b/test/functional/apps/discover/_data_grid_field_data.ts index dd2f5cfa3ca53..137c19149d274 100644 --- a/test/functional/apps/discover/_data_grid_field_data.ts +++ b/test/functional/apps/discover/_data_grid_field_data.ts @@ -88,7 +88,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const expectedError = 'Expected ":", "<", "<=", ">", ">=", AND, OR, end of input, ' + 'whitespace but "(" found.'; - await queryBar.setQuery('xxx('); + await queryBar.setQuery('xxx(yyy))'); await queryBar.submitQuery(); const { message } = await toasts.getErrorToast(); expect(message).to.contain(expectedError); From e5ebfe4d211cc6d6a511017ef6c63faef68bab9d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 24 Nov 2020 12:34:47 +0100 Subject: [PATCH 128/186] Add doc navigation functional tests --- .../discover/_data_grid_doc_navigation.ts | 89 +++++++++++++++++++ test/functional/apps/discover/index.js | 1 + test/functional/services/data_grid.ts | 45 +++++++++- 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 test/functional/apps/discover/_data_grid_doc_navigation.ts diff --git a/test/functional/apps/discover/_data_grid_doc_navigation.ts b/test/functional/apps/discover/_data_grid_doc_navigation.ts new file mode 100644 index 0000000000000..85e02afec6898 --- /dev/null +++ b/test/functional/apps/discover/_data_grid_doc_navigation.ts @@ -0,0 +1,89 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const filterBar = getService('filterBar'); + const dataGrid = getService('dataGrid'); + const testSubjects = getService('testSubjects'); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'context']); + const esArchiver = getService('esArchiver'); + const retry = getService('retry'); + const kibanaServer = getService('kibanaServer'); + const defaultSettings = { defaultIndex: 'logstash-*', 'doc_table:legacy': false }; + + describe('discover data grid doc link', function () { + beforeEach(async function () { + await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('discover'); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await kibanaServer.uiSettings.update(defaultSettings); + await PageObjects.common.navigateToApp('discover'); + }); + + it('should open the doc view of the selected document', async function () { + // navigate to the doc view + await dataGrid.clickRowToggle({ rowIndex: 0 }); + + // click the open action + await retry.try(async () => { + const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); + if (!rowActions.length) { + throw new Error('row actions empty, trying again'); + } + await rowActions[1].click(); + }); + + const hasDocHit = await testSubjects.exists('doc-hit'); + expect(hasDocHit).to.be(true); + }); + + it('add filter should create an exists filter if value is null (#7189)', async function () { + await PageObjects.discover.waitUntilSearchingHasFinished(); + // Filter special document + await filterBar.addFilter('agent', 'is', 'Missing/Fields'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + await retry.try(async () => { + // navigate to the doc view + await dataGrid.clickRowToggle({ rowIndex: 0 }); + + const details = await dataGrid.getDetailsRow(); + await dataGrid.addInclusiveFilter(details, 'referer'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + const hasInclusiveFilter = await filterBar.hasFilter( + 'referer', + 'exists', + true, + false, + true + ); + expect(hasInclusiveFilter).to.be(true); + + await dataGrid.removeInclusiveFilter(details, 'referer'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + const hasExcludeFilter = await filterBar.hasFilter('referer', 'exists', true, false, false); + expect(hasExcludeFilter).to.be(true); + }); + }); + }); +} diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index ee6e7fcdc1303..a37d086301e3f 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -52,5 +52,6 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_data_grid')); loadTestFile(require.resolve('./_data_grid_context')); loadTestFile(require.resolve('./_data_grid_field_data')); + loadTestFile(require.resolve('./_data_grid_doc_navigation')); }); } diff --git a/test/functional/services/data_grid.ts b/test/functional/services/data_grid.ts index 927afe509aa6e..d68cec6a8a440 100644 --- a/test/functional/services/data_grid.ts +++ b/test/functional/services/data_grid.ts @@ -29,9 +29,10 @@ interface SelectOptions { rowIndex: number; } -export function DataGridProvider({ getService }: FtrProviderContext) { +export function DataGridProvider({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const testSubjects = getService('testSubjects'); + const PageObjects = getPageObjects(['common', 'header']); class DataGrid { async getDataGridTableData(): Promise { @@ -135,6 +136,48 @@ export function DataGridProvider({ getService }: FtrProviderContext) { await find.clickByCssSelector('.euiDataGridHeaderCell__button'); await find.clickByButtonText('Sort Desc'); } + public async getDetailsRow(): Promise { + const detailRows = await this.getDetailsRows(); + return detailRows[0]; + } + public async addInclusiveFilter( + detailsRow: WebElementWrapper, + fieldName: string + ): Promise { + const tableDocViewRow = await this.getTableDocViewRow(detailsRow, fieldName); + const addInclusiveFilterButton = await this.getAddInclusiveFilterButton(tableDocViewRow); + await addInclusiveFilterButton.click(); + await PageObjects.header.awaitGlobalLoadingIndicatorHidden(); + } + + public async getAddInclusiveFilterButton( + tableDocViewRow: WebElementWrapper + ): Promise { + return await tableDocViewRow.findByTestSubject(`~addInclusiveFilterButton`); + } + + public async getTableDocViewRow( + detailsRow: WebElementWrapper, + fieldName: string + ): Promise { + return await detailsRow.findByTestSubject(`~tableDocViewRow-${fieldName}`); + } + + public async getRemoveInclusiveFilterButton( + tableDocViewRow: WebElementWrapper + ): Promise { + return await tableDocViewRow.findByTestSubject(`~removeInclusiveFilterButton`); + } + + public async removeInclusiveFilter( + detailsRow: WebElementWrapper, + fieldName: string + ): Promise { + const tableDocViewRow = await this.getTableDocViewRow(detailsRow, fieldName); + const addInclusiveFilterButton = await this.getRemoveInclusiveFilterButton(tableDocViewRow); + await addInclusiveFilterButton.click(); + await PageObjects.header.awaitGlobalLoadingIndicatorHidden(); + } } return new DataGrid(); From f613d0e17207dce59e49849f206fa4fe4dcb5dd4 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 30 Nov 2020 18:47:18 +0100 Subject: [PATCH 129/186] Cleanup code --- .../components/discover_grid/constants.ts | 36 +++ .../discover_grid/discover_grid.tsx | 222 ++++++++---------- .../discover_grid_cell_actions.tsx | 80 +++++++ .../discover_grid/discover_grid_columns.tsx | 100 +++++++- .../discover_grid/discover_grid_helpers.tsx | 173 +------------- 5 files changed, 324 insertions(+), 287 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/constants.ts create mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx diff --git a/src/plugins/discover/public/application/components/discover_grid/constants.ts b/src/plugins/discover/public/application/components/discover_grid/constants.ts new file mode 100644 index 0000000000000..305a52b5afd58 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/constants.ts @@ -0,0 +1,36 @@ +/* + * 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 const kibanaJSON = 'kibana-json'; +export const geoPoint = 'geo-point'; +export const gridStyle = { + border: 'horizontal', + fontSize: 's', + cellPadding: 's', + rowHover: 'none', +}; + +export const pageSizeArr = [25, 50, 100]; +export const defaultPageSize = 25; +export const toolbarVisibility = { + showColumnSelector: { + allowHide: false, + allowReorder: true, + }, + showStyleSelector: false, +}; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 32704e54180e3..5d3614fe489df 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -17,10 +17,13 @@ * under the License. */ import React, { useCallback, useMemo, useState } from 'react'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import './discover_grid.scss'; import { i18n } from '@kbn/i18n'; import { + EuiDataGridSorting, + EuiDataGridStyle, + EuiDataGridProps, EuiDataGrid, EuiIcon, EuiScreenReaderOnly, @@ -31,25 +34,25 @@ import { import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; import { getDefaultSort } from '../../angular/doc_table/lib/get_default_sort'; -import { - getEuiGridColumns, - getPopoverContents, - getSchemaDetectors, - getVisibleColumns, -} from './discover_grid_helpers'; +import { getPopoverContents, getSchemaDetectors } from './discover_grid_helpers'; import { DiscoverGridFlyout } from './discover_grid_flyout'; import { DiscoverGridContext } from './discover_grid_context'; import { getRenderCellValueFn } from './get_render_cell_value'; import { DiscoverGridSettings } from './types'; import { SortPairArr } from '../../angular/doc_table/lib/get_sort'; -import { leadControlColumns } from './discover_grid_columns'; +import { + getEuiGridColumns, + getLeadControlColumns, + getVisibleColumns, +} from './discover_grid_columns'; +import { defaultPageSize, gridStyle, pageSizeArr, toolbarVisibility } from './constants'; interface SortObj { id: string; direction: string; } -interface Props { +interface DiscoverGridProps { ariaLabelledBy: string; columns: string[]; getContextAppHref: (id: string) => string; @@ -69,16 +72,9 @@ interface Props { sort: SortPairArr[]; } -const gridStyle = { - border: 'horizontal', - fontSize: 's', - cellPadding: 's', - rowHover: 'none', -}; -const pageSizeArr = [25, 50, 100, 500]; -const defaultPageSize = 50; - -export const EuiDataGridMemoized = React.memo((props: any) => ); +export const EuiDataGridMemoized = React.memo((props: EuiDataGridProps) => ( + +)); export const DiscoverGrid = React.memo( ({ @@ -99,7 +95,7 @@ export const DiscoverGrid = React.memo( onAddColumn, showTimeCol, onSetColumns, - }: Props) => { + }: DiscoverGridProps) => { const [showSelected, setShowSelected] = useState(false); const [viewed, setViewed] = useState(-1); const timeString = useMemo( @@ -156,14 +152,6 @@ export const DiscoverGrid = React.memo( indexPattern, ]); - const toolbarVisibility = { - showColumnSelector: { - allowHide: false, - allowReorder: true, - }, - showStyleSelector: false, - }; - /** * Render variables */ @@ -193,106 +181,102 @@ export const DiscoverGrid = React.memo( sortingColumns, onTableSort, ]); - const lead = useMemo(() => leadControlColumns(rows), [rows]); + const lead = useMemo(() => getLeadControlColumns(rows), [rows]); if (!rowCount || !rows) { return ( - -
    - - - - - -
    -
    +
    + + + + + +
    ); } return ( - - - <> - { - if (onResize) { - onResize(col); - } - }} - /> + + <> + { + if (onResize) { + onResize(col); + } + }} + /> - {showDisclaimer && ( -

    - - - - -

    - )} - {searchTitle && ( - -

    - {searchDescription ? ( - - ) : ( - - )} -

    -
    - )} - {viewed > -1 && rows[viewed] && ( - { - setViewed(-1); - }} + {showDisclaimer && ( +

    + - )} - - - + + + +

    + )} + {searchTitle && ( + +

    + {searchDescription ? ( + + ) : ( + + )} +

    +
    + )} + {viewed > -1 && rows[viewed] && ( + { + setViewed(-1); + }} + /> + )} + +
    ); } ); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx new file mode 100644 index 0000000000000..3e4709c5c8676 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx @@ -0,0 +1,80 @@ +/* + * 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 React, { useContext } from 'react'; +import { i18n } from '@kbn/i18n'; +import { IndexPatternField } from '../../../../../data/common/index_patterns/fields'; +import { DiscoverGridContext } from './discover_grid_context'; + +const FilterInBtn = ({ Component, rowIndex, columnId }: any) => { + const context = useContext(DiscoverGridContext); + return ( + { + const row = context.rows[rowIndex]; + const flattened = context.indexPattern.flattenHit(row); + + if (flattened) { + context.onFilter(columnId, flattened[columnId], '+'); + } + }} + iconType="plusInCircle" + aria-label={i18n.translate('discover.grid.filterForAria', { + defaultMessage: 'Filter for {value}', + values: { value: columnId }, + })} + > + {i18n.translate('discover.grid.filterFor', { + defaultMessage: 'Filter for', + })} + + ); +}; + +const FilterOutBtn = ({ Component, rowIndex, columnId }: any) => { + const context = useContext(DiscoverGridContext); + return ( + { + const row = context.rows[rowIndex]; + const flattened = context.indexPattern.flattenHit(row); + + if (flattened) { + context.onFilter(columnId, flattened[columnId], '-'); + } + }} + iconType="minusInCircle" + aria-label={i18n.translate('discover.grid.filterOutAria', { + defaultMessage: 'Filter out {value}', + values: { value: columnId }, + })} + > + {i18n.translate('discover.grid.filterOut', { + defaultMessage: 'Filter out', + })} + + ); +}; + +export function buildCellActions(field: IndexPatternField) { + if (!field.aggregatable) { + return undefined; + } + + return [FilterInBtn, FilterOutBtn]; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index 24a68de085095..59786210d4d16 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -18,11 +18,15 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiScreenReaderOnly } from '@elastic/eui'; +import { EuiDataGridColumn, EuiScreenReaderOnly } from '@elastic/eui'; import { ViewButton } from './discover_grid_view_button'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { DiscoverGridSettings } from './types'; +import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; +import { kibanaJSON, geoPoint } from './constants'; +import { buildCellActions } from './discover_grid_cell_actions'; -export function leadControlColumns(rows: ElasticSearchHit[] | undefined) { +export function getLeadControlColumns(rows: ElasticSearchHit[] | undefined) { if (!rows) { return []; } @@ -44,3 +48,95 @@ export function leadControlColumns(rows: ElasticSearchHit[] | undefined) { }, ]; } + +export function buildEuiGridColumn( + columnName: string, + columnWidth: number | undefined = 0, + indexPattern: IndexPattern, + timeString: string +) { + const indexPatternField = indexPattern.getFieldByName(columnName); + const column: EuiDataGridColumn = { + id: columnName, + schema: indexPatternField?.type, + isSortable: indexPatternField?.sortable, + display: indexPatternField?.displayName, + actions: { + showHide: { label: 'Remove column' }, + }, + cellActions: indexPatternField ? buildCellActions(indexPatternField) : [], + }; + + // Default DataGrid schemas: boolean, numeric, datetime, json, currency + // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts + switch (column.schema) { + case 'date': + column.schema = 'datetime'; + break; + case 'number': + column.schema = 'numeric'; + break; + case '_source': + column.schema = kibanaJSON; + break; + case 'object': + column.schema = 'json'; + break; + case 'geo_point': + column.schema = geoPoint; + break; + default: + column.schema = 'json'; + break; + } + + if (column.id === indexPattern.timeFieldName) { + column.display = `${timeString} (${indexPattern.timeFieldName})`; + column.initialWidth = 180; + } + if (columnWidth > 0) { + column.initialWidth = Number(columnWidth); + } + return column; +} + +export function getEuiGridColumns( + columns: string[], + settings: DiscoverGridSettings | undefined, + indexPattern: IndexPattern, + showTimeCol: boolean, + timeString: string +) { + const timeFieldName = indexPattern.timeFieldName; + const getColWidth = (column: string) => { + if (settings?.columns && settings.columns[column]) { + return settings.columns[column].width || 0; + } + return 0; + }; + + if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { + const usedColumns = [indexPattern.timeFieldName, ...columns]; + return usedColumns.map((column) => + buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) + ); + } + + return columns.map((column) => + buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) + ); +} + +export function getVisibleColumns( + columns: string[], + indexPattern: IndexPattern, + showTimeCol: boolean +) { + const timeFieldName = indexPattern.timeFieldName; + + if (showTimeCol && !columns.find((col) => col === timeFieldName)) { + return [timeFieldName, ...columns]; + } + + return columns; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx index a6333b37af7c2..f4622d71dcfcf 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx @@ -16,169 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -import React, { ReactNode, useContext } from 'react'; -import { EuiCodeBlock, EuiDataGridColumn } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { IndexPattern, IndexPatternField } from '../../../../../data/common'; -import { DiscoverGridSettings } from './types'; -import { DiscoverGridContext } from './discover_grid_context'; +import React, { ReactNode } from 'react'; +import { EuiCodeBlock } from '@elastic/eui'; +import { geoPoint, kibanaJSON } from './constants'; -const kibanaJSON = 'kibana-json'; -const geoPoint = 'geo-point'; - -export function getEuiGridColumns( - columns: string[], - settings: DiscoverGridSettings | undefined, - indexPattern: IndexPattern, - showTimeCol: boolean, - timeString: string -) { - const timeFieldName = indexPattern.timeFieldName; - const getColWidth = (column: string) => { - if (settings?.columns && settings.columns[column]) { - return settings.columns[column].width || 0; - } - return 0; - }; - - if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { - const usedColumns = [indexPattern.timeFieldName, ...columns]; - return usedColumns.map((column) => - buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) - ); - } - - return columns.map((column) => - buildEuiGridColumn(column, getColWidth(column), indexPattern, timeString) - ); -} - -export function getVisibleColumns( - columns: string[], - indexPattern: IndexPattern, - showTimeCol: boolean -) { - const timeFieldName = indexPattern.timeFieldName; - - if (showTimeCol && !columns.find((col) => col === timeFieldName)) { - return [timeFieldName, ...columns]; - } - - return columns; -} - -const FilterInBtn = ({ Component, rowIndex, columnId }: any) => { - const context = useContext(DiscoverGridContext); - return ( - { - const row = context.rows[rowIndex]; - const flattened = context.indexPattern.flattenHit(row); - - if (flattened) { - context.onFilter(columnId, flattened[columnId], '+'); - } - }} - iconType="plusInCircle" - aria-label={i18n.translate('discover.grid.filterForAria', { - defaultMessage: 'Filter for {value}', - values: { value: columnId }, - })} - > - {i18n.translate('discover.grid.filterFor', { - defaultMessage: 'Filter for', - })} - - ); -}; - -const FilterOutBtn = ({ Component, rowIndex, columnId }: any) => { - const context = useContext(DiscoverGridContext); - return ( - { - const row = context.rows[rowIndex]; - const flattened = context.indexPattern.flattenHit(row); - - if (flattened) { - context.onFilter(columnId, flattened[columnId], '-'); - } - }} - iconType="minusInCircle" - aria-label={i18n.translate('discover.grid.filterOutAria', { - defaultMessage: 'Filter out {value}', - values: { value: columnId }, - })} - > - {i18n.translate('discover.grid.filterOut', { - defaultMessage: 'Filter out', - })} - - ); -}; - -export function buildCellActions(field: IndexPatternField) { - if (!field.aggregatable) { - return undefined; - } - - return [FilterInBtn, FilterOutBtn]; -} - -export function buildEuiGridColumn( - columnName: string, - columnWidth: number | undefined = 0, - indexPattern: IndexPattern, - timeString: string -) { - const indexPatternField = indexPattern.getFieldByName(columnName); - const column: EuiDataGridColumn = { - id: columnName, - schema: indexPatternField?.type, - isSortable: indexPatternField?.sortable, - display: indexPatternField?.displayName, - actions: { - showHide: { label: 'Remove column' }, - showSortAsc: { label: 'Sort ASC' }, - showSortDesc: { label: 'Sort DESC' }, - }, - cellActions: indexPatternField ? buildCellActions(indexPatternField) : [], - }; - - // Default DataGrid schemas: boolean, numeric, datetime, json, currency - // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts - switch (column.schema) { - case 'date': - column.schema = 'datetime'; - break; - case 'number': - column.schema = 'numeric'; - break; - case '_source': - column.schema = kibanaJSON; - break; - case 'object': - column.schema = 'json'; - break; - case 'geo_point': - column.schema = geoPoint; - break; - default: - column.schema = 'json'; - break; - } - - if (column.id === indexPattern.timeFieldName) { - column.display = `${timeString} (${indexPattern.timeFieldName})`; - column.initialWidth = 180; - } - if (columnWidth > 0) { - column.initialWidth = Number(columnWidth); - } - return column; -} - -// Types [geoPoint], [kibanaJSON], numeric, datetime export function getSchemaDetectors() { return [ { @@ -186,10 +27,10 @@ export function getSchemaDetectors() { detector() { return 0; // this schema is always explicitly defined }, - sortTextAsc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - sortTextDesc: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - icon: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 - color: '', // Eventually this column will be non-sortable: https://github.com/elastic/eui/issues/2623 + sortTextAsc: '', + sortTextDesc: '', + icon: '', + color: '', }, { type: geoPoint, From 62d6a87ea00dc6378440cad4567b69ddec467cc0 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 1 Dec 2020 07:14:21 +0100 Subject: [PATCH 130/186] Add doc table functional tests --- .../discover_grid/discover_grid_flyout.tsx | 6 +- .../apps/discover/_data_grid_doc_table.ts | 132 ++++++++++++++++++ test/functional/apps/discover/index.js | 1 + test/functional/services/data_grid.ts | 11 +- 4 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 test/functional/apps/discover/_data_grid_doc_table.ts diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 9d6f1b648299d..58929340378bc 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -65,7 +65,11 @@ export const DiscoverGridFlyout = function DiscoverGridInner({ - +

    {' '} {i18n.translate('discover.grid.tableRow.detailHeading', { diff --git a/test/functional/apps/discover/_data_grid_doc_table.ts b/test/functional/apps/discover/_data_grid_doc_table.ts new file mode 100644 index 0000000000000..1224823abf048 --- /dev/null +++ b/test/functional/apps/discover/_data_grid_doc_table.ts @@ -0,0 +1,132 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const dataGrid = getService('dataGrid'); + const log = getService('log'); + const retry = getService('retry'); + const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); + const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); + const defaultSettings = { + defaultIndex: 'logstash-*', + 'doc_table:legacy': false, + }; + + describe('discover data grid doc table', function describeIndexTests() { + const defaultRowsLimit = 25; + + before(async function () { + log.debug('load kibana index with default index pattern'); + await esArchiver.load('discover'); + await esArchiver.loadIfNeeded('logstash_functional'); + await kibanaServer.uiSettings.replace(defaultSettings); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); + await PageObjects.common.navigateToApp('discover'); + }); + + it('should show the first 50 rows by default', async function () { + // with the default range the number of hits is ~14000 + const rows = await dataGrid.getDocTableRows(); + expect(rows.length).to.be(defaultRowsLimit); + }); + + it('should refresh the table content when changing time window', async function () { + const initialRows = await dataGrid.getDocTableRows(); + + const fromTime = 'Sep 20, 2015 @ 23:00:00.000'; + const toTime = 'Sep 20, 2015 @ 23:14:00.000'; + + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await PageObjects.discover.waitUntilSearchingHasFinished(); + + const finalRows = await PageObjects.discover.getDocTableRows(); + expect(finalRows.length).to.be.below(initialRows.length); + await PageObjects.timePicker.setDefaultAbsoluteRange(); + }); + + describe('expand a document row', function () { + const rowToInspect = 1; + + it('should expand the detail row when the toggle arrow is clicked', async function () { + await retry.try(async function () { + await dataGrid.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 }); + const detailsEl = await dataGrid.getDetailsRows(); + const defaultMessageEl = await detailsEl[0].findByTestSubject('docTableRowDetailsTitle'); + expect(defaultMessageEl).to.be.ok(); + await dataGrid.closeFlyout(); + }); + }); + + it('should show the detail panel actions', async function () { + await retry.try(async function () { + await dataGrid.clickRowToggle({ isAnchorRow: false, rowIndex: rowToInspect - 1 }); + const [surroundingActionEl, singleActionEl] = await dataGrid.getRowActions({ + isAnchorRow: false, + rowIndex: rowToInspect - 1, + }); + expect(surroundingActionEl).to.be.ok(); + expect(singleActionEl).to.be.ok(); + await dataGrid.closeFlyout(); + }); + }); + }); + + describe('add and remove columns', function () { + const extraColumns = ['phpmemory', 'ip']; + + afterEach(async function () { + for (const column of extraColumns) { + await PageObjects.discover.clickFieldListItemRemove(column); + await PageObjects.header.waitUntilLoadingHasFinished(); + } + }); + + it('should add more columns to the table', async function () { + for (const column of extraColumns) { + await PageObjects.discover.clearFieldSearchInput(); + await PageObjects.discover.findFieldByName(column); + await PageObjects.discover.clickFieldListItemAdd(column); + await PageObjects.header.waitUntilLoadingHasFinished(); + // test the header now + const header = await dataGrid.getHeaderFields(); + expect(header.join(' ')).to.have.string(column); + } + }); + + it('should remove columns from the table', async function () { + for (const column of extraColumns) { + await PageObjects.discover.clearFieldSearchInput(); + await PageObjects.discover.findFieldByName(column); + await PageObjects.discover.clickFieldListItemAdd(column); + await PageObjects.header.waitUntilLoadingHasFinished(); + } + // remove the second column + await PageObjects.discover.clickFieldListItemAdd(extraColumns[1]); + await PageObjects.header.waitUntilLoadingHasFinished(); + // test that the second column is no longer there + const header = await dataGrid.getHeaderFields(); + expect(header.join(' ')).to.not.have.string(extraColumns[1]); + }); + }); + }); +} diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index a37d086301e3f..ad0563ec92c8a 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -53,5 +53,6 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_data_grid_context')); loadTestFile(require.resolve('./_data_grid_field_data')); loadTestFile(require.resolve('./_data_grid_doc_navigation')); + loadTestFile(require.resolve('./_data_grid_doc_table')); }); } diff --git a/test/functional/services/data_grid.ts b/test/functional/services/data_grid.ts index d68cec6a8a440..671989a9a7ee4 100644 --- a/test/functional/services/data_grid.ts +++ b/test/functional/services/data_grid.ts @@ -84,6 +84,11 @@ export function DataGridProvider({ getService, getPageObjects }: FtrProviderCont return await table.findAllByTestSubject('dataGridRow'); } + public async getDocTableRows() { + const table = await this.getTable(); + return await table.findAllByTestSubject('dataGridRow'); + } + public async getAnchorRow(): Promise { const table = await this.getTable(); return await table.findByTestSubject('~docTableAnchorRow'); @@ -104,7 +109,11 @@ export function DataGridProvider({ getService, getPageObjects }: FtrProviderCont } public async getDetailsRows(): Promise { - return [await testSubjects.find('docTableDetailsFlyout')]; + return await testSubjects.findAll('docTableDetailsFlyout'); + } + + public async closeFlyout() { + await testSubjects.click('euiFlyoutCloseButton'); } public async getHeaderFields(): Promise { From bde5f9689741be8d2900b504238770eb60418752 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 1 Dec 2020 07:18:47 +0100 Subject: [PATCH 131/186] Fix functional --- test/functional/apps/discover/_data_grid_field_data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_data_grid_field_data.ts b/test/functional/apps/discover/_data_grid_field_data.ts index 137c19149d274..c9c83883e0f6f 100644 --- a/test/functional/apps/discover/_data_grid_field_data.ts +++ b/test/functional/apps/discover/_data_grid_field_data.ts @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('the search term should be highlighted in the field data', async function () { // marks is the style that highlights the text in yellow const marks = await PageObjects.discover.getMarks(); - expect(marks.length).to.be(50); + expect(marks.length).to.be.above(25); expect(marks.indexOf('php')).to.be(0); }); From 32ac7cd8989ebfff572c466383110d61c3a6bc5f Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 1 Dec 2020 09:04:26 +0100 Subject: [PATCH 132/186] Fix functional --- test/functional/apps/discover/_data_grid_field_data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_data_grid_field_data.ts b/test/functional/apps/discover/_data_grid_field_data.ts index c9c83883e0f6f..8224f59f7fabf 100644 --- a/test/functional/apps/discover/_data_grid_field_data.ts +++ b/test/functional/apps/discover/_data_grid_field_data.ts @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('the search term should be highlighted in the field data', async function () { // marks is the style that highlights the text in yellow const marks = await PageObjects.discover.getMarks(); - expect(marks.length).to.be.above(25); + expect(marks.length).to.be(25); expect(marks.indexOf('php')).to.be(0); }); From 072bf4dad790de0767c20e283e119161f11f6d63 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 1 Dec 2020 10:29:42 +0100 Subject: [PATCH 133/186] Add jest tests --- .../public/__mocks__/index_pattern.ts | 11 +- .../get_render_cell_value.test.tsx | 112 ++++++++++++++++++ .../discover_grid/get_render_cell_value.tsx | 9 +- 3 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx diff --git a/src/plugins/discover/public/__mocks__/index_pattern.ts b/src/plugins/discover/public/__mocks__/index_pattern.ts index 696079ec72a73..a678081f2899a 100644 --- a/src/plugins/discover/public/__mocks__/index_pattern.ts +++ b/src/plugins/discover/public/__mocks__/index_pattern.ts @@ -19,8 +19,13 @@ import { IndexPattern, indexPatterns } from '../kibana_services'; import { IIndexPatternFieldList } from '../../../data/common/index_patterns/fields'; - const fields = [ + { + name: '_source', + type: '_source', + scripted: false, + filterable: false, + }, { name: '_index', type: 'string', @@ -61,6 +66,7 @@ const indexPattern = ({ id: 'the-index-pattern-id', title: 'the-index-pattern-title', metaFields: ['_index', '_score'], + formatField: jest.fn(), flattenHit: undefined, formatHit: jest.fn((hit) => hit._source), fields, @@ -70,5 +76,8 @@ const indexPattern = ({ } as unknown) as IndexPattern; indexPattern.flattenHit = indexPatterns.flattenHitWrapper(indexPattern, indexPattern.metaFields); +indexPattern.formatField = (hit: Record, fieldName: string) => { + return fieldName === '_source' ? hit._source : indexPattern.flattenHit(hit)[fieldName]; +}; export const indexPatternMock = indexPattern; diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx new file mode 100644 index 0000000000000..792506551a213 --- /dev/null +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx @@ -0,0 +1,112 @@ +/* + * 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 React from 'react'; +import { shallow } from 'enzyme'; +import { getRenderCellValueFn } from './get_render_cell_value'; +import { indexPatternMock } from '../../../__mocks__/index_pattern'; +const rows = [ + { + _id: '1', + _index: 'test', + _type: 'test', + _score: 1, + _source: { bytes: 100 }, + }, +]; + +describe('Discover grid cell rendering', function () { + it('renders bytes column correctly', () => { + const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const component = shallow( + + ); + expect(component.html()).toMatchInlineSnapshot(`"100"`); + }); + it('renders _source column correctly', () => { + const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const component = shallow( + + ); + expect(component.html()).toMatchInlineSnapshot( + `"
    bytes
    100
    "` + ); + }); + + it('renders _source column correctly when isDetails is set to true', () => { + const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const component = shallow( + + ); + expect(component.html()).toMatchInlineSnapshot(` + "{ + "bytes": 100 + }" + `); + }); + + it('renders correctly when invalid row is given', () => { + const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const component = shallow( + + ); + expect(component.html()).toMatchInlineSnapshot(`"-"`); + }); + it('renders correctly when invalid column is given', () => { + const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const component = shallow( + + ); + expect(component.html()).toMatchInlineSnapshot(`"-"`); + }); +}); diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx index 6f96e2f77ed38..619b690ed8730 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx @@ -26,11 +26,11 @@ export const getRenderCellValueFn = ( rows: ElasticSearchHit[] | undefined ) => ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { const row = rows ? (rows[rowIndex] as Record) : undefined; + const field = indexPattern.fields.getByName(columnId); - if (typeof row === 'undefined') { - return '-'; + if (typeof row === 'undefined' || !field) { + return -; } - const field = indexPattern.fields.getByName(columnId); const formatSource = () => { const formatted = indexPattern.formatHit(row); @@ -59,7 +59,8 @@ export const getRenderCellValueFn = ( ); if (isDetails && field && field.type === '_source') { - return JSON.stringify(row[columnId], null, 2); + // nicely formatted JSON for the expanded view + return {JSON.stringify(row[columnId], null, 2)}; } return value; }; From 02ee34ac2fd7fd6fe741905cb7100d12ada376c5 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 1 Dec 2020 10:43:45 +0100 Subject: [PATCH 134/186] Fix functional tests --- test/functional/services/data_grid.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/services/data_grid.ts b/test/functional/services/data_grid.ts index 671989a9a7ee4..2323c01ef91e4 100644 --- a/test/functional/services/data_grid.ts +++ b/test/functional/services/data_grid.ts @@ -138,12 +138,12 @@ export function DataGridProvider({ getService, getPageObjects }: FtrProviderCont public async clickDocSortAsc() { await find.clickByCssSelector('.euiDataGridHeaderCell__button'); - await find.clickByButtonText('Sort ASC'); + await find.clickByButtonText('Sort New-Old'); } public async clickDocSortDesc() { await find.clickByCssSelector('.euiDataGridHeaderCell__button'); - await find.clickByButtonText('Sort Desc'); + await find.clickByButtonText('Sort Old-New'); } public async getDetailsRow(): Promise { const detailRows = await this.getDetailsRows(); From 60ec2e90e9c89db0e7f719f6150ead6050d899ed Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 7 Dec 2020 12:38:29 +0100 Subject: [PATCH 135/186] Fix tests --- .../application/components/discover.scss | 18 ------ .../application/components/discover.tsx | 2 - .../discover_grid/discover_grid.scss | 55 +++++++------------ .../discover_grid/discover_grid.tsx | 2 +- .../components/discover_legacy.tsx | 2 +- .../components/sidebar/discover_field.tsx | 1 - 6 files changed, 21 insertions(+), 59 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index f807baba66151..6ecf3eea5b91d 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -83,24 +83,6 @@ discover-app { padding: $euiSizeS $euiSizeS 0 $euiSizeS; } -.dscApp .dscFormatSource { - word-break: break-word; -} - -.dscFormatSource__title { - background-color: transparentize(shade($euiColorPrimary, 20%), 0.9); - border-radius: $euiBorderRadius / 2; - color: $euiTextColor; - padding: ($euiSizeXS / 2) $euiSizeXS; - margin-right: $euiSizeXS; - word-break: normal; - display: inline; -} - -.dscFormatSource__description { - display: inline; -} - .dscTable { // SASSTODO: add a monospace modifier to the doc-table component .kbnDocTable__row { diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 6cff6a355d8fa..4cf1e392faaf6 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -21,8 +21,6 @@ import React, { useState, useRef } from 'react'; import { EuiButtonEmpty, EuiButtonIcon, - EuiDataGrid, - EuiDataGridProps, EuiFlexGroup, EuiFlexItem, EuiHideFor, diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index 014cd338afcb5..1eb279dde3016 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -4,7 +4,7 @@ height: 100%; overflow: hidden; } -.dscTable__footer { +.dscDiscoverGrid__footer { background-color: $euiColorLightShade; padding: $euiSize / 2 $euiSize; margin-top: $euiSize / 4; @@ -15,41 +15,6 @@ white-space: nowrap; } -.dscEuiDataGridRowCell .euiDataGridRowCell { - align-items: start; -} - -.dscEuiDataGridRowCellFilter { - display: none; - text-align: right; -} - -.dscEuiDataGridRowCellBtn { - text-align: right; - padding: 0 2px; - min-height: auto; - min-width: auto; - transition: none; - -webkit-transition: none; - -o-transition: none; -} - -.dscValue { - position: relative; -} - -.dscValue .dscValueFilter { - background: $euiColorLightShade; -} - -.euiDataGridRowCell:hover .dscEuiDataGridRowCellFilter { - display: flex; -} - -.euiDataGrid__verticalScroll { - will-change: transform; -} - // We only truncate if the cell is not a control column. .euiDataGridHeader { .euiDataGridHeaderCell__content { @@ -80,3 +45,21 @@ height: 100%; width: 100%; } + +.dscApp .dscFormatSource { + word-break: break-word; +} + +.dscFormatSource__title { + background-color: transparentize(shade($euiColorPrimary, 20%), 0.9); + border-radius: $euiBorderRadius / 2; + color: $euiTextColor; + padding: ($euiSizeXS / 2) $euiSizeXS; + margin-right: $euiSizeXS; + word-break: normal; + display: inline; +} + +.dscFormatSource__description { + display: inline; +} diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index a1edb8922aa16..52000d3eb8a11 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -222,7 +222,7 @@ export const DiscoverGrid = ({ /> {showDisclaimer && ( -

    +

    {opts.chartAggConfigs && rows.length !== 0 && ( -

    +
    Date: Mon, 7 Dec 2020 15:45:29 +0100 Subject: [PATCH 136/186] Cleanup --- .../angular/discover_datagrid.html | 23 ++++--------------- .../application/angular/discover_legacy.html | 3 +-- .../components/create_discover_directive.ts | 10 +------- .../create_discover_legacy_directive.ts | 2 +- .../application/components/discover.tsx | 8 +++---- .../components/discover_legacy.tsx | 11 +++++---- test/accessibility/apps/discover.ts | 1 - .../apps/context/_discover_navigation.js | 3 +-- .../apps/dashboard/dashboard_state.js | 4 ---- .../apps/dashboard/dashboard_time_picker.js | 6 +---- .../apps/discover/_data_grid_context.ts | 1 - test/functional/apps/discover/_date_nanos.js | 5 +--- .../apps/discover/_date_nanos_mixed.js | 5 +--- test/functional/apps/discover/_discover.js | 1 - .../apps/discover/_doc_navigation.js | 2 -- test/functional/apps/discover/_field_data.js | 1 - .../functional/apps/discover/_large_string.js | 5 +--- test/functional/page_objects/settings_page.ts | 3 --- .../discover_enhanced/public/plugin.ts | 2 +- .../apps/security/doc_level_security_roles.js | 1 - .../apps/security/field_level_security.js | 1 - .../apps/security/secure_roles_perm.js | 5 +--- 22 files changed, 24 insertions(+), 79 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover_datagrid.html b/src/plugins/discover/public/application/angular/discover_datagrid.html index 5569dc01dab1a..e59ebbb0fafd0 100644 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ b/src/plugins/discover/public/application/angular/discover_datagrid.html @@ -1,18 +1,12 @@ diff --git a/src/plugins/discover/public/application/angular/discover_legacy.html b/src/plugins/discover/public/application/angular/discover_legacy.html index 7cdcd6cbbca3a..3596c0a2519ed 100644 --- a/src/plugins/discover/public/application/angular/discover_legacy.html +++ b/src/plugins/discover/public/application/angular/discover_legacy.html @@ -1,6 +1,5 @@ ( )); export function Discover({ - addColumn, fetch, fetchCounter, - fieldCounts, fetchError, + fieldCounts, histogramData, hits, indexPattern, + onAddColumn, onAddFilter, onChangeInterval, onRemoveColumn, @@ -128,7 +128,7 @@ export function Discover({ fieldCounts={fieldCounts} hits={rows} indexPatternList={indexPatternList} - onAddField={addColumn} + onAddField={onAddColumn} onAddFilter={onAddFilter} onRemoveField={onRemoveColumn} selectedIndexPattern={searchSource && searchSource.getField('index')} @@ -273,7 +273,7 @@ export function Discover({ showTimeCol={Boolean(showTimeCol)} services={services} settings={state.grid} - onAddColumn={addColumn} + onAddColumn={onAddColumn} onFilter={onAddFilter} onRemoveColumn={onRemoveColumn} onSetColumns={onSetColumns} diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index f18e1fe9d2a95..596ade4380c0d 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -17,6 +17,7 @@ * under the License. */ import './discover.scss'; + import React, { useState, useRef } from 'react'; import { EuiButtonEmpty, @@ -62,7 +63,6 @@ import { import { DocViewFilterFn, ElasticSearchHit } from '../doc_views/doc_views_types'; export interface DiscoverProps { - addColumn: (column: string) => void; fetch: () => void; fetchCounter: number; fetchError: Error; @@ -71,6 +71,7 @@ export interface DiscoverProps { hits: number; indexPattern: IndexPattern; minimumVisibleRows: number; + onAddColumn: (column: string) => void; onAddFilter: DocViewFilterFn; onChangeInterval: (interval: string) => void; onMoveColumn: (columns: string, newIdx: number) => void; @@ -113,7 +114,6 @@ export const SidebarMemoized = React.memo((props: DiscoverSidebarResponsiveProps )); export function DiscoverLegacy({ - addColumn, fetch, fetchCounter, fieldCounts, @@ -122,6 +122,7 @@ export function DiscoverLegacy({ hits, indexPattern, minimumVisibleRows, + onAddColumn, onAddFilter, onChangeInterval, onMoveColumn, @@ -191,7 +192,7 @@ export function DiscoverLegacy({ fieldCounts={fieldCounts} hits={rows} indexPatternList={indexPatternList} - onAddField={addColumn} + onAddField={onAddColumn} onAddFilter={onAddFilter} onRemoveField={onRemoveColumn} selectedIndexPattern={searchSource && searchSource.getField('index')} @@ -299,7 +300,7 @@ export function DiscoverLegacy({ className="dscTimechart" > {opts.chartAggConfigs && rows.length !== 0 && ( -
    +
    { before(async () => { - await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/dashboard/dashboard_state.js b/test/functional/apps/dashboard/dashboard_state.js index 2222d7c71dee3..3656c824394f4 100644 --- a/test/functional/apps/dashboard/dashboard_state.js +++ b/test/functional/apps/dashboard/dashboard_state.js @@ -32,8 +32,6 @@ export default function ({ getService, getPageObjects }) { 'tileMap', 'visChart', 'timePicker', - 'settings', - 'common', ]); const testSubjects = getService('testSubjects'); const browser = getService('browser'); @@ -48,8 +46,6 @@ export default function ({ getService, getPageObjects }) { before(async function () { await PageObjects.dashboard.initTests(); await PageObjects.dashboard.preserveCrossAppState(); - await PageObjects.settings.setLegacyDiscoverTable(); - await PageObjects.common.navigateToApp('dashboard'); }); after(async function () { diff --git a/test/functional/apps/dashboard/dashboard_time_picker.js b/test/functional/apps/dashboard/dashboard_time_picker.js index 3684b647d0332..975fb5166a8e6 100644 --- a/test/functional/apps/dashboard/dashboard_time_picker.js +++ b/test/functional/apps/dashboard/dashboard_time_picker.js @@ -22,7 +22,6 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const dashboardExpect = getService('dashboardExpect'); - const testSubjects = getService('testSubjects'); const pieChart = getService('pieChart'); const dashboardVisualizations = getService('dashboardVisualizations'); const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'timePicker']); @@ -57,16 +56,13 @@ export default function ({ getService, getPageObjects }) { name: 'saved search', fields: ['bytes', 'agent'], }); - - const tableFields = await testSubjects.findAll('docTableField', 2500); - expect(tableFields.length).to.greaterThan(0); + await dashboardExpect.docTableFieldCount(150); // Set to time range with no data await PageObjects.timePicker.setAbsoluteRange( 'Jan 1, 2000 @ 00:00:00.000', 'Jan 1, 2000 @ 01:00:00.000' ); - await dashboardExpect.docTableFieldCount(0); }); diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts index b3854ea54e315..19de2ac4715b9 100644 --- a/test/functional/apps/discover/_data_grid_context.ts +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -38,7 +38,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('discover data grid context tests', () => { before(async () => { await esArchiver.loadIfNeeded('logstash_functional'); - await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update(defaultSettings); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_date_nanos.js b/test/functional/apps/discover/_date_nanos.js index b44859137ee37..1b5c033d67a43 100644 --- a/test/functional/apps/discover/_date_nanos.js +++ b/test/functional/apps/discover/_date_nanos.js @@ -30,10 +30,7 @@ export default function ({ getService, getPageObjects }) { describe('date_nanos', function () { before(async function () { await esArchiver.loadIfNeeded('date_nanos'); - await kibanaServer.uiSettings.replace({ - defaultIndex: 'date-nanos', - 'doc_table:legacy': true, - }); + await kibanaServer.uiSettings.replace({ defaultIndex: 'date-nanos' }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos']); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); diff --git a/test/functional/apps/discover/_date_nanos_mixed.js b/test/functional/apps/discover/_date_nanos_mixed.js index 415df99244aef..63509d85afd3a 100644 --- a/test/functional/apps/discover/_date_nanos_mixed.js +++ b/test/functional/apps/discover/_date_nanos_mixed.js @@ -30,10 +30,7 @@ export default function ({ getService, getPageObjects }) { describe('date_nanos_mixed', function () { before(async function () { await esArchiver.loadIfNeeded('date_nanos_mixed'); - await kibanaServer.uiSettings.replace({ - defaultIndex: 'timestamp-*', - 'doc_table:legacy': true, - }); + await kibanaServer.uiSettings.replace({ defaultIndex: 'timestamp-*' }); await security.testUser.setRoles(['kibana_admin', 'kibana_date_nanos_mixed']); await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index d4c9a8abce98d..78197cd8d66ff 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -30,7 +30,6 @@ export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']); const defaultSettings = { defaultIndex: 'logstash-*', - 'doc_table:legacy': true, }; describe('discover test', function describeIndexTests() { diff --git a/test/functional/apps/discover/_doc_navigation.js b/test/functional/apps/discover/_doc_navigation.js index cb7814a2ccb28..59c4371b95d80 100644 --- a/test/functional/apps/discover/_doc_navigation.js +++ b/test/functional/apps/discover/_doc_navigation.js @@ -26,12 +26,10 @@ export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'context']); const esArchiver = getService('esArchiver'); const retry = getService('retry'); - const kibanaServer = getService('kibanaServer'); describe('doc link in discover', function contextSize() { beforeEach(async function () { await esArchiver.loadIfNeeded('logstash_functional'); - await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); await esArchiver.loadIfNeeded('discover'); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_field_data.js b/test/functional/apps/discover/_field_data.js index 17ac4d53d46c6..d45b8f4841cb6 100644 --- a/test/functional/apps/discover/_field_data.js +++ b/test/functional/apps/discover/_field_data.js @@ -34,7 +34,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.load('discover'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', - 'doc_table:legacy': true, }); await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/apps/discover/_large_string.js b/test/functional/apps/discover/_large_string.js index dfcfa40df9f0f..6142f042c1148 100644 --- a/test/functional/apps/discover/_large_string.js +++ b/test/functional/apps/discover/_large_string.js @@ -33,10 +33,7 @@ export default function ({ getService, getPageObjects }) { await security.testUser.setRoles(['kibana_admin', 'kibana_large_strings']); await esArchiver.load('empty_kibana'); await esArchiver.loadIfNeeded('hamlet'); - await kibanaServer.uiSettings.replace({ - defaultIndex: 'testlargestring', - 'doc_table:legacy': true, - }); + await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring' }); }); it('verify the large string book present', async function () { diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index f8d6656cb7665..e29f75b806574 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -366,9 +366,6 @@ export function SettingsPageProvider({ getService, getPageObjects }: FtrProvider return await this.getIndexPatternIdFromUrl(); } - async setLegacyDiscoverTable(value = true) { - // currently unused - } async clickAddNewIndexPatternButton() { await PageObjects.common.scrollKibanaBodyTop(); await testSubjects.click('createIndexPatternButton'); diff --git a/x-pack/plugins/discover_enhanced/public/plugin.ts b/x-pack/plugins/discover_enhanced/public/plugin.ts index beff9944a975f..f1273ab00bdd4 100644 --- a/x-pack/plugins/discover_enhanced/public/plugin.ts +++ b/x-pack/plugins/discover_enhanced/public/plugin.ts @@ -64,7 +64,7 @@ export class DiscoverEnhancedPlugin setup( core: CoreSetup, - { uiActions, share, discover }: DiscoverEnhancedSetupDependencies + { uiActions, share }: DiscoverEnhancedSetupDependencies ) { const start = createStartServicesGetter(core.getStartServices); const isSharePluginInstalled = !!share; diff --git a/x-pack/test/functional/apps/security/doc_level_security_roles.js b/x-pack/test/functional/apps/security/doc_level_security_roles.js index c6dadd7a1b6e7..72f463be48fd5 100644 --- a/x-pack/test/functional/apps/security/doc_level_security_roles.js +++ b/x-pack/test/functional/apps/security/doc_level_security_roles.js @@ -20,7 +20,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.load('empty_kibana'); await esArchiver.loadIfNeeded('security/dlstest'); await browser.setWindowSize(1600, 1000); - await PageObjects.settings.setLegacyDiscoverTable(); await PageObjects.common.navigateToApp('settings'); await PageObjects.settings.createIndexPattern('dlstest', null); diff --git a/x-pack/test/functional/apps/security/field_level_security.js b/x-pack/test/functional/apps/security/field_level_security.js index 1ef7f053e760d..7b22d72885c9d 100644 --- a/x-pack/test/functional/apps/security/field_level_security.js +++ b/x-pack/test/functional/apps/security/field_level_security.js @@ -19,7 +19,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('security/flstest/data'); //( data) await esArchiver.load('security/flstest/kibana'); //(savedobject) await browser.setWindowSize(1600, 1000); - await PageObjects.settings.setLegacyDiscoverTable(); }); it('should add new role a_viewssnrole', async function () { diff --git a/x-pack/test/functional/apps/security/secure_roles_perm.js b/x-pack/test/functional/apps/security/secure_roles_perm.js index b0aa708abae13..c547657bf880a 100644 --- a/x-pack/test/functional/apps/security/secure_roles_perm.js +++ b/x-pack/test/functional/apps/security/secure_roles_perm.js @@ -29,10 +29,7 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('logstash_functional'); log.debug('load kibana index with default index pattern'); await esArchiver.load('security/discover'); - await kibanaServer.uiSettings.replace({ - defaultIndex: 'logstash-*', - 'doc_table:legacy': true, - }); + await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' }); await PageObjects.settings.navigateTo(); }); From 59a71021b9a36107a24595a6ad8399c03cd238b2 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 7 Dec 2020 15:59:31 +0100 Subject: [PATCH 137/186] More cleanups --- .../public/application/components/sidebar/lib/group_fields.tsx | 3 +-- test/functional/apps/management/_scripted_fields.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx b/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx index 5d8121e0a056c..cb4485d90531c 100644 --- a/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx +++ b/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx @@ -70,8 +70,7 @@ export function groupFields( result.unpopular.push(field); } } - // allows removal of columns, that were part of the former index pattern, that have no matching - // field in the current index pattern, temporary solution + // filter out columns, that were part of the former index pattern, but not of the current for (const column of columns) { if (!result.selected.find((field) => field.name === column)) { result.selected.push({ name: column, displayName: column } as IndexPatternField); diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 68969b3bbd7bf..a2cc976f23127 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -61,7 +61,7 @@ export default function ({ getService, getPageObjects }) { await browser.setWindowSize(1200, 800); await esArchiver.load('discover'); // delete .kibana index and then wait for Kibana to re-create it - await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); + await kibanaServer.uiSettings.replace({}); await kibanaServer.uiSettings.update({}); }); From 1a3f19aa3308203456f8894d9652a976bc211aa7 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 7 Dec 2020 22:51:07 +0100 Subject: [PATCH 138/186] Small fixes --- .../discover/public/application/angular/discover.js | 1 - .../components/discover_grid/discover_grid.tsx | 8 ++++---- .../public/application/helpers/persist_saved_search.ts | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 0ff5929fcff1c..9e98ffb390f4f 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -340,7 +340,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab $scope.minimumVisibleRows = 50; $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; - $scope.useNewGrid = config.get('doc_table:legacy', false); $scope.showTimeCol = !config.get('doc_table:hideTimeColumn', false) && $scope.indexPattern.timeFieldName; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 52000d3eb8a11..31de7181a0697 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -72,9 +72,9 @@ export interface DiscoverGridProps { sort: SortPairArr[]; } -export const EuiDataGridMemoized = React.memo((props: EuiDataGridProps) => ( - -)); +export const EuiDataGridMemoized = React.memo((props: EuiDataGridProps) => { + return ; +}); export const DiscoverGrid = ({ ariaLabelledBy, @@ -152,7 +152,7 @@ export const DiscoverGrid = ({ * Render variables */ const showDisclaimer = rowsLength === sampleSize && isOnLastPage; - const randomId = useMemo(() => String(htmlIdGenerator()), []); + const randomId = useMemo(() => htmlIdGenerator()(), []); const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( diff --git a/src/plugins/discover/public/application/helpers/persist_saved_search.ts b/src/plugins/discover/public/application/helpers/persist_saved_search.ts index 8e956eff598f3..8ec2012b5843e 100644 --- a/src/plugins/discover/public/application/helpers/persist_saved_search.ts +++ b/src/plugins/discover/public/application/helpers/persist_saved_search.ts @@ -53,6 +53,9 @@ export async function persistSavedSearch( savedSearch.columns = state.columns || []; savedSearch.sort = (state.sort as SortOrder[]) || []; + if (state.grid) { + savedSearch.grid = state.grid; + } try { const id = await savedSearch.save(saveOptions); From c0b3a245c4dbb42d352c2e855d533d728858070d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 8 Dec 2020 22:39:55 +0100 Subject: [PATCH 139/186] Fix embeddable --- .../components/create_discover_grid_directive.tsx | 6 +++++- .../public/application/embeddable/search_embeddable.ts | 8 +++++++- .../application/embeddable/search_template_datagrid.html | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx index 67f0f268f3346..4e2a2506e282d 100644 --- a/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx +++ b/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx @@ -21,10 +21,14 @@ import { I18nProvider } from '@kbn/i18n/react'; import { DiscoverGrid, DiscoverGridProps } from './discover_grid/discover_grid'; import { getServices } from '../../kibana_services'; +export const DataGridMemoized = React.memo((props: DiscoverGridProps) => ( + +)); + export function DiscoverGridEmbeddable(props: DiscoverGridProps) { return ( - + ); } diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index d226be1d13269..27147fb69784b 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -51,6 +51,7 @@ import { SavedSearch } from '../..'; import { SAMPLE_SIZE_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../common'; import { DiscoverGridSettings } from '../components/discover_grid/types'; import { DiscoverServices } from '../../build_services'; +import { ElasticSearchHit } from '../doc_views/doc_views_types'; interface SearchScope extends ng.IScope { columns?: string[]; @@ -60,11 +61,12 @@ interface SearchScope extends ng.IScope { sharedItemTitle?: string; inspectorAdapters?: Adapters; setSortOrder?: (sortPair: SortOrder[]) => void; + setColumns?: (columns: string[]) => void; removeColumn?: (column: string) => void; addColumn?: (column: string) => void; moveColumn?: (column: string, index: number) => void; filter?: (field: IFieldType, value: string[], operator: string) => void; - hits?: any[]; + hits?: ElasticSearchHit[]; indexPattern?: IndexPattern; totalHitCount?: number; isLoading?: boolean; @@ -250,6 +252,10 @@ export class SearchEmbeddable this.updateInput({ columns }); }; + searchScope.setColumns = (columns: string[]) => { + this.updateInput({ columns }); + }; + if (this.savedSearch.grid) { searchScope.settings = this.savedSearch.grid; } diff --git a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html index f7e98ea99502a..6524783897f8f 100644 --- a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html +++ b/src/plugins/discover/public/application/embeddable/search_template_datagrid.html @@ -1,4 +1,5 @@ Date: Wed, 9 Dec 2020 13:39:39 +0100 Subject: [PATCH 140/186] Address review comments --- src/plugins/discover/common/index.ts | 2 +- .../discover_grid/discover_grid_columns.tsx | 7 +------ .../discover_grid/discover_grid_flyout.tsx | 6 +----- .../discover_grid/discover_grid_schema.tsx | 12 ++++++------ src/plugins/discover/server/ui_settings.ts | 4 ++-- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/plugins/discover/common/index.ts b/src/plugins/discover/common/index.ts index 680844e762540..321a102e8d782 100644 --- a/src/plugins/discover/common/index.ts +++ b/src/plugins/discover/common/index.ts @@ -27,5 +27,5 @@ export const FIELDS_LIMIT_SETTING = 'fields:popularLimit'; export const CONTEXT_DEFAULT_SIZE_SETTING = 'context:defaultSize'; export const CONTEXT_STEP_SETTING = 'context:step'; export const CONTEXT_TIE_BREAKER_FIELDS_SETTING = 'context:tieBreakerFields'; -export const DOC_TABLE_LEGACY_TABLE = 'doc_table:legacy'; +export const DOC_TABLE_LEGACY = 'doc_table:legacy'; export const MODIFY_COLUMNS_ON_SWITCH = 'discover:modifyColumnsOnSwitch'; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index 16763a50b6e5a..609478bf226ed 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -86,12 +86,7 @@ export function getEuiGridColumns( showTimeCol: boolean ) { const timeFieldName = indexPattern.timeFieldName; - const getColWidth = (column: string) => { - if (settings?.columns && settings.columns[column]) { - return settings.columns[column].width || 0; - } - return 0; - }; + const getColWidth = (column: string) => settings?.columns?.[column]?.width ?? 0; if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { const usedColumns = [indexPattern.timeFieldName, ...columns]; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index c9b234d60e511..112185d273cb1 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -57,13 +57,9 @@ export function DiscoverGridFlyout({ onAddColumn, services, }: Props) { - if (!hit) { - return null; - } - return ( - onClose()} size="m" data-test-subj="docTableDetailsFlyout"> + diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx index 27ac8405c8932..00ee6f7c8ed95 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx @@ -19,20 +19,20 @@ import React, { ReactNode } from 'react'; import { EuiCodeBlock } from '@elastic/eui'; import { geoPoint, kibanaJSON } from './constants'; +import { KBN_FIELD_TYPES } from '../../../../../data/common'; export function getSchemaByKbnType(kbnType: string | undefined) { // Default DataGrid schemas: boolean, numeric, datetime, json, currency - // Default indexPattern types: KBN_FIELD_TYPES in src/plugins/data/common/kbn_field_types/types.ts switch (kbnType) { - case 'date': + case KBN_FIELD_TYPES.DATE: return 'datetime'; - case 'number': + case KBN_FIELD_TYPES.NUMBER: return 'numeric'; - case '_source': + case KBN_FIELD_TYPES._SOURCE: return kibanaJSON; - case 'object': + case KBN_FIELD_TYPES.OBJECT: return 'json'; - case 'geo_point': + case KBN_FIELD_TYPES.GEO_POINT: return geoPoint; default: return 'json'; diff --git a/src/plugins/discover/server/ui_settings.ts b/src/plugins/discover/server/ui_settings.ts index 9556c4968fab8..df1bb40f023cf 100644 --- a/src/plugins/discover/server/ui_settings.ts +++ b/src/plugins/discover/server/ui_settings.ts @@ -33,7 +33,7 @@ import { CONTEXT_DEFAULT_SIZE_SETTING, CONTEXT_STEP_SETTING, CONTEXT_TIE_BREAKER_FIELDS_SETTING, - DOC_TABLE_LEGACY_TABLE, + DOC_TABLE_LEGACY, MODIFY_COLUMNS_ON_SWITCH, } from '../common'; @@ -166,7 +166,7 @@ export const uiSettings: Record = { category: ['discover'], schema: schema.arrayOf(schema.string()), }, - [DOC_TABLE_LEGACY_TABLE]: { + [DOC_TABLE_LEGACY]: { name: i18n.translate('discover.advancedSettings.docTableVersionName', { defaultMessage: 'Use legacy table', }), From 4ab2702c2709450afaa54b63bd09a6fcb14a0881 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 9 Dec 2020 23:10:32 +0100 Subject: [PATCH 141/186] Address review comments --- .../public/application/angular/discover.js | 7 +++- .../application/components/discover.tsx | 6 ++-- .../discover_grid/discover_grid.tsx | 33 ++++++++++++------- .../discover_grid/discover_grid_columns.tsx | 27 +++++++++------ 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 9e98ffb390f4f..635ec56604a84 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -414,7 +414,7 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab function getStateDefaults() { const query = $scope.searchSource.getField('query') || data.query.queryString.getDefaultQuery(); - return { + const defaultState = { query, sort: getSortArray(savedSearch.sort, $scope.indexPattern), columns: @@ -425,6 +425,11 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab interval: 'auto', filters: _.cloneDeep($scope.searchSource.getOwnField('filter')), }; + if (savedSearch.grid) { + defaultState.grid = savedSearch.grid; + } + + return defaultState; } $scope.state.index = $scope.indexPattern.id; diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 45a98ed091650..b39f76ae62d68 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -84,7 +84,6 @@ export function Discover({ }: DiscoverProps) { const scrollableDesktop = useRef(null); const collapseIcon = useRef(null); - const [toggleOn, toggleChart] = useState(true); const [isSidebarClosed, setIsSidebarClosed] = useState(false); const services = getServices(); @@ -98,7 +97,7 @@ export function Discover({ : undefined; const contentCentered = resultState === 'uninitialized'; const showTimeCol = !config.get('doc_table:hideTimeColumn', false) && indexPattern.timeFieldName; - + const columns = state.columns && state.columns.length > 0 ? state.columns : ['_source']; return ( @@ -263,7 +262,8 @@ export function Discover({
    void; onFilter: DocViewFilterFn; @@ -79,6 +80,7 @@ export const EuiDataGridMemoized = React.memo((props: EuiDataGridProps) => { export const DiscoverGrid = ({ ariaLabelledBy, columns, + defaultColumns, indexPattern, onAddColumn, onFilter, @@ -156,8 +158,8 @@ export const DiscoverGrid = ({ const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( - () => getEuiGridColumns(columns, settings, indexPattern, showTimeCol), - [columns, indexPattern, showTimeCol, settings] + () => getEuiGridColumns(columns, settings, indexPattern, showTimeCol, defaultColumns), + [columns, indexPattern, showTimeCol, settings, defaultColumns] ); const schemaDetectors = useMemo(() => getSchemaDetectors(), []); const popoverContents = useMemo(() => getPopoverContents(), []); @@ -200,25 +202,32 @@ export const DiscoverGrid = ({ > <> { if (onResize) { onResize(col); } }} + pagination={paginationObj} + popoverContents={popoverContents} + renderCellValue={renderCellValue} + rowCount={rowCount} + schemaDetectors={schemaDetectors} + sorting={sorting as EuiDataGridSorting} + toolbarVisibility={ + defaultColumns + ? { + ...toolbarVisibility, + showColumnSelector: false, + } + : toolbarVisibility + } /> {showDisclaimer && ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index 609478bf226ed..3e7afc6633ecc 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -40,7 +40,6 @@ export function getLeadControlColumns() { ), rowCellRender: ViewButton, - cellActions: [], }, ]; } @@ -48,7 +47,8 @@ export function getLeadControlColumns() { export function buildEuiGridColumn( columnName: string, columnWidth: number | undefined = 0, - indexPattern: IndexPattern + indexPattern: IndexPattern, + defaultColumns: boolean ) { const timeString = i18n.translate('discover.timeLabel', { defaultMessage: 'Time', @@ -60,11 +60,15 @@ export function buildEuiGridColumn( isSortable: indexPatternField?.sortable, display: indexPatternField?.displayName, actions: { - showHide: { - label: i18n.translate('discover.removeColumnLabel', { - defaultMessage: 'Remove column', - }), - }, + showHide: defaultColumns + ? false + : { + label: i18n.translate('discover.removeColumnLabel', { + defaultMessage: 'Remove column', + }), + }, + showMoveLeft: !defaultColumns, + showMoveRight: !defaultColumns, }, cellActions: indexPatternField ? buildCellActions(indexPatternField) : [], }; @@ -83,7 +87,8 @@ export function getEuiGridColumns( columns: string[], settings: DiscoverGridSettings | undefined, indexPattern: IndexPattern, - showTimeCol: boolean + showTimeCol: boolean, + defaultColumns: boolean ) { const timeFieldName = indexPattern.timeFieldName; const getColWidth = (column: string) => settings?.columns?.[column]?.width ?? 0; @@ -91,11 +96,13 @@ export function getEuiGridColumns( if (showTimeCol && indexPattern.timeFieldName && !columns.find((col) => col === timeFieldName)) { const usedColumns = [indexPattern.timeFieldName, ...columns]; return usedColumns.map((column) => - buildEuiGridColumn(column, getColWidth(column), indexPattern) + buildEuiGridColumn(column, getColWidth(column), indexPattern, defaultColumns) ); } - return columns.map((column) => buildEuiGridColumn(column, getColWidth(column), indexPattern)); + return columns.map((column) => + buildEuiGridColumn(column, getColWidth(column), indexPattern, defaultColumns) + ); } export function getVisibleColumns( From 731e63cc78b5220c9b8cd7e40345c01926247c99 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 08:53:41 +0100 Subject: [PATCH 142/186] Change handling of default sort, allow unsorted data --- .../discover/public/application/angular/discover.js | 5 ++++- .../angular/doc_table/lib/get_sort_for_search_source.ts | 8 +++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 635ec56604a84..cd611cc59e797 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -70,6 +70,7 @@ import { loadIndexPattern, resolveIndexPattern } from '../helpers/resolve_index_ import { getTopNavLinks } from '../components/top_nav/get_top_nav_links'; import { updateSearchSource } from '../helpers/update_search_source'; import { calcFieldCounts } from '../helpers/calc_field_counts'; +import { getDefaultSort } from './doc_table/lib/get_default_sort'; const services = getServices(); @@ -414,9 +415,11 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab function getStateDefaults() { const query = $scope.searchSource.getField('query') || data.query.queryString.getDefaultQuery(); + const sort = getSortArray(savedSearch.sort, $scope.indexPattern); + const defaultState = { query, - sort: getSortArray(savedSearch.sort, $scope.indexPattern), + sort: !sort.length ? getDefaultSort($scope.indexPattern) : sort, columns: savedSearch.columns.length > 0 ? savedSearch.columns diff --git a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.ts b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.ts index 6721f7a03584c..42bc59b82293e 100644 --- a/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.ts +++ b/src/plugins/discover/public/application/angular/doc_table/lib/get_sort_for_search_source.ts @@ -19,7 +19,6 @@ import { EsQuerySortValue, IndexPattern } from '../../../../kibana_services'; import { SortOrder } from '../components/table_header/helpers'; import { getSort } from './get_sort'; -import { getDefaultSort } from './get_default_sort'; /** * Prepares sort for search source, that's sending the request to ES @@ -33,10 +32,9 @@ export function getSortForSearchSource( indexPattern?: IndexPattern, defaultDirection: string = 'desc' ): EsQuerySortValue[] { - if (!sort || !indexPattern) { - return []; - } else if (Array.isArray(sort) && sort.length === 0) { - sort = getDefaultSort(indexPattern, defaultDirection); + if (!sort || !indexPattern || (Array.isArray(sort) && sort.length === 0)) { + // sorting by index order + return [{ _doc: defaultDirection } as EsQuerySortValue]; } const { timeFieldName } = indexPattern; return getSort(sort, indexPattern).map((sortPair: Record) => { From 4210bbca3c6886e10fc756b815e90c47dc1b5148 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 08:54:05 +0100 Subject: [PATCH 143/186] Allow user to remove all sorting --- .../components/discover_grid/discover_grid.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index fab96993c82a0..e751ba525e540 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -32,7 +32,6 @@ import { } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { getDefaultSort } from '../../angular/doc_table/lib/get_default_sort'; import { getPopoverContents, getSchemaDetectors } from './discover_grid_schema'; import { DiscoverGridFlyout } from './discover_grid_flyout'; import { DiscoverGridContext } from './discover_grid_context'; @@ -127,13 +126,7 @@ export const DiscoverGrid = ({ /** * Sorting */ - const sortingColumns = useMemo(() => { - return sort.length === 0 - ? getDefaultSort(indexPattern).map( - ([id, direction]) => ({ id, direction } as { id: string; direction: 'asc' | 'desc' }) - ) - : sort.map(([id, direction]) => ({ id, direction })); - }, [sort, indexPattern]); + const sortingColumns = useMemo(() => sort.map(([id, direction]) => ({ id, direction })), [sort]); const onTableSort = useCallback( (sortingColumnsData) => { From 5786f1e886ed2cd902545268baaa772f77dda3e3 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 09:02:25 +0100 Subject: [PATCH 144/186] Fix get_sharing_data.test.ts --- .../application/helpers/get_sharing_data.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts b/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts index 43d2cbd18850f..ffdfd01352648 100644 --- a/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts +++ b/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts @@ -21,6 +21,7 @@ import { getSharingData } from './get_sharing_data'; import { IUiSettingsClient } from 'kibana/public'; import { createSearchSourceMock } from '../../../../data/common/search/search_source/mocks'; import { indexPatternMock } from '../../__mocks__/index_pattern'; +import { SORT_DEFAULT_ORDER_SETTING } from '../../../common'; describe('getSharingData', () => { test('returns valid data for sharing', async () => { @@ -29,7 +30,10 @@ describe('getSharingData', () => { searchSourceMock, { columns: [] }, ({ - get: () => { + get: (key: string) => { + if (key === SORT_DEFAULT_ORDER_SETTING) { + return 'desc'; + } return false; }, } as unknown) as IUiSettingsClient, @@ -62,7 +66,13 @@ describe('getSharingData', () => { }, }, "script_fields": Object {}, - "sort": Array [], + "sort": Array [ + Object { + "_doc": Object { + "order": "desc", + }, + }, + ], "stored_fields": Array [ "date", ], From d3245b61ae10dcc41650ba76d3ab77d99c3081d2 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 09:16:18 +0100 Subject: [PATCH 145/186] Fix discover_grid_columns.test.tsx --- .../discover_grid_columns.test.tsx | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx index f028a7f3077c4..86120e2d91e92 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx @@ -21,7 +21,7 @@ import { getEuiGridColumns } from './discover_grid_columns'; describe('Discover grid columns ', function () { it('returns eui grid columns without time column', async () => { - const actual = getEuiGridColumns(['extension', 'message'], {}, indexPatternMock, false); + const actual = getEuiGridColumns(['extension', 'message'], {}, indexPatternMock, false, false); expect(actual).toMatchInlineSnapshot(` Array [ Object { @@ -29,6 +29,8 @@ describe('Discover grid columns ', function () { "showHide": Object { "label": "Remove column", }, + "showMoveLeft": true, + "showMoveRight": true, }, "cellActions": undefined, "display": undefined, @@ -41,6 +43,39 @@ describe('Discover grid columns ', function () { "showHide": Object { "label": "Remove column", }, + "showMoveLeft": true, + "showMoveRight": true, + }, + "cellActions": undefined, + "display": undefined, + "id": "message", + "isSortable": undefined, + "schema": "json", + }, + ] + `); + }); + it('returns eui grid columns without time column showing default columns', async () => { + const actual = getEuiGridColumns(['extension', 'message'], {}, indexPatternMock, false, true); + expect(actual).toMatchInlineSnapshot(` + Array [ + Object { + "actions": Object { + "showHide": false, + "showMoveLeft": false, + "showMoveRight": false, + }, + "cellActions": undefined, + "display": undefined, + "id": "extension", + "isSortable": undefined, + "schema": "json", + }, + Object { + "actions": Object { + "showHide": false, + "showMoveLeft": false, + "showMoveRight": false, }, "cellActions": undefined, "display": undefined, @@ -52,7 +87,7 @@ describe('Discover grid columns ', function () { `); }); it('returns eui grid columns with time column', async () => { - const actual = getEuiGridColumns(['extension', 'message'], {}, indexPatternMock, true); + const actual = getEuiGridColumns(['extension', 'message'], {}, indexPatternMock, true, false); expect(actual).toMatchInlineSnapshot(` Array [ Object { @@ -60,6 +95,8 @@ describe('Discover grid columns ', function () { "showHide": Object { "label": "Remove column", }, + "showMoveLeft": true, + "showMoveRight": true, }, "cellActions": undefined, "display": "Time (date)", @@ -73,6 +110,8 @@ describe('Discover grid columns ', function () { "showHide": Object { "label": "Remove column", }, + "showMoveLeft": true, + "showMoveRight": true, }, "cellActions": undefined, "display": undefined, @@ -85,6 +124,8 @@ describe('Discover grid columns ', function () { "showHide": Object { "label": "Remove column", }, + "showMoveLeft": true, + "showMoveRight": true, }, "cellActions": undefined, "display": undefined, From ba40602367f6d64dfe2f5236db54840cd85f42d2 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 09:42:25 +0100 Subject: [PATCH 146/186] Don't add default for grid in saved object --- src/plugins/discover/public/saved_searches/_saved_search.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/discover/public/saved_searches/_saved_search.ts b/src/plugins/discover/public/saved_searches/_saved_search.ts index 69c9a10b7e291..8a0ec128b4eb2 100644 --- a/src/plugins/discover/public/saved_searches/_saved_search.ts +++ b/src/plugins/discover/public/saved_searches/_saved_search.ts @@ -55,7 +55,6 @@ export function createSavedSearchClass(savedObjects: SavedObjectsStart) { title: '', description: '', columns: [], - grid: {}, hits: 0, sort: [], version: 1, From 29198b1df09a615480e6a05148914c4f20a5ca38 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 09:43:16 +0100 Subject: [PATCH 147/186] Fix sharing functional test - broken because of different default sort handling --- test/functional/apps/discover/_shared_links.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_shared_links.js b/test/functional/apps/discover/_shared_links.js index 60058ead1101e..a19c04d1e0d87 100644 --- a/test/functional/apps/discover/_shared_links.js +++ b/test/functional/apps/discover/_shared_links.js @@ -90,7 +90,7 @@ export default function ({ getService, getPageObjects }) { ":(from:'2015-09-19T06:31:44.000Z',to:'2015-09" + "-23T18:31:44.000Z'))&_a=(columns:!(_source),filters:!(),index:'logstash-" + "*',interval:auto,query:(language:kuery,query:'')" + - ',sort:!())'; + ",sort:!(!('@timestamp',desc)))"; const actualUrl = await PageObjects.share.getSharedUrl(); // strip the timestamp out of each URL expect(actualUrl.replace(/_t=\d{13}/, '_t=TIMESTAMP')).to.be( From 7a72c7581abf3cae12a102fd1ef88b535ad8742f Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 10:14:56 +0100 Subject: [PATCH 148/186] Add string to data grid schemas --- .../discover_grid/discover_grid_schema.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx index 00ee6f7c8ed95..21b779c5c8635 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx @@ -22,16 +22,20 @@ import { geoPoint, kibanaJSON } from './constants'; import { KBN_FIELD_TYPES } from '../../../../../data/common'; export function getSchemaByKbnType(kbnType: string | undefined) { - // Default DataGrid schemas: boolean, numeric, datetime, json, currency + // Default DataGrid schemas: boolean, numeric, datetime, json, currency, string switch (kbnType) { - case KBN_FIELD_TYPES.DATE: - return 'datetime'; + case KBN_FIELD_TYPES.IP: + case KBN_FIELD_TYPES.GEO_SHAPE: case KBN_FIELD_TYPES.NUMBER: return 'numeric'; + case KBN_FIELD_TYPES.BOOLEAN: + return 'boolean'; + case KBN_FIELD_TYPES.STRING: + return 'string'; + case KBN_FIELD_TYPES.DATE: + return 'datetime'; case KBN_FIELD_TYPES._SOURCE: return kibanaJSON; - case KBN_FIELD_TYPES.OBJECT: - return 'json'; case KBN_FIELD_TYPES.GEO_POINT: return geoPoint; default: From 12bad034020bba3141161fa872b5e8ad711d1ad1 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Dec 2020 11:12:18 +0100 Subject: [PATCH 149/186] Improve default column handling --- .../public/application/components/discover.tsx | 14 ++++++++++++-- .../discover_grid/discover_grid_columns.tsx | 15 ++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index b39f76ae62d68..51da59094f861 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -97,7 +97,17 @@ export function Discover({ : undefined; const contentCentered = resultState === 'uninitialized'; const showTimeCol = !config.get('doc_table:hideTimeColumn', false) && indexPattern.timeFieldName; - const columns = state.columns && state.columns.length > 0 ? state.columns : ['_source']; + const columns = + state.columns && + state.columns.length > 0 && + // check if all columns where removed except the configured timeField (this can't be removed) + !(state.columns.length === 1 && state.columns[0] === indexPattern.timeFieldName) + ? state.columns + : ['_source']; + // if columns include _source this is considered as default view, so you can't remove columns + // until you add a column using Discover's sidebar + const defaultColumns = columns.includes('_source'); + return ( @@ -263,7 +273,7 @@ export function Discover({ Date: Thu, 10 Dec 2020 11:41:23 +0100 Subject: [PATCH 150/186] Fix test and types --- .../discover_grid_cell_actions.tsx | 21 +++++++++++++++++-- .../discover_grid_columns.test.tsx | 4 +--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx index dd517fe646353..77d87c7348256 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx @@ -17,11 +17,20 @@ * under the License. */ import React, { useContext } from 'react'; +import { EuiButtonEmpty, EuiButtonIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { IndexPatternField } from '../../../../../data/common/index_patterns/fields'; import { DiscoverGridContext } from './discover_grid_context'; -export const FilterInBtn = ({ Component, rowIndex, columnId }: any) => { +export const FilterInBtn = ({ + Component, + rowIndex, + columnId, +}: { + Component: typeof EuiButtonEmpty | typeof EuiButtonIcon; + rowIndex: number; + columnId: string; +}) => { const context = useContext(DiscoverGridContext); return ( { ); }; -export const FilterOutBtn = ({ Component, rowIndex, columnId }: any) => { +export const FilterOutBtn = ({ + Component, + rowIndex, + columnId, +}: { + Component: typeof EuiButtonEmpty | typeof EuiButtonIcon; + rowIndex: number; + columnId: string; +}) => { const context = useContext(DiscoverGridContext); return ( Date: Thu, 10 Dec 2020 16:06:25 +0100 Subject: [PATCH 151/186] Improve documentation --- .../discover_grid/discover_grid.tsx | 59 ++++++++++++++++++- .../components/discover_grid/types.ts | 2 +- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index e751ba525e540..cad99c45dd837 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -52,23 +52,80 @@ interface SortObj { } export interface DiscoverGridProps { + /** + * Determines which element labels the grid for ARIA + */ ariaLabelledBy: string; + /** + * Determines which columns are displayed + */ columns: string[]; + /** + * Determines whether the given columns are the default ones, so parts of the document + * are displayed (_source) with limited actions (cannor move, remove columns) + * Implemented for matching with legacy behavior + */ defaultColumns: boolean; + /** + * The used index pattern + */ indexPattern: IndexPattern; + /** + * Function used to add a column in the document flyout + */ onAddColumn: (column: string) => void; + /** + * Function to add a filter in the grid cell or document flyout + */ onFilter: DocViewFilterFn; + /** + * Function used in the grid header and flyout to remove a column + * @param column + */ onRemoveColumn: (column: string) => void; + /** + * Function triggered when a column is resized by the user + */ onResize?: (colSettings: { columnId: string; width: number }) => void; + /** + * Function to set all columns + */ onSetColumns: (columns: string[]) => void; - onSort: (props: any) => void; + /** + * function to change sorting of the documents + */ + onSort: (sort: string[][]) => void; + /** + * Array of documents provided by Elasticsearch + */ rows?: ElasticSearchHit[]; + /** + * The max size of the documents returned by Elasticsearch + */ sampleSize: number; + /** + * Grid display settings persisted in Elasticsearch (e.g. column width) + */ settings?: DiscoverGridSettings; + /** + * Saved search description + */ searchDescription?: string; + /** + * Saved search title + */ searchTitle?: string; + /** + * Discover plugin services + */ services: DiscoverServices; + /** + * Determines whether the time columns should be displayed (legacy settings) + */ showTimeCol: boolean; + /** + * Current sort setting + */ sort: SortPairArr[]; } diff --git a/src/plugins/discover/public/application/components/discover_grid/types.ts b/src/plugins/discover/public/application/components/discover_grid/types.ts index c5783c7f07194..3d57dbffe924e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/types.ts +++ b/src/plugins/discover/public/application/components/discover_grid/types.ts @@ -18,7 +18,7 @@ */ /** - * User configureable state of data grid, persisted in saved search + * User configurable state of data grid, persisted in saved search */ export interface DiscoverGridSettings { columns?: Record; From beccad259a062445ad3b0e152900271d11ef929a Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Fri, 11 Dec 2020 16:34:51 -0500 Subject: [PATCH 152/186] add truncation to source --- .../application/components/discover_grid/discover_grid.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index 1eb279dde3016..7327b6aa5ef9e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -46,8 +46,8 @@ width: 100%; } -.dscApp .dscFormatSource { - word-break: break-word; +.dscFormatSource { + @include euiTextTruncate; } .dscFormatSource__title { From 3f0fee61120c31640a9bec35a1acb27362e9ae20 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sat, 12 Dec 2020 12:30:20 +0100 Subject: [PATCH 153/186] Fix types --- .../discover_grid/discover_grid_cell_actions.tsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx index 77d87c7348256..e447bf4609512 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { useContext } from 'react'; -import { EuiButtonEmpty, EuiButtonIcon } from '@elastic/eui'; +import { EuiDataGridColumnCellActionProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { IndexPatternField } from '../../../../../data/common/index_patterns/fields'; import { DiscoverGridContext } from './discover_grid_context'; @@ -26,11 +26,7 @@ export const FilterInBtn = ({ Component, rowIndex, columnId, -}: { - Component: typeof EuiButtonEmpty | typeof EuiButtonIcon; - rowIndex: number; - columnId: string; -}) => { +}: EuiDataGridColumnCellActionProps) => { const context = useContext(DiscoverGridContext); return ( { +}: EuiDataGridColumnCellActionProps) => { const context = useContext(DiscoverGridContext); return ( Date: Sat, 12 Dec 2020 12:48:23 +0100 Subject: [PATCH 154/186] Undo search source modification --- src/plugins/data/common/search/search_source/search_source.ts | 2 +- src/plugins/discover/public/__mocks__/index_pattern.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index 8eea8b7bc3722..fce0b737b962b 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -494,7 +494,7 @@ export class SearchSource { body.stored_fields = storedFields; // apply source filters from index pattern if specified by the user - let filteredDocvalueFields = docvalueFields || []; + let filteredDocvalueFields = docvalueFields; if (index) { const sourceFilters = index.getSourceFiltering(); if (!body.hasOwnProperty('_source')) { diff --git a/src/plugins/discover/public/__mocks__/index_pattern.ts b/src/plugins/discover/public/__mocks__/index_pattern.ts index fb1b10ec80e5e..4a9ee5d039ff3 100644 --- a/src/plugins/discover/public/__mocks__/index_pattern.ts +++ b/src/plugins/discover/public/__mocks__/index_pattern.ts @@ -75,7 +75,7 @@ const indexPattern = ({ flattenHit: undefined, formatHit: jest.fn((hit) => hit._source), fields, - getComputedFields: () => ({}), + getComputedFields: () => ({ docvalueFields: [], scriptFields: {}, storedFields: ['*'] }), getSourceFiltering: () => ({}), getFieldByName: () => ({}), timeFieldName: 'date', From 20d6492db4948eb4af1b2c7aad8caf93348f87eb Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 13 Dec 2020 18:12:49 +0100 Subject: [PATCH 155/186] Fix discover - dashboard overlapping --- src/core/public/chrome/ui/header/_index.scss | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/public/chrome/ui/header/_index.scss b/src/core/public/chrome/ui/header/_index.scss index 58cc61bbce96a..1eecaa57c6cfd 100644 --- a/src/core/public/chrome/ui/header/_index.scss +++ b/src/core/public/chrome/ui/header/_index.scss @@ -1,11 +1,19 @@ @include euiHeaderAffordForFixed; .euiDataGrid__restrictBody { - .headerGlobalNav { + .headerGlobalNav, + .kbnTopNavMenu__wrapper { display: none; } } +.euiDataGrid__restrictBody.euiBody--headerIsFixed { + .euiFlyout { + top: 0; + height: 100%; + } +} + .chrHeaderHelpMenu__version { text-transform: none; } From 689c8887f6346729535ecef1ed8b7b6e4cbf5f34 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 13 Dec 2020 18:14:08 +0100 Subject: [PATCH 156/186] Adapt UI settings wording --- src/plugins/discover/server/ui_settings.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/server/ui_settings.ts b/src/plugins/discover/server/ui_settings.ts index df1bb40f023cf..e2c7da95df872 100644 --- a/src/plugins/discover/server/ui_settings.ts +++ b/src/plugins/discover/server/ui_settings.ts @@ -172,11 +172,14 @@ export const uiSettings: Record = { }), value: true, description: i18n.translate('discover.advancedSettings.docTableVersionDescription', { - defaultMessage: - 'Prefer the legacy version of the documents table in Discover while available', + defaultMessage: 'Prefer the legacy version of the documents table in Discover.', }), category: ['discover'], schema: schema.boolean(), + metric: { + type: METRIC_TYPE.CLICK, + name: 'discover:useLegacyDataGrid', + }, }, [MODIFY_COLUMNS_ON_SWITCH]: { name: i18n.translate('discover.advancedSettings.discover.modifyColumnsOnSwitchTitle', { From 1e61efe92e343e618b28acbca6839a488340b81b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 13 Dec 2020 18:15:27 +0100 Subject: [PATCH 157/186] Add functional test for dashboard --- .../apps/discover/_data_grid_dashboard.ts | 59 +++++++++++++++++++ test/functional/apps/discover/index.js | 1 + 2 files changed, 60 insertions(+) create mode 100644 test/functional/apps/discover/_data_grid_dashboard.ts diff --git a/test/functional/apps/discover/_data_grid_dashboard.ts b/test/functional/apps/discover/_data_grid_dashboard.ts new file mode 100644 index 0000000000000..d7d1da969657b --- /dev/null +++ b/test/functional/apps/discover/_data_grid_dashboard.ts @@ -0,0 +1,59 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const dashboardAddPanel = getService('dashboardAddPanel'); + const filterBar = getService('filterBar'); + const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); + const find = getService('find'); + const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + + describe('discover data grid dashboard', () => { + before(async () => { + await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('dashboard/current/data'); + await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await kibanaServer.uiSettings.replace({ + defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', + 'doc_table:legacy': false, + }); + await PageObjects.common.navigateToApp('dashboard'); + await filterBar.ensureFieldEditorModalIsClosed(); + await PageObjects.dashboard.gotoDashboardLandingPage(); + await PageObjects.dashboard.clickNewDashboard(); + await PageObjects.timePicker.setDefaultDataRange(); + }); + + describe('saved search filters', function () { + it('are added when a cell filter is clicked', async function () { + await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); + await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`); + await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`); + await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`); + await find.clickByCssSelector(`[data-test-subj="filterForButton"]`); + const filterCount = await filterBar.getFilterCount(); + expect(filterCount).to.equal(2); + }); + }); + }); +} diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index ad0563ec92c8a..5ede5d30b8291 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -54,5 +54,6 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_data_grid_field_data')); loadTestFile(require.resolve('./_data_grid_doc_navigation')); loadTestFile(require.resolve('./_data_grid_doc_table')); + loadTestFile(require.resolve('./_data_grid_dashboard')); }); } From 33a68d871b375d4f18da78db567137c6f7924cbc Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 13 Dec 2020 18:16:24 +0100 Subject: [PATCH 158/186] Improve columns sorting --- .../discover/public/application/angular/discover.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index cd611cc59e797..da7fbd7962965 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -793,8 +793,13 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab }; $scope.setColumns = function setColumns(columns) { - $scope.state = { ...$scope.state, columns }; - setAppState({ columns }); + // remove first element of columns if it's the configured timeFieldName, which is prepended automatically + const actualColumns = + $scope.indexPattern.timeFieldName && $scope.indexPattern.timeFieldName === columns[0] + ? columns.slice(1) + : columns; + $scope.state = { ...$scope.state, columns: actualColumns }; + setAppState({ columns: actualColumns }); }; async function setupVisualization() { From e54cc4cf7b8a89836de1aada6ecaeade09176cad Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 13 Dec 2020 18:19:38 +0100 Subject: [PATCH 159/186] Improve selected columns sorting --- .../sidebar/lib/group_fields.test.ts | 117 ++++++++++++------ .../components/sidebar/lib/group_fields.tsx | 5 +- 2 files changed, 81 insertions(+), 41 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/lib/group_fields.test.ts b/src/plugins/discover/public/application/components/sidebar/lib/group_fields.test.ts index d4670a1e76011..36d8f2d1a8fb4 100644 --- a/src/plugins/discover/public/application/components/sidebar/lib/group_fields.test.ts +++ b/src/plugins/discover/public/application/components/sidebar/lib/group_fields.test.ts @@ -19,51 +19,58 @@ import { groupFields } from './group_fields'; import { getDefaultFieldFilter } from './field_filter'; +import { IndexPatternField } from '../../../../../../data/common/index_patterns/fields'; -describe('group_fields', function () { - it('should group fields in selected, popular, unpopular group', function () { - const fields = [ - { - name: 'category', - type: 'string', - esTypes: ['text'], - count: 1, - scripted: false, - searchable: true, - aggregatable: true, - readFromDocValues: true, - }, - { - name: 'currency', - type: 'string', - esTypes: ['keyword'], - count: 0, - scripted: false, - searchable: true, - aggregatable: true, - readFromDocValues: true, - }, - { - name: 'customer_birth_date', - type: 'date', - esTypes: ['date'], - count: 0, - scripted: false, - searchable: true, - aggregatable: true, - readFromDocValues: true, - }, - ]; +const fields = [ + { + name: 'category', + type: 'string', + esTypes: ['text'], + count: 1, + scripted: false, + searchable: true, + aggregatable: true, + readFromDocValues: true, + }, + { + name: 'currency', + type: 'string', + esTypes: ['keyword'], + count: 0, + scripted: false, + searchable: true, + aggregatable: true, + readFromDocValues: true, + }, + { + name: 'customer_birth_date', + type: 'date', + esTypes: ['date'], + count: 0, + scripted: false, + searchable: true, + aggregatable: true, + readFromDocValues: true, + }, +]; - const fieldCounts = { - category: 1, - currency: 1, - customer_birth_date: 1, - }; +const fieldCounts = { + category: 1, + currency: 1, + customer_birth_date: 1, +}; +describe('group_fields', function () { + it('should group fields in selected, popular, unpopular group', function () { const fieldFilterState = getDefaultFieldFilter(); - const actual = groupFields(fields as any, ['currency'], 5, fieldCounts, fieldFilterState); + const actual = groupFields( + fields as IndexPatternField[], + ['currency'], + 5, + fieldCounts, + fieldFilterState + ); expect(actual).toMatchInlineSnapshot(` Object { "popular": Array [ @@ -111,4 +118,34 @@ describe('group_fields', function () { } `); }); + + it('should sort selected fields by columns order ', function () { + const fieldFilterState = getDefaultFieldFilter(); + + const actual1 = groupFields( + fields as IndexPatternField[], + ['customer_birth_date', 'currency', 'unknown'], + 5, + fieldCounts, + fieldFilterState + ); + expect(actual1.selected.map((field) => field.name)).toEqual([ + 'customer_birth_date', + 'currency', + 'unknown', + ]); + + const actual2 = groupFields( + fields as IndexPatternField[], + ['currency', 'customer_birth_date', 'invalid_name'], + 5, + fieldCounts, + fieldFilterState + ); + expect(actual2.selected.map((field) => field.name)).toEqual([ + 'currency', + 'customer_birth_date', + 'unknown', + ]); + }); }); diff --git a/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx b/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx index cb4485d90531c..c34becc97cb93 100644 --- a/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx +++ b/src/plugins/discover/public/application/components/sidebar/lib/group_fields.tsx @@ -70,12 +70,15 @@ export function groupFields( result.unpopular.push(field); } } - // filter out columns, that were part of the former index pattern, but not of the current + // add columns, that are not part of the index pattern, to be removeable for (const column of columns) { if (!result.selected.find((field) => field.name === column)) { result.selected.push({ name: column, displayName: column } as IndexPatternField); } } + result.selected.sort((a, b) => { + return columns.indexOf(a.name) - columns.indexOf(b.name); + }); return result; } From 5a7b02c00ad28c91ae0a91424f14ea74f3b1822b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sun, 13 Dec 2020 23:11:16 +0100 Subject: [PATCH 160/186] Refactorings and docs --- .../discover_grid_cell_actions.test.tsx | 2 + .../discover_grid/discover_grid_columns.tsx | 4 +- ...x => discover_grid_expand_button.test.tsx} | 8 +- ...on.tsx => discover_grid_expand_button.tsx} | 5 +- .../discover_grid/discover_grid_flyout.tsx | 3 + .../components/discover_legacy.tsx | 123 +++++++++++++++++- .../sidebar/lib/group_fields.test.ts | 2 +- 7 files changed, 135 insertions(+), 12 deletions(-) rename src/plugins/discover/public/application/components/discover_grid/{discover_grid_view_button.test.tsx => discover_grid_expand_button.test.tsx} (94%) rename src/plugins/discover/public/application/components/discover_grid/{discover_grid_view_button.tsx => discover_grid_expand_button.tsx} (93%) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx index cf7ade9c9c4de..7309a26ce6b80 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx @@ -42,6 +42,7 @@ describe('Discover cell actions ', function () { Component={(props: any) => } rowIndex={1} columnId={'extension'} + isExpanded={false} /> ); @@ -64,6 +65,7 @@ describe('Discover cell actions ', function () { Component={(props: any) => } rowIndex={1} columnId={'extension'} + isExpanded={false} /> ); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index fcd4d00a8120e..a6abf116a386c 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { EuiDataGridColumn, EuiScreenReaderOnly } from '@elastic/eui'; -import { ViewButton } from './discover_grid_view_button'; +import { ExpandButton } from './discover_grid_expand_button'; import { DiscoverGridSettings } from './types'; import { IndexPattern } from '../../../../../data/common/index_patterns/index_patterns'; import { buildCellActions } from './discover_grid_cell_actions'; @@ -39,7 +39,7 @@ export function getLeadControlColumns() { ), - rowCellRender: ViewButton, + rowCellRender: ExpandButton, }, ]; } diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx similarity index 94% rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.test.tsx rename to src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx index 287044d329e6f..bd1fd06159cec 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { mountWithIntl } from '@kbn/test/jest'; import { findTestSubject } from '@elastic/eui/lib/test'; -import { ViewButton } from './discover_grid_view_button'; +import { ExpandButton } from './discover_grid_expand_button'; import { DiscoverGridContext } from './discover_grid_context'; import { indexPatternMock } from '../../../__mocks__/index_pattern'; import { esHits } from '../../../__mocks__/es_hits'; @@ -36,7 +36,7 @@ describe('Discover grid view button ', function () { const component = mountWithIntl( - + ); const button = findTestSubject(component, 'docTableExpandToggleColumn'); @@ -54,7 +54,7 @@ describe('Discover grid view button ', function () { const component = mountWithIntl( - + ); const button = findTestSubject(component, 'docTableExpandToggleColumn'); @@ -72,7 +72,7 @@ describe('Discover grid view button ', function () { const component = mountWithIntl( - + ); const button = findTestSubject(component, 'docTableExpandToggleColumn'); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx similarity index 93% rename from src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx rename to src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx index 468df36d8e269..18ecd618d367b 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx @@ -21,7 +21,10 @@ import { EuiIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DiscoverGridContext } from './discover_grid_context'; -export const ViewButton = ({ rowIndex }: { rowIndex: number }) => { +/** + * Button to expand a given row + */ +export const ExpandButton = ({ rowIndex }: { rowIndex: number }) => { const { expanded, setExpanded, rows } = useContext(DiscoverGridContext); const current = rows[rowIndex]; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 112185d273cb1..0601011580938 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -47,6 +47,9 @@ interface Props { services: DiscoverServices; } +/** + * Flyout displaying an expanded Elasticsearch document + */ export function DiscoverGridFlyout({ hit, indexPattern, diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 596ade4380c0d..c03f3b594b46d 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -63,46 +63,161 @@ import { import { DocViewFilterFn, ElasticSearchHit } from '../doc_views/doc_views_types'; export interface DiscoverProps { + /** + * Function to fetch documents from Elasticsearch + */ fetch: () => void; + /** + * Counter how often data was fetched (used for testing) + */ fetchCounter: number; - fetchError: Error; + /** + * Error in case of a failing document fetch + */ + fetchError?: Error; + /** + * Statistics by fields calculated using the fetched documents + */ fieldCounts: Record; - histogramData: Chart; + /** + * Histogram aggregation data + */ + histogramData?: Chart; + /** + * Number of documents found by recent fetch + */ hits: number; + /** + * Current IndexPattern + */ indexPattern: IndexPattern; + /** + * Value needed for legacy "infinite" loading functionality + * Determins how much records are rendered using the legacy table + * Increased when scrolling down + */ minimumVisibleRows: number; + /** + * Function to add a column to state + */ onAddColumn: (column: string) => void; + /** + * Function to add a filter to state + */ onAddFilter: DocViewFilterFn; + /** + * Function to change the used time interval of the date histogram + */ onChangeInterval: (interval: string) => void; + /** + * Function to move a given column to a given index, used in legacy table + */ onMoveColumn: (columns: string, newIdx: number) => void; + /** + * Function to remove a given column from state + */ onRemoveColumn: (column: string) => void; + /** + * Function to replace columns in state + */ onSetColumns: (columns: string[]) => void; + /** + * Function to scroll down the legacy table to the bottom + */ onSkipBottomButtonClick: () => void; + /** + * Function to change sorting of the table, triggers a fetch + */ onSort: (sort: string[][]) => void; opts: { + /** + * Date histogram aggregation config + */ chartAggConfigs?: AggConfigs; + /** + * Client of uiSettings + */ config: IUiSettingsClient; + /** + * Data plugin + */ data: DataPublicPluginStart; - fixedScroll: (el: HTMLElement) => void; + /** + * Data plugin filter manager + */ filterManager: FilterManager; + /** + * List of available index patterns + */ indexPatternList: Array>; + /** + * The number of documents that can be displayed in the table/grid + */ sampleSize: number; + /** + * Current instance of SavedSearch + */ savedSearch: SavedSearch; + /** + * Function to set the header menu + */ setHeaderActionMenu: (menuMount: MountPoint | undefined) => void; + /** + * Timefield of the currently used index pattern + */ timefield: string; + /** + * Function to set the current state + */ setAppState: (state: Partial) => void; }; + /** + * Function to reset the current query + */ resetQuery: () => void; + /** + * Current state of the actual query, one of 'uninitialized', 'loading' ,'ready', 'none' + */ resultState: string; + /** + * Array of document of the recent successful search request + */ rows: ElasticSearchHit[]; + /** + * Instance of SearchSource, the high level search API + */ searchSource: ISearchSource; + /** + * Function to change the current index pattern + */ setIndexPattern: (id: string) => void; + /** + * Determines whether the user should be able to use the save query feature + */ showSaveQuery: boolean; + /** + * Current app state of URL + */ state: AppState; + /** + * Function to update the time filter + */ timefilterUpdateHandler: (ranges: { from: number; to: number }) => void; + /** + * Currently selected time range + */ timeRange?: { from: string; to: string }; + /** + * Menu data of top navigation (New, save ...) + */ topNavMenu: TopNavMenuData[]; + /** + * Function to update the actual query + */ updateQuery: (payload: { dateRange: TimeRange; query?: Query }, isUpdate?: boolean) => void; + /** + * Function to update the actual savedQuery id + */ updateSavedQueryId: (savedQueryId?: string) => void; } @@ -299,7 +414,7 @@ export function DiscoverLegacy({ )} className="dscTimechart" > - {opts.chartAggConfigs && rows.length !== 0 && ( + {opts.chartAggConfigs && histogramData && rows.length !== 0 && (
    Date: Mon, 14 Dec 2020 07:01:52 +0100 Subject: [PATCH 161/186] Fix type --- src/plugins/discover/public/application/components/discover.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 51da59094f861..46158cc13563d 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -243,7 +243,7 @@ export function Discover({ )} className="dscTimechart" > - {opts.chartAggConfigs && rows.length !== 0 && ( + {opts.chartAggConfigs && histogramData && rows.length !== 0 && (
    Date: Tue, 15 Dec 2020 10:04:03 +0100 Subject: [PATCH 162/186] Fix types and tests --- .../discover_grid/discover_grid_cell_actions.test.tsx | 2 ++ .../public/application/helpers/get_sharing_data.test.ts | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx index 7309a26ce6b80..c121dc5302234 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx @@ -43,6 +43,7 @@ describe('Discover cell actions ', function () { rowIndex={1} columnId={'extension'} isExpanded={false} + closePopover={jest.fn()} /> ); @@ -66,6 +67,7 @@ describe('Discover cell actions ', function () { rowIndex={1} columnId={'extension'} isExpanded={false} + closePopover={jest.fn()} /> ); diff --git a/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts b/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts index d3f81005a3f32..6ffd7d576a3aa 100644 --- a/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts +++ b/src/plugins/discover/public/application/helpers/get_sharing_data.test.ts @@ -21,7 +21,6 @@ import { getSharingData } from './get_sharing_data'; import { IUiSettingsClient } from 'kibana/public'; import { createSearchSourceMock } from '../../../../data/common/search/search_source/mocks'; import { indexPatternMock } from '../../__mocks__/index_pattern'; -import { SORT_DEFAULT_ORDER_SETTING } from '../../../common'; describe('getSharingData', () => { test('returns valid data for sharing', async () => { From ee0739c6e6df1551e7bb65b6d945fb2b1be87797 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 15 Dec 2020 10:14:37 +0100 Subject: [PATCH 163/186] Add sidebar aria label --- .../discover/public/application/components/discover.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 46158cc13563d..b684321e9b592 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -157,7 +157,9 @@ export function Discover({ data-test-subj="collapseSideBarButton" aria-controls="discover-sidebar" aria-expanded={isSidebarClosed ? 'false' : 'true'} - aria-label="Toggle sidebar" + aria-label={i18n.translate('discover.toggleSidebarAriaLabel', { + defaultMessage: 'Toggle sidebar', + })} buttonRef={collapseIcon} /> From f2f18e5e519c7b33e1a19ba89c876f8fd909f3af Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 15 Dec 2020 10:30:44 +0100 Subject: [PATCH 164/186] Address review comments --- .../public/application/components/discover.tsx | 2 +- .../components/discover_grid/discover_grid.tsx | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index b684321e9b592..1b55787ddd5eb 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -176,7 +176,7 @@ export function Discover({ {resultState === 'none' && ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index cad99c45dd837..b5d0b62be420e 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -159,9 +159,11 @@ export const DiscoverGrid = ({ * Pagination */ const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize }); - - const rowsLength = rows ? rows.length : 0; - const pageCount = Math.ceil(rowsLength / pagination.pageSize); + const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); + const pageCount = useMemo(() => Math.ceil(rowCount / pagination.pageSize), [ + rowCount, + pagination, + ]); const isOnLastPage = pagination.pageIndex === pageCount - 1; const paginationObj = useMemo(() => { @@ -203,10 +205,9 @@ export const DiscoverGrid = ({ /** * Render variables */ - const showDisclaimer = rowsLength === sampleSize && isOnLastPage; + const showDisclaimer = rowCount === sampleSize && isOnLastPage; const randomId = useMemo(() => htmlIdGenerator()(), []); - const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); const euiGridColumns = useMemo( () => getEuiGridColumns(columns, settings, indexPattern, showTimeCol, defaultColumns), [columns, indexPattern, showTimeCol, settings, defaultColumns] @@ -228,7 +229,7 @@ export const DiscoverGrid = ({ ]); const lead = useMemo(() => getLeadControlColumns(), []); - if (!rowCount || !rows) { + if (!rowCount) { return (
    @@ -245,7 +246,7 @@ export const DiscoverGrid = ({ value={{ expanded, setExpanded, - rows, + rows: rows || [], onFilter, indexPattern, }} From 1cbfee5b047fedf14a23c09eabc59a903b2a7a21 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 15 Dec 2020 11:34:27 +0100 Subject: [PATCH 165/186] Fix adding of filter in full screen mode --- src/core/public/chrome/ui/header/_index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/public/chrome/ui/header/_index.scss b/src/core/public/chrome/ui/header/_index.scss index 1eecaa57c6cfd..b11e7e47f4ae7 100644 --- a/src/core/public/chrome/ui/header/_index.scss +++ b/src/core/public/chrome/ui/header/_index.scss @@ -2,7 +2,7 @@ .euiDataGrid__restrictBody { .headerGlobalNav, - .kbnTopNavMenu__wrapper { + .kbnQueryBar { display: none; } } From 0ad2cb7757cb7b03836972b8ea3fb791b5d3659f Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 17 Dec 2020 11:31:01 -0500 Subject: [PATCH 166/186] Change _source to use EuiDescriptionList component --- .../get_render_cell_value.test.tsx | 2 +- .../discover_grid/get_render_cell_value.tsx | 25 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx index 792506551a213..c83341c1abb21 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx @@ -58,7 +58,7 @@ describe('Discover grid cell rendering', function () { /> ); expect(component.html()).toMatchInlineSnapshot( - `"
    bytes
    100
    "` + `"
    bytes
    100
    "` ); }); diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx index 619b690ed8730..550abf5dab3bf 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx @@ -16,8 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import React from 'react'; -import { EuiDataGridCellValueElementProps } from '@elastic/eui'; +import React, { Fragment } from 'react'; +import { + EuiDataGridCellValueElementProps, + EuiDescriptionList, + EuiDescriptionListTitle, + EuiDescriptionListDescription, +} from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; @@ -35,18 +40,14 @@ export const getRenderCellValueFn = ( const formatted = indexPattern.formatHit(row); return ( -
    + {Object.keys(formatted).map((key) => ( - -
    {key}
    -
    - + + {key} + + ))} -
    + ); }; From db0ff46da038692a731af66ee6de0790577b78cd Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 17 Dec 2020 11:37:59 -0500 Subject: [PATCH 167/186] Change remove column icon from eye to cross --- .../components/discover_grid/discover_grid_columns.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index a6abf116a386c..924b709dfa6c8 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -67,6 +67,7 @@ export function buildEuiGridColumn( label: i18n.translate('discover.removeColumnLabel', { defaultMessage: 'Remove column', }), + iconType: 'cross', }, showMoveLeft: !defaultColumns, showMoveRight: !defaultColumns, From ec996e2ae659495a7c401335499bfd245090586c Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 17 Dec 2020 11:54:52 -0500 Subject: [PATCH 168/186] Change expand button to use EuiButtonIcon --- .../discover_grid/discover_grid_columns.tsx | 2 +- .../discover_grid_expand_button.tsx | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx index 924b709dfa6c8..1cf9c84405a61 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx @@ -29,7 +29,7 @@ export function getLeadControlColumns() { return [ { id: 'openDetails', - width: 31, + width: 32, headerCellRender: () => ( diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx index 18ecd618d367b..2834944e118ae 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { useContext } from 'react'; -import { EuiIcon } from '@elastic/eui'; +import { EuiButtonIcon, EuiIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DiscoverGridContext } from './discover_grid_context'; @@ -31,15 +31,17 @@ export const ExpandButton = ({ rowIndex }: { rowIndex: number }) => { const isCurrentRowExpanded = current === expanded; return ( - + onClick={() => setExpanded(isCurrentRowExpanded ? undefined : current)} + color={isCurrentRowExpanded ? 'primary' : 'subdued'} + iconType={isCurrentRowExpanded ? 'minimize' : 'expand'} + isSelected={isCurrentRowExpanded ? true : false} + /> ); }; From 9eb63759991a98902cd14595a5d216ea70f195f3 Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 17 Dec 2020 11:56:59 -0500 Subject: [PATCH 169/186] Remove unused CSS --- .../components/discover_grid/discover_grid.scss | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index 7327b6aa5ef9e..e4a5474018212 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -49,17 +49,3 @@ .dscFormatSource { @include euiTextTruncate; } - -.dscFormatSource__title { - background-color: transparentize(shade($euiColorPrimary, 20%), 0.9); - border-radius: $euiBorderRadius / 2; - color: $euiTextColor; - padding: ($euiSizeXS / 2) $euiSizeXS; - margin-right: $euiSizeXS; - word-break: normal; - display: inline; -} - -.dscFormatSource__description { - display: inline; -} From 917fd5c5999f130c78d39c2b8adc62b8c552051c Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 17 Dec 2020 12:15:11 -0500 Subject: [PATCH 170/186] Stylistic update to flyout --- .../discover_grid_expand_button.tsx | 2 +- .../discover_grid/discover_grid_flyout.tsx | 60 +++++++++++-------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx index 2834944e118ae..a3a58a4fa31dd 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { useContext } from 'react'; -import { EuiButtonIcon, EuiIcon } from '@elastic/eui'; +import { EuiButtonIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DiscoverGridContext } from './discover_grid_context'; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 0601011580938..701ee667bde02 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -29,6 +29,8 @@ import { EuiPortal, EuiTitle, EuiButtonEmpty, + EuiText, + EuiSpacer, } from '@elastic/eui'; import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; @@ -64,7 +66,10 @@ export function DiscoverGridFlyout({ - + + + +

    - {' '} {i18n.translate('discover.grid.tableRow.detailHeading', { defaultMessage: 'Expanded document', })} @@ -80,28 +84,18 @@ export function DiscoverGridFlyout({ - - - - {indexPattern.isTimeBased() && indexPattern.id && ( - - - {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkText', { - defaultMessage: 'View surrounding documents', + + + + + + + {i18n.translate('discover.grid.tableRow.viewText', { + defaultMessage: 'View:', })} - - - )} + + + - {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkText', { - defaultMessage: 'View single document', + {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkTextSimple', { + defaultMessage: 'Single document', })} + {indexPattern.isTimeBased() && indexPattern.id && ( + + + {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkTextSimple', { + defaultMessage: 'Surrounding documents', + })} + + + )} + + Date: Thu, 17 Dec 2020 12:53:22 -0500 Subject: [PATCH 171/186] Adding tooltips / titles to icon only buttons --- .../discover_grid_cell_actions.tsx | 22 +++++++++----- .../discover_grid_expand_button.tsx | 29 ++++++++++--------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx index e447bf4609512..b798589f40cc9 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx @@ -28,6 +28,11 @@ export const FilterInBtn = ({ columnId, }: EuiDataGridColumnCellActionProps) => { const context = useContext(DiscoverGridContext); + const buttonTitle = i18n.translate('discover.grid.filterForAria', { + defaultMessage: 'Filter for this {value}', + values: { value: columnId }, + }); + return ( { @@ -39,10 +44,8 @@ export const FilterInBtn = ({ } }} iconType="plusInCircle" - aria-label={i18n.translate('discover.grid.filterForAria', { - defaultMessage: 'Filter for {value}', - values: { value: columnId }, - })} + aria-label={buttonTitle} + title={buttonTitle} data-test-subj="filterForButton" > {i18n.translate('discover.grid.filterFor', { @@ -58,6 +61,11 @@ export const FilterOutBtn = ({ columnId, }: EuiDataGridColumnCellActionProps) => { const context = useContext(DiscoverGridContext); + const buttonTitle = i18n.translate('discover.grid.filterOutAria', { + defaultMessage: 'Filter out this {value}', + values: { value: columnId }, + }); + return ( { @@ -69,10 +77,8 @@ export const FilterOutBtn = ({ } }} iconType="minusInCircle" - aria-label={i18n.translate('discover.grid.filterOutAria', { - defaultMessage: 'Filter out {value}', - values: { value: columnId }, - })} + aria-label={buttonTitle} + title={buttonTitle} data-test-subj="filterOutButton" > {i18n.translate('discover.grid.filterOut', { diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx index a3a58a4fa31dd..5be6100838f5a 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx @@ -17,7 +17,7 @@ * under the License. */ import React, { useContext } from 'react'; -import { EuiButtonIcon } from '@elastic/eui'; +import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DiscoverGridContext } from './discover_grid_context'; @@ -29,19 +29,22 @@ export const ExpandButton = ({ rowIndex }: { rowIndex: number }) => { const current = rows[rowIndex]; const isCurrentRowExpanded = current === expanded; + const buttonLabel = i18n.translate('discover.grid.viewDoc', { + defaultMessage: 'Toggle dialog with details', + }); return ( - setExpanded(isCurrentRowExpanded ? undefined : current)} - color={isCurrentRowExpanded ? 'primary' : 'subdued'} - iconType={isCurrentRowExpanded ? 'minimize' : 'expand'} - isSelected={isCurrentRowExpanded ? true : false} - /> + + setExpanded(isCurrentRowExpanded ? undefined : current)} + color={isCurrentRowExpanded ? 'primary' : 'subdued'} + iconType={isCurrentRowExpanded ? 'minimize' : 'expand'} + isSelected={isCurrentRowExpanded ? true : false} + /> + ); }; From 49938ef068e33252c9f2ba96a98566b11e369be8 Mon Sep 17 00:00:00 2001 From: cchaos Date: Thu, 17 Dec 2020 13:15:44 -0500 Subject: [PATCH 172/186] Min height for chart heading and added border --- .../discover/public/application/components/discover.scss | 1 + .../discover/public/application/components/discover.tsx | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index 6ecf3eea5b91d..c1f89e78b2248 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -46,6 +46,7 @@ discover-app { .dscResultCount { padding: $euiSizeS; + min-height: $euiSize * 3; @include euiBreakpoint('xs', 's') { .dscResultCount__toggle { diff --git a/src/plugins/discover/public/application/components/discover.tsx b/src/plugins/discover/public/application/components/discover.tsx index 1b55787ddd5eb..aa756d960e435 100644 --- a/src/plugins/discover/public/application/components/discover.tsx +++ b/src/plugins/discover/public/application/components/discover.tsx @@ -24,9 +24,11 @@ import { EuiFlexGroup, EuiFlexItem, EuiHideFor, + EuiHorizontalRule, EuiPage, EuiPageBody, EuiPageContent, + EuiSpacer, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; @@ -254,9 +256,12 @@ export function Discover({

    )}

    +
    )} + +
    Date: Fri, 18 Dec 2020 08:29:49 +0100 Subject: [PATCH 173/186] Address review comments part 1 --- .../discover_grid_columns.test.tsx | 4 + .../discover_grid/discover_grid_flyout.tsx | 131 +++++++++--------- .../discover_grid/discover_grid_schema.tsx | 2 +- .../get_render_cell_value.test.tsx | 2 +- .../discover_grid/get_render_cell_value.tsx | 32 ++--- .../apps/discover/_data_grid_context.ts | 2 +- 6 files changed, 87 insertions(+), 86 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx index 7f431a647bdba..5b5b8e27e201c 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx @@ -28,6 +28,7 @@ describe('Discover grid columns ', function () { Object { "actions": Object { "showHide": Object { + "iconType": "cross", "label": "Remove column", }, "showMoveLeft": true, @@ -42,6 +43,7 @@ describe('Discover grid columns ', function () { Object { "actions": Object { "showHide": Object { + "iconType": "cross", "label": "Remove column", }, "showMoveLeft": true, @@ -119,6 +121,7 @@ describe('Discover grid columns ', function () { Object { "actions": Object { "showHide": Object { + "iconType": "cross", "label": "Remove column", }, "showMoveLeft": true, @@ -133,6 +136,7 @@ describe('Discover grid columns ', function () { Object { "actions": Object { "showHide": Object { + "iconType": "cross", "label": "Remove column", }, "showMoveLeft": true, diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 701ee667bde02..be88e4cea8b87 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -26,7 +26,6 @@ import { EuiFlyoutBody, EuiFlyoutHeader, EuiIcon, - EuiPortal, EuiTitle, EuiButtonEmpty, EuiText, @@ -63,80 +62,78 @@ export function DiscoverGridFlyout({ services, }: Props) { return ( - - - - - - - - - -

    - {i18n.translate('discover.grid.tableRow.detailHeading', { - defaultMessage: 'Expanded document', - })} -

    -
    -
    -
    + + + + + + + + +

    + {i18n.translate('discover.grid.tableRow.detailHeading', { + defaultMessage: 'Expanded document', + })} +

    +
    +
    +
    - - - - - - {i18n.translate('discover.grid.tableRow.viewText', { - defaultMessage: 'View:', - })} - - - + + + + + + {i18n.translate('discover.grid.tableRow.viewText', { + defaultMessage: 'View:', + })} + + + + + + {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkTextSimple', { + defaultMessage: 'Single document', + })} + + + {indexPattern.isTimeBased() && indexPattern.id && ( - {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkTextSimple', { - defaultMessage: 'Single document', + {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkTextSimple', { + defaultMessage: 'Surrounding documents', })} - {indexPattern.isTimeBased() && indexPattern.id && ( - - - {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkTextSimple', { - defaultMessage: 'Surrounding documents', - })} - - - )} - -
    - - - -
    -
    + )} + + + + + + ); } diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx index 21b779c5c8635..fdd1611bb0a57 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx @@ -77,7 +77,7 @@ export function getPopoverContents() { }, [kibanaJSON]: ({ children }: { children: ReactNode }) => { return ( - + {children} ); diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx index c83341c1abb21..617bd2bd7b8b5 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx @@ -58,7 +58,7 @@ describe('Discover grid cell rendering', function () { /> ); expect(component.html()).toMatchInlineSnapshot( - `"
    bytes
    100
    "` + `"
    bytes
    100
    "` ); }); diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx index 550abf5dab3bf..dd8ba679c674b 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx @@ -33,10 +33,16 @@ export const getRenderCellValueFn = ( const row = rows ? (rows[rowIndex] as Record) : undefined; const field = indexPattern.fields.getByName(columnId); - if (typeof row === 'undefined' || !field) { + if (typeof row === 'undefined') { return -; } - const formatSource = () => { + + if (isDetails && typeof row[columnId] === 'object') { + // nicely formatted JSON for the expanded view + return {JSON.stringify(row[columnId], null, 2)}; + } + + if (field && field.type === '_source') { const formatted = indexPattern.formatHit(row); return ( @@ -49,19 +55,13 @@ export const getRenderCellValueFn = ( ))} ); - }; - - const value = - field && field.type === '_source' ? ( - formatSource() - ) : ( - // eslint-disable-next-line react/no-danger - - ); - - if (isDetails && field && field.type === '_source') { - // nicely formatted JSON for the expanded view - return {JSON.stringify(row[columnId], null, 2)}; } - return value; + const valueFormatted = indexPattern.formatField(row, columnId); + if (typeof valueFormatted === 'undefined') { + return -; + } + return ( + // eslint-disable-next-line react/no-danger + + ); }; diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts index 19de2ac4715b9..6821b9c69cf7e 100644 --- a/test/functional/apps/discover/_data_grid_context.ts +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -65,7 +65,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // navigate to the context view await dataGrid.clickRowToggle({ rowIndex: 0 }); const rowActions = await dataGrid.getRowActions({ rowIndex: 0 }); - await rowActions[0].click(); + await rowActions[1].click(); // entering the context view (contains the legacy type) const contextFields = await docTable.getFields(); const anchorTimestamp = contextFields[0][0]; From 9d5b5c41019b99c27314ce4f96caa763f0a3f642 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 18 Dec 2020 14:57:54 +0100 Subject: [PATCH 174/186] Fix functional test --- test/functional/apps/discover/_data_grid_doc_navigation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_data_grid_doc_navigation.ts b/test/functional/apps/discover/_data_grid_doc_navigation.ts index 85e02afec6898..fff37765e55ac 100644 --- a/test/functional/apps/discover/_data_grid_doc_navigation.ts +++ b/test/functional/apps/discover/_data_grid_doc_navigation.ts @@ -49,7 +49,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { if (!rowActions.length) { throw new Error('row actions empty, trying again'); } - await rowActions[1].click(); + await rowActions[0].click(); }); const hasDocHit = await testSubjects.exists('doc-hit'); From ef0933e900aa39f1bac05182430e8f1dc6fb860a Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 18 Dec 2020 15:12:07 +0100 Subject: [PATCH 175/186] Show filters also if a field is searchable ... of course --- .../components/discover_grid/discover_grid_cell_actions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx index b798589f40cc9..ef56166258c9b 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.tsx @@ -89,7 +89,7 @@ export const FilterOutBtn = ({ }; export function buildCellActions(field: IndexPatternField) { - if (!field.aggregatable) { + if (!field.aggregatable && !field.searchable) { return undefined; } From f9685c7b9d48c08cd68e5d13f6cc464f781cceed Mon Sep 17 00:00:00 2001 From: Dave Snider Date: Fri, 18 Dec 2020 10:15:49 -0800 Subject: [PATCH 176/186] more design cleanup for dg --- .../components/discover_grid/constants.ts | 2 +- .../discover_grid/discover_grid.scss | 17 ++++++++++ .../discover_grid/discover_grid_flyout.tsx | 31 +++++++------------ .../__snapshots__/doc_viewer.test.tsx.snap | 1 + .../components/doc_viewer/doc_viewer.scss | 1 - .../components/doc_viewer/doc_viewer.tsx | 2 +- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/constants.ts b/src/plugins/discover/public/application/components/discover_grid/constants.ts index 305a52b5afd58..3ca1e9f05bbd0 100644 --- a/src/plugins/discover/public/application/components/discover_grid/constants.ts +++ b/src/plugins/discover/public/application/components/discover_grid/constants.ts @@ -19,7 +19,7 @@ export const kibanaJSON = 'kibana-json'; export const geoPoint = 'geo-point'; export const gridStyle = { - border: 'horizontal', + border: 'all', fontSize: 's', cellPadding: 's', rowHover: 'none', diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss index e4a5474018212..64a7eda963349 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss @@ -3,7 +3,24 @@ max-width: 100%; height: 100%; overflow: hidden; + + .euiDataGrid__controls { + border: none; + border-bottom: $euiBorderThin; + } + + .euiDataGridRowCell:first-of-type, + .euiDataGrid--headerShade.euiDataGrid--bordersAll .euiDataGridHeaderCell:first-of-type { + border-left: none; + border-right: none; + } + + .euiDataGridRowCell:last-of-type, + .euiDataGridHeaderCell:last-of-type { + border-right: none; + } } + .dscDiscoverGrid__footer { background-color: $euiColorLightShade; padding: $euiSize / 2 $euiSize; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index be88e4cea8b87..8271d297b1282 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -64,26 +64,19 @@ export function DiscoverGridFlyout({ return ( - - - - - - -

    - {i18n.translate('discover.grid.tableRow.detailHeading', { - defaultMessage: 'Expanded document', - })} -

    -
    -
    -
    + +

    + {i18n.translate('discover.grid.tableRow.detailHeading', { + defaultMessage: 'Expanded document', + })} +

    +
    - + diff --git a/src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap b/src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap index b5bd961037e21..d02b484a06a49 100644 --- a/src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap +++ b/src/plugins/discover/public/application/components/doc_viewer/__snapshots__/doc_viewer.test.tsx.snap @@ -6,6 +6,7 @@ exports[`Render with 3 different tabs 1`] = ` > - + ); } From b20b6e91f04f7ace068ce517d11a6b069492548a Mon Sep 17 00:00:00 2001 From: Dave Snider Date: Fri, 18 Dec 2020 10:31:09 -0800 Subject: [PATCH 177/186] amsterdam fix --- .../discover/public/application/components/discover.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index c1f89e78b2248..665bd98c232a5 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -35,6 +35,10 @@ discover-app { } } +.dscPageContent { + border: $euiBorderThin; +} + .dscPageContent, .dscPageContent__inner { height: 100%; From 917fdcd8cae971fab6fb3b6a657a88a8b1e6f384 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 18 Dec 2020 22:44:21 +0100 Subject: [PATCH 178/186] Fix import --- .../components/discover_grid/discover_grid_flyout.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 8271d297b1282..75058e03ce58c 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -25,7 +25,6 @@ import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader, - EuiIcon, EuiTitle, EuiButtonEmpty, EuiText, From 53b74990e3d4039b129f14e81f1dc9360bcc073b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 21 Dec 2020 15:16:43 +0100 Subject: [PATCH 179/186] Close flyout when filter, column is added --- .../discover_grid/discover_grid_flyout.tsx | 126 ++++++++++-------- 1 file changed, 69 insertions(+), 57 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 75058e03ce58c..91de00d1f940c 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -29,6 +29,7 @@ import { EuiButtonEmpty, EuiText, EuiSpacer, + EuiPortal, } from '@elastic/eui'; import { DocViewer } from '../doc_viewer/doc_viewer'; import { IndexPattern } from '../../../kibana_services'; @@ -61,71 +62,82 @@ export function DiscoverGridFlyout({ services, }: Props) { return ( - - - -

    - {i18n.translate('discover.grid.tableRow.detailHeading', { - defaultMessage: 'Expanded document', - })} -

    -
    - - - - - - - {i18n.translate('discover.grid.tableRow.viewText', { - defaultMessage: 'View:', - })} - - - - - - {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkTextSimple', { - defaultMessage: 'Single document', + + + + +

    + {i18n.translate('discover.grid.tableRow.detailHeading', { + defaultMessage: 'Expanded document', })} - - - {indexPattern.isTimeBased() && indexPattern.id && ( +

    +
    + + + + + + + {i18n.translate('discover.grid.tableRow.viewText', { + defaultMessage: 'View:', + })} + + + - {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkTextSimple', { - defaultMessage: 'Surrounding documents', + {i18n.translate('discover.grid.tableRow.viewSingleDocumentLinkTextSimple', { + defaultMessage: 'Single document', })} - )} - -
    - - - -
    + {indexPattern.isTimeBased() && indexPattern.id && ( + + + {i18n.translate('discover.grid.tableRow.viewSurroundingDocumentsLinkTextSimple', { + defaultMessage: 'Surrounding documents', + })} + + + )} +
    +
    + + { + onClose(); + onFilter(mapping, value, mode); + }} + onRemoveColumn={(columnName: string) => { + onClose(); + onRemoveColumn(columnName); + }} + onAddColumn={(columnName: string) => { + onClose(); + onAddColumn(columnName); + }} + /> + +
    + ); } From 1c23410dc677ee7569e9d7c5efcae1efb08870f7 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 22 Dec 2020 11:41:04 +0100 Subject: [PATCH 180/186] Implement row highlighting when flyout is displayed --- .../discover_grid/discover_grid.tsx | 1 + .../discover_grid/discover_grid_context.tsx | 1 + .../discover_grid_expand_button.test.tsx | 30 +++++++++++++++++-- .../discover_grid_expand_button.tsx | 26 +++++++++++----- .../discover_grid/get_render_cell_value.tsx | 23 ++++++++++++-- 5 files changed, 69 insertions(+), 12 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index b5d0b62be420e..07fe306bdb6f3 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -249,6 +249,7 @@ export const DiscoverGrid = ({ rows: rows || [], onFilter, indexPattern, + isDarkMode: services.uiSettings.get('theme:darkMode'), }} > <> diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx index 5f4ba9658b909..dcc404a0e48df 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx @@ -26,6 +26,7 @@ export interface GridContext { rows: ElasticSearchHit[]; onFilter: DocViewFilterFn; indexPattern: IndexPattern; + isDarkMode: boolean; } const defaultContext = ({} as unknown) as GridContext; diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx index bd1fd06159cec..82fcad8c2cd6f 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.test.tsx @@ -32,11 +32,19 @@ describe('Discover grid view button ', function () { rows: esHits, onFilter: jest.fn(), indexPattern: indexPatternMock, + isDarkMode: false, }; const component = mountWithIntl( - + ); const button = findTestSubject(component, 'docTableExpandToggleColumn'); @@ -50,11 +58,19 @@ describe('Discover grid view button ', function () { rows: esHits, onFilter: jest.fn(), indexPattern: indexPatternMock, + isDarkMode: false, }; const component = mountWithIntl( - + ); const button = findTestSubject(component, 'docTableExpandToggleColumn'); @@ -68,11 +84,19 @@ describe('Discover grid view button ', function () { rows: esHits, onFilter: jest.fn(), indexPattern: indexPatternMock, + isDarkMode: false, }; const component = mountWithIntl( - + ); const button = findTestSubject(component, 'docTableExpandToggleColumn'); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx index 5be6100838f5a..d4a3fe85e34ef 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_expand_button.tsx @@ -16,18 +16,30 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useContext } from 'react'; -import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; +import React, { useContext, useEffect } from 'react'; +import { EuiButtonIcon, EuiDataGridCellValueElementProps, EuiToolTip } from '@elastic/eui'; +import themeDark from '@elastic/eui/dist/eui_theme_dark.json'; +import themeLight from '@elastic/eui/dist/eui_theme_light.json'; import { i18n } from '@kbn/i18n'; import { DiscoverGridContext } from './discover_grid_context'; - /** * Button to expand a given row */ -export const ExpandButton = ({ rowIndex }: { rowIndex: number }) => { - const { expanded, setExpanded, rows } = useContext(DiscoverGridContext); - +export const ExpandButton = ({ rowIndex, setCellProps }: EuiDataGridCellValueElementProps) => { + const { expanded, setExpanded, rows, isDarkMode } = useContext(DiscoverGridContext); const current = rows[rowIndex]; + useEffect(() => { + if (expanded && current && expanded._id === current._id) { + setCellProps({ + style: { + backgroundColor: isDarkMode ? themeDark.euiColorHighlight : themeLight.euiColorHighlight, + }, + }); + } else { + setCellProps({ style: undefined }); + } + }, [expanded, current, setCellProps, isDarkMode]); + const isCurrentRowExpanded = current === expanded; const buttonLabel = i18n.translate('discover.grid.viewDoc', { defaultMessage: 'Toggle dialog with details', @@ -43,7 +55,7 @@ export const ExpandButton = ({ rowIndex }: { rowIndex: number }) => { onClick={() => setExpanded(isCurrentRowExpanded ? undefined : current)} color={isCurrentRowExpanded ? 'primary' : 'subdued'} iconType={isCurrentRowExpanded ? 'minimize' : 'expand'} - isSelected={isCurrentRowExpanded ? true : false} + isSelected={isCurrentRowExpanded} /> ); diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx index dd8ba679c674b..05b19d7a59acf 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx @@ -16,7 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -import React, { Fragment } from 'react'; +import React, { Fragment, useContext, useEffect } from 'react'; +import themeLight from '@elastic/eui/dist/eui_theme_light.json'; +import themeDark from '@elastic/eui/dist/eui_theme_dark.json'; + import { EuiDataGridCellValueElementProps, EuiDescriptionList, @@ -25,13 +28,29 @@ import { } from '@elastic/eui'; import { IndexPattern } from '../../../kibana_services'; import { ElasticSearchHit } from '../../doc_views/doc_views_types'; +import { DiscoverGridContext } from './discover_grid_context'; export const getRenderCellValueFn = ( indexPattern: IndexPattern, rows: ElasticSearchHit[] | undefined -) => ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { +) => ({ rowIndex, columnId, isDetails, setCellProps }: EuiDataGridCellValueElementProps) => { const row = rows ? (rows[rowIndex] as Record) : undefined; const field = indexPattern.fields.getByName(columnId); + const ctx = useContext(DiscoverGridContext); + + useEffect(() => { + if (ctx.expanded && row && ctx.expanded._id === row._id) { + setCellProps({ + style: { + backgroundColor: ctx.isDarkMode + ? themeDark.euiColorHighlight + : themeLight.euiColorHighlight, + }, + }); + } else { + setCellProps({ style: undefined }); + } + }, [ctx, row, setCellProps]); if (typeof row === 'undefined') { return -; From 3836c15cf4abf3ca315afdf55f07e4aeab685305 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 22 Dec 2020 12:00:04 +0100 Subject: [PATCH 181/186] Fix TypeScript errors --- .../discover_grid/discover_grid_cell_actions.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx index c121dc5302234..a85583f66c6fa 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_cell_actions.test.tsx @@ -34,6 +34,7 @@ describe('Discover cell actions ', function () { rows: esHits, onFilter: jest.fn(), indexPattern: indexPatternMock, + isDarkMode: false, }; const component = mountWithIntl( @@ -58,6 +59,7 @@ describe('Discover cell actions ', function () { rows: esHits, onFilter: jest.fn(), indexPattern: indexPatternMock, + isDarkMode: false, }; const component = mountWithIntl( From c0eadc987c475de0197a47cd80bf9a345bb2887b Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 22 Dec 2020 14:09:14 +0100 Subject: [PATCH 182/186] Fix embeddable --- .../discover/public/application/embeddable/search_embeddable.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 51d300fdd17fd..e4a8ab7bc67ff 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -43,6 +43,7 @@ import { getSortForSearchSource } from '../angular/doc_table'; import { getRequestInspectorStats, getResponseInspectorStats, + getServices, IndexPattern, ISearchSource, } from '../../kibana_services'; From 61774d3254b330e0bfcc2ea87d6f500a2eb9fba7 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 22 Dec 2020 16:50:37 +0100 Subject: [PATCH 183/186] Improve schema for objects and geo_point data --- .../components/discover_grid/constants.ts | 2 + .../discover_grid/discover_grid.tsx | 13 ++++-- .../discover_grid_columns.test.tsx | 14 +++--- .../discover_grid/discover_grid_schema.tsx | 21 ++++++++- .../get_render_cell_value.test.tsx | 30 ++++++++++--- .../discover_grid/get_render_cell_value.tsx | 44 ++++++++++++++++--- 6 files changed, 99 insertions(+), 25 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/constants.ts b/src/plugins/discover/public/application/components/discover_grid/constants.ts index 3ca1e9f05bbd0..dec483da8f8a1 100644 --- a/src/plugins/discover/public/application/components/discover_grid/constants.ts +++ b/src/plugins/discover/public/application/components/discover_grid/constants.ts @@ -16,8 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +// data types export const kibanaJSON = 'kibana-json'; export const geoPoint = 'geo-point'; +export const unknownType = 'unknown'; export const gridStyle = { border: 'all', fontSize: 's', diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx index 07fe306bdb6f3..9588f74ed2bc2 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx @@ -197,10 +197,15 @@ export const DiscoverGrid = ({ /** * Cell rendering */ - const renderCellValue = useMemo(() => getRenderCellValueFn(indexPattern, rows), [ - rows, - indexPattern, - ]); + const renderCellValue = useMemo( + () => + getRenderCellValueFn( + indexPattern, + rows, + rows ? rows.map((hit) => indexPattern.flattenHit(hit)) : [] + ), + [rows, indexPattern] + ); /** * Render variables diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx index 5b5b8e27e201c..dad7e1363fdd9 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.test.tsx @@ -38,7 +38,7 @@ describe('Discover grid columns ', function () { "display": undefined, "id": "extension", "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, Object { "actions": Object { @@ -53,7 +53,7 @@ describe('Discover grid columns ', function () { "display": undefined, "id": "message", "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, ] `); @@ -78,7 +78,7 @@ describe('Discover grid columns ', function () { "display": undefined, "id": "extension", "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, Object { "actions": Object { @@ -90,7 +90,7 @@ describe('Discover grid columns ', function () { "display": undefined, "id": "message", "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, ] `); @@ -116,7 +116,7 @@ describe('Discover grid columns ', function () { "id": "timestamp", "initialWidth": 180, "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, Object { "actions": Object { @@ -131,7 +131,7 @@ describe('Discover grid columns ', function () { "display": undefined, "id": "extension", "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, Object { "actions": Object { @@ -146,7 +146,7 @@ describe('Discover grid columns ', function () { "display": undefined, "id": "message", "isSortable": undefined, - "schema": "json", + "schema": "unknown", }, ] `); diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx index fdd1611bb0a57..aa87d3982fa06 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_schema.tsx @@ -18,7 +18,7 @@ */ import React, { ReactNode } from 'react'; import { EuiCodeBlock } from '@elastic/eui'; -import { geoPoint, kibanaJSON } from './constants'; +import { geoPoint, kibanaJSON, unknownType } from './constants'; import { KBN_FIELD_TYPES } from '../../../../../data/common'; export function getSchemaByKbnType(kbnType: string | undefined) { @@ -39,7 +39,7 @@ export function getSchemaByKbnType(kbnType: string | undefined) { case KBN_FIELD_TYPES.GEO_POINT: return geoPoint; default: - return 'json'; + return unknownType; } } @@ -55,6 +55,16 @@ export function getSchemaDetectors() { icon: '', color: '', }, + { + type: unknownType, + detector() { + return 0; // this schema is always explicitly defined + }, + sortTextAsc: '', + sortTextDesc: '', + icon: '', + color: '', + }, { type: geoPoint, detector() { @@ -75,6 +85,13 @@ export function getPopoverContents() { [geoPoint]: ({ children }: { children: ReactNode }) => { return {children}; }, + [unknownType]: ({ children }: { children: ReactNode }) => { + return ( + + {children} + + ); + }, [kibanaJSON]: ({ children }: { children: ReactNode }) => { return ( diff --git a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx index 617bd2bd7b8b5..d9896f4c53907 100644 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.test.tsx @@ -32,7 +32,11 @@ const rows = [ describe('Discover grid cell rendering', function () { it('renders bytes column correctly', () => { - const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const DiscoverGridCellValue = getRenderCellValueFn( + indexPatternMock, + rows, + rows.map((row) => indexPatternMock.flattenHit(row)) + ); const component = shallow( 100
    "`); }); it('renders _source column correctly', () => { - const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const DiscoverGridCellValue = getRenderCellValueFn( + indexPatternMock, + rows, + rows.map((row) => indexPatternMock.flattenHit(row)) + ); const component = shallow( { - const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const DiscoverGridCellValue = getRenderCellValueFn( + indexPatternMock, + rows, + rows.map((row) => indexPatternMock.flattenHit(row)) + ); const component = shallow( { - const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const DiscoverGridCellValue = getRenderCellValueFn( + indexPatternMock, + rows, + rows.map((row) => indexPatternMock.flattenHit(row)) + ); const component = shallow( -
    "`); }); it('renders correctly when invalid column is given', () => { - const DiscoverGridCellValue = getRenderCellValueFn(indexPatternMock, rows); + const DiscoverGridCellValue = getRenderCellValueFn( + indexPatternMock, + rows, + rows.map((row) => indexPatternMock.flattenHit(row)) + ); const component = shallow( > ) => ({ rowIndex, columnId, isDetails, setCellProps }: EuiDataGridCellValueElementProps) => { const row = rows ? (rows[rowIndex] as Record) : undefined; + const rowFlattened = rowsFlattened + ? (rowsFlattened[rowIndex] as Record) + : undefined; + const field = indexPattern.fields.getByName(columnId); const ctx = useContext(DiscoverGridContext); @@ -52,16 +58,15 @@ export const getRenderCellValueFn = ( } }, [ctx, row, setCellProps]); - if (typeof row === 'undefined') { + if (typeof row === 'undefined' || typeof rowFlattened === 'undefined') { return -; } - if (isDetails && typeof row[columnId] === 'object') { - // nicely formatted JSON for the expanded view - return {JSON.stringify(row[columnId], null, 2)}; - } - if (field && field.type === '_source') { + if (isDetails) { + // nicely formatted JSON for the expanded view + return {JSON.stringify(row[columnId], null, 2)}; + } const formatted = indexPattern.formatHit(row); return ( @@ -75,6 +80,31 @@ export const getRenderCellValueFn = ( ); } + + if (!field?.type && rowFlattened && typeof rowFlattened[columnId] === 'object') { + if (isDetails) { + // nicely formatted JSON for the expanded view + return {JSON.stringify(rowFlattened[columnId], null, 2)}; + } + + return {JSON.stringify(rowFlattened[columnId])}; + } + + if (field?.type === 'geo_point' && rowFlattened && rowFlattened[columnId]) { + const valueFormatted = rowFlattened[columnId] as { lat: number; lon: number }; + return ( +
    + {i18n.translate('discover.latitudeAndLongitude', { + defaultMessage: 'Lat: {lat} Lon: {lon}', + values: { + lat: valueFormatted?.lat, + lon: valueFormatted?.lon, + }, + })} +
    + ); + } + const valueFormatted = indexPattern.formatField(row, columnId); if (typeof valueFormatted === 'undefined') { return -; From 5847ad9a5a11fff33ab75732cb3dd5e89676d527 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 22 Dec 2020 17:19:40 +0100 Subject: [PATCH 184/186] Fix functional test --- .../components/discover_grid/discover_grid_flyout.tsx | 6 +++--- test/functional/apps/discover/_data_grid_doc_navigation.ts | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx index 91de00d1f940c..79ad98ae2babe 100644 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx @@ -124,16 +124,16 @@ export function DiscoverGridFlyout({ columns={columns} indexPattern={indexPattern} filter={(mapping, value, mode) => { - onClose(); onFilter(mapping, value, mode); + onClose(); }} onRemoveColumn={(columnName: string) => { - onClose(); onRemoveColumn(columnName); + onClose(); }} onAddColumn={(columnName: string) => { - onClose(); onAddColumn(columnName); + onClose(); }} /> diff --git a/test/functional/apps/discover/_data_grid_doc_navigation.ts b/test/functional/apps/discover/_data_grid_doc_navigation.ts index fff37765e55ac..92d9893cab0b6 100644 --- a/test/functional/apps/discover/_data_grid_doc_navigation.ts +++ b/test/functional/apps/discover/_data_grid_doc_navigation.ts @@ -79,7 +79,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ); expect(hasInclusiveFilter).to.be(true); - await dataGrid.removeInclusiveFilter(details, 'referer'); + await dataGrid.clickRowToggle({ rowIndex: 0 }); + const detailsExcluding = await dataGrid.getDetailsRow(); + await dataGrid.removeInclusiveFilter(detailsExcluding, 'referer'); await PageObjects.discover.waitUntilSearchingHasFinished(); const hasExcludeFilter = await filterBar.hasFilter('referer', 'exists', true, false, false); expect(hasExcludeFilter).to.be(true); From 46f60d704e966773969c0f033065996b6b18c992 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 22 Dec 2020 23:06:36 +0100 Subject: [PATCH 185/186] Move embeddable functional tests to dashboard --- .../embeddable_data_grid.ts} | 4 ++-- test/functional/apps/dashboard/index.ts | 1 + test/functional/apps/discover/index.ts | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) rename test/functional/apps/{discover/_data_grid_dashboard.ts => dashboard/embeddable_data_grid.ts} (97%) diff --git a/test/functional/apps/discover/_data_grid_dashboard.ts b/test/functional/apps/dashboard/embeddable_data_grid.ts similarity index 97% rename from test/functional/apps/discover/_data_grid_dashboard.ts rename to test/functional/apps/dashboard/embeddable_data_grid.ts index d7d1da969657b..2f2c5310c7e4c 100644 --- a/test/functional/apps/discover/_data_grid_dashboard.ts +++ b/test/functional/apps/dashboard/embeddable_data_grid.ts @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); - describe('discover data grid dashboard', () => { + describe('dashboard embeddable data grid', () => { before(async () => { await esArchiver.loadIfNeeded('logstash_functional'); await esArchiver.loadIfNeeded('dashboard/current/data'); @@ -46,7 +46,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('saved search filters', function () { it('are added when a cell filter is clicked', async function () { - await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); + await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search-datagrid'); await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`); await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`); await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`); diff --git a/test/functional/apps/dashboard/index.ts b/test/functional/apps/dashboard/index.ts index 6fb5f874022a0..43ad1aad5de00 100644 --- a/test/functional/apps/dashboard/index.ts +++ b/test/functional/apps/dashboard/index.ts @@ -54,6 +54,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./empty_dashboard')); loadTestFile(require.resolve('./url_field_formatter')); loadTestFile(require.resolve('./embeddable_rendering')); + loadTestFile(require.resolve('./embeddable_data_grid')); loadTestFile(require.resolve('./create_and_add_embeddables')); loadTestFile(require.resolve('./edit_embeddable_redirects')); loadTestFile(require.resolve('./edit_visualizations')); diff --git a/test/functional/apps/discover/index.ts b/test/functional/apps/discover/index.ts index a6656a52a4f20..450049af66abf 100644 --- a/test/functional/apps/discover/index.ts +++ b/test/functional/apps/discover/index.ts @@ -56,6 +56,5 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./_data_grid_field_data')); loadTestFile(require.resolve('./_data_grid_doc_navigation')); loadTestFile(require.resolve('./_data_grid_doc_table')); - loadTestFile(require.resolve('./_data_grid_dashboard')); }); } From 71d943ff0f036500f492952a98648b7dc20f1905 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 23 Dec 2020 06:37:35 +0100 Subject: [PATCH 186/186] Hopefully fix functional test --- test/functional/apps/dashboard/embeddable_data_grid.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/dashboard/embeddable_data_grid.ts b/test/functional/apps/dashboard/embeddable_data_grid.ts index 2f2c5310c7e4c..067536ab7aa93 100644 --- a/test/functional/apps/dashboard/embeddable_data_grid.ts +++ b/test/functional/apps/dashboard/embeddable_data_grid.ts @@ -46,9 +46,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('saved search filters', function () { it('are added when a cell filter is clicked', async function () { - await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search-datagrid'); + await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`); await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`); + await PageObjects.header.waitUntilLoadingHasFinished(); await find.clickByCssSelector(`[role="gridcell"]:nth-child(2)`); await find.clickByCssSelector(`[data-test-subj="filterForButton"]`); const filterCount = await filterBar.getFilterCount();