From 22a61084cabbd07f701a79345cf5f05427d44055 Mon Sep 17 00:00:00 2001 From: maxiadlovskii Date: Fri, 2 Feb 2024 11:11:29 +0100 Subject: [PATCH] Handle getting Processing and Indexing Failures stream name for non enterprise version (#18143) --- .../src/components/streams/hooks/useStream.ts | 7 +++++-- .../ChangeFieldType/ChangeFieldTypeModal.tsx | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/graylog2-web-interface/src/components/streams/hooks/useStream.ts b/graylog2-web-interface/src/components/streams/hooks/useStream.ts index 94faad5929eb..4358ca02345d 100644 --- a/graylog2-web-interface/src/components/streams/hooks/useStream.ts +++ b/graylog2-web-interface/src/components/streams/hooks/useStream.ts @@ -28,12 +28,13 @@ const fetchStream = (streamId: string) => { return fetch('GET', qualifyUrl(url)); }; -const useStream = (streamId: string): { +const useStream = (streamId: string, { enabled } = { enabled: true }): { data: Stream refetch: () => void, isFetching: boolean, + isError, } => { - const { data, refetch, isFetching } = useQuery( + const { data, refetch, isFetching, isError } = useQuery( ['streams', streamId], () => fetchStream(streamId), { @@ -42,6 +43,7 @@ const useStream = (streamId: string): { 'Could not load Stream'); }, keepPreviousData: true, + enabled, }, ); @@ -49,6 +51,7 @@ const useStream = (streamId: string): { data, refetch, isFetching, + isError, }); }; diff --git a/graylog2-web-interface/src/views/logic/fieldactions/ChangeFieldType/ChangeFieldTypeModal.tsx b/graylog2-web-interface/src/views/logic/fieldactions/ChangeFieldType/ChangeFieldTypeModal.tsx index 5ca423a15f7a..5527d3861301 100644 --- a/graylog2-web-interface/src/views/logic/fieldactions/ChangeFieldType/ChangeFieldTypeModal.tsx +++ b/graylog2-web-interface/src/views/logic/fieldactions/ChangeFieldType/ChangeFieldTypeModal.tsx @@ -32,6 +32,8 @@ import { getPathnameWithoutId } from 'util/URLUtils'; import useLocation from 'routing/useLocation'; import FieldSelect from 'views/logic/fieldactions/ChangeFieldType/FieldSelect'; import useFieldTypesForMappings from 'views/logic/fieldactions/ChangeFieldType/hooks/useFieldTypesForMappings'; +import { Link } from 'components/common/router'; +import Routes from 'routing/Routes'; const StyledSelect = styled(Select)` width: 400px; @@ -64,6 +66,18 @@ type Props = { } } +const FailureStreamLink = () => { + const { data: failureStream, isFetching: isFetchingFailureStream, isError: isErrorFailureStream } = useStream(failureStreamId); + if (isFetchingFailureStream) return ; + + return ( + + + (Enterprise Plugin required) + + ); +}; + const ChangeFieldTypeModal = ({ show, onSubmitCallback, @@ -83,7 +97,6 @@ const ChangeFieldTypeModal = ({ value, label, })), [fieldTypes]); - const { data: failureStream, isFetching: failureStreamLoading } = useStream(failureStreamId); const [indexSetSelection, setIndexSetSelection] = useState>(); @@ -149,7 +162,7 @@ const ChangeFieldTypeModal = ({ Changing the type of the field {fieldName} can have a significant impact on the ingestion of future log messages. If you declare a field to have a type which is incompatible with the logs you are ingesting, it can lead to ingestion errors. It is recommended to enable and watch - the {failureStreamLoading ? : } stream closely afterwards. + the stream closely afterwards. {`Select Field Type For ${fieldName || 'Field'}`}