From e6671e5210b44e723de52353d2d2da74e6451e57 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Tue, 14 Jan 2020 16:40:27 -0500 Subject: [PATCH 001/158] 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 f19728a52dd70b..1ab1885fe01d28 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 1cefabe08c2d57..351b52f8b0322c 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 0da28e41579aed..534c95f460d71f 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 c65243d99c8f49..d4b365547b40c5 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 45490ac7adc0f0..66125b9eace093 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 78ac99567d10e8..99b63b6abd7362 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 459dcfb30d17b9..39bdbc93ab7cee 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 0491430e5fddde..4097ad6fb95f0c 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 00000000000000..999e0d69e2480a --- /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 00000000000000..23823ab78fa9ed --- /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 00000000000000..c861ed9ec18fcb --- /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 00000000000000..b06d9e6570561b --- /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 68594cbe538cfc..5840ebc92578c7 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 6ed3c2be8f96e4..ee14f4bb76e875 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 e3482dd4830357..a6a88066169541 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/158] 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 4097ad6fb95f0c..56703ebf595d9a 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/158] 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 534c95f460d71f..43cb937c5b4a8a 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 66125b9eace093..35eee2b8f26569 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 6d1b7a7f33d235..bcd75746152197 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 02a4f10a543c4a..c5bf6ef8353a2c 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/158] 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 43cb937c5b4a8a..5f5d2c3f22d81e 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 b06d9e6570561b..0ecef05559d03e 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 e25d2955159710..f9ca006ec0cffd 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 aabce6baa87835..b405f85571e64d 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 b99de9fee6db19..74bfeac786b052 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 432e83891aa928..db8d98f6934a72 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 65291c3c4772c5..4c43468c8f0b9b 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 e92780143f09a6..27391c5678c24b 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 5761369f9e4685..dde4d8ab846bfe 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/158] 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 0ecef05559d03e..a3de5637fded6b 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/158] 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 03945f4ed8642d..730a2f88c5eb72 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 74bfeac786b052..094119c879913a 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 db8d98f6934a72..6da5cab8b5d173 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 62d42f3da5c846..e90e05776cf930 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 ece289b4a666ee..333ba96a0253cf 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/158] 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 a3de5637fded6b..76f7602d80a32a 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 c5bf6ef8353a2c..778056a9ee0eb0 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 094119c879913a..ec8c506fb7fa9e 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 00000000000000..75d8980e7e94f6 --- /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 a5052b2403074c..9fb73e6020d729 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 64a5a61335365e..82b94fafc8af0f 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 85d8cff675f2d0..310dc7dba4bc0e 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 16e9d755bf261b..a39f6ea3c95819 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/158] 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 b9172990c501dc..9f31112a83ef67 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 75d8980e7e94f6..64391d2e2c68d9 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 d7fc267ab1d5ea..e6f6838f1efaac 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 310dc7dba4bc0e..b1830557b1b59f 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/158] 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 23823ab78fa9ed..2a6d3dfb3ef342 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 76f7602d80a32a..6a23ad492f1f4c 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/158] 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 9b06b9ac84cfdb..341c47bc55957f 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/158] 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 b405f85571e64d..1a849459837b51 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 9f31112a83ef67..b807de205fab56 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 341c47bc55957f..06c0620b1925c8 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 0bb6848db4d102..edaa4d03eb0686 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 e6f6838f1efaac..f9f69a2b03f537 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 27391c5678c24b..d4ea370690b44a 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 9acb90801ce25a..94203c9bd902c6 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 bd90ad6e18dd35..32d75c834c90b7 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/158] 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 6a23ad492f1f4c..ab91884f81710f 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/158] 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 bcd75746152197..d8e604460732e5 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 3329ffc7cd102a..0d199e22a02fc9 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 ab91884f81710f..900d9274b29824 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/158] 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 64391d2e2c68d9..83f40a489eca7e 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 f9f69a2b03f537..9c52664f5cf850 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 b1830557b1b59f..85d8cff675f2d0 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/158] 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 8a10a2bde3b440..3cac100a25bd93 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/158] 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 5f5d2c3f22d81e..fbe0fcfea625a9 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 f8a3e67a0f5f59..08710ea19db2cb 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 8789847058affb..eb50d15fd3076d 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/158] 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 95dcb0fbc678a6..9d14998d88d5f6 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 f148064f71e1f4..fa19f2c485154d 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/158] 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 fa19f2c485154d..4065e34d351782 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/158] 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 4065e34d351782..f451d0245a1941 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/158] 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 832210be1b3350..53e7bc6a816a6a 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 6c0ac5af3abd46..6b1dc729906f21 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/158] 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 53e7bc6a816a6a..ef2b7e7c06a255 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/158] 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 f451d0245a1941..fa469646dce782 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/158] 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 6a2842a0e4c5c8..302fdd32fa6140 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/158] 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 fa469646dce782..5b35e3f219378b 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 00000000000000..ec3a8f4ee15217 --- /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 00000000000000..1eeb791c992333 --- /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/158] 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 1112777f8c3efd..3adc1b984f6941 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 9d14998d88d5f6..3190a486b6464f 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 5b35e3f219378b..d9f24e8963f13c 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/158] 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 6732eddd0f5457..60e7f867a50098 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 d9f24e8963f13c..18d94ecbae840e 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 00000000000000..0a558cdd4b9759 --- /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/158] 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 18d94ecbae840e..1cd429ee54c1ef 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/158] 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 1cd429ee54c1ef..20087a176196a2 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/158] 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 20087a176196a2..83c62e86db777f 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/158] 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 83c62e86db777f..0cc0b1a7409cbe 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/158] 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 d4babf1216c6da..40797ce0d707d0 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 0cc0b1a7409cbe..cbf661dacd269d 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 ec3a8f4ee15217..f600ae8113a9d6 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 00000000000000..10251b5d249032 --- /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/158] 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 cbf661dacd269d..fe806e19daae92 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 00000000000000..db4ea05178d77a --- /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 f600ae8113a9d6..378c03d02cf102 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 10251b5d249032..00000000000000 --- 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 00000000000000..56f725ddcc1707 --- /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 1eeb791c992333..3cbb8a972ccc9b 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 00000000000000..858a30a7ebc7be --- /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 00000000000000..bc1d222bd7fdcd --- /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 00000000000000..0608e541a11944 --- /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 00000000000000..35772186bc1125 --- /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/158] 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 5d8969a78f0182..e42139ac95addb 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 48a8442b063160..1f3aa82c9d62a6 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 60e7f867a50098..c91df8936c5460 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 00000000000000..6b6c3eb289667f --- /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 00000000000000..7d098bd400a517 --- /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 40797ce0d707d0..066f6e6cfc0c6f 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 fe806e19daae92..4d4a796d432dc8 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 3cbb8a972ccc9b..13afa61472f1ed 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 880a493983adfa..d9cad8e30bac0b 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 0206bc48257ac3..79a9f11e6cb50f 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 75c83e30d80ad3..2f9c58c5ab84cc 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 0b03220329d0c3..a204f0be626e83 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/158] 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 7d098bd400a517..d2001de0905a1d 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/158] 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 2a3b12342165b7..4751a1d760d3e1 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 c91df8936c5460..fbcb9cd7edd1ac 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/158] 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 746966b754f320..68954fb32c0569 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 4d4a796d432dc8..1bc6bc20785b10 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 00000000000000..87cb5c90993305 --- /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 0a558cdd4b9759..2f442fcac3934a 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/158] 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 43eee31999e62d..d0ac9d6f798628 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 b7c7736201dd72..f00261e00971aa 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 4751a1d760d3e1..6789ef0d33de9c 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 d2001de0905a1d..ba5a881b7affa9 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/158] 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 4751a1d760d3e1..42ae41898ec49a 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 d2001de0905a1d..ad7d2e0bbbc1fd 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/158] 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 3f1dc9385971c4..4bb68395259812 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 2f442fcac3934a..9eef5dadb21603 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 20e13d204e0e9e..5b1d8840518f35 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 45ab0a62b03b32..b754c34b490bf8 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/158] 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 4bb68395259812..283ce007683b0f 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 13afa61472f1ed..2d98c9a5b6df02 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/158] 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 ba5a881b7affa9..a8f591a5633588 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/158] 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 a5d1de681e2e51..b280ebcdc78013 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/158] 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 7b2e26395808ce..4189d13b55cff7 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/158] 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 4189d13b55cff7..10272ca748e32c 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 00000000000000..ec6a213694a4bb --- /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 b280ebcdc78013..6b09fe705905ed 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/158] 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 6b09fe705905ed..4c000759c8182f 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/158] 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 0367cbe6bae26b..22aaa5b2b69c63 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 e348ee7e24f492..5f239a6034652a 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 d470e13d493d84..a37da1b2dccdc5 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 867ef297cb76fb..98cf36efe94d55 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 0a03b868f6a1ee..95f3c8dad886f3 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 b754c34b490bf8..8f62e03518253b 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 03d794e16ea564..b44859137ee379 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 8387c6dd6bcf62..415df99244aef1 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 516a2618140d81..3aa68e790b57ae 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 53eb93a075f710..16391ff9b4be27 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 7011c8eac0c8bf..d9fe308be6c74c 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 5b163aaacf3fe0..dfcfa40df9f0ff 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 35c1c255d3f331..f6c6aac6363092 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 5ea759f11912ae..f453345bedbf66 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/158] 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 56f725ddcc1707..6730e2c0762c13 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/158] 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 a37da1b2dccdc5..82ad3637481572 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 fbcb9cd7edd1ac..9d347a77414287 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 6b6c3eb289667f..091951b44a1769 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 4c000759c8182f..a1c47a57044291 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 3190a486b6464f..5d03511b9c8aca 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 283ce007683b0f..f65d4e64c9398a 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 9eef5dadb21603..6619fd414103eb 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 98cf36efe94d55..db41651048d392 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 2b8574a8fa1183..685bb1860c7002 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 d601d087afcee8..397d2ec85afaf2 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 c13550e543ab60..c0015521106625 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/158] 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 378c03d02cf102..0d81584ba4ce75 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 5f7dd9f37dcd3d..699197e90b994b 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 bd842eb5c6f72a..142761768b4720 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 dab22c103bc48e..43a711fc72da52 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 bbef54cb4ecc77..878088ae0a6d8f 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 3e5a0579297016..1a32ba3be1712f 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/158] 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 0d81584ba4ce75..f2987fcec7fe94 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/158] 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 5d03511b9c8aca..db7ce7b4e14844 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 b38b931068d989..6de904c000dd99 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/158] 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 db7ce7b4e14844..548d8f0e768675 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 91060c4d3db832..c109cbfb68f1cc 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 f65d4e64c9398a..841c3b54acb25e 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 00000000000000..a38632874ab04f --- /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 6619fd414103eb..3907ff23e63fe7 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 6de904c000dd99..89c09141bb307c 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 84187c48370ebd..93fe85a7a3d381 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/158] 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 a1c47a57044291..02d61092ce0642 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 800b9d334caa8e..76b25a6548833b 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/158] 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 82ad3637481572..5062c823bcacb7 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 9d347a77414287..2be87c7b7ab837 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 091951b44a1769..4c26231a2ba066 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 02d61092ce0642..ff64dc29109d59 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 841c3b54acb25e..ef93d2af92e877 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/158] 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 c109cbfb68f1cc..b14775a36832bf 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 ef93d2af92e877..5315f9578a9fd6 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 f2987fcec7fe94..b070b2846c268d 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 858a30a7ebc7be..7c1069bea2f178 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/158] 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 ff64dc29109d59..715b12f887849f 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 f6d4751e81438f..2b0c55e696c11a 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/158] 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 10272ca748e32c..142c604c34c073 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 715b12f887849f..598dc309f2fa53 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 00000000000000..9afc3d86b94eae --- /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 1b837840b52f69..414ce56a6e4fd4 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/158] 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 ec6a213694a4bb..d7c54dbec8599f 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 598dc309f2fa53..acd76921e82bd8 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/158] 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 142c604c34c073..f72bf9f0ed3d1c 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 d7c54dbec8599f..a0a5e7884a3e6a 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 acd76921e82bd8..070dfdd3d777dc 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 bb330cba68e2e6..7930c337e5ba35 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 9b33af526b5df1..9bf1c71a8505ec 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/158] 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 070dfdd3d777dc..2ae5fbbd7e80aa 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 3907ff23e63fe7..c4f17643eb9818 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 7930c337e5ba35..99f03cea28a1be 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 0a3855f9cd776c..10e92f7a5a8ff9 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/158] 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 2ae5fbbd7e80aa..fc0f3a0a734e88 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 da8646383003a9..a4d7c449d8a7e1 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 10e92f7a5a8ff9..5a243639b29fc8 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/158] 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 f72bf9f0ed3d1c..d4b3fca1699480 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 a0a5e7884a3e6a..50ede048e72d0a 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 fc0f3a0a734e88..adba018831ff55 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 a4d7c449d8a7e1..7b233fb5e0d5a6 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 5a243639b29fc8..6c7f06cc8aa05a 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 414ce56a6e4fd4..15781236541fb3 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/158] 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 d20f0ad079e005..834a708ab8688e 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/158] 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 834a708ab8688e..5691d1010f4d08 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 5ddb6a92b5fd48..a759bf3c627cda 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 73ae691529e2b4..2605ec5bf67456 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/158] 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 adba018831ff55..b0e5271f5fb79d 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 c4f17643eb9818..3907ff23e63fe7 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 7b233fb5e0d5a6..0a083ef38aee8e 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/158] 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 729c4cdd9d49cc..0306466b700cfb 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 7ea945e820bf99..85b23ffc797679 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 f4dcb8ae3844ee..ea90a950bbc38c 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/158] 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 ea90a950bbc38c..039f10939abb9a 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 b070b2846c268d..1ba17f6936ac97 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 0a083ef38aee8e..8c04aa70e818a9 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 699197e90b994b..f121b5f5a553e0 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/158] 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 f121b5f5a553e0..95ed759501389e 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/158] 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 039f10939abb9a..b7987dbe4cb8db 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 d1f8440dfa009d..79390d1417ae0c 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/158] 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 b7987dbe4cb8db..c8917c40989188 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/158] 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 79390d1417ae0c..2e770302f2bd06 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/158] 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 99dad418c04bdd..57c71a2bd6a552 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 8c04aa70e818a9..4cdee4d4dd1e08 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/158] 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 0306466b700cfb..41f5caaa0977c6 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 9c3d833d73b237..aa341de1d113e8 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/158] 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 aa341de1d113e8..b11faf85d303fb 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/158] 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 c8917c40989188..d92414708cd869 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 2e770302f2bd06..a3977f16bf79f3 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 b75e2980c78761..00000000000000 --- 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 00000000000000..a3d04ed425493d --- /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 dced08d5a3c318..7575b5691a95aa 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/158] 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 a3d04ed425493d..b6622e168ba058 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/158] 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 41f5caaa0977c6..4907a67dfa1d72 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 50ede048e72d0a..e633c30bcfddc8 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 d92414708cd869..976c066cae2b25 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 b9318d83ef70b0..8c27416fee3674 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/158] 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 4907a67dfa1d72..1fa54471d9ebeb 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 85b23ffc797679..5778cbfa3ba7f3 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 976c066cae2b25..a99a5228af7e41 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 8c27416fee3674..1e87c29c0b2e4f 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/158] 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 1fa54471d9ebeb..ad8d3b88d5a117 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 73e2062b3ee9dc..c132e8c863f362 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 9074de1b5b3d1a..ecbc6a48ea8161 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/158] 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 1d38d0fc534d1e..e91e15497f64c8 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/158] 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 5691d1010f4d08..5c6877107a2588 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 e91e15497f64c8..d8fa990d0701a3 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 1e87c29c0b2e4f..d71d4169e3e8e1 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/158] 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 ad8d3b88d5a117..2c71886ab3d6f9 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 d71d4169e3e8e1..6450b9933a7953 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/158] 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 2c71886ab3d6f9..ad8d3b88d5a117 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/158] 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 14d2a96d609ccd..c64b4fcd3a79f4 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 625d6833406eb8..ab8a720ef6b128 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 4a3b2b75cdc459..63a0a897004206 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/158] 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 6575a9f935bee2..50d8525c3fb640 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 a3977f16bf79f3..c6f289889bee2f 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/158] 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 ad8d3b88d5a117..a86972d29ae2fb 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 05be5bef79852f..c8bb0082a98815 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/158] 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 e4314426bfce53..7ec0a6027474da 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/158] 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 c64b4fcd3a79f4..dc28e0e3564aa1 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 0d61b6ae2750d4..52b08c8234b37b 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/158] 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 50d8525c3fb640..50f6abbd941eaa 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 a38632874ab04f..00000000000000 --- 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 dc28e0e3564aa1..cfdbe16576effe 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 52b08c8234b37b..6f96e2f77ed381 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/158] 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 c6f289889bee2f..22a1f6e4354ab0 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/158] 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 7feaeef39653bd..d86f7f2eefe6b4 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 e3cc3967836282..b5a863aec4a0a5 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/158] 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 7fc120f9ea4745..dae83e8f41552f 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 60532c81493f9c..503a9158c1072a 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/158] 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 8a39d9df5eba53..5930af880a0bfd 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 2be87c7b7ab837..5569dc01dab1af 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 a759bf3c627cda..95f38274e158ac 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 4c26231a2ba066..4bce2a1e917e20 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 00000000000000..c526319f884a1f --- /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 d86f7f2eefe6b4..66539578005480 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 50f6abbd941eaa..c413601862dc60 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 cfdbe16576effe..18f68ea6276902 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 00000000000000..c5783c7f071947 --- /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 2b39b8569e558d..08d04fb82dae1a 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 48684cc614d918..444e34bec56910 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 f61fa361f0c0e6..d85476568201ff 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 93fe85a7a3d381..ff48a815e64d0f 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/158] 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 a86972d29ae2fb..b39072e224923a 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/158] 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 c413601862dc60..34e0019ab51703 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 db4ea05178d77a..ccd247de1bfe4b 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 00000000000000..2add74ae7ab286 --- /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 4b903a2f2d5c1b..b729244b5bf33b 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 7c1069bea2f178..00000000000000 --- 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 996a0175227fc2..17e2e07817b1f1 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 628045bd32f612..34a64dd7652749 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 6c90861e267278..016788870cb96f 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 834ad8b70ad0db..a56155db02f6b2 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 b13ca32601aa95..271fc75a0853ee 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 bfc4f881f84588..41d6db25da5e2a 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 d0a9c067e9da28..11b7c07acc2c29 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/158] 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 ae455c26fc5d3d..58cc61bbce96a7 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 b39072e224923a..a86972d29ae2fb 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/158] 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 71c74ee0f30ad0..082fd8fd1734ac 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 3d40f7b178dc5c..2ace65c31cc036 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/158] 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 b14775a36832bf..821445655d2cfe 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 34e0019ab51703..6cb59a3d364444 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 18f68ea6276902..d94b51db2fce29 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/158] 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 b6622e168ba058..45da33cdbd5c1f 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/158] 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 95f38274e158ac..f8960c38e990fb 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 082fd8fd1734ac..9ffbf2f3c2ee2c 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 6cb59a3d364444..f691f9b7c21b5e 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 1bc1d969fe5286..416c65f2713013 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/158] 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 9ca2bf6abf7956..00000000000000 --- 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 a38632874ab04f..00000000000000 --- 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/158] 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 2add74ae7ab286..989121de6706ec 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/158] 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 d94b51db2fce29..a6333b37af7c2c 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/158] 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 f691f9b7c21b5e..0efb34fbbb39b7 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 00000000000000..ef4befcf8dbebd --- /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 989121de6706ec..32c10be6014da6 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 b729244b5bf33b..00000000000000 --- 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 17e2e07817b1f1..00000000000000 --- 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 e823b1bde01fe9..4afd75a5096cbf 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/158] 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 9ffbf2f3c2ee2c..e25e70c73e62b7 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 0efb34fbbb39b7..7bcfc70c0350d7 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 ef4befcf8dbebd..24a68de0850959 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 437cfde95306b1..1bdb0b8e607bc6 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 32c10be6014da6..00000000000000 --- 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 50bdafef0d33ee..b8e8bb314dd559 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 7ec0a6027474da..e4314426bfce53 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 9663b9faf7b529..647746b98cbd18 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 3a6a5e66d7f958..beff9944a975fe 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 f4c6d7754417eeb620216e49653db203998b238e Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 18 Nov 2020 14:59:13 +0100 Subject: [PATCH 124/158] Extract layout changes --- docs/management/advanced-options.asciidoc | 4 - src/core/public/chrome/ui/header/_index.scss | 6 - src/plugins/discover/common/index.ts | 1 - .../public/application/_discover.scss | 6 - .../public/application/angular/discover.js | 38 +-- .../angular/discover_datagrid.html | 46 --- .../application/angular/discover_state.ts | 8 - .../components/create_discover_directive.ts | 61 ---- .../create_discover_grid_directive.tsx | 74 ----- .../application/components/discover.tsx | 268 ---------------- .../discover_grid/discover_grid.scss | 86 ----- .../discover_grid/discover_grid.tsx | 297 ------------------ .../discover_grid/discover_grid_columns.tsx | 46 --- .../discover_grid/discover_grid_context.tsx | 35 --- .../discover_grid/discover_grid_flyout.tsx | 125 -------- .../discover_grid/discover_grid_helpers.tsx | 219 ------------- .../discover_grid_view_button.tsx | 38 --- .../discover_grid/get_render_cell_value.tsx | 65 ---- .../components/discover_grid/types.ts | 29 -- .../components/discover_legacy.tsx | 1 + .../components/sidebar/lib/group_fields.tsx | 7 - .../embeddable/search_embeddable.ts | 10 +- .../embeddable/search_template_datagrid.html | 20 -- .../discover/public/get_inner_angular.ts | 6 +- .../public/saved_searches/_saved_search.ts | 3 - .../discover/public/saved_searches/types.ts | 2 - .../discover/server/saved_objects/search.ts | 1 - src/plugins/discover/server/ui_settings.ts | 13 - 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 +- test/functional/apps/discover/_data_grid.ts | 67 ---- test/functional/apps/discover/_date_nanos.js | 1 - .../apps/discover/_date_nanos_mixed.js | 1 - 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 | 1 - test/functional/apps/discover/index.js | 1 - .../apps/management/_scripted_fields.js | 1 - 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 +- 46 files changed, 8 insertions(+), 1609 deletions(-) delete mode 100644 src/plugins/discover/public/application/angular/discover_datagrid.html delete mode 100644 src/plugins/discover/public/application/components/create_discover_directive.ts delete mode 100644 src/plugins/discover/public/application/components/create_discover_grid_directive.tsx delete mode 100644 src/plugins/discover/public/application/components/discover.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid.scss delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx delete 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_context.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx delete mode 100644 src/plugins/discover/public/application/components/discover_grid/types.ts delete mode 100644 src/plugins/discover/public/application/embeddable/search_template_datagrid.html delete mode 100644 test/functional/apps/discover/_data_grid.ts diff --git a/docs/management/advanced-options.asciidoc b/docs/management/advanced-options.asciidoc index 3f0e25d5f940ea..dbac6997ff4333 100644 --- a/docs/management/advanced-options.asciidoc +++ b/docs/management/advanced-options.asciidoc @@ -262,10 +262,6 @@ Hides the "Time" column in *Discover* and in all saved searches on dashboards. Highlights results in *Discover* and saved searches on dashboards. Highlighting slows requests when working on big documents. -[[doctable-legacy]]`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]] ==== Machine learning diff --git a/src/core/public/chrome/ui/header/_index.scss b/src/core/public/chrome/ui/header/_index.scss index 58cc61bbce96a7..44cd8642783252 100644 --- a/src/core/public/chrome/ui/header/_index.scss +++ b/src/core/public/chrome/ui/header/_index.scss @@ -1,11 +1,5 @@ @include euiHeaderAffordForFixed; -.euiDataGrid__restrictBody { - .headerGlobalNav { - display: none; - } -} - .chrHeaderHelpMenu__version { text-transform: none; } diff --git a/src/plugins/discover/common/index.ts b/src/plugins/discover/common/index.ts index 680844e762540c..4334af63539e36 100644 --- a/src/plugins/discover/common/index.ts +++ b/src/plugins/discover/common/index.ts @@ -27,5 +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:legacy'; export const MODIFY_COLUMNS_ON_SWITCH = 'discover:modifyColumnsOnSwitch'; diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index a86972d29ae2fb..73e77c71ffe3c8 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -71,12 +71,6 @@ discover-app { height: $euiSize * 12.5; padding: $euiSizeS; } -// new slimmer layout for data grid -.dscHistogramGrid { - display: flex; - height: $euiSize * 8; - padding: $euiSizeS $euiSizeS 0 $euiSizeS; -} // SASSTODO: replace the z-index value with a variable .dscWrapper { diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 05acc01e28bcb8..1d4ada23d5756f 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -37,7 +37,6 @@ import { SavedObjectSaveModal, showSaveModal } from '../../../../saved_objects/p import { getSortArray, getSortForSearchSource } from './doc_table'; import * as columnActions from './doc_table/actions/columns'; import indexTemplateLegacy from './discover_legacy.html'; -import indexTemplateGrid from './discover_datagrid.html'; import { showOpenSearchPanel } from '../components/top_nav/show_open_search_panel'; import { addHelpMenuToAppChrome } from '../components/help_menu/help_menu_util'; import { discoverResponseHandler } from './response_handler'; @@ -74,7 +73,6 @@ import { popularizeField } from '../helpers/popularize_field'; import { getSwitchIndexPatternAppState } from '../helpers/get_switch_index_pattern_app_state'; import { getIndexPatternId } from '../helpers/get_index_pattern_id'; import { addFatalError } from '../../../../kibana_legacy/public'; -import rison from 'rison-node'; import { SAMPLE_SIZE_SETTING, SORT_DEFAULT_ORDER_SETTING, @@ -122,9 +120,7 @@ app.config(($routeProvider) => { }; const discoverRoute = { ...defaults, - template: getServices().uiSettings.get('doc_table:legacy', true) - ? indexTemplateLegacy - : indexTemplateGrid, + template: indexTemplateLegacy, reloadOnSearch: false, resolve: { savedObjects: function ($route, Promise) { @@ -342,8 +338,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab $scope.minimumVisibleRows = 50; $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; - $scope.useShortDots = config.get('shortDots:enable', false); - $scope.useNewGrid = config.get('doc_table:legacy', false); $scope.showTimeCol = !config.get('doc_table:hideTimeColumn', false) && $scope.indexPattern.timeFieldName; @@ -474,29 +468,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab }, }; - $scope.getContextAppHref = (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: (filterManager.getAppFilters() || []).map(esFilters.disableFilter), - }) - ); - return `${path}?${urlSearchParams.toString()}`; - }; - const inspectSearch = { id: 'inspect', label: i18n.translate('discover.localMenu.inspectTitle', { @@ -762,7 +733,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab await $scope.updateDataSource(); savedSearch.columns = $scope.state.columns; - savedSearch.grid = $scope.state.grid; savedSearch.sort = $scope.state.sort; try { @@ -1071,12 +1041,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab const columns = columnActions.moveColumn($scope.state.columns, columnName, newIndex); setAppState({ columns }); }; - - $scope.setColumns = function setColumns(columns) { - $scope.state = { ...$scope.state, columns }; - setAppState({ columns }); - }; - 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 deleted file mode 100644 index 5569dc01dab1af..00000000000000 --- a/src/plugins/discover/public/application/angular/discover_datagrid.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - diff --git a/src/plugins/discover/public/application/angular/discover_state.ts b/src/plugins/discover/public/application/angular/discover_state.ts index f8960c38e990fb..0c4a44073ea5c4 100644 --- a/src/plugins/discover/public/application/angular/discover_state.ts +++ b/src/plugins/discover/public/application/angular/discover_state.ts @@ -32,7 +32,6 @@ 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'; import { SortPairArr } from './doc_table/lib/get_sort'; export interface AppState { @@ -44,10 +43,6 @@ export interface AppState { * Array of applied filters */ filters?: Filter[]; - /** - * Data Grid related state - */ - grid?: DiscoverGridSettings; /** * id of the used index pattern */ @@ -221,9 +216,6 @@ export function getStateDefaults( interval: 'auto', filters: _.cloneDeep(searchSource.getOwnField('filter')) as Filter[], }; - 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 deleted file mode 100644 index 4bce2a1e917e20..00000000000000 --- a/src/plugins/discover/public/application/components/create_discover_directive.ts +++ /dev/null @@ -1,61 +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 } 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' }], - ['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/create_discover_grid_directive.tsx b/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx deleted file mode 100644 index c526319f884a1f..00000000000000 --- a/src/plugins/discover/public/application/components/create_discover_grid_directive.tsx +++ /dev/null @@ -1,74 +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 * 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 deleted file mode 100644 index e25e70c73e62b7..00000000000000 --- a/src/plugins/discover/public/application/components/discover.tsx +++ /dev/null @@ -1,268 +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 rison from 'rison-node'; -import classNames from 'classnames'; - -// import { EuiResizableContainer } from '@elastic/eui'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -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, 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, - fetch, - fetchCounter, - fetchError, - fieldCounts, - histogramData, - hits, - indexPattern, - onAddFilter, - onChangeInterval, - onRemoveColumn, - onSetColumns, - onSort, - opts, - resetQuery, - resultState, - rows, - searchSource, - setIndexPattern, - showSaveQuery, - state, - timefilterUpdateHandler, - timeRange, - topNavMenu, - updateQuery, - updateSavedQueryId, -}: DiscoverProps) { - const [toggleOn, toggleChart] = useState(true); - const [isSidebarClosed, setIsSidebarClosed] = useState(false); - const { trackUiMetric } = getServices(); - if (!timeRange) { - return

    Loading
    ; - } - const { TopNavMenu } = getServices().navigation.ui; - 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(String(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()}`; - }; - const sidebarClassName = classNames({ - closed: isSidebarClosed, - }); - return ( - -
    -

    {savedSearch.title}

    - -
    - <> - {!isSidebarClosed && ( - - )} - - 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); - }} - > - {toggleOn ? 'Hide chart' : 'Show chart'} - - - -
    - -
    - {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 }); - }} - /> -
    - )} -
    -
    - - )} -
    - -
    -
    -
    - ); -} 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 deleted file mode 100644 index 821445655d2cfe..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.scss +++ /dev/null @@ -1,86 +0,0 @@ -.dscDiscoverGrid { - width: 100%; - max-width: 100%; - height: 100%; - overflow: hidden; -} -.dscTable__footer { - background-color: $euiColorLightShade; - padding: $euiSize / 2 $euiSize; - margin-top: $euiSize / 4; - text-align: center; -} - -.dscTable__flyoutHeader { - white-space: nowrap; -} -// this is a hack than needs to be improved -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 { - 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 { - @include euiTextTruncate; - overflow: hidden; - white-space: nowrap; - flex-grow: 1; - } - - .euiDataGridHeaderCell__popover { - flex-grow: 0; - flex-basis: auto; - width: auto; - padding-left: $euiSizeXS; - } -} - -.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 deleted file mode 100644 index 7bcfc70c0350d7..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid.tsx +++ /dev/null @@ -1,297 +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, { useCallback, useMemo, useState } from 'react'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import './discover_grid.scss'; -import { i18n } from '@kbn/i18n'; -import { - EuiDataGrid, - EuiIcon, - EuiScreenReaderOnly, - EuiSpacer, - EuiText, - htmlIdGenerator, -} 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 { - getEuiGridColumns, - getPopoverContents, - getSchemaDetectors, - getVisibleColumns, -} 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'; - -interface SortObj { - id: string; - direction: string; -} - -interface Props { - ariaLabelledBy: string; - columns: string[]; - getContextAppHref: (id: string) => string; - indexPattern: IndexPattern; - onAddColumn: (column: string) => void; - onFilter: DocViewFilterFn; - onRemoveColumn: (column: string) => void; - onResize?: (colSettings: { columnId: string; width: number }) => void; - onSetColumns: (columns: string[]) => void; - onSort: (props: any) => void; - rows?: ElasticSearchHit[]; - sampleSize: number; - settings?: DiscoverGridSettings; - searchDescription?: string; - searchTitle?: string; - showTimeCol: boolean; - 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 DiscoverGrid = React.memo( - ({ - rows, - columns, - sort, - settings, - indexPattern, - ariaLabelledBy, - searchTitle, - searchDescription, - onSort, - onResize, - sampleSize, - onFilter, - getContextAppHref, - onRemoveColumn, - onAddColumn, - showTimeCol, - onSetColumns, - }: Props) => { - const [showSelected, setShowSelected] = useState(false); - const [viewed, setViewed] = useState(-1); - const timeString = useMemo( - () => - i18n.translate('discover.timeLabel', { - defaultMessage: 'Time', - }), - [] - ); - - /** - * Pagination - */ - const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: defaultPageSize }); - - const paginationObj = useMemo(() => { - const onChangeItemsPerPage = (pageSize: number) => - setPagination((paginationData) => ({ ...paginationData, pageSize })); - - const onChangePage = (pageIndex: number) => - setPagination((paginationData) => ({ ...paginationData, pageIndex })); - - return { - ...pagination, - onChangeItemsPerPage, - onChangePage, - pageSizeOptions: pageSizeArr, - }; - }, [pagination]); - - /** - * 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] - ); - - /** - * Cell rendering - */ - const renderCellValue = useMemo(() => getRenderCellValueFn(indexPattern, rows), [ - rows, - indexPattern, - ]); - - const toolbarVisibility = { - showColumnSelector: { - allowHide: false, - allowReorder: true, - }, - showStyleSelector: false, - }; - - /** - * Render variables - */ - const rowsLength = rows ? rows.length : 0; - const pageCount = Math.ceil(rowsLength / pagination.pageSize); - const isOnLastPage = pagination.pageIndex === pageCount - 1; - const showDisclaimer = rowsLength === sampleSize && isOnLastPage; - const randomId = useMemo(() => String(htmlIdGenerator()), []); - - const rowCount = useMemo(() => (rows ? rows.length : 0), [rows]); - const euiGridColumns = useMemo( - () => getEuiGridColumns(columns, settings, indexPattern, showTimeCol, timeString), - [columns, indexPattern, showTimeCol, timeString, settings] - ); - const schemaDetectors = useMemo(() => getSchemaDetectors(), []); - const popoverContents = useMemo(() => getPopoverContents(), []); - const columnsVisibility = useMemo( - () => ({ - visibleColumns: getVisibleColumns(columns, indexPattern, showTimeCol) as string[], - setVisibleColumns: (newColumns: string[]) => { - onSetColumns(newColumns); - }, - }), - [columns, indexPattern, showTimeCol, onSetColumns] - ); - const sorting = useMemo(() => ({ columns: sortingColumns, onSort: onTableSort }), [ - sortingColumns, - onTableSort, - ]); - const lead = useMemo(() => leadControlColumns(rows), [rows]); - - if (!rowCount || !rows) { - return ( - -
    - - - - - -
    -
    - ); - } - - return ( - - - <> - { - if (onResize) { - onResize(col); - } - }} - /> - - {showDisclaimer && ( -

    - - - - -

    - )} - {searchTitle && ( - -

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

    -
    - )} - {viewed > -1 && rows[viewed] && ( - { - setViewed(-1); - }} - /> - )} - -
    -
    - ); - } -); 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 deleted file mode 100644 index 24a68de0850959..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_columns.tsx +++ /dev/null @@ -1,46 +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 { EuiScreenReaderOnly } from '@elastic/eui'; -import { ViewButton } from './discover_grid_view_button'; -import { ElasticSearchHit } from '../../doc_views/doc_views_types'; - -export function leadControlColumns(rows: ElasticSearchHit[] | undefined) { - if (!rows) { - return []; - } - return [ - { - id: 'openDetails', - width: 31, - headerCellRender: () => ( - - - {i18n.translate('discover.controlColumnHeader', { - defaultMessage: 'Control column', - })} - - - ), - rowCellRender: ViewButton, - cellActions: [], - }, - ]; -} 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 deleted file mode 100644 index 1bdb0b8e607bc6..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_context.tsx +++ /dev/null @@ -1,35 +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 { DocViewFilterFn, ElasticSearchHit } from '../../doc_views/doc_views_types'; -import { IndexPattern } from '../../../kibana_services'; - -export interface GridContext { - viewed: number; - setViewed: (id: number) => void; - showSelected: boolean; - setShowSelected: (value: boolean) => void; - rows: ElasticSearchHit[]; - onFilter: DocViewFilterFn; - indexPattern: IndexPattern; -} - -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_flyout.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx deleted file mode 100644 index 1ba17f6936ac97..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_flyout.tsx +++ /dev/null @@ -1,125 +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 { - EuiFlexGroup, - EuiFlexItem, - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiIcon, - EuiPortal, - EuiTitle, - EuiButtonEmpty, -} 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 { - hit: ElasticSearchHit; - columns: string[]; - getContextAppHref: (id: string) => string; - 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_helpers.tsx b/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx deleted file mode 100644 index a6333b37af7c2c..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_helpers.tsx +++ /dev/null @@ -1,219 +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, 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'; - -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 [ - { - 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}; - }, - [kibanaJSON]: ({ children }: { children: ReactNode }) => { - return ( - - {children} - - ); - }, - }; -} 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 deleted file mode 100644 index 4afd75a5096cbf..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/discover_grid_view_button.tsx +++ /dev/null @@ -1,38 +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 { 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/get_render_cell_value.tsx b/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx deleted file mode 100644 index 6f96e2f77ed381..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/get_render_cell_value.tsx +++ /dev/null @@ -1,65 +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 { EuiDataGridCellValueElementProps } from '@elastic/eui'; -import { IndexPattern } from '../../../kibana_services'; -import { ElasticSearchHit } from '../../doc_views/doc_views_types'; - -export const getRenderCellValueFn = ( - indexPattern: IndexPattern, - rows: ElasticSearchHit[] | undefined -) => ({ rowIndex, columnId, isDetails }: EuiDataGridCellValueElementProps) => { - const row = rows ? (rows[rowIndex] as Record) : undefined; - - if (typeof row === 'undefined') { - return '-'; - } - const field = indexPattern.fields.getByName(columnId); - const formatSource = () => { - const formatted = indexPattern.formatHit(row); - - return ( -
    - {Object.keys(formatted).map((key) => ( - -
    {key}
    -
    - - ))} -
    - ); - }; - - const value = - field && field.type === '_source' ? ( - formatSource() - ) : ( - // eslint-disable-next-line react/no-danger - - ); - - if (isDetails && field && field.type === '_source') { - return JSON.stringify(row[columnId], null, 2); - } - return value; -}; diff --git a/src/plugins/discover/public/application/components/discover_grid/types.ts b/src/plugins/discover/public/application/components/discover_grid/types.ts deleted file mode 100644 index c5783c7f071947..00000000000000 --- a/src/plugins/discover/public/application/components/discover_grid/types.ts +++ /dev/null @@ -1,29 +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. - */ - -/** - * 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 416c65f2713013..3f0761148ed6b3 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 React, { useState } from 'react'; +import './discover.scss'; import classNames from 'classnames'; import { EuiButtonEmpty, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiHideFor } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; 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 5d8121e0a056cd..c6a06618900fd5 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,13 +70,6 @@ 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 - for (const column of columns) { - if (!result.selected.find((field) => field.name === column)) { - result.selected.push({ name: column, displayName: column } as IndexPatternField); - } - } return result; } diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 2eb33bd01a7865..258fe6a53bdd89 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -36,7 +36,6 @@ import { import { Container, Embeddable } from '../../../../embeddable/public'; import * as columnActions from '../angular/doc_table/actions/columns'; import searchTemplate from './search_template.html'; -import searchTemplateGrid from './search_template_datagrid.html'; import { ISearchEmbeddable, SearchInput, SearchOutput } from './types'; import { SortOrder } from '../angular/doc_table/components/table_header/helpers'; import { getSortForSearchSource } from '../angular/doc_table'; @@ -49,12 +48,10 @@ import { 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[]; - settings?: DiscoverGridSettings; description?: string; sort?: SortOrder[]; sharedItemTitle?: string; @@ -172,9 +169,7 @@ export class SearchEmbeddable if (!this.searchScope) { throw new Error('Search scope not defined'); } - this.searchInstance = this.$compile( - this.services.uiSettings.get('doc_table:legacy', true) ? searchTemplate : searchTemplateGrid - )(this.searchScope); + this.searchInstance = this.$compile(searchTemplate)(this.searchScope); const rootNode = angular.element(domNode); rootNode.append(this.searchInstance); @@ -250,9 +245,6 @@ export class SearchEmbeddable this.updateInput({ columns }); }; - if (this.savedSearch.grid) { - searchScope.settings = this.savedSearch.grid; - } searchScope.showTimeCol = !this.services.uiSettings.get('doc_table:hideTimeColumn', false); 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 deleted file mode 100644 index ff48a815e64d0f..00000000000000 --- a/src/plugins/discover/public/application/embeddable/search_template_datagrid.html +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/src/plugins/discover/public/get_inner_angular.ts b/src/plugins/discover/public/get_inner_angular.ts index 2ace65c31cc036..c70a1619c9c53e 100644 --- a/src/plugins/discover/public/get_inner_angular.ts +++ b/src/plugins/discover/public/get_inner_angular.ts @@ -41,7 +41,6 @@ import { createTableRowDirective } from './application/angular/doc_table/compone import { createPagerFactory } from './application/angular/doc_table/lib/pager/pager_factory'; import { createInfiniteScrollDirective } from './application/angular/doc_table/infinite_scroll'; import { createDocViewerDirective } from './application/angular/doc_viewer'; -import { createDiscoverGridDirective } from './application/components/create_discover_grid_directive'; import { createRenderCompleteDirective } from './application/angular/directives/render_complete'; import { initAngularBootstrap, @@ -56,7 +55,6 @@ import { import { DiscoverStartPlugins } from './plugin'; import { getScopedHistory } from './kibana_services'; import { createDiscoverLegacyDirective } from './application/components/create_discover_legacy_directive'; -import { createDiscoverDirective } from './application/components/create_discover_directive'; /** * returns the main inner angular module, it contains all the parts of Angular Discover @@ -139,8 +137,7 @@ export function initializeInnerAngularModule( .config(watchMultiDecorator) .run(registerListenEventListener) .directive('renderComplete', createRenderCompleteDirective) - .directive('discoverLegacy', createDiscoverLegacyDirective) - .directive('discover', createDiscoverDirective); + .directive('discoverLegacy', createDiscoverLegacyDirective); } function createLocalPromiseModule() { @@ -192,7 +189,6 @@ function createDocTableModule() { .directive('kbnTableRow', createTableRowDirective) .directive('toolBarPagerButtons', createToolBarPagerButtonsDirective) .directive('kbnInfiniteScroll', createInfiniteScrollDirective) - .directive('discoverGrid', createDiscoverGridDirective) .directive('docViewer', createDocViewerDirective) .directive('contextAppLegacy', createContextAppLegacy); } diff --git a/src/plugins/discover/public/saved_searches/_saved_search.ts b/src/plugins/discover/public/saved_searches/_saved_search.ts index 69c9a10b7e291b..1ec4549f05d491 100644 --- a/src/plugins/discover/public/saved_searches/_saved_search.ts +++ b/src/plugins/discover/public/saved_searches/_saved_search.ts @@ -26,7 +26,6 @@ export function createSavedSearchClass(savedObjects: SavedObjectsStart) { description: 'text', hits: 'integer', columns: 'keyword', - grid: 'object', sort: 'keyword', version: 'integer', }; @@ -46,7 +45,6 @@ export function createSavedSearchClass(savedObjects: SavedObjectsStart) { description: 'text', hits: 'integer', columns: 'keyword', - grid: 'object', sort: 'keyword', version: 'integer', }, @@ -55,7 +53,6 @@ export function createSavedSearchClass(savedObjects: SavedObjectsStart) { 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 a0f1cf0e1b4cc1..13361cb647ddc0 100644 --- a/src/plugins/discover/public/saved_searches/types.ts +++ b/src/plugins/discover/public/saved_searches/types.ts @@ -18,7 +18,6 @@ */ import { ISearchSource } from '../../../data/public'; -import { DiscoverGridSettings } from '../application/components/discover_grid/types'; export type SortOrder = [string, string]; export interface SavedSearch { @@ -28,7 +27,6 @@ export interface SavedSearch { description?: string; columns: string[]; sort: SortOrder[]; - grid: DiscoverGridSettings; destroy: () => void; lastSavedTitle?: string; } diff --git a/src/plugins/discover/server/saved_objects/search.ts b/src/plugins/discover/server/saved_objects/search.ts index d124a24b120fdc..a6e42f956a025f 100644 --- a/src/plugins/discover/server/saved_objects/search.ts +++ b/src/plugins/discover/server/saved_objects/search.ts @@ -53,7 +53,6 @@ export const searchSavedObjectType: SavedObjectsType = { }, sort: { type: 'keyword', index: false, doc_values: false }, title: { type: 'text' }, - grid: { type: 'object', enabled: false }, version: { type: 'integer' }, }, }, diff --git a/src/plugins/discover/server/ui_settings.ts b/src/plugins/discover/server/ui_settings.ts index 9556c4968fab88..f45281ee62202c 100644 --- a/src/plugins/discover/server/ui_settings.ts +++ b/src/plugins/discover/server/ui_settings.ts @@ -33,7 +33,6 @@ import { CONTEXT_DEFAULT_SIZE_SETTING, CONTEXT_STEP_SETTING, CONTEXT_TIE_BREAKER_FIELDS_SETTING, - DOC_TABLE_LEGACY_TABLE, MODIFY_COLUMNS_ON_SWITCH, } from '../common'; @@ -166,18 +165,6 @@ export const uiSettings: Record = { category: ['discover'], schema: schema.arrayOf(schema.string()), }, - [DOC_TABLE_LEGACY_TABLE]: { - name: i18n.translate('discover.advancedSettings.docTableVersionName', { - defaultMessage: 'Use legacy table', - }), - value: true, - description: i18n.translate('discover.advancedSettings.docTableVersionDescription', { - defaultMessage: - 'Prefer the legacy version of the documents table in Discover while available', - }), - category: ['discover'], - schema: schema.boolean(), - }, [MODIFY_COLUMNS_ON_SWITCH]: { name: i18n.translate('discover.advancedSettings.discover.modifyColumnsOnSwitchTitle', { defaultMessage: 'Modify columns when changing index patterns', diff --git a/test/accessibility/apps/discover.ts b/test/accessibility/apps/discover.ts index 373c72f6fd8c78..64e78b57c5a1b1 100644 --- a/test/accessibility/apps/discover.ts +++ b/test/accessibility/apps/discover.ts @@ -34,7 +34,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded('logstash_functional'); await kibanaServer.uiSettings.update({ defaultIndex: 'logstash-*', - 'doc_table:legacy': 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 ba701663c29a22..6d7f7165e1b389 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -29,11 +29,10 @@ export default function ({ getService, getPageObjects }) { const retry = getService('retry'); const docTable = getService('docTable'); const filterBar = getService('filterBar'); - const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings']); + const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); describe('context link in discover', () => { 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 2222d7c71dee3c..3656c824394f46 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 3684b647d03328..975fb5166a8e67 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.ts b/test/functional/apps/discover/_data_grid.ts deleted file mode 100644 index 8f62e03518253b..00000000000000 --- a/test/functional/apps/discover/_data_grid.ts +++ /dev/null @@ -1,67 +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 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-*', 'doc_table:legacy': false }; - const testSubjects = getService('testSubjects'); - - 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(); - }); - - after(async function () { - await kibanaServer.uiSettings.replace({ 'doc_table:legacy': true }); - }); - - it('can add fields to the table', async function () { - const getTitles = async () => - (await testSubjects.getVisibleText('dataGridHeader')).replace(/\s|\r?\n|\r/g, ' '); - - expect(await getTitles()).to.be('Time (@timestamp) _source'); - - await PageObjects.discover.clickFieldListItemAdd('bytes'); - expect(await getTitles()).to.be('Time (@timestamp) bytes'); - - await PageObjects.discover.clickFieldListItemAdd('agent'); - expect(await getTitles()).to.be('Time (@timestamp) bytes agent'); - - await PageObjects.discover.clickFieldListItemAdd('bytes'); - expect(await getTitles()).to.be('Time (@timestamp) agent'); - - await PageObjects.discover.clickFieldListItemAdd('agent'); - expect(await getTitles()).to.be('Time (@timestamp) _source'); - }); - }); -} diff --git a/test/functional/apps/discover/_date_nanos.js b/test/functional/apps/discover/_date_nanos.js index 7e32f1e8368559..2b41f9d8d6e322 100644 --- a/test/functional/apps/discover/_date_nanos.js +++ b/test/functional/apps/discover/_date_nanos.js @@ -33,7 +33,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('date_nanos'); await kibanaServer.uiSettings.replace({ defaultIndex: 'date-nanos', - '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 415df99244aef1..db1d775b8903e4 100644 --- a/test/functional/apps/discover/_date_nanos_mixed.js +++ b/test/functional/apps/discover/_date_nanos_mixed.js @@ -32,7 +32,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('date_nanos_mixed'); await kibanaServer.uiSettings.replace({ defaultIndex: 'timestamp-*', - '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 b1be262e28db56..e5c2b2e4dbada0 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, }; // Failing: See https://github.com/elastic/kibana/issues/82915 diff --git a/test/functional/apps/discover/_doc_navigation.js b/test/functional/apps/discover/_doc_navigation.js index cb7814a2ccb288..59c4371b95d807 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 17ac4d53d46c6e..d45b8f4841cb6a 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 dfcfa40df9f0ff..366fe352a31733 100644 --- a/test/functional/apps/discover/_large_string.js +++ b/test/functional/apps/discover/_large_string.js @@ -35,7 +35,6 @@ export default function ({ getService, getPageObjects }) { await esArchiver.loadIfNeeded('hamlet'); await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring', - 'doc_table:legacy': true, }); }); diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index cff40774d06816..bd6b7a806fbb37 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -49,6 +49,5 @@ export default function ({ getService, loadTestFile }) { loadTestFile(require.resolve('./_date_nanos')); loadTestFile(require.resolve('./_date_nanos_mixed')); loadTestFile(require.resolve('./_indexpattern_without_timefield')); - loadTestFile(require.resolve('./_data_grid')); }); } diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 7f9787d35328e3..94da0c30d3a56f 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -60,7 +60,6 @@ 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.update({}); }); diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index f8d6656cb76654..e29f75b8065744 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 beff9944a975fe..f1273ab00bdd40 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 c6dadd7a1b6e74..72f463be48fd53 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 1ef7f053e760dc..7b22d72885c9d2 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 b0aa708abae139..c547657bf880ae 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 979e2e92bdbda735701703190e96145c5873ac77 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 18 Nov 2020 18:50:53 +0100 Subject: [PATCH 125/158] Improve code, fix TODO --- .../application/components/discover_legacy.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 3f0761148ed6b3..dfbae5fa249a90 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState } from 'react'; +import React, { useState, useRef } from 'react'; import './discover.scss'; import classNames from 'classnames'; import { EuiButtonEmpty, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiHideFor } from '@elastic/eui'; @@ -124,6 +124,7 @@ export function DiscoverLegacy({ updateQuery, updateSavedQueryId, }: DiscoverProps) { + const scrollable = useRef(null); const [toggleOn, toggleChart] = useState(true); const [isSidebarClosed, setIsSidebarClosed] = useState(false); const { TopNavMenu } = getServices().navigation.ui; @@ -256,6 +257,7 @@ export function DiscoverLegacy({

    { - // TODO: make it right - // @ts-ignore - ev.currentTarget?.parentNode?.parentNode?.parentNode?.scrollTo( - 0, - 0 - ); + onClick={() => { + if (scrollable.current) { + scrollable.current.scrollTo(0, 0); + } }} > Date: Thu, 19 Nov 2020 07:33:12 +0100 Subject: [PATCH 126/158] Improve tests --- .../angular/directives/fixed_scroll.js | 155 ------------------ .../public/application/angular/discover.js | 4 - .../components/discover_legacy.tsx | 7 +- .../sidebar/discover_sidebar.test.tsx | 59 ++++--- .../components/sidebar/discover_sidebar.tsx | 19 ++- .../discover_sidebar_responsive.test.tsx | 144 ++++++++++++++++ .../sidebar/discover_sidebar_responsive.tsx | 25 +-- 7 files changed, 202 insertions(+), 211 deletions(-) delete mode 100644 src/plugins/discover/public/application/angular/directives/fixed_scroll.js create mode 100644 src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx diff --git a/src/plugins/discover/public/application/angular/directives/fixed_scroll.js b/src/plugins/discover/public/application/angular/directives/fixed_scroll.js deleted file mode 100644 index e2d5f10a0faf71..00000000000000 --- a/src/plugins/discover/public/application/angular/directives/fixed_scroll.js +++ /dev/null @@ -1,155 +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 $ from 'jquery'; -import _ from 'lodash'; -import { createDebounceProviderTimeout } from './debounce'; - -const SCROLLER_HEIGHT = 20; - -/** - * This directive adds a fixed horizontal scrollbar to the bottom of the window that proxies its scroll events - * to the target element's real scrollbar. This is useful when the target element's horizontal scrollbar - * might be waaaay down the page, like the doc table on Discover. - */ -export function FixedScrollProvider($timeout) { - return { - restrict: 'A', - link: function ($scope, $el) { - return createFixedScroll($scope, $timeout)($el); - }, - }; -} - -export function createFixedScroll($scope, $timeout) { - const debounce = createDebounceProviderTimeout($timeout); - return function (el) { - const $el = typeof el.css === 'function' ? el : $(el); - let $window = $(window); - let $scroller = $('
    ').height(SCROLLER_HEIGHT); - - /** - * Remove the listeners bound in listen() - * @type {function} - */ - let unlisten = _.noop; - - /** - * Listen for scroll events on the $scroller and the $el, sets unlisten() - * - * unlisten must be called before calling or listen() will throw an Error - * - * Since the browser emits "scroll" events after setting scrollLeft - * the listeners also prevent tug-of-war - * - * @throws {Error} If unlisten was not called first - * @return {undefined} - */ - function listen() { - if (unlisten !== _.noop) { - throw new Error('fixedScroll listeners were not cleaned up properly before re-listening!'); - } - - let blockTo; - function bind($from, $to) { - function handler() { - if (blockTo === $to) return (blockTo = null); - $to.scrollLeft((blockTo = $from).scrollLeft()); - } - - $from.on('scroll', handler); - return function () { - $from.off('scroll', handler); - }; - } - - unlisten = _.flow(bind($el, $scroller), bind($scroller, $el), function () { - unlisten = _.noop; - }); - } - - /** - * Revert DOM changes and event listeners - * @return {undefined} - */ - function cleanUp() { - unlisten(); - $scroller.detach(); - $el.css('padding-bottom', 0); - } - - /** - * Modify the DOM and attach event listeners based on need. - * Is called many times to re-setup, must be idempotent - * @return {undefined} - */ - function setup() { - cleanUp(); - - const containerWidth = $el.width(); - const contentWidth = $el.prop('scrollWidth'); - const containerHorizOverflow = contentWidth - containerWidth; - - const elTop = $el.offset().top - $window.scrollTop(); - const elBottom = elTop + $el.height(); - const windowVertOverflow = elBottom - $window.height(); - - const requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0; - if (!requireScroller) return; - - // push the content away from the scroller - $el.css('padding-bottom', SCROLLER_HEIGHT); - - // fill the scroller with a dummy element that mimics the content - $scroller - .width(containerWidth) - .html($('
    ').css({ width: contentWidth, height: SCROLLER_HEIGHT })) - .insertAfter($el); - - // listen for scroll events - listen(); - } - - let width; - let scrollWidth; - function checkWidth() { - const newScrollWidth = $el.prop('scrollWidth'); - const newWidth = $el.width(); - - if (scrollWidth !== newScrollWidth || width !== newWidth) { - $scope.$apply(setup); - - scrollWidth = newScrollWidth; - width = newWidth; - } - } - - const debouncedCheckWidth = debounce(checkWidth, 100, { - invokeApply: false, - }); - $scope.$watch(debouncedCheckWidth); - - function destroy() { - cleanUp(); - debouncedCheckWidth.cancel(); - $scroller = $window = null; - } - return destroy; - }; -} diff --git a/src/plugins/discover/public/application/angular/discover.js b/src/plugins/discover/public/application/angular/discover.js index 1d4ada23d5756f..5eb9b5c773d239 100644 --- a/src/plugins/discover/public/application/angular/discover.js +++ b/src/plugins/discover/public/application/angular/discover.js @@ -338,8 +338,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab $scope.minimumVisibleRows = 50; $scope.fetchStatus = fetchStatuses.UNINITIALIZED; $scope.showSaveQuery = uiCapabilities.discover.saveQuery; - $scope.showTimeCol = - !config.get('doc_table:hideTimeColumn', false) && $scope.indexPattern.timeFieldName; let abortController; $scope.$on('$destroy', () => { @@ -617,8 +615,6 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab indexPatternList: $route.current.locals.savedObjects.ip.list, config: config, setHeaderActionMenu: getHeaderActionMenuMounter(), - filterManager, - setAppState, data, }; diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index dfbae5fa249a90..02d325d856eeaf 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -127,8 +127,9 @@ export function DiscoverLegacy({ const scrollable = useRef(null); const [toggleOn, toggleChart] = useState(true); const [isSidebarClosed, setIsSidebarClosed] = useState(false); - const { TopNavMenu } = getServices().navigation.ui; - const { trackUiMetric } = getServices(); + const services = getServices(); + const { TopNavMenu } = services.navigation.ui; + const { trackUiMetric } = services; const { savedSearch, indexPatternList } = opts; const bucketAggConfig = opts.chartAggConfigs?.aggs[1]; const bucketInterval = @@ -168,8 +169,8 @@ export function DiscoverLegacy({ onAddFilter={onAddFilter} onRemoveField={onRemoveColumn} selectedIndexPattern={searchSource && searchSource.getField('index')} + services={services} setIndexPattern={setIndexPattern} - legacy={true} sidebarClassName={sidebarClassName} trackUiMetric={trackUiMetric} /> diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx index ac4151d653a7a0..84a4b1410aeaa7 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx @@ -31,32 +31,35 @@ import { coreMock } from '../../../../../../core/public/mocks'; import { IndexPatternAttributes } from '../../../../../data/common'; import { getStubIndexPattern } from '../../../../../data/public/test_utils'; import { SavedObject } from '../../../../../../core/types'; -import { FieldFilterState } from './lib/field_filter'; -import { DiscoverSidebarResponsive } from './discover_sidebar_responsive'; +import { getDefaultFieldFilter } from './lib/field_filter'; +import { DiscoverSidebar } from './discover_sidebar'; +import { DiscoverServices } from '../../../build_services'; -jest.mock('../../../kibana_services', () => ({ - getServices: () => ({ - history: () => ({ - location: { - search: '', - }, - }), - capabilities: { - visualize: { - show: true, - }, - discover: { - save: false, - }, - }, - uiSettings: { - get: (key: string) => { - if (key === 'fields:popularLimit') { - return 5; - } - }, +const mockServices = ({ + history: () => ({ + location: { + search: '', }, }), + capabilities: { + visualize: { + show: true, + }, + discover: { + save: false, + }, + }, + uiSettings: { + get: (key: string) => { + if (key === 'fields:popularLimit') { + return 5; + } + }, + }, +} as unknown) as DiscoverServices; + +jest.mock('../../../kibana_services', () => ({ + getServices: () => mockServices, })); jest.mock('./lib/get_index_pattern_field_list', () => ({ @@ -99,10 +102,11 @@ function getCompProps() { onAddField: jest.fn(), onRemoveField: jest.fn(), selectedIndexPattern: indexPattern, + services: mockServices, setIndexPattern: jest.fn(), state: {}, trackUiMetric: jest.fn(), - fieldFilter: {} as FieldFilterState, + fieldFilter: getDefaultFieldFilter(), setFieldFilter: jest.fn(), }; } @@ -113,7 +117,7 @@ describe('discover sidebar', function () { beforeAll(() => { props = getCompProps(); - comp = mountWithIntl(); + comp = mountWithIntl(); }); it('should have Selected Fields and Available Fields with Popular Fields sections', function () { @@ -132,9 +136,4 @@ describe('discover sidebar', function () { findTestSubject(comp, 'fieldToggle-extension').simulate('click'); expect(props.onRemoveField).toHaveBeenCalledWith('extension'); }); - it('should allow adding filters', function () { - findTestSubject(comp, 'field-extension-showDetails').simulate('click'); - findTestSubject(comp, 'plus-extension-gif').simulate('click'); - expect(props.onAddFilter).toHaveBeenCalled(); - }); }); 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 6f8ac76c6d9d20..a5b273d4235673 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -16,10 +16,12 @@ * 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 { isEqual, sortBy } from 'lodash'; import { i18n } from '@kbn/i18n'; +import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { UiStatsMetricType } from '@kbn/analytics'; +import './discover_sidebar.scss'; import { EuiAccordion, EuiFlexItem, @@ -29,9 +31,6 @@ import { EuiSpacer, EuiNotificationBadge, } from '@elastic/eui'; -import { sortBy } from 'lodash'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { UiStatsMetricType } from '@kbn/analytics'; import { DiscoverField } from './discover_field'; import { DiscoverIndexPattern } from './discover_index_pattern'; import { DiscoverFieldSearch } from './discover_field_search'; @@ -43,7 +42,7 @@ import { IndexPatternField, IndexPattern } from '../../../../../data/public'; import { getDetails } from './lib/get_details'; import { FieldFilterState, getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter'; import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list'; -import { getServices } from '../../../kibana_services'; +import { DiscoverServices } from '../../../build_services'; export interface DiscoverSidebarProps { /** @@ -79,6 +78,10 @@ export interface DiscoverSidebarProps { * Currently selected index pattern */ selectedIndexPattern?: IndexPattern; + /** + * Discover plugin services; + */ + services: DiscoverServices; /** * Callback function to select another index pattern */ @@ -116,6 +119,7 @@ export function DiscoverSidebar({ onAddFilter, onRemoveField, selectedIndexPattern, + services, setIndexPattern, trackUiMetric, mobile = false, @@ -124,11 +128,10 @@ export function DiscoverSidebar({ setFieldFilter, }: DiscoverSidebarProps) { const [fields, setFields] = useState(null); - const services = useMemo(() => getServices(), []); useEffect(() => { const newFields = getIndexPatternFieldList(selectedIndexPattern, fieldCounts); setFields(newFields); - }, [selectedIndexPattern, fieldCounts, hits, services]); + }, [selectedIndexPattern, fieldCounts, hits]); const onChangeFieldSearch = useCallback( (field: string, value: string | boolean | undefined) => { diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx new file mode 100644 index 00000000000000..4f402e25376c83 --- /dev/null +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.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 _ from 'lodash'; +import { ReactWrapper } from 'enzyme'; +import { findTestSubject } from '@elastic/eui/lib/test'; +// @ts-ignore +import realHits from 'fixtures/real_hits.js'; +// @ts-ignore +import stubbedLogstashFields from 'fixtures/logstash_fields'; +import { mountWithIntl } from '@kbn/test/jest'; +import React from 'react'; +import { DiscoverSidebarProps } from './discover_sidebar'; +import { coreMock } from '../../../../../../core/public/mocks'; +import { IndexPatternAttributes } from '../../../../../data/common'; +import { getStubIndexPattern } from '../../../../../data/public/test_utils'; +import { SavedObject } from '../../../../../../core/types'; +import { FieldFilterState } from './lib/field_filter'; +import { DiscoverSidebarResponsive } from './discover_sidebar_responsive'; +import { DiscoverServices } from '../../../build_services'; + +const mockServices = ({ + history: () => ({ + location: { + search: '', + }, + }), + capabilities: { + visualize: { + show: true, + }, + discover: { + save: false, + }, + }, + uiSettings: { + get: (key: string) => { + if (key === 'fields:popularLimit') { + return 5; + } + }, + }, +} as unknown) as DiscoverServices; + +jest.mock('../../../kibana_services', () => ({ + getServices: () => mockServices, +})); + +jest.mock('./lib/get_index_pattern_field_list', () => ({ + getIndexPatternFieldList: jest.fn((indexPattern) => indexPattern.fields), +})); + +function getCompProps() { + const indexPattern = getStubIndexPattern( + 'logstash-*', + (cfg: any) => cfg, + 'time', + stubbedLogstashFields(), + coreMock.createSetup() + ); + + // @ts-expect-error _.each() is passing additional args to flattenHit + const hits = _.each(_.cloneDeep(realHits), indexPattern.flattenHit) as Array< + Record + >; + + const indexPatternList = [ + { id: '0', attributes: { title: 'b' } } as SavedObject, + { id: '1', attributes: { title: 'a' } } as SavedObject, + { id: '2', attributes: { title: 'c' } } as SavedObject, + ]; + + const fieldCounts: Record = {}; + + for (const hit of hits) { + for (const key of Object.keys(indexPattern.flattenHit(hit))) { + fieldCounts[key] = (fieldCounts[key] || 0) + 1; + } + } + return { + columns: ['extension'], + fieldCounts, + hits, + indexPatternList, + onAddFilter: jest.fn(), + onAddField: jest.fn(), + onRemoveField: jest.fn(), + selectedIndexPattern: indexPattern, + services: mockServices, + setIndexPattern: jest.fn(), + state: {}, + trackUiMetric: jest.fn(), + fieldFilter: {} as FieldFilterState, + setFieldFilter: jest.fn(), + }; +} + +describe('discover sidebar', function () { + let props: DiscoverSidebarProps; + let comp: ReactWrapper; + + beforeAll(() => { + props = getCompProps(); + comp = mountWithIntl(); + }); + + it('should have Selected Fields and Available Fields with Popular Fields sections', function () { + const popular = findTestSubject(comp, 'fieldList-popular'); + const selected = findTestSubject(comp, 'fieldList-selected'); + const unpopular = findTestSubject(comp, 'fieldList-unpopular'); + expect(popular.children().length).toBe(1); + expect(unpopular.children().length).toBe(7); + expect(selected.children().length).toBe(1); + }); + it('should allow selecting fields', function () { + findTestSubject(comp, 'fieldToggle-bytes').simulate('click'); + expect(props.onAddField).toHaveBeenCalledWith('bytes'); + }); + it('should allow deselecting fields', function () { + findTestSubject(comp, 'fieldToggle-extension').simulate('click'); + expect(props.onRemoveField).toHaveBeenCalledWith('extension'); + }); + it('should allow adding filters', function () { + findTestSubject(comp, 'field-extension-showDetails').simulate('click'); + findTestSubject(comp, 'plus-extension-gif').simulate('click'); + expect(props.onAddFilter).toHaveBeenCalled(); + }); +}); 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 45da33cdbd5c1f..23fd6281f5490f 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 @@ -16,9 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -import './discover_sidebar.scss'; import React, { useState } from 'react'; +import { sortBy } from 'lodash'; import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; import { UiStatsMetricType } from '@kbn/analytics'; import { EuiFlexItem, @@ -33,14 +34,13 @@ import { 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'; +import { DiscoverServices } from '../../../build_services'; export interface DiscoverSidebarResponsiveProps { /** @@ -76,6 +76,10 @@ export interface DiscoverSidebarResponsiveProps { * Currently selected index pattern */ selectedIndexPattern?: IndexPattern; + /** + * Discover plugin services; + */ + services: DiscoverServices; /** * Callback function to select another index pattern */ @@ -89,11 +93,7 @@ export interface DiscoverSidebarResponsiveProps { */ useFlyout?: boolean; /** - * Adapt to legacy layout - */ - legacy?: boolean; - /** - * Additional classname used for legacy + * Additional classname */ sidebarClassName?: string; /** @@ -104,6 +104,11 @@ export interface DiscoverSidebarResponsiveProps { trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void; } +/** + * Component providing 2 different renderings for the sidebar + * Desktop: Sidebar view, all elements visible + * Mobile: Index pattern selector visible and a button to trigger a flyout with all elements + */ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) { const [fieldFilter, setFieldFilter] = useState(getDefaultFieldFilter()); const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); @@ -112,9 +117,7 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) return null; } - const className = props.legacy - ? `dscSidebar dscSidebar__desktop dscCollapsibleSidebar ${props.sidebarClassName}` - : `dscSidebar dscSidebar__desktop`; + const className = `dscSidebar dscSidebar__desktop dscCollapsibleSidebar ${props.sidebarClassName}`; return ( <> From 5e206a9d2dc3bfc1f56eaf52202a20be3de04e0f Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 19 Nov 2020 09:57:31 +0100 Subject: [PATCH 127/158] Improve scroll to top functionality --- .../components/discover_legacy.tsx | 45 ++++++++++++------- .../sidebar/discover_sidebar_responsive.tsx | 12 ++--- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 02d325d856eeaf..9b2f42f4a6a0b3 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -124,7 +124,14 @@ export function DiscoverLegacy({ updateQuery, updateSavedQueryId, }: DiscoverProps) { - const scrollable = useRef(null); + const scrollableDesktop = useRef(null); + const scrollableMobile = useRef(null); + const collapseIcon = useRef(null); + const isMobile = () => { + // collapse icon isn't displayed in mobile view, use it to detect which view is displayed + return collapseIcon && !collapseIcon.current; + }; + const [toggleOn, toggleChart] = useState(true); const [isSidebarClosed, setIsSidebarClosed] = useState(false); const services = getServices(); @@ -159,7 +166,7 @@ export function DiscoverLegacy({ showSearchBar={true} useDefaultBehaviors={true} /> -
    +
    - setIsSidebarClosed(!isSidebarClosed)} - data-test-subj="collapseSideBarButton" - aria-controls="discover-sidebar" - aria-expanded={isSidebarClosed ? 'false' : 'true'} - aria-label="Toggle sidebar" - className={`dscCollapsibleSidebar__collapseButton ${sidebarClassName}`} - /> + + 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' && ( @@ -258,7 +267,7 @@ export function DiscoverLegacy({

    { - if (scrollable.current) { - scrollable.current.scrollTo(0, 0); + // depending on screen size there are different + if (!isMobile() && scrollableDesktop.current) { + scrollableDesktop.current.scrollTo(0, 0); + } + if (isMobile() && scrollableMobile.current) { + scrollableMobile.current.scrollTo(0, 0); } }} > 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 23fd6281f5490f..1639ce7850df45 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 @@ -105,9 +105,9 @@ export interface DiscoverSidebarResponsiveProps { } /** - * Component providing 2 different renderings for the sidebar - * Desktop: Sidebar view, all elements visible - * Mobile: Index pattern selector visible and a button to trigger a flyout with all elements + * Component providing 2 different renderings for the sidebar depending on available screen space + * Desktop: Sidebar view, all elements are visible + * Mobile: Index pattern selector is visible and a button to trigger a flyout with all elements */ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) { const [fieldFilter, setFieldFilter] = useState(getDefaultFieldFilter()); @@ -117,12 +117,12 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) return null; } - const className = `dscSidebar dscSidebar__desktop dscCollapsibleSidebar ${props.sidebarClassName}`; - return ( <> -
    +
    From 120f5bc71bc0c06c675c77328fdfba34b1e0062d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 19 Nov 2020 10:21:57 +0100 Subject: [PATCH 128/158] Clean up code --- .../discover_sidebar_responsive.test.tsx | 2 +- .../embeddable/search_embeddable.ts | 18 ++++++------------ .../embeddable/search_embeddable_factory.ts | 1 - .../discover/public/get_inner_angular.ts | 1 - test/functional/apps/discover/_date_nanos.js | 4 +--- .../apps/discover/_date_nanos_mixed.js | 4 +--- test/functional/apps/discover/_doc_table.ts | 15 +++++++-------- test/functional/apps/discover/_large_string.js | 4 +--- .../apps/management/_scripted_fields.js | 1 + 9 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx index 4f402e25376c83..303f18c5ab1a1d 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx @@ -111,7 +111,7 @@ function getCompProps() { }; } -describe('discover sidebar', function () { +describe('discover responsive sidebar', function () { let props: DiscoverSidebarProps; let comp: ReactWrapper; diff --git a/src/plugins/discover/public/application/embeddable/search_embeddable.ts b/src/plugins/discover/public/application/embeddable/search_embeddable.ts index 258fe6a53bdd89..170078076ec6f4 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable.ts @@ -42,13 +42,13 @@ 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 { DiscoverServices } from '../../build_services'; interface SearchScope extends ng.IScope { columns?: string[]; @@ -65,7 +65,6 @@ interface SearchScope extends ng.IScope { indexPattern?: IndexPattern; totalHitCount?: number; isLoading?: boolean; - showTimeCol?: boolean; } interface SearchEmbeddableConfig { @@ -77,7 +76,6 @@ interface SearchEmbeddableConfig { indexPatterns?: IndexPattern[]; editable: boolean; filterManager: FilterManager; - services: DiscoverServices; } export class SearchEmbeddable @@ -96,7 +94,6 @@ 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,7 +109,6 @@ export class SearchEmbeddable indexPatterns, editable, filterManager, - services, }: SearchEmbeddableConfig, initialInput: SearchInput, private readonly executeTriggerActions: UiActionsStart['executeTriggerActions'], @@ -130,7 +126,7 @@ export class SearchEmbeddable }, parent ); - this.services = services; + this.filterManager = filterManager; this.savedSearch = savedSearch; this.$rootScope = $rootScope; @@ -140,8 +136,8 @@ export class SearchEmbeddable }; this.initializeSearchScope(); - this.autoRefreshFetchSubscription = this.services.timefilter - .getAutoRefreshFetch$() + this.autoRefreshFetchSubscription = getServices() + .timefilter.getAutoRefreshFetch$() .subscribe(this.fetch); this.subscription = Rx.merge(this.getOutput$(), this.getInput$()).subscribe(() => { @@ -245,8 +241,6 @@ export class SearchEmbeddable this.updateInput({ columns }); }; - searchScope.showTimeCol = !this.services.uiSettings.get('doc_table:hideTimeColumn', false); - searchScope.filter = async (field, value, operator) => { let filters = esFilters.generateFilters( this.filterManager, @@ -282,13 +276,13 @@ export class SearchEmbeddable if (this.abortController) this.abortController.abort(); this.abortController = new AbortController(); - searchSource.setField('size', this.services.uiSettings.get(SAMPLE_SIZE_SETTING)); + searchSource.setField('size', getServices().uiSettings.get(SAMPLE_SIZE_SETTING)); searchSource.setField( 'sort', getSortForSearchSource( this.searchScope.sort, this.searchScope.indexPattern, - this.services.uiSettings.get(SORT_DEFAULT_ORDER_SETTING) + getServices().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 d85476568201ff..f61fa361f0c0e6 100644 --- a/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts +++ b/src/plugins/discover/public/application/embeddable/search_embeddable_factory.ts @@ -103,7 +103,6 @@ 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/get_inner_angular.ts b/src/plugins/discover/public/get_inner_angular.ts index c70a1619c9c53e..651a26cad755db 100644 --- a/src/plugins/discover/public/get_inner_angular.ts +++ b/src/plugins/discover/public/get_inner_angular.ts @@ -55,7 +55,6 @@ import { import { DiscoverStartPlugins } from './plugin'; import { getScopedHistory } from './kibana_services'; import { createDiscoverLegacyDirective } from './application/components/create_discover_legacy_directive'; - /** * returns the main inner angular module, it contains all the parts of Angular Discover * needs to render, so in the end the current 'kibana' angular module is no longer necessary diff --git a/test/functional/apps/discover/_date_nanos.js b/test/functional/apps/discover/_date_nanos.js index 2b41f9d8d6e322..9b076c82157544 100644 --- a/test/functional/apps/discover/_date_nanos.js +++ b/test/functional/apps/discover/_date_nanos.js @@ -31,9 +31,7 @@ export default function ({ getService, getPageObjects }) { describe.skip('date_nanos', function () { before(async function () { await esArchiver.loadIfNeeded('date_nanos'); - await kibanaServer.uiSettings.replace({ - defaultIndex: 'date-nanos', - }); + 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 db1d775b8903e4..63509d85afd3a0 100644 --- a/test/functional/apps/discover/_date_nanos_mixed.js +++ b/test/functional/apps/discover/_date_nanos_mixed.js @@ -30,9 +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-*', - }); + 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/_doc_table.ts b/test/functional/apps/discover/_doc_table.ts index 0bcb4ad576a6e9..dceb12a02f87f4 100644 --- a/test/functional/apps/discover/_doc_table.ts +++ b/test/functional/apps/discover/_doc_table.ts @@ -135,14 +135,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); 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 - expect(await PageObjects.discover.getDocHeader()).to.have.string(column); - } + 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); }); it('should remove columns from the table', async function () { diff --git a/test/functional/apps/discover/_large_string.js b/test/functional/apps/discover/_large_string.js index 366fe352a31733..6142f042c1148a 100644 --- a/test/functional/apps/discover/_large_string.js +++ b/test/functional/apps/discover/_large_string.js @@ -33,9 +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', - }); + await kibanaServer.uiSettings.replace({ defaultIndex: 'testlargestring' }); }); it('verify the large string book present', async function () { diff --git a/test/functional/apps/management/_scripted_fields.js b/test/functional/apps/management/_scripted_fields.js index 94da0c30d3a56f..5ca01f239e762f 100644 --- a/test/functional/apps/management/_scripted_fields.js +++ b/test/functional/apps/management/_scripted_fields.js @@ -60,6 +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({}); await kibanaServer.uiSettings.update({}); }); From 6cce664a04928db98573e3dcd012406cfb27cef6 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 19 Nov 2020 10:29:36 +0100 Subject: [PATCH 129/158] Improve code --- .../public/application/angular/discover_state.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/plugins/discover/public/application/angular/discover_state.ts b/src/plugins/discover/public/application/angular/discover_state.ts index 0c4a44073ea5c4..0d343d7fdd29a1 100644 --- a/src/plugins/discover/public/application/angular/discover_state.ts +++ b/src/plugins/discover/public/application/angular/discover_state.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import _, { isEqual } from 'lodash'; +import { isEqual, cloneDeep } from 'lodash'; import { History } from 'history'; import { IUiSettingsClient, NotificationsStart } from 'kibana/public'; import { @@ -204,19 +204,15 @@ export function getStateDefaults( language: string; } ): AppState { - const { searchSource } = savedSearch; - const defaultState: AppState = { + const { searchSource, columns, sort } = savedSearch; + return { query: searchSource.getField('query') || defaultQuery, - sort: getSortArray(savedSearch.sort, indexPattern), - columns: - savedSearch.columns.length > 0 - ? savedSearch.columns - : config.get(DEFAULT_COLUMNS_SETTING).slice(), + sort: getSortArray(sort, indexPattern), + columns: columns.length > 0 ? columns : config.get(DEFAULT_COLUMNS_SETTING).slice(), index: indexPattern.id, interval: 'auto', - filters: _.cloneDeep(searchSource.getOwnField('filter')) as Filter[], + filters: cloneDeep(searchSource.getOwnField('filter')) as Filter[], }; - return defaultState; } /** From 1a91fcaf51d0f21710d5e38f6730e15456d4d8de Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 20 Nov 2020 06:16:52 +0100 Subject: [PATCH 130/158] Address review comments --- .../components/discover_legacy.tsx | 18 +++++--- .../skip_bottom_button/skip_bottom_button.tsx | 42 +++++++++---------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 9b2f42f4a6a0b3..b3f9fb532ec7f9 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -150,7 +150,6 @@ export function DiscoverLegacy({ return (
    -

    {savedSearch.title}

    -
    +
    +

    + {savedSearch.title} +

    - + ​ - + {rows.length === opts.sampleSize && (
    { - // depending on screen size there are different + const skipToBottomBtn = document.getElementById('dscSkipButton'); + if (skipToBottomBtn) { + skipToBottomBtn.focus(); + } + // depending on screen size there are different elements to scroll if (!isMobile() && scrollableDesktop.current) { scrollableDesktop.current.scrollTo(0, 0); } @@ -328,7 +334,7 @@ export function DiscoverLegacy({ )}
    -
    +

    ); diff --git a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx index d5bc5bb64f59be..562cbda1fc3a03 100644 --- a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx +++ b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { EuiSkipLink } from '@elastic/eui'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; export interface SkipBottomButtonProps { /** @@ -29,26 +29,24 @@ export interface SkipBottomButtonProps { export function SkipBottomButton({ onClick }: SkipBottomButtonProps) { return ( - - { - // prevent the anchor to reload the page on click - event.preventDefault(); - // The destinationId prop cannot be leveraged here as the table needs - // to be updated first (angular logic) - onClick(); - }} - className="dscSkipButton" - destinationId="" - data-test-subj="discoverSkipTableButton" - > - - - + ) => { + // prevent the anchor to reload the page on click + event.preventDefault(); + // The destinationId prop cannot be leveraged here as the table needs + // to be updated first (angular logic) + onClick(); + }} + className="dscSkipButton" + id="dscSkipButton" + destinationId="" + data-test-subj="discoverSkipTableButton" + > + + ); } From ab8dae66d6927f3f67a404f4fee466e88f8258ab Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 20 Nov 2020 06:29:20 +0100 Subject: [PATCH 131/158] Add aria label to flyout back button --- .../components/sidebar/discover_sidebar_responsive.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 1639ce7850df45..345af31fe99728 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 @@ -170,7 +170,13 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) responsive={false} > - setIsFlyoutVisible(false)} iconType="arrowLeft" /> + setIsFlyoutVisible(false)} + iconType="arrowLeft" + /> From 13cadc26f4d4b639a32886977ea928de61be0bc5 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 24 Nov 2020 13:22:02 +0100 Subject: [PATCH 132/158] Fix doc viewer button width --- .../public/application/components/doc_viewer/doc_viewer.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.scss b/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.scss index 5959cb4a32b44a..b6b7a244bd1f6f 100644 --- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.scss +++ b/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.scss @@ -45,10 +45,9 @@ white-space: nowrap; } .kbnDocViewer__buttons { - width: 60px; + width: 96px; // Show all icons if one is focused, - // IE doesn't support, but the fallback is just the focused button becomes visible &:focus-within { .kbnDocViewer__actionButton { opacity: 1; From 189f308e593c3005cff7da9495f8f1818976431d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 24 Nov 2020 15:19:19 +0100 Subject: [PATCH 133/158] Cleanup `dscFieldSearch__toggleButton` --- .../components/sidebar/discover_field_search.tsx | 1 - .../application/components/sidebar/discover_sidebar.scss | 8 -------- 2 files changed, 9 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 c8a0e6579a28b8..8f957f96c9e7ef 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 @@ -166,7 +166,6 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { 0} numFilters={0} 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 4cdee4d4dd1e08..3095a6b54fb885 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -131,14 +131,6 @@ padding: $euiSizeS; } -.dscFieldSearch__toggleButton { - // width: calc(100% - #{$euiSizeS}); - // color: $euiColorPrimary; - // padding-left: $euiSizeXS; - // margin-left: $euiSizeXS; - // borde -} - .dscFieldSearch__filterWrapper { width: 100%; } From 6e568ba1ef4bb55e6846451302bad6eed725950a Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 24 Nov 2020 15:33:59 +0100 Subject: [PATCH 134/158] Cleanup css classes --- .../discover/public/application/_discover.scss | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 73e77c71ffe3c8..00c72b58e80e5f 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -186,18 +186,6 @@ discover-app { display: inline; } -.dscTableFixedScroll { - overflow-x: auto; - padding-bottom: 0; - - + .dscTableFixedScroll__scroller { - position: fixed; - bottom: 0; - overflow-x: auto; - overflow-y: hidden; - } -} - .dscCollapsibleSidebar__collapseButton { align-self: flex-start; &:not(.closed) { From b6b365e1dd34d0edd8a9dad57a486d3f59657a80 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Tue, 24 Nov 2020 16:42:25 +0100 Subject: [PATCH 135/158] Memoize components for better performance --- .../application/components/discover_legacy.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index b3f9fb532ec7f9..010731bffb32ba 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -29,7 +29,7 @@ import { getServices, IndexPattern } from '../../kibana_services'; import { DiscoverUninitialized, DiscoverHistogram } from '../angular/directives'; import { DiscoverNoResults } from './no_results'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; -import { DocTableLegacy } from '../angular/doc_table/create_doc_table_react'; +import { DocTableLegacy, DocTableLegacyProps } from '../angular/doc_table/create_doc_table_react'; import { SkipBottomButton } from './skip_bottom_button'; import { search, @@ -49,6 +49,7 @@ import { SavedObject } from '../../../../../core/types'; import { TopNavMenuData } from '../../../../navigation/public'; import { DiscoverSidebarResponsive } from './sidebar'; import { DocViewFilterFn, ElasticSearchHit } from '../doc_views/doc_views_types'; +import { DiscoverSidebarResponsiveProps } from './sidebar/discover_sidebar_responsive'; export interface DiscoverProps { addColumn: (column: string) => void; @@ -94,6 +95,13 @@ export interface DiscoverProps { updateSavedQueryId: (savedQueryId?: string) => void; } +export const DocTableLegacyMemoized = React.memo((props: DocTableLegacyProps) => ( + +)); +export const SidebarMemoized = React.memo((props: DiscoverSidebarResponsiveProps) => ( + +)); + export function DiscoverLegacy({ addColumn, fetch, @@ -169,7 +177,7 @@ export function DiscoverLegacy({

    {savedSearch.title}

    - {rows && rows.length && (
    - Date: Tue, 24 Nov 2020 12:25:39 -0500 Subject: [PATCH 136/158] change location of skip button --- .../discover/public/application/components/discover_legacy.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index b3f9fb532ec7f9..7de478aadf9a39 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -211,7 +211,6 @@ export function DiscoverLegacy({ {resultState === 'loading' && } {resultState === 'ready' && ( <> -
    - + {toggleOn && opts.timefield && (
    Date: Tue, 24 Nov 2020 12:56:24 -0500 Subject: [PATCH 137/158] change styling of skip button --- src/plugins/discover/public/application/_discover.scss | 7 ------- .../public/application/components/discover_legacy.tsx | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 00c72b58e80e5f..70d7645097349a 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -162,13 +162,6 @@ discover-app { width: auto; } -.dscSkipButton { - position: absolute; - right: $euiSizeM; - top: $euiSizeXS; - z-index: $euiZLevel1; -} - .dscApp .dscFormatSource { word-break: break-word; } diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 7de478aadf9a39..dd917d70cc8013 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -242,10 +242,10 @@ export function DiscoverLegacy({ > {toggleOn ? 'Hide chart' : 'Show chart'} +
    - {toggleOn && opts.timefield && (
    Date: Tue, 24 Nov 2020 13:23:19 -0500 Subject: [PATCH 138/158] improve prompt screen when search on load is disabled --- .../angular/directives/_index.scss | 1 + .../angular/directives/_uninitialized.scss | 3 + .../angular/directives/uninitialized.tsx | 58 ++++++++----------- 3 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 src/plugins/discover/public/application/angular/directives/_uninitialized.scss diff --git a/src/plugins/discover/public/application/angular/directives/_index.scss b/src/plugins/discover/public/application/angular/directives/_index.scss index dfacdf45c9d7bf..fe04a167a94905 100644 --- a/src/plugins/discover/public/application/angular/directives/_index.scss +++ b/src/plugins/discover/public/application/angular/directives/_index.scss @@ -1 +1,2 @@ @import 'histogram'; +@import 'uninitialized'; diff --git a/src/plugins/discover/public/application/angular/directives/_uninitialized.scss b/src/plugins/discover/public/application/angular/directives/_uninitialized.scss new file mode 100644 index 00000000000000..2e517f2e0cab89 --- /dev/null +++ b/src/plugins/discover/public/application/angular/directives/_uninitialized.scss @@ -0,0 +1,3 @@ +.dscUninitialized { + margin-top: $euiSize; +} diff --git a/src/plugins/discover/public/application/angular/directives/uninitialized.tsx b/src/plugins/discover/public/application/angular/directives/uninitialized.tsx index d04aea09331159..b315cd82a33f8e 100644 --- a/src/plugins/discover/public/application/angular/directives/uninitialized.tsx +++ b/src/plugins/discover/public/application/angular/directives/uninitialized.tsx @@ -20,7 +20,7 @@ import React from 'react'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; -import { EuiButton, EuiEmptyPrompt, EuiPage, EuiPageBody, EuiPageContent } from '@elastic/eui'; +import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; interface Props { onRefresh: () => void; @@ -29,39 +29,31 @@ interface Props { export const DiscoverUninitialized = ({ onRefresh }: Props) => { return ( - - - - - - - } - body={ -

    - -

    - } - actions={ - - - - } + + + + } + body={ +

    + - - - +

    + } + actions={ + + + + } + />
    ); }; From 2725d5b9435402d39da6f041bbd314776e6cff4b Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 24 Nov 2020 15:03:21 -0500 Subject: [PATCH 139/158] adjust space between Selected and Available fields --- .../public/application/components/sidebar/discover_sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a5b273d4235673..22c1f162ab22b8 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -290,7 +290,7 @@ export function DiscoverSidebar({ })} - {' '} + {' '} ) : null} Date: Tue, 24 Nov 2020 21:42:59 +0100 Subject: [PATCH 140/158] Improve scroll to top functionality --- .../application/components/discover_legacy.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 010731bffb32ba..c67b4f82909c44 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -173,7 +173,12 @@ export function DiscoverLegacy({ showSearchBar={true} useDefaultBehaviors={true} /> -
    +

    {savedSearch.title}

    @@ -315,9 +320,8 @@ export function DiscoverLegacy({ { - const skipToBottomBtn = document.getElementById('dscSkipButton'); - if (skipToBottomBtn) { - skipToBottomBtn.focus(); + if (scrollableMobile && scrollableMobile.current) { + scrollableMobile.current.focus(); } // depending on screen size there are different elements to scroll if (!isMobile() && scrollableDesktop.current) { From aa74f8672e8acc191d0d6894f314a54045a64beb Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 24 Nov 2020 16:55:49 -0500 Subject: [PATCH 141/158] Basic layout now using EuiPage components --- .../public/application/_discover.scss | 349 +++++++++-------- .../components/discover_legacy.tsx | 357 ++++++++++-------- .../sidebar/change_indexpattern.tsx | 14 +- .../sidebar/discover_field_search.tsx | 1 - .../components/sidebar/discover_sidebar.scss | 12 +- .../components/sidebar/discover_sidebar.tsx | 17 +- .../sidebar/discover_sidebar_responsive.tsx | 9 +- 7 files changed, 416 insertions(+), 343 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 70d7645097349a..42da7ab5f8139e 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -1,110 +1,150 @@ -.dscAppWrapper { - display: flex; - flex-direction: column; +discover-app { flex-grow: 1; - overflow: hidden; } .dscAppContainer { - position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; - display: flex; + height: calc(100vh - #{($euiHeaderHeightCompensation * 2)}); flex-direction: column; - > * { - position: relative; - } -} + overflow: hidden; + padding: 0; -discover-app { - flex-grow: 1; + .dscApp__frame { + overflow: hidden; + } } -.dscHitsCounter, -.dscTimeChartHeader { - flex-grow: 0; +.dscPageBody__contents { + overflow: hidden; + padding-top: $euiSizeXS / 2; // A little breathing room for the index pattern button } -.dscApp { - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - display: flex; - flex-direction: column; - height: 100%; +.eui-overflowHidden { overflow: hidden; } -.dscApp__header { - border-bottom: $euiBorderThin; - margin-bottom: $euiSize; +.dscPageContent, +.dscPageContent__inner { + height: 100%; } -.dscApp__frame { - position: relative; +.dscPageSidebar { + margin: 0; flex-grow: 1; - display: flex; - overflow: hidden; - @include euiBreakpoint('xs', 's') { - flex-grow: 0; - flex-wrap: wrap; - margin-left: 0; - margin-right: 0; - overflow-y: auto; - } + padding-left: $euiSize; + width: $euiSize * 19; } -.dscApp__content { - flex-grow: 1; - flex-direction: column; - display: flex; - overflow: hidden; - padding-right: $euiSizeS; +.dscPageSidebar__content { + height: 100%; } +.dscPageContent__wrapper { + padding: 0 $euiSize $euiSize 0; +} + +// .dscAppWrapper { +// display: flex; +// flex-direction: column; +// flex-grow: 1; +// overflow: hidden; +// } + +// .dscAppContainer { +// position: absolute; +// left: 0; +// right: 0; +// top: 0; +// bottom: 0; +// display: flex; +// flex-direction: column; +// > * { +// position: relative; +// } +// } + +// .dscHitsCounter, +// .dscTimeChartHeader { +// flex-grow: 0; +// } + +// .dscApp { +// position: absolute; +// top: 0; +// bottom: 0; +// left: 0; +// right: 0; +// display: flex; +// flex-direction: column; +// height: 100%; +// overflow: hidden; +// } + +// .dscApp__header { +// border-bottom: $euiBorderThin; +// margin-bottom: $euiSize; +// } + +// .dscApp__frame { +// position: relative; +// flex-grow: 1; +// display: flex; +// overflow: hidden; +// @include euiBreakpoint('xs', 's') { +// flex-grow: 0; +// flex-wrap: wrap; +// margin-left: 0; +// margin-right: 0; +// overflow-y: auto; +// } +// } + +// .dscApp__content { +// flex-grow: 1; +// flex-direction: column; +// display: flex; +// overflow: hidden; +// padding-right: $euiSizeS; +// } + .dscHistogram { display: flex; height: $euiSize * 12.5; padding: $euiSizeS; } -// SASSTODO: replace the z-index value with a variable -.dscWrapper { - padding-left: $euiSizeXL; - padding-right: $euiSizeS; - z-index: 1; - @include euiBreakpoint('xs', 's', 'm') { - padding-left: $euiSizeS; - } -} - -@include euiPanel('.dscWrapper__content'); - -.dscWrapper__content { - padding-top: $euiSizeXS; - background-color: $euiColorEmptyShade; - flex-grow: 1; - flex-direction: column; - display: flex; - overflow: hidden; - - @include euiBreakpoint('m', 'l', 'xl') { - margin-right: $euiSize; - margin-bottom: $euiSize; - } - - @include euiBreakpoint('xs', 's') { - margin: $euiSizeS; - } - - .kbn-table { - margin-bottom: 0; - } -} +// // SASSTODO: replace the z-index value with a variable +// .dscWrapper { +// padding-left: $euiSizeXL; +// padding-right: $euiSizeS; +// z-index: 1; +// @include euiBreakpoint('xs', 's', 'm') { +// padding-left: $euiSizeS; +// } +// } + +// @include euiPanel('.dscWrapper__content'); + +// .dscWrapper__content { +// padding-top: $euiSizeXS; +// background-color: $euiColorEmptyShade; +// flex-grow: 1; +// flex-direction: column; +// display: flex; +// overflow: hidden; + +// @include euiBreakpoint('m', 'l', 'xl') { +// margin-right: $euiSize; +// margin-bottom: $euiSize; +// } + +// @include euiBreakpoint('xs', 's') { +// margin: $euiSizeS; +// } + +// .kbn-table { +// margin-bottom: 0; +// } +// } .dscTimechart { display: block; @@ -118,7 +158,8 @@ discover-app { } .dscResultCount { - padding: 0 $euiSizeS; + padding-left: $euiSizeS; + padding-right: $euiSizeS; } .dscTimechart__header { @@ -128,21 +169,21 @@ discover-app { padding: $euiSizeXS 0; } -.dscLoading { - text-align: center; - padding: $euiSizeL 0; -} +// .dscLoading { +// text-align: center; +// padding: $euiSizeL 0; +// } -.dscTable { - overflow: auto; - //will-change: transform; +// .dscTable { +// overflow: auto; +// //will-change: transform; - // SASSTODO: add a monospace modifier to the doc-table component - .kbnDocTable__row { - font-family: $euiCodeFontFamily; - font-size: $euiFontSizeXS; - } -} +// // SASSTODO: add a monospace modifier to the doc-table component +// .kbnDocTable__row { +// font-family: $euiCodeFontFamily; +// font-size: $euiFontSizeXS; +// } +// } .dscTable__footer { background-color: $euiColorLightShade; @@ -150,62 +191,62 @@ discover-app { text-align: center; } -.dscResults { - flex-grow: 1; - flex-direction: column; - display: flex; - overflow: hidden; -} - -.dscResults__interval { - display: inline-block; - width: auto; -} - -.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; -} - -.dscCollapsibleSidebar__collapseButton { - align-self: flex-start; - &:not(.closed) { - position: relative; - left: -$euiSizeS; - } -} - -.dscCollapsibleSidebar { - position: relative; - z-index: $euiZLevel1; - - &.closed { - width: 0 !important; - border-right-width: 0; - border-left-width: 0; - } -} - -@include euiBreakpoint('xs', 's', 'm') { - .dscCollapsibleSidebar { - &.closed { - display: none; - } - - .dscCollapsibleSidebar__collapseButton { - display: none; - } - } -} +// .dscResults { +// flex-grow: 1; +// flex-direction: column; +// display: flex; +// overflow: hidden; +// } + +// .dscResults__interval { +// display: inline-block; +// width: auto; +// } + +// .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; +// } + +// .dscCollapsibleSidebar__collapseButton { +// align-self: flex-start; +// &:not(.closed) { +// position: relative; +// left: -$euiSizeS; +// } +// } + +// .dscCollapsibleSidebar { +// position: relative; +// z-index: $euiZLevel1; + +// &.closed { +// width: 0 !important; +// border-right-width: 0; +// border-left-width: 0; +// } +// } + +// @include euiBreakpoint('xs', 's', 'm') { +// .dscCollapsibleSidebar { +// &.closed { +// display: none; +// } + +// .dscCollapsibleSidebar__collapseButton { +// display: none; +// } +// } +// } diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index dd917d70cc8013..d1023d4755fd95 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -19,7 +19,16 @@ import React, { useState, useRef } from 'react'; import './discover.scss'; import classNames from 'classnames'; -import { EuiButtonEmpty, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiHideFor } from '@elastic/eui'; +import { + EuiButtonEmpty, + EuiButtonIcon, + EuiFlexGroup, + EuiFlexItem, + EuiHideFor, + EuiPage, + EuiPageBody, + EuiPageContent, +} from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { IUiSettingsClient, MountPoint } from 'kibana/public'; @@ -149,7 +158,7 @@ export function DiscoverLegacy({ return ( -
    + -
    +

    {savedSearch.title}

    - - - - 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); - }} - > - {toggleOn ? 'Hide chart' : 'Show chart'} - - - - -
    - {toggleOn && opts.timefield && ( -
    + + + 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' && ( + - {opts.chartAggConfigs && rows.length !== 0 && ( -
    - -
    + + + + 0 ? hits : 0} + showResetButton={!!(savedSearch && savedSearch.id)} + onResetQuery={resetQuery} + /> + + + + + + { + toggleChart(!toggleOn); + }} + > + {toggleOn ? 'Hide chart' : 'Show chart'} + + + + + + {toggleOn && opts.timefield && ( + +
    + {opts.chartAggConfigs && rows.length !== 0 && ( +
    + +
    + )} +
    +
    )} -
    - )} -
    -
    -

    - -

    - {rows && rows.length && ( -
    - - - ​ - - {rows.length === opts.sampleSize && ( -
    - +
    +

    + +

    + {rows && rows.length && ( +
    + + + ​ + + {rows.length === opts.sampleSize && ( +
    + - { - const skipToBottomBtn = document.getElementById('dscSkipButton'); - if (skipToBottomBtn) { - skipToBottomBtn.focus(); - } - // depending on screen size there are different elements to scroll - if (!isMobile() && scrollableDesktop.current) { - scrollableDesktop.current.scrollTo(0, 0); - } - if (isMobile() && scrollableMobile.current) { - scrollableMobile.current.scrollTo(0, 0); - } - }} - > - - + { + const skipToBottomBtn = document.getElementById( + 'dscSkipButton' + ); + if (skipToBottomBtn) { + skipToBottomBtn.focus(); + } + // depending on screen size there are different elements to scroll + if (!isMobile() && scrollableDesktop.current) { + scrollableDesktop.current.scrollTo(0, 0); + } + if (isMobile() && scrollableMobile.current) { + scrollableMobile.current.scrollTo(0, 0); + } + }} + > + + +
    + )}
    )} -
    - )} -
    -
    - - )} -
    -
    -
    +
    +
    + + )} + + + + + ); } diff --git a/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx b/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx index 4a539b618f817f..903ea73553ddd8 100644 --- a/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx +++ b/src/plugins/discover/public/application/components/sidebar/change_indexpattern.tsx @@ -20,16 +20,16 @@ import { i18n } from '@kbn/i18n'; import React, { useState } from 'react'; import { - EuiButtonEmpty, + EuiButton, EuiPopover, EuiPopoverTitle, EuiSelectable, - EuiButtonEmptyProps, + EuiButtonProps, } from '@elastic/eui'; import { EuiSelectableProps } from '@elastic/eui/src/components/selectable/selectable'; import { IndexPatternRef } from './types'; -export type ChangeIndexPatternTriggerProps = EuiButtonEmptyProps & { +export type ChangeIndexPatternTriggerProps = EuiButtonProps & { label: string; title?: string; }; @@ -54,9 +54,7 @@ export function ChangeIndexPattern({ const createTrigger = function () { const { label, title, ...rest } = trigger; return ( - {label} - + ); }; @@ -74,8 +72,6 @@ export function ChangeIndexPattern({ button={createTrigger()} isOpen={isPopoverOpen} closePopover={() => setPopoverIsOpen(false)} - className="eui-textTruncate" - anchorClassName="eui-textTruncate" display="block" panelPaddingSize="s" ownFocus 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 8f957f96c9e7ef..70dcb010456ca2 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 @@ -257,7 +257,6 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { onChange('name', event.currentTarget.value)} placeholder={searchPlaceholder} 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 3095a6b54fb885..75fd79668cb5de 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -57,12 +57,12 @@ border-bottom-color: transparent; } -.dscIndexPattern__container { - display: flex; - align-items: center; - height: $euiSize * 3; - margin-top: -$euiSizeS; -} +// .dscIndexPattern__container { +// display: flex; +// align-items: center; +// height: $euiSize * 3; +// margin-top: -$euiSizeS; +// } .dscIndexPattern__triggerButton { @include euiTitle('xs'); 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 a5b273d4235673..790bef7ab70116 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -30,6 +30,7 @@ import { EuiTitle, EuiSpacer, EuiNotificationBadge, + EuiPageSideBar, } from '@elastic/eui'; import { DiscoverField } from './discover_field'; import { DiscoverIndexPattern } from './discover_index_pattern'; @@ -199,8 +200,8 @@ export function DiscoverSidebar({ return ( -
    - {' '} - +
    {fields.length > 0 && ( @@ -385,7 +386,7 @@ export function DiscoverSidebar({
    -
    +
    ); } 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 345af31fe99728..7ebad24810fcb3 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 @@ -120,11 +120,12 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) return ( <> -
    - -
    + fieldFilter={fieldFilter} + setFieldFilter={setFieldFilter} + />
    From bd98104a8355806f1959bb54f06c63a957f07bc4 Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 24 Nov 2020 18:12:12 -0500 Subject: [PATCH 142/158] Cleanup of class names and styles --- .../public/application/_discover.scss | 252 --------------- .../angular/doc_table/infinite_scroll.ts | 2 +- .../application/components/discover.scss | 70 ++++- .../components/discover_legacy.tsx | 27 +- .../components/hits_counter/hits_counter.scss | 3 + .../components/hits_counter/hits_counter.tsx | 2 + .../loading_spinner/loading_spinner.scss | 4 + .../loading_spinner/loading_spinner.tsx | 2 + .../sidebar/change_indexpattern.tsx | 3 +- .../sidebar/discover_field_details.scss | 5 + .../sidebar/discover_field_search.scss | 7 + .../sidebar/discover_field_search.tsx | 4 +- .../sidebar/discover_index_pattern.tsx | 39 ++- .../components/sidebar/discover_sidebar.scss | 103 ++---- .../components/sidebar/discover_sidebar.tsx | 297 +++++++++--------- .../sidebar/discover_sidebar_responsive.tsx | 18 +- .../timechart_header/timechart_header.scss | 4 + .../discover/public/application/index.scss | 1 - 18 files changed, 289 insertions(+), 554 deletions(-) delete mode 100644 src/plugins/discover/public/application/_discover.scss create mode 100644 src/plugins/discover/public/application/components/hits_counter/hits_counter.scss create mode 100644 src/plugins/discover/public/application/components/loading_spinner/loading_spinner.scss create mode 100644 src/plugins/discover/public/application/components/sidebar/discover_field_search.scss diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss deleted file mode 100644 index 42da7ab5f8139e..00000000000000 --- a/src/plugins/discover/public/application/_discover.scss +++ /dev/null @@ -1,252 +0,0 @@ -discover-app { - flex-grow: 1; -} - -.dscAppContainer { - height: calc(100vh - #{($euiHeaderHeightCompensation * 2)}); - flex-direction: column; - overflow: hidden; - padding: 0; - - .dscApp__frame { - overflow: hidden; - } -} - -.dscPageBody__contents { - overflow: hidden; - padding-top: $euiSizeXS / 2; // A little breathing room for the index pattern button -} - -.eui-overflowHidden { - overflow: hidden; -} - -.dscPageContent, -.dscPageContent__inner { - height: 100%; -} - -.dscPageSidebar { - margin: 0; - flex-grow: 1; - padding-left: $euiSize; - width: $euiSize * 19; -} - -.dscPageSidebar__content { - height: 100%; -} - -.dscPageContent__wrapper { - padding: 0 $euiSize $euiSize 0; -} - -// .dscAppWrapper { -// display: flex; -// flex-direction: column; -// flex-grow: 1; -// overflow: hidden; -// } - -// .dscAppContainer { -// position: absolute; -// left: 0; -// right: 0; -// top: 0; -// bottom: 0; -// display: flex; -// flex-direction: column; -// > * { -// position: relative; -// } -// } - -// .dscHitsCounter, -// .dscTimeChartHeader { -// flex-grow: 0; -// } - -// .dscApp { -// position: absolute; -// top: 0; -// bottom: 0; -// left: 0; -// right: 0; -// display: flex; -// flex-direction: column; -// height: 100%; -// overflow: hidden; -// } - -// .dscApp__header { -// border-bottom: $euiBorderThin; -// margin-bottom: $euiSize; -// } - -// .dscApp__frame { -// position: relative; -// flex-grow: 1; -// display: flex; -// overflow: hidden; -// @include euiBreakpoint('xs', 's') { -// flex-grow: 0; -// flex-wrap: wrap; -// margin-left: 0; -// margin-right: 0; -// overflow-y: auto; -// } -// } - -// .dscApp__content { -// flex-grow: 1; -// flex-direction: column; -// display: flex; -// overflow: hidden; -// padding-right: $euiSizeS; -// } - -.dscHistogram { - display: flex; - height: $euiSize * 12.5; - padding: $euiSizeS; -} - -// // SASSTODO: replace the z-index value with a variable -// .dscWrapper { -// padding-left: $euiSizeXL; -// padding-right: $euiSizeS; -// z-index: 1; -// @include euiBreakpoint('xs', 's', 'm') { -// padding-left: $euiSizeS; -// } -// } - -// @include euiPanel('.dscWrapper__content'); - -// .dscWrapper__content { -// padding-top: $euiSizeXS; -// background-color: $euiColorEmptyShade; -// flex-grow: 1; -// flex-direction: column; -// display: flex; -// overflow: hidden; - -// @include euiBreakpoint('m', 'l', 'xl') { -// margin-right: $euiSize; -// margin-bottom: $euiSize; -// } - -// @include euiBreakpoint('xs', 's') { -// margin: $euiSizeS; -// } - -// .kbn-table { -// margin-bottom: 0; -// } -// } - -.dscTimechart { - display: block; - position: relative; - - // SASSTODO: the visualizing component should have an option or a modifier - .series > rect { - fill-opacity: 0.5; - stroke-width: 1; - } -} - -.dscResultCount { - padding-left: $euiSizeS; - padding-right: $euiSizeS; -} - -.dscTimechart__header { - display: flex; - justify-content: center; - min-height: $euiSizeXXL; - padding: $euiSizeXS 0; -} - -// .dscLoading { -// text-align: center; -// padding: $euiSizeL 0; -// } - -// .dscTable { -// overflow: auto; -// //will-change: transform; - -// // SASSTODO: add a monospace modifier to the doc-table component -// .kbnDocTable__row { -// font-family: $euiCodeFontFamily; -// font-size: $euiFontSizeXS; -// } -// } - -.dscTable__footer { - background-color: $euiColorLightShade; - padding: $euiSizeXS $euiSizeS; - text-align: center; -} - -// .dscResults { -// flex-grow: 1; -// flex-direction: column; -// display: flex; -// overflow: hidden; -// } - -// .dscResults__interval { -// display: inline-block; -// width: auto; -// } - -// .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; -// } - -// .dscCollapsibleSidebar__collapseButton { -// align-self: flex-start; -// &:not(.closed) { -// position: relative; -// left: -$euiSizeS; -// } -// } - -// .dscCollapsibleSidebar { -// position: relative; -// z-index: $euiZLevel1; - -// &.closed { -// width: 0 !important; -// border-right-width: 0; -// border-left-width: 0; -// } -// } - -// @include euiBreakpoint('xs', 's', 'm') { -// .dscCollapsibleSidebar { -// &.closed { -// display: none; -// } - -// .dscCollapsibleSidebar__collapseButton { -// display: none; -// } -// } -// } 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 0db5fb6d8302f9..fdd45ffb5e1ad0 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 @@ -33,7 +33,7 @@ export function createInfiniteScrollDirective() { * and have therefore to be considered for calculation of infinite scrolling */ const scrollDiv = $element.parents('.dscTable'); - const scrollDivMobile = $element.parents('.dscApp__frame'); + const scrollDivMobile = $element.parents('.dscPageBody'); function onScroll() { if (!$scope.more) return; diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index e633c30bcfddc8..48e520a5ac8716 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -1,4 +1,36 @@ +discover-app { + flex-grow: 1; +} + +.dscPage { + height: calc(100vh - #{($euiHeaderHeightCompensation * 2)}); + flex-direction: column; + overflow: hidden; + padding: 0; + + .dscPageBody { + overflow: hidden; + } +} + +.dscPageBody__contents { + overflow: hidden; + padding-top: $euiSizeXS / 2; // A little breathing room for the index pattern button +} + +.dscPageContent__wrapper { + padding: 0 $euiSize $euiSize 0; +} + +.dscPageContent, +.dscPageContent__inner { + height: 100%; +} + .dscResultCount { + padding-left: $euiSizeS; + padding-right: $euiSizeS; + @include euiBreakpoint('xs', 's') { .dscResultCount__toggle { align-items: flex-end; @@ -12,25 +44,33 @@ } } -.dscSidebar__mobile { - width: 100%; - padding: 0 $euiSizeS $euiSizeS; - .dscSidebar__sectionStatic { - padding: 0; - } - .dscSidebar__mobileButton { - justify-content: space-between; - } - .dscSidebar__mobileBadge { - margin-left: $euiSizeXS; +.dscTimechart { + display: block; + position: relative; + + // SASSTODO: the visualizing component should have an option or a modifier + .series > rect { + fill-opacity: 0.5; + stroke-width: 1; } } -.dscSidebarFlyout__header { - align-items: center; +.dscHistogram { + display: flex; + height: $euiSize * 12.5; + padding: $euiSizeS; +} + +.dscTable { + // SASSTODO: add a monospace modifier to the doc-table component + .kbnDocTable__row { + font-family: $euiCodeFontFamily; + font-size: $euiFontSizeXS; + } } -.dscLoading { +.dscTable__footer { + background-color: $euiColorLightShade; + padding: $euiSizeXS $euiSizeS; text-align: center; - padding: $euiSizeL 0; } diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index d1023d4755fd95..df43d95e342da0 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState, useRef } from 'react'; import './discover.scss'; -import classNames from 'classnames'; + +import React, { useState, useRef } from 'react'; import { EuiButtonEmpty, EuiButtonIcon, @@ -135,7 +135,7 @@ export function DiscoverLegacy({ }: DiscoverProps) { const scrollableDesktop = useRef(null); const scrollableMobile = useRef(null); - const collapseIcon = useRef(null); + const collapseIcon = useRef(null); const isMobile = () => { // collapse icon isn't displayed in mobile view, use it to detect which view is displayed return collapseIcon && !collapseIcon.current; @@ -152,13 +152,10 @@ export function DiscoverLegacy({ bucketAggConfig && search.aggs.isDateHistogramBucketAggConfig(bucketAggConfig) ? bucketAggConfig.buckets?.getInterval() : undefined; - const sidebarClassName = classNames({ - closed: isSidebarClosed, - }); return ( - + @@ -195,22 +192,20 @@ export function DiscoverLegacy({ selectedIndexPattern={searchSource && searchSource.getField('index')} services={services} setIndexPattern={setIndexPattern} - sidebarClassName={sidebarClassName} + isClosed={isSidebarClosed} trackUiMetric={trackUiMetric} /> - + setIsSidebarClosed(!isSidebarClosed)} data-test-subj="collapseSideBarButton" aria-controls="discover-sidebar" aria-expanded={isSidebarClosed ? 'false' : 'true'} aria-label="Toggle sidebar" - className={`dscCollapsibleSidebar__collapseButton ${sidebarClassName}`} + buttonRef={collapseIcon} /> @@ -292,9 +287,9 @@ export function DiscoverLegacy({ )} - +
    @@ -305,7 +300,7 @@ export function DiscoverLegacy({ /> {rows && rows.length && ( -
    +
    setPopoverIsOpen(!isPopoverOpen)} {...rest} > - {label} + {label} ); }; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_details.scss b/src/plugins/discover/public/application/components/sidebar/discover_field_details.scss index f4b3eed741f9f0..ca48d67f75dec4 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field_details.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_details.scss @@ -1,3 +1,8 @@ +.dscFieldDetails { + color: $euiTextColor; + margin-bottom: $euiSizeS; +} + .dscFieldDetails__visualizeBtn { @include euiFontSizeXS; height: $euiSizeL !important; diff --git a/src/plugins/discover/public/application/components/sidebar/discover_field_search.scss b/src/plugins/discover/public/application/components/sidebar/discover_field_search.scss new file mode 100644 index 00000000000000..4b620f20737710 --- /dev/null +++ b/src/plugins/discover/public/application/components/sidebar/discover_field_search.scss @@ -0,0 +1,7 @@ +.dscFieldSearch__formWrapper { + padding: $euiSizeM; +} + +.dscFieldSearch__filterWrapper { + width: 100%; +} 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 70dcb010456ca2..60eccefd350069 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 @@ -16,6 +16,8 @@ * specific language governing permissions and limitations * under the License. */ +import './discover_field_search.scss'; + import React, { OptionHTMLAttributes, ReactNode, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { @@ -271,7 +273,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) { id="dataPanelTypeFilter" panelClassName="euiFilterGroup__popoverPanel" panelPaddingSize="none" - anchorPosition="downLeft" + anchorPosition="rightUp" display="block" isOpen={isPopoverOpen} closePopover={() => { diff --git a/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.tsx b/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.tsx index 3acdcb1e920919..0bb03492cfc75f 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_index_pattern.tsx @@ -65,26 +65,23 @@ export function DiscoverIndexPattern({ } return ( -
    - - { - const indexPattern = options.find((pattern) => pattern.id === id); - if (indexPattern) { - setIndexPattern(id); - setSelected(indexPattern); - } - }} - /> - -
    + + { + const indexPattern = options.find((pattern) => pattern.id === id); + if (indexPattern) { + setIndexPattern(id); + setSelected(indexPattern); + } + }} + /> + ); } 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 75fd79668cb5de..3f005c0059b1d1 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -1,73 +1,34 @@ .dscSidebar { margin: 0; - display: flex; - flex-direction: column; - position: relative; + flex-grow: 1; + padding-left: $euiSize; + width: $euiSize * 19; + height: 100%; } -.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: 0 $euiSize; - } +.dscSidebar__group { + height: 100%; } -/** - * 1. Don't cut off the shadow of the field items - */ - -.dscSidebar__scrollSection { - @include euiBreakpoint('xs', 's') { - padding-left: $euiSize; - padding-top: $euiSize; +.dscSidebar__mobile { + width: 100%; + padding: 0 $euiSizeS $euiSizeS; + .dscSidebar__sectionStatic { + padding: 0; } - @include euiOverflowShadow; - @include euiScrollBar; - margin-left: -$euiSize; /* 1 */ - position: relative; - flex-grow: 1; - overflow: auto; -} - -.dscSidebar__scrollSectionList { - @include euiBreakpoint('m', 'l', 'xl') { - padding-top: $euiSizeS; - position: absolute; - top: 0; - left: $euiSize; /* 1 */ - right: $euiSizeXS; /* 1 */ + .dscSidebar__mobileButton { + justify-content: space-between; + } + .dscSidebar__mobileBadge { + margin-left: $euiSizeXS; } } -.dscSidebar__container { - padding-left: 0 !important; - padding-right: 0 !important; - background-color: transparent; - border-right-color: transparent; - border-bottom-color: transparent; +.dscSidebar__flyoutHeader { + align-items: center; } -// .dscIndexPattern__container { -// display: flex; -// align-items: center; -// height: $euiSize * 3; -// margin-top: -$euiSizeS; -// } - -.dscIndexPattern__triggerButton { - @include euiTitle('xs'); - line-height: $euiSizeXXL; -} +/// MOVE .dscFieldList { list-style: none; @@ -84,15 +45,6 @@ background-color: lightOrDarkTheme(tint($euiColorPrimary, 90%), $euiColorLightShade); } -.dscFieldChooser { - padding-left: $euiSize; -} - -.dscFieldChooser__toggle { - color: $euiColorMediumShade; - margin-left: $euiSizeS !important; -} - .dscSidebarItem { &:hover, &:focus-within, @@ -126,20 +78,3 @@ padding: 0 4px; } } - -.dscFieldSearch { - padding: $euiSizeS; -} - -.dscFieldSearch__filterWrapper { - width: 100%; -} - -.dscFieldSearch__formWrapper { - padding: $euiSizeM; -} - -.dscFieldDetails { - color: $euiTextColor; - margin-bottom: $euiSizeS; -} 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 80c3f10a2b4a58..8f607ecf338ef7 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -16,12 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +import './discover_sidebar.scss'; + import React, { useCallback, useEffect, useState, useMemo } from 'react'; import { isEqual, sortBy } from 'lodash'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { UiStatsMetricType } from '@kbn/analytics'; -import './discover_sidebar.scss'; import { EuiAccordion, EuiFlexItem, @@ -182,7 +183,6 @@ export function DiscoverSidebar({ if (useFlyout) { return (
    -
    -
    - {fields.length > 0 && ( - <> - {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 && ( - <> - - - -
      + + } + extraAction={ + - {popularFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    - - )} -
      + } > - {unpopularFields.map((field: IndexPatternField) => { - return ( -
    • - -
    • - ); - })} -
    -
    + +
      + {selectedFields.map((field: IndexPatternField) => { + return ( +
    • + +
    • + ); + })} +
    + + {' '} + + ) : null} + + + + + + } + extraAction={ + + {popularFields.length + unpopularFields.length} + + } + > - - )} -
    + {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_responsive.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.tsx index 7ebad24810fcb3..6897d574fc8a34 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 @@ -93,9 +93,9 @@ export interface DiscoverSidebarResponsiveProps { */ useFlyout?: boolean; /** - * Additional classname + * Has been toggled closed */ - sidebarClassName?: string; + isClosed?: boolean; /** * Metric tracking function * @param metricType @@ -113,24 +113,18 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) const [fieldFilter, setFieldFilter] = useState(getDefaultFieldFilter()); const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); - if (!props.selectedIndexPattern) { + if (!props.selectedIndexPattern || props.isClosed) { return null; } return ( <> - + -
    +
    setIsFlyoutVisible(false)} aria-labelledby="flyoutTitle"> diff --git a/src/plugins/discover/public/application/components/timechart_header/timechart_header.scss b/src/plugins/discover/public/application/components/timechart_header/timechart_header.scss index 980ab9a004e3a4..506dc26d9bee37 100644 --- a/src/plugins/discover/public/application/components/timechart_header/timechart_header.scss +++ b/src/plugins/discover/public/application/components/timechart_header/timechart_header.scss @@ -1,3 +1,7 @@ .dscTimeIntervalSelect { align-items: center; } + +.dscTimeChartHeader { + flex-grow: 0; +} diff --git a/src/plugins/discover/public/application/index.scss b/src/plugins/discover/public/application/index.scss index 5aa353828274cb..3c24d4f51de2e6 100644 --- a/src/plugins/discover/public/application/index.scss +++ b/src/plugins/discover/public/application/index.scss @@ -1,2 +1 @@ @import 'angular/index'; -@import 'discover'; From ede3d6ea04421fe9487c5e99a00765c5a86eccb0 Mon Sep 17 00:00:00 2001 From: cchaos Date: Tue, 24 Nov 2020 22:31:13 -0500 Subject: [PATCH 143/158] Cleaning up old style and fixing up mobile flyout --- .../application/components/discover.scss | 18 +++- .../components/discover_legacy.tsx | 9 +- .../components/sidebar/discover_sidebar.scss | 31 +++---- .../components/sidebar/discover_sidebar.tsx | 20 ++--- .../sidebar/discover_sidebar_responsive.tsx | 84 ++++++++++--------- .../timechart_header/timechart_header.tsx | 3 +- 6 files changed, 83 insertions(+), 82 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index 48e520a5ac8716..efab60f7b61b7f 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -3,7 +3,10 @@ discover-app { } .dscPage { - height: calc(100vh - #{($euiHeaderHeightCompensation * 2)}); + @include euiBreakpoint('m', 'l', 'xl') { + height: calc(100vh - #{($euiHeaderHeightCompensation * 2)}); + } + flex-direction: column; overflow: hidden; padding: 0; @@ -13,6 +16,11 @@ discover-app { } } +.dscPageBody__inner { + overflow: hidden; + height: 100%; +} + .dscPageBody__contents { overflow: hidden; padding-top: $euiSizeXS / 2; // A little breathing room for the index pattern button @@ -20,6 +28,10 @@ discover-app { .dscPageContent__wrapper { padding: 0 $euiSize $euiSize 0; + + @include euiBreakpoint('xs', 's') { + padding: 0 $euiSize $euiSize; + } } .dscPageContent, @@ -28,13 +40,11 @@ discover-app { } .dscResultCount { - padding-left: $euiSizeS; - padding-right: $euiSizeS; + padding: $euiSizeS; @include euiBreakpoint('xs', 's') { .dscResultCount__toggle { align-items: flex-end; - margin-top: 0 !important; } .dscResuntCount__title, diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index df43d95e342da0..f6564e29eacb90 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -171,15 +171,11 @@ export function DiscoverLegacy({ showSearchBar={true} useDefaultBehaviors={true} /> - +

    {savedSearch.title}

    - + { toggleChart(!toggleOn); 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 3f005c0059b1d1..ea871aae6c3d54 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -4,6 +4,12 @@ padding-left: $euiSize; width: $euiSize * 19; height: 100%; + + @include euiBreakpoint('xs', 's') { + width: 100%; + padding: $euiSize; + background-color: $euiPageBackgroundColor; + } } .dscSidebar__group { @@ -12,15 +18,11 @@ .dscSidebar__mobile { width: 100%; - padding: 0 $euiSizeS $euiSizeS; - .dscSidebar__sectionStatic { - padding: 0; - } - .dscSidebar__mobileButton { - justify-content: space-between; - } + padding: $euiSize $euiSize 0; + .dscSidebar__mobileBadge { - margin-left: $euiSizeXS; + margin-left: $euiSizeS; + vertical-align: text-bottom; } } @@ -28,11 +30,7 @@ align-items: center; } -/// MOVE - .dscFieldList { - list-style: none; - margin-bottom: 0; padding: 0 $euiSizeXS $euiSizeXS; } @@ -42,6 +40,7 @@ } .dscFieldList--popular { + padding-bottom: $euiSizeS; background-color: lightOrDarkTheme(tint($euiColorPrimary, 90%), $euiColorLightShade); } @@ -61,7 +60,6 @@ */ .dscSidebarItem__action { opacity: 0; /* 1 */ - transition: none; &.dscSidebarItem__mobile { opacity: 1; @@ -70,11 +68,4 @@ &:focus { opacity: 1; /* 2 */ } - font-size: $euiFontSizeXS; - padding: 2px 6px !important; - height: 22px !important; - min-width: auto !important; - .euiButton__content { - padding: 0 4px; - } } 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 8f607ecf338ef7..697812b3a90ed7 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -187,13 +187,11 @@ export function DiscoverSidebar({ defaultMessage: 'Index and fields', })} > -
    - o.attributes.title)} - /> -
    + o.attributes.title)} + />
    ); } @@ -261,9 +259,9 @@ export function DiscoverSidebar({ } > - +
      @@ -290,7 +288,7 @@ export function DiscoverSidebar({ })}
    - {' '} + {' '} ) : null} 0 && ( <> -
    + setIsFlyoutVisible(true)} > @@ -151,48 +152,51 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) id="discover.fieldChooser.fieldsMobileButtonLabel" defaultMessage="Fields" /> - + {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', - })} -

    -
    -
    -
    -
    - + + setIsFlyoutVisible(false)} + aria-labelledby="flyoutTitle" + ownFocus + > + + +

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

    +
    +
    + {/* No flyout body because the list has its own background and scroll */} -
    -
    + + )} 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 ecbc6a48ea8161..bef83400c25a8b 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 @@ -104,7 +104,8 @@ export function TimechartHeader({ From 1aa09c35cb34262a3ae0cbe04c520958d9431ccd Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 25 Nov 2020 07:10:05 +0100 Subject: [PATCH 144/158] Cleanups --- .../public/application/_discover.scss | 55 ------------------- 1 file changed, 55 deletions(-) diff --git a/src/plugins/discover/public/application/_discover.scss b/src/plugins/discover/public/application/_discover.scss index 70d7645097349a..e9fe760c0956ea 100644 --- a/src/plugins/discover/public/application/_discover.scss +++ b/src/plugins/discover/public/application/_discover.scss @@ -27,23 +27,6 @@ discover-app { flex-grow: 0; } -.dscApp { - position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - display: flex; - flex-direction: column; - height: 100%; - overflow: hidden; -} - -.dscApp__header { - border-bottom: $euiBorderThin; - margin-bottom: $euiSize; -} - .dscApp__frame { position: relative; flex-grow: 1; @@ -58,14 +41,6 @@ discover-app { } } -.dscApp__content { - flex-grow: 1; - flex-direction: column; - display: flex; - overflow: hidden; - padding-right: $euiSizeS; -} - .dscHistogram { display: flex; height: $euiSize * 12.5; @@ -121,13 +96,6 @@ discover-app { padding: 0 $euiSizeS; } -.dscTimechart__header { - display: flex; - justify-content: center; - min-height: $euiSizeXXL; - padding: $euiSizeXS 0; -} - .dscLoading { text-align: center; padding: $euiSizeL 0; @@ -135,7 +103,6 @@ discover-app { .dscTable { overflow: auto; - //will-change: transform; // SASSTODO: add a monospace modifier to the doc-table component .kbnDocTable__row { @@ -157,28 +124,6 @@ discover-app { overflow: hidden; } -.dscResults__interval { - display: inline-block; - width: auto; -} - -.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; -} - .dscCollapsibleSidebar__collapseButton { align-self: flex-start; &:not(.closed) { From fb8ad1d7baf6ce4a5b77db2da1c10066adc7c157 Mon Sep 17 00:00:00 2001 From: cchaos Date: Wed, 25 Nov 2020 13:22:36 -0500 Subject: [PATCH 145/158] Fixing position of skip button --- .../public/application/components/discover_legacy.tsx | 2 +- .../components/sidebar/discover_sidebar_responsive.tsx | 4 ---- .../components/skip_bottom_button/skip_bottom_button.tsx | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index f6564e29eacb90..232443ee26c74f 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -257,9 +257,9 @@ export function DiscoverLegacy({ > {toggleOn ? 'Hide chart' : 'Show chart'} - + {toggleOn && opts.timefield && ( 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 69b501b7d284cc..e0cc2c8d759e67 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 @@ -22,16 +22,12 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { UiStatsMetricType } from '@kbn/analytics'; import { - EuiFlexItem, - EuiFlexGroup, EuiTitle, EuiHideFor, EuiShowFor, EuiButton, EuiBadge, EuiFlyoutHeader, - EuiButtonIcon, - EuiFlyoutBody, EuiFlyout, EuiSpacer, EuiIcon, diff --git a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx index 562cbda1fc3a03..fbcfc422d20408 100644 --- a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx +++ b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx @@ -42,6 +42,7 @@ export function SkipBottomButton({ onClick }: SkipBottomButtonProps) { id="dscSkipButton" destinationId="" data-test-subj="discoverSkipTableButton" + position="absolute" > Date: Wed, 25 Nov 2020 13:32:50 -0500 Subject: [PATCH 146/158] Using centered content for uninitialized --- .../public/application/angular/directives/_index.scss | 1 - .../angular/directives/_uninitialized.scss | 3 --- .../application/angular/directives/uninitialized.tsx | 1 - .../public/application/components/discover.scss | 4 ++++ .../public/application/components/discover_legacy.tsx | 11 ++++++++++- 5 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 src/plugins/discover/public/application/angular/directives/_uninitialized.scss diff --git a/src/plugins/discover/public/application/angular/directives/_index.scss b/src/plugins/discover/public/application/angular/directives/_index.scss index fe04a167a94905..dfacdf45c9d7bf 100644 --- a/src/plugins/discover/public/application/angular/directives/_index.scss +++ b/src/plugins/discover/public/application/angular/directives/_index.scss @@ -1,2 +1 @@ @import 'histogram'; -@import 'uninitialized'; diff --git a/src/plugins/discover/public/application/angular/directives/_uninitialized.scss b/src/plugins/discover/public/application/angular/directives/_uninitialized.scss deleted file mode 100644 index 2e517f2e0cab89..00000000000000 --- a/src/plugins/discover/public/application/angular/directives/_uninitialized.scss +++ /dev/null @@ -1,3 +0,0 @@ -.dscUninitialized { - margin-top: $euiSize; -} diff --git a/src/plugins/discover/public/application/angular/directives/uninitialized.tsx b/src/plugins/discover/public/application/angular/directives/uninitialized.tsx index b315cd82a33f8e..f2b1f584224ef7 100644 --- a/src/plugins/discover/public/application/angular/directives/uninitialized.tsx +++ b/src/plugins/discover/public/application/angular/directives/uninitialized.tsx @@ -31,7 +31,6 @@ export const DiscoverUninitialized = ({ onRefresh }: Props) => { diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index efab60f7b61b7f..1c32976132a32f 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -39,6 +39,10 @@ discover-app { height: 100%; } +.dscPageContent--centered { + height: auto; +} + .dscResultCount { padding: $euiSizeS; diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 232443ee26c74f..1e23e917504e4a 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -32,6 +32,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; import { IUiSettingsClient, MountPoint } from 'kibana/public'; +import classNames from 'classnames'; import { HitsCounter } from './hits_counter'; import { TimechartHeader } from './timechart_header'; import { getServices, IndexPattern } from '../../kibana_services'; @@ -152,6 +153,7 @@ export function DiscoverLegacy({ bucketAggConfig && search.aggs.isDateHistogramBucketAggConfig(bucketAggConfig) ? bucketAggConfig.buckets?.getInterval() : undefined; + const contentCentered = resultState === 'uninitialized'; return ( @@ -206,7 +208,14 @@ export function DiscoverLegacy({ - + {resultState === 'none' && ( Date: Wed, 25 Nov 2020 13:45:52 -0500 Subject: [PATCH 147/158] Fixed scroll to top --- .../discover/public/application/components/discover_legacy.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 1e23e917504e4a..f0011351768cea 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -295,7 +295,7 @@ export function DiscoverLegacy({
    From d234a7d94806084030b2b812a60f7d8414cba530 Mon Sep 17 00:00:00 2001 From: cchaos Date: Wed, 25 Nov 2020 14:38:46 -0500 Subject: [PATCH 148/158] A few more fixes --- .../components/action_bar/action_bar.tsx | 3 +- .../context_app/context_app_legacy.scss | 5 - .../context_app/context_app_legacy.tsx | 24 ++- .../application/components/discover.scss | 1 + .../components/discover_legacy.tsx | 25 +-- .../public/application/components/doc/doc.tsx | 146 +++++++++--------- .../components/no_results/_no_results.scss | 5 +- .../components/no_results/no_results.tsx | 1 - .../components/sidebar/discover_sidebar.scss | 2 +- .../sidebar/discover_sidebar_responsive.tsx | 16 +- 10 files changed, 112 insertions(+), 116 deletions(-) delete mode 100644 src/plugins/discover/public/application/components/context_app/context_app_legacy.scss diff --git a/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx b/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx index d294ffca863414..14e43a8aa203c8 100644 --- a/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx +++ b/src/plugins/discover/public/application/angular/context/components/action_bar/action_bar.tsx @@ -119,7 +119,7 @@ export function ActionBar({ - + { if (status === LOADING_STATUS.UNINITIALIZED || status === LOADING_STATUS.LOADING) { return ( - - - - - + + + ); } return null; @@ -122,13 +116,13 @@ export function ContextAppLegacy(renderProps: ContextAppProps) { {loadingFeedback()} + {isLoaded ? ( - -
    - -
    -
    +
    + +
    ) : null} +
    diff --git a/src/plugins/discover/public/application/components/discover.scss b/src/plugins/discover/public/application/components/discover.scss index 1c32976132a32f..b17da97a459307 100644 --- a/src/plugins/discover/public/application/components/discover.scss +++ b/src/plugins/discover/public/application/components/discover.scss @@ -28,6 +28,7 @@ discover-app { .dscPageContent__wrapper { padding: 0 $euiSize $euiSize 0; + overflow: hidden; // Ensures horizontal scroll of table @include euiBreakpoint('xs', 's') { padding: 0 $euiSize $euiSize; diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index f0011351768cea..542abc014ecc05 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -39,7 +39,7 @@ import { getServices, IndexPattern } from '../../kibana_services'; import { DiscoverUninitialized, DiscoverHistogram } from '../angular/directives'; import { DiscoverNoResults } from './no_results'; import { LoadingSpinner } from './loading_spinner/loading_spinner'; -import { DocTableLegacy } from '../angular/doc_table/create_doc_table_react'; +import { DocTableLegacy, DocTableLegacyProps } from '../angular/doc_table/create_doc_table_react'; import { SkipBottomButton } from './skip_bottom_button'; import { search, @@ -54,10 +54,12 @@ import { import { Chart } from '../angular/helpers/point_series'; import { AppState } from '../angular/discover_state'; import { SavedSearch } from '../../saved_searches'; - import { SavedObject } from '../../../../../core/types'; import { TopNavMenuData } from '../../../../navigation/public'; -import { DiscoverSidebarResponsive } from './sidebar'; +import { + DiscoverSidebarResponsive, + DiscoverSidebarResponsiveProps, +} from './sidebar/discover_sidebar_responsive'; import { DocViewFilterFn, ElasticSearchHit } from '../doc_views/doc_views_types'; export interface DiscoverProps { @@ -104,6 +106,13 @@ export interface DiscoverProps { updateSavedQueryId: (savedQueryId?: string) => void; } +export const DocTableLegacyMemoized = React.memo((props: DocTableLegacyProps) => ( + +)); +export const SidebarMemoized = React.memo((props: DiscoverSidebarResponsiveProps) => ( + +)); + export function DiscoverLegacy({ addColumn, fetch, @@ -135,7 +144,6 @@ export function DiscoverLegacy({ updateSavedQueryId, }: DiscoverProps) { const scrollableDesktop = useRef(null); - const scrollableMobile = useRef(null); const collapseIcon = useRef(null); const isMobile = () => { // collapse icon isn't displayed in mobile view, use it to detect which view is displayed @@ -179,7 +187,7 @@ export function DiscoverLegacy({ - {rows && rows.length && (
    - - - {reqState === ElasticRequestState.NotFoundIndexPattern && ( - - } - /> - )} - {reqState === ElasticRequestState.NotFound && ( - - } - > - + + {reqState === ElasticRequestState.NotFoundIndexPattern && ( + + } /> - - )} - - {reqState === ElasticRequestState.Error && ( - + } + > - } - > - {' '} - + )} + + {reqState === ElasticRequestState.Error && ( + + } > - - - )} + id="discover.doc.somethingWentWrongDescription" + defaultMessage="{indexName} is missing." + values={{ indexName: props.index }} + />{' '} + + + + + )} - {reqState === ElasticRequestState.Loading && ( - - {' '} - - - )} + {reqState === ElasticRequestState.Loading && ( + + {' '} + + + )} - {reqState === ElasticRequestState.Found && hit !== null && indexPattern && ( -
    - -
    - )} -
    + {reqState === ElasticRequestState.Found && hit !== null && indexPattern && ( +
    + +
    + )} + + ); } diff --git a/src/plugins/discover/public/application/components/no_results/_no_results.scss b/src/plugins/discover/public/application/components/no_results/_no_results.scss index 5778cbfa3ba7f3..6500593d572348 100644 --- a/src/plugins/discover/public/application/components/no_results/_no_results.scss +++ b/src/plugins/discover/public/application/components/no_results/_no_results.scss @@ -1,6 +1,3 @@ .dscNoResults { - @include euiBreakpoint('xs', 's') { - padding: 0 $euiSizeS; - } - padding: 0 $euiSize; + padding: $euiSize; } diff --git a/src/plugins/discover/public/application/components/no_results/no_results.tsx b/src/plugins/discover/public/application/components/no_results/no_results.tsx index fcc2912d16dd5d..4d7489ef40573f 100644 --- a/src/plugins/discover/public/application/components/no_results/no_results.tsx +++ b/src/plugins/discover/public/application/components/no_results/no_results.tsx @@ -85,7 +85,6 @@ export function DiscoverNoResults({ return ( - {callOut} ); 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 ea871aae6c3d54..aaf1743653d7d7 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.scss @@ -7,7 +7,7 @@ @include euiBreakpoint('xs', 's') { width: 100%; - padding: $euiSize; + padding: $euiSize $euiSize 0 $euiSize; background-color: $euiPageBackgroundColor; } } 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 e0cc2c8d759e67..60d6599e32c6ee 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 @@ -184,13 +184,15 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) - {/* No flyout body because the list has its own background and scroll */} - + {/* Using only the direct flyout body class because we maintain scroll in a lower sidebar component. Needs a fix on the EUI side */} +
    + +
    )} From a44ef6f7a81944f25e373f391af8d2fffc96efaa Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 26 Nov 2020 10:22:54 +0100 Subject: [PATCH 149/158] Fix infinite_scroll.ts --- .../angular/doc_table/infinite_scroll.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 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 fdd45ffb5e1ad0..f7f7d4dd90eafb 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 @@ -16,6 +16,9 @@ * specific language governing permissions and limitations * under the License. */ + +import $ from 'jquery'; + interface LazyScope extends ng.IScope { [key: string]: any; } @@ -33,20 +36,20 @@ export function createInfiniteScrollDirective() { * and have therefore to be considered for calculation of infinite scrolling */ const scrollDiv = $element.parents('.dscTable'); - const scrollDivMobile = $element.parents('.dscPageBody'); + const scrollDivMobile = $(window); function onScroll() { if (!$scope.more) return; - const usedScrollDiv = document.getElementsByClassName('dscSidebar__mobile').length - ? scrollDivMobile - : scrollDiv; + const isMobileView = document.getElementsByClassName('dscSidebar__mobile').length > 0; + const usedScrollDiv = isMobileView ? scrollDivMobile : scrollDiv; + const scrollTop = usedScrollDiv.scrollTop(); const winHeight = Number(usedScrollDiv.height()); - const winBottom = Number(winHeight) + Number(usedScrollDiv.scrollTop()); + const winBottom = Number(winHeight) + Number(scrollTop); const elTop = $element.get(0).offsetTop || 0; const remaining = elTop - winBottom; - if (remaining <= winHeight * 0.5) { + if (remaining <= winHeight) { $scope[$scope.$$phase ? '$eval' : '$apply'](function () { $scope.more(); }); @@ -62,11 +65,11 @@ export function createInfiniteScrollDirective() { } scrollDiv.on('scroll', scheduleCheck); - scrollDivMobile.on('scroll', scheduleCheck); + window.addEventListener('scroll', scheduleCheck); $scope.$on('$destroy', function () { clearTimeout(checkTimer); scrollDiv.off('scroll', scheduleCheck); - scrollDivMobile.off('scroll', scheduleCheck); + window.removeEventListener('scroll', scheduleCheck); }); scheduleCheck(); }, From 2207ea06816e7ddb861c026f2b3b5a7c6cd4bdcf Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 26 Nov 2020 22:44:21 +0100 Subject: [PATCH 150/158] Fix functional tests --- .../components/no_results/no_results.tsx | 2 +- .../components/sidebar/discover_sidebar.tsx | 353 +++++++++--------- .../discover/{_sidebar.js => _sidebar.ts} | 35 +- test/functional/page_objects/discover_page.ts | 5 - 4 files changed, 184 insertions(+), 211 deletions(-) rename test/functional/apps/discover/{_sidebar.js => _sidebar.ts} (65%) diff --git a/src/plugins/discover/public/application/components/no_results/no_results.tsx b/src/plugins/discover/public/application/components/no_results/no_results.tsx index 4d7489ef40573f..df28b4795b4fb6 100644 --- a/src/plugins/discover/public/application/components/no_results/no_results.tsx +++ b/src/plugins/discover/public/application/components/no_results/no_results.tsx @@ -19,7 +19,7 @@ import React, { Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiButton, EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; +import { EuiButton, EuiCallOut, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { getServices } from '../../../kibana_services'; import { DataPublicPluginStart } from '../../../../../data/public'; import { getLuceneQueryMessage, getTimeFieldMessage } from './no_results_helper'; 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 697812b3a90ed7..d9d74bc1c6f770 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -197,191 +197,186 @@ export function DiscoverSidebar({ } return ( - - + - - - o.attributes.title)} + + o.attributes.title)} + /> + + +
    + - - - - - - - -
    - {fields.length > 0 && ( - <> - {selectedFields && - selectedFields.length > 0 && - selectedFields[0].displayName !== '_source' ? ( - <> - - - - - - } - extraAction={ - - {selectedFields.length} - - } + + + +
    + {fields.length > 0 && ( + <> + {selectedFields && + selectedFields.length > 0 && + selectedFields[0].displayName !== '_source' ? ( + <> + + + + + + } + extraAction={ + + {selectedFields.length} + + } + > + +
      - -
        - {selectedFields.map((field: IndexPatternField) => { - return ( -
      • - -
      • - ); - })} -
      - - {' '} - - ) : null} - - + {selectedFields.map((field: IndexPatternField) => { + return ( +
    • + +
    • + ); + })} +
    +
    + {' '} + + ) : null} + + + + + + } + extraAction={ + + {popularFields.length + unpopularFields.length} + + } + > + + {popularFields.length > 0 && ( + <> + + + +
      + {popularFields.map((field: IndexPatternField) => { + return ( +
    • + +
    • + ); + })} +
    + + )} +
      - - {popularFields.length > 0 && ( - <> - - - -
        { + return ( +
      • - {popularFields.map((field: IndexPatternField) => { - return ( -
      • - -
      • - ); - })} -
      - - )} -
        - {unpopularFields.map((field: IndexPatternField) => { - return ( -
      • - -
      • - ); - })} -
      - - - )} -
    -
    - - - + + + ); + })} + +
    + + )} +
    +
    +
    +
    ); } diff --git a/test/functional/apps/discover/_sidebar.js b/test/functional/apps/discover/_sidebar.ts similarity index 65% rename from test/functional/apps/discover/_sidebar.js rename to test/functional/apps/discover/_sidebar.ts index ce7ebff9cce74c..c91c9020b373b9 100644 --- a/test/functional/apps/discover/_sidebar.js +++ b/test/functional/apps/discover/_sidebar.ts @@ -17,31 +17,23 @@ * under the License. */ -import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; -export default function ({ getService, getPageObjects }) { - const log = getService('log'); +export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const kibanaServer = getService('kibanaServer'); const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); + const testSubjects = getService('testSubjects'); describe('discover sidebar', function describeIndexTests() { before(async function () { - // delete .kibana index and update configDoc + await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('discover'); await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*', }); - - log.debug('load kibana index with default index pattern'); - await esArchiver.load('discover'); - - // and load a set of makelogs data - await esArchiver.loadIfNeeded('logstash_functional'); - - log.debug('discover'); + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); - - await PageObjects.timePicker.setDefaultAbsoluteRange(); }); describe('field filtering', function () { @@ -53,26 +45,17 @@ export default function ({ getService, getPageObjects }) { describe('collapse expand', function () { it('should initially be expanded', async function () { - const width = await PageObjects.discover.getSidebarWidth(); - log.debug('expanded sidebar width = ' + width); - expect(width > 20).to.be(true); + await testSubjects.existOrFail('discover-sidebar'); }); it('should collapse when clicked', async function () { await PageObjects.discover.toggleSidebarCollapse(); - log.debug('PageObjects.discover.getSidebarWidth()'); - const width = await PageObjects.discover.getSidebarWidth(); - log.debug('collapsed sidebar width = ' + width); - expect(width < 20).to.be(true); + await testSubjects.missingOrFail('discover-sidebar'); }); it('should expand when clicked', async function () { await PageObjects.discover.toggleSidebarCollapse(); - - log.debug('PageObjects.discover.getSidebarWidth()'); - const width = await PageObjects.discover.getSidebarWidth(); - log.debug('expanded sidebar width = ' + width); - expect(width > 20).to.be(true); + await testSubjects.existOrFail('discover-sidebar'); }); }); }); diff --git a/test/functional/page_objects/discover_page.ts b/test/functional/page_objects/discover_page.ts index b16b0c04452f2a..494141355806f1 100644 --- a/test/functional/page_objects/discover_page.ts +++ b/test/functional/page_objects/discover_page.ts @@ -251,11 +251,6 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider .map((field) => $(field).text()); } - public async getSidebarWidth() { - const sidebar = await testSubjects.find('discover-sidebar'); - return await sidebar.getAttribute('clientWidth'); - } - public async hasNoResults() { return await testSubjects.exists('discoverNoResults'); } From ab971e03251ce73b87b068de6bae53eabde2b94f Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Fri, 27 Nov 2020 08:02:02 +0100 Subject: [PATCH 151/158] Fix redundant import --- .../public/application/components/sidebar/discover_sidebar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d9d74bc1c6f770..f5212a7d414183 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -21,7 +21,7 @@ import './discover_sidebar.scss'; import React, { useCallback, useEffect, useState, useMemo } from 'react'; import { isEqual, sortBy } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; +import { FormattedMessage } from '@kbn/i18n/react'; import { UiStatsMetricType } from '@kbn/analytics'; import { EuiAccordion, From bdf05da843fa5a1275a51631f99b983523dd4aa7 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 30 Nov 2020 08:35:51 +0100 Subject: [PATCH 152/158] Fix scroll to top for mobile --- .../public/application/components/discover_legacy.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 542abc014ecc05..6191120f3a283e 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -306,6 +306,7 @@ export function DiscoverLegacy({ className="dscTable eui-yScroll" aria-labelledby="documentsAriaLabel" ref={scrollableDesktop} + tabIndex={-1} >

    { - const skipToBottomBtn = document.getElementById( - 'dscSkipButton' - ); - if (skipToBottomBtn) { - skipToBottomBtn.focus(); + if (scrollableDesktop && scrollableDesktop.current) { + scrollableDesktop.current.focus(); } // Only the desktop one needs to target a specific container if (!isMobile() && scrollableDesktop.current) { scrollableDesktop.current.scrollTo(0, 0); + } else if (window) { + window.scrollTo(0, 0); } }} > From 762772c3210f9a20f76684936c4457b6685be51d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 30 Nov 2020 11:55:10 +0100 Subject: [PATCH 153/158] Refactorings, address review comments --- .../components/discover_legacy.tsx | 28 ++-- .../components/sidebar/discover_field.tsx | 26 ++-- .../components/sidebar/discover_sidebar.tsx | 49 +++--- .../sidebar/discover_sidebar_responsive.tsx | 36 +++-- .../timechart_header/timechart_header.tsx | 147 +++++++++--------- 5 files changed, 143 insertions(+), 143 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 6191120f3a283e..99f165e83a7024 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -254,16 +254,18 @@ export function DiscoverLegacy({ onResetQuery={resetQuery} /> - - - + {toggleOn && ( + + + + )} - - ​ - {rows.length === opts.sampleSize && (
    )} + + ​ +

    )}
    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 c1bea69aec1629..cc55eaee54893c 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_field.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_field.tsx @@ -16,18 +16,24 @@ * specific language governing permissions and limitations * under the License. */ +import './discover_field.scss'; + import React, { useState } from 'react'; import { EuiPopover, EuiPopoverTitle, EuiButtonIcon, EuiToolTip } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { UiStatsMetricType } from '@kbn/analytics'; +import classNames from 'classnames'; import { DiscoverFieldDetails } from './discover_field_details'; import { FieldIcon, FieldButton } from '../../../../../kibana_react/public'; import { FieldDetails } from './types'; import { IndexPatternField, IndexPattern } from '../../../../../data/public'; import { getFieldTypeName } from './lib/get_field_type_name'; -import './discover_field.scss'; export interface DiscoverFieldProps { + /** + * Determines whether add/remove button is displayed not only when focused + */ + alwaysShowActionButton?: boolean; /** * The displayed field */ @@ -63,13 +69,10 @@ export interface DiscoverFieldProps { * @param eventName */ trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void; - /** - * Shows Add button at all times and not only on focus - */ - mobile?: boolean; } export function DiscoverField({ + alwaysShowActionButton = false, field, indexPattern, onAddField, @@ -78,7 +81,6 @@ export function DiscoverField({ getDetails, selected, trackUiMetric, - mobile, }: DiscoverFieldProps) { const addLabelAria = i18n.translate('discover.fieldChooser.discoverField.addButtonAriaLabel', { defaultMessage: 'Add {field} to table', @@ -125,7 +127,9 @@ export function DiscoverField({ {wrapOnDot(field.displayName)} ); - + const actionBtnClassName = classNames('dscSidebarItem__action', { + ['dscSidebarItem__mobile']: alwaysShowActionButton, + }); let actionButton; if (field.name !== '_source' && !selected) { actionButton = ( @@ -137,9 +141,7 @@ export function DiscoverField({ > ) => { if (ev.type === 'click') { ev.currentTarget.focus(); @@ -164,9 +166,7 @@ export function DiscoverField({ ) => { if (ev.type === 'click') { ev.currentTarget.focus(); 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 f5212a7d414183..6298bc83e2b77e 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -17,11 +17,8 @@ * under the License. */ import './discover_sidebar.scss'; - import React, { useCallback, useEffect, useState, useMemo } from 'react'; -import { isEqual, sortBy } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n/react'; import { UiStatsMetricType } from '@kbn/analytics'; import { EuiAccordion, @@ -33,6 +30,8 @@ import { EuiNotificationBadge, EuiPageSideBar, } from '@elastic/eui'; +import { isEqual, sortBy } from 'lodash'; +import { FormattedMessage } from '@kbn/i18n/react'; import { DiscoverField } from './discover_field'; import { DiscoverIndexPattern } from './discover_index_pattern'; import { DiscoverFieldSearch } from './discover_field_search'; @@ -47,6 +46,10 @@ import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list'; import { DiscoverServices } from '../../../build_services'; export interface DiscoverSidebarProps { + /** + * Determines whether add/remove buttons are displayed not only when focused + */ + alwaysShowActionButtons?: boolean; /** * the selected columns displayed in the doc table in discover */ @@ -55,6 +58,10 @@ export interface DiscoverSidebarProps { * a statistics of the distribution of fields in the given hits */ fieldCounts: Record; + /** + * Current state of the field filter, filtering fields by name, type, ... + */ + fieldFilter: FieldFilterState; /** * hits fetched from ES, displayed in the doc table */ @@ -84,37 +91,31 @@ export interface DiscoverSidebarProps { * Discover plugin services; */ services: DiscoverServices; - /** - * 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; - /** - * Current state of the field filter, filtering fields by name, type, ... - */ - fieldFilter: FieldFilterState; /** * Change current state of fieldFilter */ setFieldFilter: (next: FieldFilterState) => void; + /** + * Callback function to select another index pattern + */ + setIndexPattern: (id: string) => void; /** * Metric tracking function * @param metricType * @param eventName */ trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void; + /** + * Shows index pattern and a button that displays the sidebar in a flyout + */ + useFlyout?: boolean; } export function DiscoverSidebar({ + alwaysShowActionButtons = false, columns, fieldCounts, + fieldFilter, hits, indexPatternList, onAddField, @@ -122,12 +123,10 @@ export function DiscoverSidebar({ onRemoveField, selectedIndexPattern, services, + setFieldFilter, setIndexPattern, trackUiMetric, - mobile = false, useFlyout = false, - fieldFilter, - setFieldFilter, }: DiscoverSidebarProps) { const [fields, setFields] = useState(null); useEffect(() => { @@ -269,6 +268,7 @@ export function DiscoverSidebar({ className="dscSidebar__item" > @@ -330,13 +329,13 @@ export function DiscoverSidebar({ className="dscSidebar__item" > @@ -358,13 +357,13 @@ export function DiscoverSidebar({ className="dscSidebar__item" > 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 60d6599e32c6ee..49f5983fa7b595 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 @@ -43,6 +43,10 @@ import { DiscoverSidebar } from './discover_sidebar'; import { DiscoverServices } from '../../../build_services'; export interface DiscoverSidebarResponsiveProps { + /** + * Determines whether add/remove buttons are displayed non only when focused + */ + alwaysShowActionButtons?: boolean; /** * the selected columns displayed in the doc table in discover */ @@ -59,6 +63,10 @@ export interface DiscoverSidebarResponsiveProps { * List of available index patterns */ indexPatternList: Array>; + /** + * Has been toggled closed + */ + isClosed?: boolean; /** * Callback function when selecting a field */ @@ -84,24 +92,16 @@ export interface DiscoverSidebarResponsiveProps { * 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; - /** - * Has been toggled closed - */ - isClosed?: boolean; /** * Metric tracking function * @param metricType * @param eventName */ trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void; + /** + * Shows index pattern and a button that displays the sidebar in a flyout + */ + useFlyout?: boolean; } /** @@ -113,15 +113,17 @@ export function DiscoverSidebarResponsive(props: DiscoverSidebarResponsiveProps) const [fieldFilter, setFieldFilter] = useState(getDefaultFieldFilter()); const [isFlyoutVisible, setIsFlyoutVisible] = useState(false); - if (!props.selectedIndexPattern || props.isClosed) { + if (!props.selectedIndexPattern) { return null; } return ( <> - - - + {props.isClosed ? null : ( + + + + )}
    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 bef83400c25a8b..ada36204c47a1b 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 @@ -25,7 +25,6 @@ import { EuiSelect, EuiIconTip, } from '@elastic/eui'; -import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import './timechart_header.scss'; import moment from 'moment'; @@ -100,80 +99,78 @@ export function TimechartHeader({ } return ( - - - - + + + + {`${toMoment(timeRange.from)} - ${toMoment(timeRange.to)} ${ + interval !== 'auto' + ? i18n.translate('discover.timechartHeader.timeIntervalSelect.per', { + defaultMessage: 'per', + }) + : '' + }`} + + + + + val !== 'custom') + .map(({ display, val }) => { + return { + text: display, + value: val, + label: display, + }; })} - delay="long" - > - - {`${toMoment(timeRange.from)} - ${toMoment(timeRange.to)} ${ - interval !== 'auto' - ? i18n.translate('discover.timechartHeader.timeIntervalSelect.per', { - defaultMessage: 'per', - }) - : '' - }`} - - - - - val !== 'custom') - .map(({ display, val }) => { - return { - text: display, - value: val, - label: display, - }; - })} - value={interval} - onChange={handleIntervalChange} - append={ - bucketInterval.scaled ? ( - 1 - ? i18n.translate('discover.bucketIntervalTooltip.tooLargeBucketsText', { - defaultMessage: 'buckets that are too large', - }) - : i18n.translate('discover.bucketIntervalTooltip.tooManyBucketsText', { - defaultMessage: 'too many buckets', - }), - bucketIntervalDescription: bucketInterval.description, - }, - })} - color="warning" - size="s" - type="alert" - /> - ) : undefined - } - /> - - - + value={interval} + onChange={handleIntervalChange} + append={ + bucketInterval.scaled ? ( + 1 + ? i18n.translate('discover.bucketIntervalTooltip.tooLargeBucketsText', { + defaultMessage: 'buckets that are too large', + }) + : i18n.translate('discover.bucketIntervalTooltip.tooManyBucketsText', { + defaultMessage: 'too many buckets', + }), + bucketIntervalDescription: bucketInterval.description, + }, + })} + color="warning" + size="s" + type="alert" + /> + ) : undefined + } + /> +
    + ); } From e4421a58dacac7f611b76691eeb66060adcc6109 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 30 Nov 2020 12:34:12 +0100 Subject: [PATCH 154/158] Improve scroll to bottom code --- .../public/application/components/discover_legacy.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 99f165e83a7024..61f5433357b5f9 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -332,10 +332,12 @@ export function DiscoverLegacy({ onRemoveColumn={onRemoveColumn} onSort={onSort} /> - {rows.length === opts.sampleSize && ( + {rows.length === opts.sampleSize ? (
    + ) : ( + + ​ + )} - - ​ -
    )}
    From 2e8dd8b2e8e079ceb9192fddb3ea6532841112fb Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 30 Nov 2020 19:58:06 +0100 Subject: [PATCH 155/158] Fix functional test --- test/functional/apps/discover/_discover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index e5c2b2e4dbada0..97a75d7e98b280 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -115,7 +115,7 @@ export default function ({ getService, getPageObjects }) { await PageObjects.discover.waitUntilSearchingHasFinished(); const newDurationHours = await PageObjects.timePicker.getTimeDurationInHours(); - expect(Math.round(newDurationHours)).to.be(23); + expect(Math.round(newDurationHours)).to.be(26); await retry.waitFor('doc table to contain the right search result', async () => { const rowData = await PageObjects.discover.getDocTableField(1); From 27779c11bf9104aaa4c069a13179270d53bb6442 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 2 Dec 2020 23:21:07 +0100 Subject: [PATCH 156/158] Address wording review comments --- .../discover/public/application/components/doc/doc.tsx | 2 +- .../components/skip_bottom_button/skip_bottom_button.tsx | 5 +---- .../components/timechart_header/timechart_header.tsx | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/plugins/discover/public/application/components/doc/doc.tsx b/src/plugins/discover/public/application/components/doc/doc.tsx index 49e156b2f53432..d43a09bd51c6aa 100644 --- a/src/plugins/discover/public/application/components/doc/doc.tsx +++ b/src/plugins/discover/public/application/components/doc/doc.tsx @@ -59,7 +59,7 @@ export function Doc(props: DocProps) { title={ } diff --git a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx index fbcfc422d20408..e2b8e0ffcf5188 100644 --- a/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx +++ b/src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx @@ -44,10 +44,7 @@ export function SkipBottomButton({ onClick }: SkipBottomButtonProps) { data-test-subj="discoverSkipTableButton" position="absolute" > - + ); } 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 ada36204c47a1b..544de61b5825be 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 @@ -110,7 +110,7 @@ export function TimechartHeader({ From 0ebf5a7ddb3c11f969ebc435bbc81f642356c2e9 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 3 Dec 2020 11:09:17 +0100 Subject: [PATCH 157/158] Add i18 for showing, hiding the chart --- .../public/application/components/discover_legacy.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/discover/public/application/components/discover_legacy.tsx b/src/plugins/discover/public/application/components/discover_legacy.tsx index 61f5433357b5f9..56f8fa46a9f690 100644 --- a/src/plugins/discover/public/application/components/discover_legacy.tsx +++ b/src/plugins/discover/public/application/components/discover_legacy.tsx @@ -274,7 +274,13 @@ export function DiscoverLegacy({ toggleChart(!toggleOn); }} > - {toggleOn ? 'Hide chart' : 'Show chart'} + {toggleOn + ? i18n.translate('discover.hideChart', { + defaultMessage: 'Hide chart', + }) + : i18n.translate('discover.showChart', { + defaultMessage: 'Show chart', + })} From c6870485d6f315f1ba05f9b29705d83989cc1104 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 3 Dec 2020 13:20:03 +0100 Subject: [PATCH 158/158] Migrate types to use ElasticSearchHit --- .../components/sidebar/discover_sidebar.test.tsx | 7 ++++--- .../application/components/sidebar/discover_sidebar.tsx | 3 ++- .../sidebar/discover_sidebar_responsive.test.tsx | 7 ++++--- .../components/sidebar/discover_sidebar_responsive.tsx | 3 ++- .../application/components/sidebar/lib/get_details.ts | 3 ++- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx index 84a4b1410aeaa7..74921a70e7f2f1 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import _ from 'lodash'; +import { each, cloneDeep } from 'lodash'; import { ReactWrapper } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore @@ -34,6 +34,7 @@ import { SavedObject } from '../../../../../../core/types'; import { getDefaultFieldFilter } from './lib/field_filter'; import { DiscoverSidebar } from './discover_sidebar'; import { DiscoverServices } from '../../../build_services'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; const mockServices = ({ history: () => ({ @@ -76,9 +77,9 @@ function getCompProps() { ); // @ts-expect-error _.each() is passing additional args to flattenHit - const hits = _.each(_.cloneDeep(realHits), indexPattern.flattenHit) as Array< + const hits = (each(cloneDeep(realHits), indexPattern.flattenHit) as Array< Record - >; + >) as ElasticSearchHit[]; const indexPatternList = [ { id: '0', attributes: { title: 'b' } } as SavedObject, 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 6298bc83e2b77e..3283551488d68f 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar.tsx @@ -44,6 +44,7 @@ import { getDetails } from './lib/get_details'; import { FieldFilterState, getDefaultFieldFilter, setFieldFilterProp } from './lib/field_filter'; import { getIndexPatternFieldList } from './lib/get_index_pattern_field_list'; import { DiscoverServices } from '../../../build_services'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; export interface DiscoverSidebarProps { /** @@ -65,7 +66,7 @@ export interface DiscoverSidebarProps { /** * hits fetched from ES, displayed in the doc table */ - hits: Array>; + hits: ElasticSearchHit[]; /** * List of available index patterns */ diff --git a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx index 303f18c5ab1a1d..906de04df3a1d7 100644 --- a/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx +++ b/src/plugins/discover/public/application/components/sidebar/discover_sidebar_responsive.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import _ from 'lodash'; +import { each, cloneDeep } from 'lodash'; import { ReactWrapper } from 'enzyme'; import { findTestSubject } from '@elastic/eui/lib/test'; // @ts-ignore @@ -34,6 +34,7 @@ import { SavedObject } from '../../../../../../core/types'; import { FieldFilterState } from './lib/field_filter'; import { DiscoverSidebarResponsive } from './discover_sidebar_responsive'; import { DiscoverServices } from '../../../build_services'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; const mockServices = ({ history: () => ({ @@ -76,9 +77,9 @@ function getCompProps() { ); // @ts-expect-error _.each() is passing additional args to flattenHit - const hits = _.each(_.cloneDeep(realHits), indexPattern.flattenHit) as Array< + const hits = (each(cloneDeep(realHits), indexPattern.flattenHit) as Array< Record - >; + >) as ElasticSearchHit[]; const indexPatternList = [ { id: '0', attributes: { title: 'b' } } as SavedObject, 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 49f5983fa7b595..369ebbde5743b1 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 @@ -41,6 +41,7 @@ import { IndexPatternField, IndexPattern } from '../../../../../data/public'; import { getDefaultFieldFilter } from './lib/field_filter'; import { DiscoverSidebar } from './discover_sidebar'; import { DiscoverServices } from '../../../build_services'; +import { ElasticSearchHit } from '../../doc_views/doc_views_types'; export interface DiscoverSidebarResponsiveProps { /** @@ -58,7 +59,7 @@ export interface DiscoverSidebarResponsiveProps { /** * hits fetched from ES, displayed in the doc table */ - hits: Array>; + hits: ElasticSearchHit[]; /** * List of available index patterns */ diff --git a/src/plugins/discover/public/application/components/sidebar/lib/get_details.ts b/src/plugins/discover/public/application/components/sidebar/lib/get_details.ts index 22a6e7a6285551..e979131a7a85fa 100644 --- a/src/plugins/discover/public/application/components/sidebar/lib/get_details.ts +++ b/src/plugins/discover/public/application/components/sidebar/lib/get_details.ts @@ -20,10 +20,11 @@ // @ts-ignore import { fieldCalculator } from './field_calculator'; import { IndexPattern, IndexPatternField } from '../../../../../../data/public'; +import { ElasticSearchHit } from '../../../doc_views/doc_views_types'; export function getDetails( field: IndexPatternField, - hits: Array>, + hits: ElasticSearchHit[], columns: string[], indexPattern?: IndexPattern ) {