Skip to content

Commit

Permalink
[Metrics UI] Saved views bugs (#72518)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
phillipb and elasticmachine authored Jul 28, 2020
1 parent 82d7e7d commit cc84ee3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export function SavedViewManageViewsFlyout<ViewState>({

const renderDeleteAction = useCallback(
(item: SavedView<ViewState>) => {
if (item.id === '0') {
return <></>;
}

return (
<DeleteConfimation
isDisabled={item.isDefault}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -211,8 +211,6 @@ export const useSavedView = (props: Props) => {
}, [setCurrentView, defaultViewId, defaultViewState]);

useEffect(() => {
const shouldLoadDefault = props.shouldLoadDefault;

if (loadingDefaultView || currentView || !shouldLoadDefault) {
return;
}
Expand All @@ -225,7 +223,7 @@ export const useSavedView = (props: Props) => {
}
}, [
loadDefaultView,
props.shouldLoadDefault,
shouldLoadDefault,
setDefault,
loadingDefaultView,
currentView,
Expand All @@ -246,7 +244,7 @@ export const useSavedView = (props: Props) => {
errorOnUpdate,
errorOnFind,
errorOnCreate: createError,
shouldLoadDefault: props.shouldLoadDefault,
shouldLoadDefault,
makeDefault,
sourceIsLoading,
deleteView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export const Layout = () => {
sourceId,
currentTime,
accountId,
region
region,
false
);

const options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit cc84ee3

Please sign in to comment.