From 0c3237ba7bed2cbc8f4df516a4534ce59be4db97 Mon Sep 17 00:00:00 2001 From: andreadelrio Date: Thu, 27 Jan 2022 09:43:32 -0800 Subject: [PATCH] added base popover --- .../components/sidebar/discover_sidebar.scss | 10 ++ .../components/sidebar/discover_sidebar.tsx | 106 ++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.scss b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.scss index 9ef123fa1a60f..94e12edc03c5b 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.scss +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.scss @@ -74,3 +74,13 @@ .dscSidebar__indexPatternSwitcher { min-width: 0; } + +.dscLearnBtn { + .euiButtonContent { + justify-content: normal; + } +} + +.dscLearnCallout { + padding: $euiSizeXS !important; +} \ No newline at end of file diff --git a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx index fd5c838c42f91..74811d1fad6b0 100644 --- a/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx +++ b/src/plugins/discover/public/application/main/components/sidebar/discover_sidebar.tsx @@ -8,10 +8,14 @@ import './discover_sidebar.scss'; import { throttle } from 'lodash'; +import classNames from 'classnames'; import React, { useCallback, useEffect, useState, useMemo, useRef, memo } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiAccordion, + EuiCallOut, + EuiButtonIcon, + EuiButtonEmpty, EuiFlexItem, EuiFlexGroup, EuiText, @@ -19,7 +23,11 @@ import { EuiSpacer, EuiNotificationBadge, EuiPageSideBar, + EuiPopover, + EuiPopoverTitle, useResizeObserver, + EuiBasicTable, + EuiToken, } from '@elastic/eui'; import useShallowCompareEffect from 'react-use/lib/useShallowCompareEffect'; @@ -114,6 +122,15 @@ export function DiscoverSidebarComponent({ const [fieldsToRender, setFieldsToRender] = useState(FIELDS_PER_PAGE); const [fieldsPerPage, setFieldsPerPage] = useState(FIELDS_PER_PAGE); const availableFieldsContainer = useRef(null); + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + const [isCalloutOpen, setIsCalloutOpen] = useState(true); + + const onButtonClick = () => setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen); + const closePopover = () => setIsPopoverOpen(false); + const closeCallout = () => { + setIsCalloutOpen(false); + setIsPopoverOpen(false); + }; useEffect(() => { if (documents) { @@ -310,6 +327,74 @@ export function DiscoverSidebarComponent({ ); } + const calloutClasses = classNames('dscLearnCallout', { hide: !isCalloutOpen }); + const callout = ( + + + + + Learn about field types + + + + + + + + ); + + const columnsSidebar = [ + { + field: 'type', + name: 'Icon', + width: '40px', + render: (name) => , + }, + { + field: 'dataType', + name: 'Data type', + width: '70px', + }, + { + field: 'description', + name: 'Description', + }, + ]; + + const items = [ + { + id: 0, + dataType: 'text', + type: 'tokenString', + description: 'Full text such as the body of an email or a product description.', + }, + { + id: 1, + dataType: 'number', + type: 'tokenNumber', + description: 'Long, integer, short, byte, double, and float values.', + }, + { + id: 2, + dataType: 'keyword', + type: 'tokenKeyword', + description: + 'Structured content such as an ID, email address, hostname, status code, or tag.', + }, + { + id: 3, + dataType: 'date', + type: 'tokenDate', + description: 'A date string or the number of seconds or milliseconds since 1/1/1970.', + }, + { + id: 4, + dataType: 'geo_point', + type: 'tokenGeo', + description: 'Latitude and longitude points.', + }, + ]; + return ( } > + + + Field types + + + + {popularFields.length > 0 && ( <>