-
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] Surface data request errors (#200860)
## Summary This PR makes it to so data request errors are surfaced to users, as a warning. Closes: #195294
- Loading branch information
1 parent
a1e97b1
commit 1f57890
Showing
4 changed files
with
107 additions
and
24 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
x-pack/plugins/maps/public/classes/styles/vector/components/legend/style_error.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,72 @@ | ||
/* | ||
* 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 { EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiText, EuiToolTip } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { DynamicStyleProperty } from '../../properties/dynamic_style_property'; | ||
|
||
interface Props { | ||
error: Error; | ||
style: DynamicStyleProperty<object>; | ||
} | ||
|
||
export const StyleError = ({ error, style }: Props) => { | ||
const [label, setLabel] = useState(''); | ||
const styleName = style.getDisplayStyleName(); | ||
|
||
useEffect(() => { | ||
let canceled = false; | ||
const getLabel = async () => { | ||
const field = style.getField(); | ||
if (!field) { | ||
return; | ||
} | ||
|
||
const fieldLabel = await field.getLabel(); | ||
|
||
if (canceled) { | ||
return; | ||
} | ||
|
||
setLabel(fieldLabel); | ||
}; | ||
|
||
getLabel(); | ||
|
||
return () => { | ||
canceled = true; | ||
}; | ||
}, [style]); | ||
|
||
return ( | ||
<div> | ||
<EuiFlexGroup gutterSize="xs" justifyContent="spaceBetween"> | ||
<EuiFlexItem grow={false}> | ||
<EuiToolTip position="top" title={styleName} content={label}> | ||
<EuiText className="eui-textTruncate" size="xs" style={{ maxWidth: '180px' }}> | ||
<small> | ||
<strong>{label}</strong> | ||
</small> | ||
</EuiText> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiFlexGroup direction="column" gutterSize="none"> | ||
<EuiCallOut | ||
title={i18n.translate('xpack.maps.vectorStyleLegend.fetchStyleMetaDataError', { | ||
defaultMessage: 'Unable to fetch style meta data', | ||
})} | ||
color="warning" | ||
iconType="warning" | ||
> | ||
<p>{error.message}</p> | ||
</EuiCallOut> | ||
</EuiFlexGroup> | ||
</div> | ||
); | ||
}; |
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