Skip to content

Commit

Permalink
[8.14] [SLOs] Refetch data views on save (#181033) (#181113)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.14`:
- [[SLOs] Refetch data views on save
(#181033)](#181033)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Shahzad","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-04-18T07:48:08Z","message":"[SLOs]
Refetch data views on save (#181033)\n\n## Summary\r\n\r\nRefetch data
views on save !!\r\n\r\nFixes
https://github.com/elastic/kibana/issues/179478","sha":"86df2fc9ae9c71b6d3e22ebdcc850bdf113c1fb3","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:obs-ux-management","v8.14.0","v8.15.0"],"title":"[SLOs]
Refetch data views on
save","number":181033,"url":"https://github.com/elastic/kibana/pull/181033","mergeCommit":{"message":"[SLOs]
Refetch data views on save (#181033)\n\n## Summary\r\n\r\nRefetch data
views on save !!\r\n\r\nFixes
https://github.com/elastic/kibana/issues/179478","sha":"86df2fc9ae9c71b6d3e22ebdcc850bdf113c1fb3"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/181033","number":181033,"mergeCommit":{"message":"[SLOs]
Refetch data views on save (#181033)\n\n## Summary\r\n\r\nRefetch data
views on save !!\r\n\r\nFixes
https://github.com/elastic/kibana/issues/179478","sha":"86df2fc9ae9c71b6d3e22ebdcc850bdf113c1fb3"}}]}]
BACKPORT-->

Co-authored-by: Shahzad <[email protected]>
  • Loading branch information
kibanamachine and shahzad31 authored Apr 18, 2024
1 parent 9590ea6 commit f8d48e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export interface UseFetchDataViewsResponse {
data: DataViewListItem[] | undefined;
}

export function useFetchDataViews(): UseFetchDataViewsResponse {
export function useFetchDataViews() {
const { dataViews } = useKibana().services;

const { isLoading, isError, isSuccess, data } = useQuery({
const { isLoading, isError, isSuccess, data, refetch } = useQuery({
queryKey: ['fetchDataViewsList'],
queryFn: async () => {
return dataViews.getIdsWithTitle();
Expand All @@ -29,5 +29,5 @@ export function useFetchDataViews(): UseFetchDataViewsResponse {
refetchOnWindowFocus: false,
});

return { isLoading, isError, isSuccess, data };
return { isLoading, isError, isSuccess, data, refetch };
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function IndexSelection() {
const { control, getFieldState, setValue, watch } = useFormContext<CreateSLOForm>();
const { dataViews: dataViewsService } = useKibana().services;

const { isLoading: isDataViewsLoading, data: dataViews = [] } = useFetchDataViews();
const { isLoading: isDataViewsLoading, data: dataViews = [], refetch } = useFetchDataViews();

const { dataViewEditor } = useKibana().services;

Expand Down Expand Up @@ -100,7 +100,8 @@ export function IndexSelection() {
setAdHocDataViews([...adHocDataViews, dataView]);
field.onChange(dataView.getIndexPattern());
} else {
field.onChange(getDataViewPatternById(dataView.id));
refetch();
field.onChange(dataView.getIndexPattern());
}
if (dataView.timeFieldName) {
setValue('indicator.params.timestampField', dataView.timeFieldName);
Expand Down

0 comments on commit f8d48e4

Please sign in to comment.