Skip to content

Commit 9ebbf27

Browse files
committed
rebase with main
1 parent 4d37dbd commit 9ebbf27

File tree

2 files changed

+10
-38
lines changed

2 files changed

+10
-38
lines changed

x-pack/platform/plugins/shared/streams/server/lib/streams/client.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import type {
1111
IndicesDataStream,
1212
IndicesGetDataStreamResponse,
1313
QueryDslQueryContainer,
14+
Result,
1415
} from '@elastic/elasticsearch/lib/api/types';
15-
import type { IScopedClusterClient, KibanaRequest, Logger } from '@kbn/core/server';
16+
import type { IScopedClusterClient, Logger, KibanaRequest } from '@kbn/core/server';
1617
import { isNotFoundError } from '@kbn/es-errors';
17-
import type { LockManagerService } from '@kbn/lock-manager';
18-
import type { Condition } from '@kbn/streamlang';
1918
import type { RoutingStatus } from '@kbn/streams-schema';
2019
import { Streams, getAncestors, getParentId } from '@kbn/streams-schema';
20+
import type { LockManagerService } from '@kbn/lock-manager';
21+
import type { Condition } from '@kbn/streamlang';
2122
import type { AssetClient } from './assets/asset_client';
2223
import type { QueryClient } from './assets/query/query_client';
2324
import {
@@ -26,11 +27,9 @@ import {
2627
} from './errors/definition_not_found_error';
2728
import { SecurityError } from './errors/security_error';
2829
import { StatusError } from './errors/status_error';
29-
import { StreamsStatusConflictError } from './errors/streams_status_conflict_error';
30-
import type { FeatureClient } from './feature/feature_client';
3130
import { LOGS_ROOT_STREAM_NAME, rootStreamDefinition } from './root_stream_definition';
32-
import { State } from './state_management/state';
3331
import type { StreamsStorageClient } from './storage/streams_storage_client';
32+
import { State } from './state_management/state';
3433
import { checkAccess, checkAccessBulk } from './stream_crud';
3534
import { StreamsStatusConflictError } from './errors/streams_status_conflict_error';
3635
import type { FeatureClient } from './feature/feature_client';
@@ -326,23 +325,6 @@ export class StreamsClient {
326325
throw new StatusError(`Child stream ${name} already exists`, 409);
327326
}
328327

329-
// TODO - These constants need to be shared between both plugins so I don't have to duplicate them
330-
// TODO: need to know prefix to do min check properly
331-
logger.info(`parent: ${parent}, \n name: ${name}`);
332-
const MIN_NAME_LENGTH = 6; // 'logs.' is already included which is 5 characters, so user must enter at least one more.
333-
const MAX_NAME_LENGTH = 200;
334-
335-
if (name.length < MIN_NAME_LENGTH) {
336-
throw new StatusError('Stream name must not be empty.', 400);
337-
}
338-
339-
if (name.length > MAX_STREAM_NAME_LENGTH) {
340-
throw new StatusError(
341-
`Stream name cannot be longer than ${MAX_STREAM_NAME_LENGTH} characters.`,
342-
400
343-
);
344-
}
345-
346328
await State.attemptChanges(
347329
[
348330
{

x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_routing/stream_name_form_row.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import {
1616
} from '@elastic/eui';
1717
import { css } from '@emotion/react';
1818
import { i18n } from '@kbn/i18n';
19-
import React from 'react';
2019
import { MAX_STREAM_NAME_LENGTH } from '@kbn/streams-plugin/public';
20+
import React from 'react';
2121
import { useStreamsRoutingSelector } from './state_management/stream_routing_state_machine';
2222

2323
interface StreamNameFormRowProps {
@@ -69,21 +69,11 @@ export function StreamNameFormRow({
6969
const prefix = parentStreamName + '.';
7070
const partitionName = value.replace(prefix, '');
7171

72-
const isLengthValid = value.length > prefix.length && value.length <= MAX_NAME_LENGTH;
72+
const isStreamNameEmpty = value.length <= prefix.length;
73+
const isStreamNameTooLong = value.length > MAX_STREAM_NAME_LENGTH;
74+
const isLengthValid = !isStreamNameEmpty && !isStreamNameTooLong;
7375

74-
const helpText =
75-
value.length >= MAX_NAME_LENGTH && !readOnly
76-
? i18n.translate('xpack.streams.streamDetailRouting.maximumNameHelpText', {
77-
defaultMessage: `Stream name cannot be longer than {maxLength} characters.`,
78-
values: {
79-
maxLength: MAX_NAME_LENGTH,
80-
},
81-
})
82-
: value.length <= prefix.length && !readOnly
83-
? i18n.translate('xpack.streams.streamDetailRouting.minimumNameHelpText', {
84-
defaultMessage: `Stream name is required.`,
85-
})
86-
: undefined;
76+
const helpText = getHelpText(isStreamNameEmpty, isStreamNameTooLong, readOnly);
8777

8878
const isDotPresent = !readOnly && partitionName.includes('.');
8979
const dotErrorMessage = isDotPresent

0 commit comments

Comments
 (0)