-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Logs UI] Remove apollo deps from log link-to routes (#74502)
This replaces the use of the old graphql-based `useSource` hook with the new plain JSON `useLogSource` hook. It also fixes two more problems: - A rendering problem with the source configuration loading screen and a `setState` race condition in the `useLogSource` hook. - A non-backwards-compatible change of the `/link-to/:sourceId/logs` route in #61162.
- Loading branch information
1 parent
1ac8716
commit 0f11282
Showing
11 changed files
with
453 additions
and
147 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
78 changes: 78 additions & 0 deletions
78
x-pack/plugins/infra/public/containers/logs/log_source/log_source.mock.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,78 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { LogSourceConfiguration, LogSourceStatus, useLogSource } from './log_source'; | ||
|
||
type CreateUseLogSource = (sourceConfiguration?: { sourceId?: string }) => typeof useLogSource; | ||
|
||
const defaultSourceId = 'default'; | ||
|
||
export const createUninitializedUseLogSourceMock: CreateUseLogSource = ({ | ||
sourceId = defaultSourceId, | ||
} = {}) => () => ({ | ||
derivedIndexPattern: { | ||
fields: [], | ||
title: 'unknown', | ||
}, | ||
hasFailedLoadingSource: false, | ||
hasFailedLoadingSourceStatus: false, | ||
initialize: jest.fn(), | ||
isLoading: false, | ||
isLoadingSourceConfiguration: false, | ||
isLoadingSourceStatus: false, | ||
isUninitialized: true, | ||
loadSource: jest.fn(), | ||
loadSourceConfiguration: jest.fn(), | ||
loadSourceFailureMessage: undefined, | ||
loadSourceStatus: jest.fn(), | ||
sourceConfiguration: undefined, | ||
sourceId, | ||
sourceStatus: undefined, | ||
updateSourceConfiguration: jest.fn(), | ||
}); | ||
|
||
export const createLoadingUseLogSourceMock: CreateUseLogSource = ({ | ||
sourceId = defaultSourceId, | ||
} = {}) => (args) => ({ | ||
...createUninitializedUseLogSourceMock({ sourceId })(args), | ||
isLoading: true, | ||
isLoadingSourceConfiguration: true, | ||
isLoadingSourceStatus: true, | ||
}); | ||
|
||
export const createLoadedUseLogSourceMock: CreateUseLogSource = ({ | ||
sourceId = defaultSourceId, | ||
} = {}) => (args) => ({ | ||
...createUninitializedUseLogSourceMock({ sourceId })(args), | ||
sourceConfiguration: createBasicSourceConfiguration(sourceId), | ||
sourceStatus: { | ||
logIndexFields: [], | ||
logIndexStatus: 'available', | ||
}, | ||
}); | ||
|
||
export const createBasicSourceConfiguration = (sourceId: string): LogSourceConfiguration => ({ | ||
id: sourceId, | ||
origin: 'stored', | ||
configuration: { | ||
description: `description for ${sourceId}`, | ||
logAlias: 'LOG_INDICES', | ||
logColumns: [], | ||
fields: { | ||
container: 'CONTAINER_FIELD', | ||
host: 'HOST_FIELD', | ||
pod: 'POD_FIELD', | ||
tiebreaker: 'TIEBREAKER_FIELD', | ||
timestamp: 'TIMESTAMP_FIELD', | ||
}, | ||
name: sourceId, | ||
}, | ||
}); | ||
|
||
export const createAvailableSourceStatus = (logIndexFields = []): LogSourceStatus => ({ | ||
logIndexFields, | ||
logIndexStatus: 'available', | ||
}); |
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.