Skip to content

Commit 8f07909

Browse files
[DI-29309] - Create Notification Channel label error validation (#13345)
* [DI-29309] - rename name to label in CreateNotificationChannelForm interface * add changeset * revert serverHandler
1 parent 82bd3ab commit 8f07909

File tree

8 files changed

+15
-10
lines changed

8 files changed

+15
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
Replaced `name` to `label` for ACLP-Alerting CreateNotificationChannelForm interface to keep it consistent with API error message fields ([#13345](https://github.com/linode/manager/pull/13345))

packages/manager/src/features/CloudPulse/Alerts/NotificationChannels/CreateChannel/CreateNotificationChannel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const overrides: CrumbOverridesProps[] = [
3333

3434
const initialValues: CreateNotificationChannelForm = {
3535
type: null,
36-
name: '',
36+
label: '',
3737
recipients: [],
3838
};
3939

@@ -105,7 +105,7 @@ export const CreateNotificationChannel = () => {
105105
// Reset the name field when the channel type changes
106106
const handleChannelTypeChange = (value: ChannelType | null) => {
107107
field.onChange(value);
108-
resetField('name', { defaultValue: '' });
108+
resetField('label', { defaultValue: '' });
109109
resetField('recipients', { defaultValue: [] });
110110
};
111111

@@ -124,7 +124,7 @@ export const CreateNotificationChannel = () => {
124124
<Controller
125125
control={control}
126126
key={channelTypeWatcher}
127-
name="name"
127+
name="label"
128128
render={({ field, fieldState }) => (
129129
<TextField
130130
{...field}

packages/manager/src/features/CloudPulse/Alerts/NotificationChannels/CreateChannel/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const specialStartRegex = /^[^a-zA-Z0-9]/;
88
const specialEndRegex = /[^a-zA-Z0-9]$/;
99

1010
export const createNotificationChannelSchema = object({
11-
name: string()
11+
label: string()
1212
.required(fieldErrorMessage)
1313
.matches(
1414
/^[^*#&+:<>"?@%{}\\/]+$/,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ChannelType } from '@linode/api-v4';
22

33
export interface CreateNotificationChannelForm {
4-
name: string;
4+
label: string;
55
recipients: string[];
66
type: ChannelType | null;
77
}

packages/manager/src/features/CloudPulse/Alerts/NotificationChannels/CreateChannel/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ export const filterCreateChannelFormValues = (
1111
usernames: formValues.recipients,
1212
},
1313
},
14-
label: formValues.name,
14+
label: formValues.label,
1515
};
1616
};

packages/manager/src/features/CloudPulse/Alerts/NotificationChannels/EditChannel/EditNotificationChannel.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('EditNotificationChannel component', () => {
218218

219219
it('should show field-specific error when API returns field error', async () => {
220220
queryMocks.mutateAsync.mockRejectedValue([
221-
{ field: 'name', reason: 'Name already exists' },
221+
{ field: 'label', reason: 'Name already exists' },
222222
]);
223223

224224
const user = userEvent.setup();

packages/manager/src/features/CloudPulse/Alerts/NotificationChannels/EditChannel/EditNotificationChannel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const EditNotificationChannel = (
5555

5656
const formMethods = useForm<CreateNotificationChannelForm>({
5757
defaultValues: {
58-
name: channelData.label,
58+
label: channelData.label,
5959
type: channelData.channel_type,
6060
recipients:
6161
channelData.channel_type === 'email'
@@ -124,7 +124,7 @@ export const EditNotificationChannel = (
124124
/>
125125
<Controller
126126
control={control}
127-
name="name"
127+
name="label"
128128
render={({ field, fieldState }) => (
129129
<TextField
130130
{...field}

packages/manager/src/features/CloudPulse/Alerts/NotificationChannels/EditChannel/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const filterEditChannelFormValues = (
77
): EditNotificationChannelPayloadWithId => {
88
return {
99
channelId,
10-
label: formValues.name,
10+
label: formValues.label,
1111
details: {
1212
email: {
1313
usernames: formValues.recipients,

0 commit comments

Comments
 (0)