+
{
+ const nextProtocol = value as PortProtocol;
onChange({
...item,
- protocol: value as PortProtocol
+ protocol: nextProtocol,
+ name: getAutoFilledName(
+ nextProtocol,
+ item.port,
+ item.protocol,
+ item.port,
+ item.name
+ )
});
}}
style={{ width: '100%' }}
>
-
+
{
+ const nextPort =
+ typeof value === 'number' ? value : (undefined as any);
onChange({
...item,
- port: typeof value === 'number' ? value : (undefined as any)
+ port: nextPort,
+ name: getAutoFilledName(
+ item.protocol,
+ nextPort,
+ item.protocol,
+ item.port,
+ item.name
+ )
});
}}
style={{ width: '100%' }}
/>
+
+
{
+ onChange({
+ ...item,
+ name: next
+ });
+ }}
+ />
+
);
};
@@ -75,7 +190,8 @@ const Ports: React.FC = () => {
...ports,
{
protocol: 'TCP',
- port: undefined as any
+ port: undefined as any,
+ name: ''
}
]);
};
@@ -113,6 +229,19 @@ const Ports: React.FC = () => {
)
);
}
+ const hasInvalidName = value.some(
+ (item: PortItemType) =>
+ item.name && item.name.length > PORT_NAME_MAX
+ );
+ if (hasInvalidName) {
+ return Promise.reject(
+ new Error(
+ intl.formatMessage({
+ id: 'gpuservice.template.ports.name.max'
+ })
+ )
+ );
+ }
return Promise.resolve();
}
}