Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics UI] Saved views bugs #72518

Merged
merged 20 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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