mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Metrics UI] Saved views bugs (#72518)
* Add test for logs and metrics telemetry * wait before you go * Remove kubenetes * Fix type check * Add back kubernetes test * Remove kubernetes * Don't allow deleting default default view. * Fix bug with duplicate loads of data. Because the load data function takes options.source and the source of options can change, we need to remove it from deps * Remove unused variable * Reload when loadData function is changed * Don't send the request immediately Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
82d7e7db69
commit
cc84ee3185
5 changed files with 12 additions and 8 deletions
|
@ -96,6 +96,10 @@ export function SavedViewManageViewsFlyout<ViewState>({
|
|||
|
||||
const renderDeleteAction = useCallback(
|
||||
(item: SavedView<ViewState>) => {
|
||||
if (item.id === '0') {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<DeleteConfimation
|
||||
isDisabled={item.isDefault}
|
||||
|
|
|
@ -161,7 +161,7 @@ export function SavedViewsToolbarControls<ViewState>(props: Props<ViewState>) {
|
|||
/>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiDescriptionList onClick={showSavedViewMenu}>
|
||||
<EuiDescriptionList compressed={true} onClick={showSavedViewMenu}>
|
||||
<EuiDescriptionListTitle>
|
||||
<FormattedMessage
|
||||
defaultMessage="Current view"
|
||||
|
|
|
@ -50,7 +50,7 @@ export const useSavedView = (props: Props) => {
|
|||
const { data, loading, find, error: errorOnFind, hasView } = useFindSavedObject<
|
||||
SavedViewSavedObject<ViewState>
|
||||
>(viewType);
|
||||
|
||||
const [shouldLoadDefault] = useState(props.shouldLoadDefault);
|
||||
const [currentView, setCurrentView] = useState<SavedView<any> | null>(null);
|
||||
const [loadingDefaultView, setLoadingDefaultView] = useState<boolean | null>(null);
|
||||
const { create, error: errorOnCreate, data: createdViewData, createdId } = useCreateSavedObject(
|
||||
|
@ -211,8 +211,6 @@ export const useSavedView = (props: Props) => {
|
|||
}, [setCurrentView, defaultViewId, defaultViewState]);
|
||||
|
||||
useEffect(() => {
|
||||
const shouldLoadDefault = props.shouldLoadDefault;
|
||||
|
||||
if (loadingDefaultView || currentView || !shouldLoadDefault) {
|
||||
return;
|
||||
}
|
||||
|
@ -225,7 +223,7 @@ export const useSavedView = (props: Props) => {
|
|||
}
|
||||
}, [
|
||||
loadDefaultView,
|
||||
props.shouldLoadDefault,
|
||||
shouldLoadDefault,
|
||||
setDefault,
|
||||
loadingDefaultView,
|
||||
currentView,
|
||||
|
@ -246,7 +244,7 @@ export const useSavedView = (props: Props) => {
|
|||
errorOnUpdate,
|
||||
errorOnFind,
|
||||
errorOnCreate: createError,
|
||||
shouldLoadDefault: props.shouldLoadDefault,
|
||||
shouldLoadDefault,
|
||||
makeDefault,
|
||||
sourceIsLoading,
|
||||
deleteView,
|
||||
|
|
|
@ -55,7 +55,8 @@ export const Layout = () => {
|
|||
sourceId,
|
||||
currentTime,
|
||||
accountId,
|
||||
region
|
||||
region,
|
||||
false
|
||||
);
|
||||
|
||||
const options = {
|
||||
|
|
|
@ -57,7 +57,8 @@ export const MetricsExplorerPage = ({ source, derivedIndexPattern }: MetricsExpl
|
|||
// load metrics explorer data after default view loaded, unless we're not loading a view
|
||||
loadData();
|
||||
}
|
||||
}, [loadData, currentView, shouldLoadDefault]);
|
||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
||||
}, [loadData, shouldLoadDefault]);
|
||||
|
||||
return (
|
||||
<EuiErrorBoundary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue