Fixes #20680: Added readTimeout input field (#20756)

* added readTimeout input field

* fixed comments

* fixed minor comment

* fixed minor comment
This commit is contained in:
Dhruv Parmar 2025-04-11 15:19:50 +05:30 committed by GitHub
parent 503ffc1986
commit 0e69bbd4dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 47 additions and 1 deletions

View File

@ -34,6 +34,7 @@ export interface AlertDetails {
category: string;
type: string;
timeout: string;
readTimeout: string;
config: {
secretKey: string;
receivers: Array<string>;

View File

@ -530,6 +530,11 @@ export const verifyAlertDetails = async ({
destinations[0].timeout.toString()
);
// Check read timeout details
await expect(page.getByTestId('read-timeout-input')).toHaveValue(
destinations[0].readTimeout.toString()
);
for (const destinationNumber in destinations) {
await expect(
page.getByTestId(`destination-${destinationNumber}`)
@ -782,7 +787,9 @@ export const createAlert = async ({
});
await page.getByTestId('connection-timeout-input').clear();
await page.getByTestId('read-timeout-input').clear();
await page.fill('[data-testid="connection-timeout-input"]', '26');
await page.fill('[data-testid="read-timeout-input"]', '26');
}
// Select Destination

View File

@ -193,6 +193,9 @@ export const editSingleFilterAlert = async ({
await page.getByTestId('connection-timeout-input').clear();
await page.fill('[data-testid="connection-timeout-input"]', '26');
await page.getByTestId('read-timeout-input').clear();
await page.fill('[data-testid="read-timeout-input"]', '26');
// Add owner GChat destination
await page.click('[data-testid="add-destination-button"]');
await addInternalDestination({

View File

@ -27,6 +27,7 @@ import { testAlertDestination } from '../../../rest/alertsAPI';
import {
getConnectionTimeoutField,
getFormattedDestinations,
getReadTimeoutField,
listLengthValidator,
} from '../../../utils/Alerts/AlertsUtil';
import { showErrorToast } from '../../../utils/ToastUtils';
@ -103,6 +104,7 @@ function DestinationFormItem({ isViewMode = false }: DestinationFormItemProps) {
heading={t('label.destination')}
subHeading={t('message.alerts-destination-description')}>
{getConnectionTimeoutField()}
{getReadTimeoutField()}
<Form.List
name={['destinations']}
rules={[

View File

@ -28,6 +28,9 @@ jest.mock('../../../utils/Alerts/AlertsUtil', () => ({
getConnectionTimeoutField: jest
.fn()
.mockReturnValue(<div data-testid="connection-timeout" />),
getReadTimeoutField: jest
.fn()
.mockReturnValue(<div data-testid="read-timeout" />),
}));
jest.mock('../../../utils/ObservabilityUtils', () => ({

View File

@ -72,3 +72,5 @@ export const DESTINATION_TYPE_BASED_PLACEHOLDERS = {
[SubscriptionType.Webhook]: 'https://example.com',
[SubscriptionType.Email]: 'Add ↵ separated Email addresses',
};
export const DEFAULT_READ_TIMEOUT = 12;

View File

@ -32,10 +32,12 @@ export interface ModifiedDestination extends Destination {
export interface ModifiedEventSubscription extends EventSubscription {
destinations: ModifiedDestination[];
timeout: number;
readTimeout: number;
}
export interface ModifiedCreateEventSubscription
extends CreateEventSubscription {
destinations: ModifiedDestination[];
timeout: number;
readTimeout: number;
}

View File

@ -65,6 +65,7 @@ import { AsyncSelect } from '../../components/common/AsyncSelect/AsyncSelect';
import { InlineAlertProps } from '../../components/common/InlineAlert/InlineAlert.interface';
import { ExtraInfoLabel } from '../../components/DataAssets/DataAssetsHeader/DataAssetsHeader.component';
import {
DEFAULT_READ_TIMEOUT,
DESTINATION_DROPDOWN_TABS,
DESTINATION_SOURCE_ITEMS,
DESTINATION_TYPE_BASED_PLACEHOLDERS,
@ -370,6 +371,29 @@ export const getConnectionTimeoutField = () => (
</Form.Item>
</Col>
</Row>
</>
);
export const getReadTimeoutField = () => (
<>
<Row align="middle" className="mt-4">
<Col span={7}>{`${t('label.read-type', {
type: t('label.timeout'),
})} (${t('label.second-plural')})`}</Col>
<Col span={1}>:</Col>
<Col data-testid="read-timeout" span={16}>
<Form.Item name="readTimeout">
<Input
data-testid="read-timeout-input"
defaultValue={DEFAULT_READ_TIMEOUT}
placeholder={`${t('label.read-type', {
type: t('label.timeout'),
})} (${t('label.second-plural')})`}
type="number"
/>
</Form.Item>
</Col>
</Row>
<Divider className="p-x-xs" />
</>
);
@ -1076,6 +1100,7 @@ export const handleAlertSave = async ({
},
category: d.category,
timeout: data.timeout,
readTimeout: data.readTimeout,
};
});
let alertDetails;
@ -1107,7 +1132,7 @@ export const handleAlertSave = async ({
alertDetails = await updateAlertAPI(initialData.id, jsonPatch);
} else {
// Remove timeout from alert object since it's only for UI
const { timeout, ...finalData } = data;
const { timeout, readTimeout, ...finalData } = data;
alertDetails = await createAlertAPI({
...finalData,
@ -1399,6 +1424,7 @@ export const getModifiedAlertDataForForm = (
return {
...alertData,
timeout: alertData.destinations[0].timeout ?? 10,
readTimeout: alertData.destinations[0].readTimeout ?? DEFAULT_READ_TIMEOUT,
destinations: alertData.destinations.map((destination) => {
const isExternalDestination =
destination.category === SubscriptionCategory.External;