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; category: string;
type: string; type: string;
timeout: string; timeout: string;
readTimeout: string;
config: { config: {
secretKey: string; secretKey: string;
receivers: Array<string>; receivers: Array<string>;

View File

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

View File

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

View File

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

View File

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

View File

@ -72,3 +72,5 @@ export const DESTINATION_TYPE_BASED_PLACEHOLDERS = {
[SubscriptionType.Webhook]: 'https://example.com', [SubscriptionType.Webhook]: 'https://example.com',
[SubscriptionType.Email]: 'Add ↵ separated Email addresses', [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 { export interface ModifiedEventSubscription extends EventSubscription {
destinations: ModifiedDestination[]; destinations: ModifiedDestination[];
timeout: number; timeout: number;
readTimeout: number;
} }
export interface ModifiedCreateEventSubscription export interface ModifiedCreateEventSubscription
extends CreateEventSubscription { extends CreateEventSubscription {
destinations: ModifiedDestination[]; destinations: ModifiedDestination[];
timeout: number; 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 { InlineAlertProps } from '../../components/common/InlineAlert/InlineAlert.interface';
import { ExtraInfoLabel } from '../../components/DataAssets/DataAssetsHeader/DataAssetsHeader.component'; import { ExtraInfoLabel } from '../../components/DataAssets/DataAssetsHeader/DataAssetsHeader.component';
import { import {
DEFAULT_READ_TIMEOUT,
DESTINATION_DROPDOWN_TABS, DESTINATION_DROPDOWN_TABS,
DESTINATION_SOURCE_ITEMS, DESTINATION_SOURCE_ITEMS,
DESTINATION_TYPE_BASED_PLACEHOLDERS, DESTINATION_TYPE_BASED_PLACEHOLDERS,
@ -370,6 +371,29 @@ export const getConnectionTimeoutField = () => (
</Form.Item> </Form.Item>
</Col> </Col>
</Row> </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" /> <Divider className="p-x-xs" />
</> </>
); );
@ -1076,6 +1100,7 @@ export const handleAlertSave = async ({
}, },
category: d.category, category: d.category,
timeout: data.timeout, timeout: data.timeout,
readTimeout: data.readTimeout,
}; };
}); });
let alertDetails; let alertDetails;
@ -1107,7 +1132,7 @@ export const handleAlertSave = async ({
alertDetails = await updateAlertAPI(initialData.id, jsonPatch); alertDetails = await updateAlertAPI(initialData.id, jsonPatch);
} else { } else {
// Remove timeout from alert object since it's only for UI // Remove timeout from alert object since it's only for UI
const { timeout, ...finalData } = data; const { timeout, readTimeout, ...finalData } = data;
alertDetails = await createAlertAPI({ alertDetails = await createAlertAPI({
...finalData, ...finalData,
@ -1399,6 +1424,7 @@ export const getModifiedAlertDataForForm = (
return { return {
...alertData, ...alertData,
timeout: alertData.destinations[0].timeout ?? 10, timeout: alertData.destinations[0].timeout ?? 10,
readTimeout: alertData.destinations[0].readTimeout ?? DEFAULT_READ_TIMEOUT,
destinations: alertData.destinations.map((destination) => { destinations: alertData.destinations.map((destination) => {
const isExternalDestination = const isExternalDestination =
destination.category === SubscriptionCategory.External; destination.category === SubscriptionCategory.External;