Skip to content

Commit e03225b

Browse files
[Metrics UI] Saved views bugs (elastic#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>
1 parent 6a954e5 commit e03225b

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

x-pack/plugins/infra/public/components/saved_views/manage_views_flyout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export function SavedViewManageViewsFlyout<ViewState>({
9696

9797
const renderDeleteAction = useCallback(
9898
(item: SavedView<ViewState>) => {
99+
if (item.id === '0') {
100+
return <></>;
101+
}
102+
99103
return (
100104
<DeleteConfimation
101105
isDisabled={item.isDefault}

x-pack/plugins/infra/public/components/saved_views/toolbar_control.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export function SavedViewsToolbarControls<ViewState>(props: Props<ViewState>) {
161161
/>
162162
</EuiFlexItem>
163163
<EuiFlexItem>
164-
<EuiDescriptionList onClick={showSavedViewMenu}>
164+
<EuiDescriptionList compressed={true} onClick={showSavedViewMenu}>
165165
<EuiDescriptionListTitle>
166166
<FormattedMessage
167167
defaultMessage="Current view"

x-pack/plugins/infra/public/containers/saved_view/saved_view.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const useSavedView = (props: Props) => {
5050
const { data, loading, find, error: errorOnFind, hasView } = useFindSavedObject<
5151
SavedViewSavedObject<ViewState>
5252
>(viewType);
53-
53+
const [shouldLoadDefault] = useState(props.shouldLoadDefault);
5454
const [currentView, setCurrentView] = useState<SavedView<any> | null>(null);
5555
const [loadingDefaultView, setLoadingDefaultView] = useState<boolean | null>(null);
5656
const { create, error: errorOnCreate, data: createdViewData, createdId } = useCreateSavedObject(
@@ -211,8 +211,6 @@ export const useSavedView = (props: Props) => {
211211
}, [setCurrentView, defaultViewId, defaultViewState]);
212212

213213
useEffect(() => {
214-
const shouldLoadDefault = props.shouldLoadDefault;
215-
216214
if (loadingDefaultView || currentView || !shouldLoadDefault) {
217215
return;
218216
}
@@ -225,7 +223,7 @@ export const useSavedView = (props: Props) => {
225223
}
226224
}, [
227225
loadDefaultView,
228-
props.shouldLoadDefault,
226+
shouldLoadDefault,
229227
setDefault,
230228
loadingDefaultView,
231229
currentView,
@@ -246,7 +244,7 @@ export const useSavedView = (props: Props) => {
246244
errorOnUpdate,
247245
errorOnFind,
248246
errorOnCreate: createError,
249-
shouldLoadDefault: props.shouldLoadDefault,
247+
shouldLoadDefault,
250248
makeDefault,
251249
sourceIsLoading,
252250
deleteView,

x-pack/plugins/infra/public/pages/metrics/inventory_view/components/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export const Layout = () => {
5555
sourceId,
5656
currentTime,
5757
accountId,
58-
region
58+
region,
59+
false
5960
);
6061

6162
const options = {

x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export const MetricsExplorerPage = ({ source, derivedIndexPattern }: MetricsExpl
5757
// load metrics explorer data after default view loaded, unless we're not loading a view
5858
loadData();
5959
}
60-
}, [loadData, currentView, shouldLoadDefault]);
60+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
61+
}, [loadData, shouldLoadDefault]);
6162

6263
return (
6364
<EuiErrorBoundary>

0 commit comments

Comments
 (0)