-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Discover] Update data view id on adhoc data view change (#142069)
* [Discover] update id on adhoc data view change * [Discover] fix ci * [Discover] fix ci * Update src/plugins/discover/public/application/main/components/layout/discover_layout.tsx Co-authored-by: Matthias Wilhelm <[email protected]> * [Discover] add filters validation * [Discover] fix ci * [Discover] fix checks * [Discover] fix ci * Update src/plugins/discover/public/application/main/hooks/use_filters_validation.ts Co-authored-by: Matthias Wilhelm <[email protected]> * Update src/plugins/discover/public/application/main/hooks/use_filters_validation.ts Co-authored-by: Matthias Wilhelm <[email protected]> * [Discover] apply suggestions * [Discover] update wording in tests * [Discover] try to fix functional * [Discover] change test impl to get rid of flakiness * [Discover] remove flaky test Co-authored-by: Matthias Wilhelm <[email protected]> Co-authored-by: Joe Reuter <[email protected]>
- Loading branch information
1 parent
7ed9067
commit 5a0e61b
Showing
18 changed files
with
256 additions
and
73 deletions.
There are no files selected for viewing
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
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
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
File renamed without changes.
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
56 changes: 56 additions & 0 deletions
56
src/plugins/discover/public/application/main/hooks/use_filters_validation.ts
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,56 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { IToasts, ToastsStart } from '@kbn/core/public'; | ||
import { FilterManager } from '@kbn/data-plugin/public'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { SavedSearch } from '@kbn/saved-search-plugin/public'; | ||
import { useEffect } from 'react'; | ||
import { debounceTime } from 'rxjs'; | ||
|
||
const addInvalidFiltersWarn = (toastNotifications: IToasts) => { | ||
const warningTitle = i18n.translate('discover.invalidFiltersWarnToast.title', { | ||
defaultMessage: 'Different index references', | ||
}); | ||
toastNotifications.addWarning({ | ||
title: warningTitle, | ||
text: i18n.translate('discover.invalidFiltersWarnToast.description', { | ||
defaultMessage: | ||
'Data view id references in some of the applied filters differ from the current data view.', | ||
}), | ||
'data-test-subj': 'invalidFiltersWarnToast', | ||
}); | ||
}; | ||
|
||
export const useFiltersValidation = ({ | ||
savedSearch, | ||
filterManager, | ||
toastNotifications, | ||
}: { | ||
savedSearch: SavedSearch; | ||
filterManager: FilterManager; | ||
toastNotifications: ToastsStart; | ||
}) => { | ||
useEffect(() => { | ||
const subscription = filterManager | ||
.getUpdates$() | ||
.pipe(debounceTime(500)) | ||
.subscribe(() => { | ||
const currentFilters = filterManager.getFilters(); | ||
const dataView = savedSearch.searchSource.getField('index'); | ||
const areFiltersInvalid = | ||
dataView && | ||
!dataView.isPersisted() && | ||
!currentFilters.every((current) => current.meta.index === dataView.id); | ||
if (areFiltersInvalid) { | ||
addInvalidFiltersWarn(toastNotifications); | ||
} | ||
}); | ||
return () => subscription.unsubscribe(); | ||
}, [filterManager, savedSearch.searchSource, toastNotifications]); | ||
}; |
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
Oops, something went wrong.