Skip to content

Commit

Permalink
Add global query bar
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei committed Dec 20, 2022
1 parent a0553cf commit a908ef8
Show file tree
Hide file tree
Showing 10 changed files with 439 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import React, { Fragment } from 'react';
import { EuiSpacer, EuiTabbedContent } from '@elastic/eui';
import { IndexPattern } from '../../../../../../src/plugins/data/public';
import { DocumentLayerSpecification } from '../../../model/mapLayerType';
import { LayerBasicSettings } from '../layer_basic_settings';
import { DocumentLayerSource } from './document_layer_source';
Expand All @@ -14,6 +15,7 @@ interface Props {
selectedLayerConfig: DocumentLayerSpecification;
setSelectedLayerConfig: Function;
setIsUpdateDisabled: Function;
layersIndexPatterns: IndexPattern[];
}

export const DocumentLayerConfigPanel = (props: Props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ import {
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import _, { Dictionary } from 'lodash';
import { IndexPattern, IndexPatternField } from '../../../../../../src/plugins/data/public';
import { useOpenSearchDashboards } from '../../../../../../src/plugins/opensearch_dashboards_react/public';
import { MapServices } from '../../../types';
import { DocumentLayerSpecification } from '../../../model/mapLayerType';
import _, { Dictionary } from "lodash";

interface Props {
setSelectedLayerConfig: Function;
selectedLayerConfig: DocumentLayerSpecification;
setIsUpdateDisabled: Function;
layersIndexPatterns: IndexPattern[];
}

export const DocumentLayerSource = ({
setSelectedLayerConfig,
selectedLayerConfig,
setIsUpdateDisabled,
layersIndexPatterns,
}: Props) => {
const {
services: {
Expand Down Expand Up @@ -140,10 +142,10 @@ export const DocumentLayerSource = ({
useEffect(() => {
const selectIndexPattern = async () => {
if (selectedLayerConfig.source.indexPatternId) {
const savedIndexPattern = await indexPatterns.get(
selectedLayerConfig.source.indexPatternId
const selectedIndexPattern = layersIndexPatterns.find(
(ip) => ip.id === selectedLayerConfig.source.indexPatternId
);
setIndexPattern(savedIndexPattern);
setIndexPattern(selectedIndexPattern);
}
};
selectIndexPattern();
Expand Down Expand Up @@ -195,7 +197,7 @@ export const DocumentLayerSource = ({

const shouldTooltipSectionOpen = () => {
return (
selectedLayerConfig.source.showTooltips === true &&
selectedLayerConfig.source.showTooltips &&
selectedLayerConfig.source.tooltipFields?.length > 0
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { MapLayerSpecification } from '../../model/mapLayerType';
import { BaseMapLayerConfigPanel } from './index';
import { DASHBOARDS_MAPS_LAYER_TYPE } from '../../../common';
import { DocumentLayerConfigPanel } from './documents_config/document_layer_config_panel';
import { IndexPattern } from '../../../../../src/plugins/data/public';

interface Props {
closeLayerConfigPanel: Function;
Expand All @@ -35,6 +36,8 @@ interface Props {
removeLayer: Function;
isNewLayer: boolean;
setIsNewLayer: Function;
layersIndexPatterns: IndexPattern[];
updateIndexPatterns: Function;
}

export const LayerConfigPanel = ({
Expand All @@ -45,6 +48,8 @@ export const LayerConfigPanel = ({
removeLayer,
isNewLayer,
setIsNewLayer,
layersIndexPatterns,
updateIndexPatterns,
}: Props) => {
const [isUpdateDisabled, setIsUpdateDisabled] = useState(false);
const [originLayerConfig, setOriginLayerConfig] = useState<MapLayerSpecification | null>(null);
Expand All @@ -71,6 +76,7 @@ export const LayerConfigPanel = ({
};
const onUpdate = () => {
updateLayer();
updateIndexPatterns();
closeLayerConfigPanel(false);
};

Expand Down Expand Up @@ -104,6 +110,7 @@ export const LayerConfigPanel = ({
selectedLayerConfig={selectedLayerConfig}
setSelectedLayerConfig={setSelectedLayerConfig}
setIsUpdateDisabled={setIsUpdateDisabled}
layersIndexPatterns={layersIndexPatterns}
/>
)}
</EuiFlexItem>
Expand Down
Loading

0 comments on commit a908ef8

Please sign in to comment.