-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[maps] pass dataFilters to ISource.getImmutableProperties (#159255)
#159161 is adding adding hyperlink to anomaly explorer for job from anomaly layer in maps. A requirement from this request is to be able to include timerange and query state in the hyperlink. This PR updates ISource.getImmutableProperties to take dataFilters parameter so hyperlink can be updated with latest query state. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
afdf3f6
commit 4376704
Showing
9 changed files
with
103 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 7 additions & 31 deletions
38
...public/connected_components/edit_layer_panel/__snapshots__/edit_layer_panel.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/maps/public/connected_components/edit_layer_panel/source_details/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { connect } from 'react-redux'; | ||
import { SourceDetails } from './source_details'; | ||
import { getDataFilters } from '../../../selectors/map_selectors'; | ||
import { MapStoreState } from '../../../reducers/store'; | ||
|
||
function mapStateToProps(state: MapStoreState) { | ||
return { | ||
dataFilters: getDataFilters(state), | ||
}; | ||
} | ||
|
||
const connected = connect(mapStateToProps, {})(SourceDetails); | ||
export { connected as SourceDetails }; |
68 changes: 68 additions & 0 deletions
68
...ugins/maps/public/connected_components/edit_layer_panel/source_details/source_details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import { EuiAccordion, EuiLink, EuiSkeletonText, EuiSpacer, EuiText } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { DataFilters } from '../../../../common/descriptor_types'; | ||
import { ImmutableSourceProperty, ISource } from '../../../classes/sources/source'; | ||
|
||
export interface Props { | ||
source: ISource; | ||
dataFilters: DataFilters; | ||
} | ||
|
||
export function SourceDetails(props: Props) { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [sourceProperties, setSourceProperties] = useState<ImmutableSourceProperty[]>([]); | ||
|
||
useEffect(() => { | ||
let ignore = false; | ||
setIsLoading(true); | ||
props.source.getImmutableProperties(props.dataFilters).then((nextSourceProperties) => { | ||
if (!ignore) { | ||
setSourceProperties(nextSourceProperties); | ||
setIsLoading(false); | ||
} | ||
}); | ||
|
||
return () => { | ||
ignore = true; | ||
}; | ||
}, [props.dataFilters, props.source]); | ||
|
||
return ( | ||
<div className="mapLayerPanel__sourceDetails"> | ||
<EuiAccordion | ||
id="accordion1" | ||
buttonContent={i18n.translate('xpack.maps.layerPanel.sourceDetailsLabel', { | ||
defaultMessage: 'Source details', | ||
})} | ||
> | ||
<EuiSpacer size="xs" /> | ||
<EuiSkeletonText lines={3} size="s" isLoading={isLoading}> | ||
<EuiText color="subdued" size="s"> | ||
{sourceProperties.map(({ label, value, link }: ImmutableSourceProperty) => { | ||
return ( | ||
<p key={label} className="mapLayerPanel__sourceDetail"> | ||
<strong>{label}</strong>{' '} | ||
{link ? ( | ||
<EuiLink href={link} target="_blank"> | ||
{value} | ||
</EuiLink> | ||
) : ( | ||
<span>{value}</span> | ||
)} | ||
</p> | ||
); | ||
})} | ||
</EuiText> | ||
</EuiSkeletonText> | ||
</EuiAccordion> | ||
</div> | ||
); | ||
} |