From 1dd7bf27364d5c35b1b6c6e27769b0b2921cd71b Mon Sep 17 00:00:00 2001 From: "Ricardo M." Date: Fri, 3 May 2024 11:26:28 +0200 Subject: [PATCH] chore(Canvas): Remove Route name restriction fix: https://github.com/KaotoIO/kaoto/issues/968 --- .../InlineEdit/routeIdValidator.test.ts | 25 ------------------- .../components/InlineEdit/routeIdValidator.ts | 7 +----- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/packages/ui/src/components/InlineEdit/routeIdValidator.test.ts b/packages/ui/src/components/InlineEdit/routeIdValidator.test.ts index a7468b280..09d6100ed 100644 --- a/packages/ui/src/components/InlineEdit/routeIdValidator.test.ts +++ b/packages/ui/src/components/InlineEdit/routeIdValidator.test.ts @@ -37,29 +37,4 @@ describe('routeIdValidator', () => { expect(result.status).toEqual(ValidationStatus.Error); expect(result.errMessages).toEqual(['Name must be unique']); }); - - it('should return an error if the name is not a valid URI', () => { - const resource = new CamelRouteResource(camelRouteJson); - const visualEntities = resource.getVisualEntities(); - jest.spyOn(visualEntities[0], 'getId').mockReturnValue('flow-1234'); - - const result = RouteIdValidator.validateUniqueName('The amazing Route', visualEntities); - - expect(result.status).toEqual(ValidationStatus.Error); - expect(result.errMessages).toEqual(['Name should only contain lowercase letters, numbers, and dashes']); - }); - - it('should return an error if the name is not unique neither a valid URI', () => { - const resource = new CamelRouteResource(camelRouteJson); - const visualEntities = resource.getVisualEntities(); - jest.spyOn(visualEntities[0], 'getId').mockReturnValue('The amazing Route'); - - const result = RouteIdValidator.validateUniqueName('The amazing Route', visualEntities); - - expect(result.status).toEqual(ValidationStatus.Error); - expect(result.errMessages).toEqual([ - 'Name should only contain lowercase letters, numbers, and dashes', - 'Name must be unique', - ]); - }); }); diff --git a/packages/ui/src/components/InlineEdit/routeIdValidator.ts b/packages/ui/src/components/InlineEdit/routeIdValidator.ts index c8e9a1883..ec26d0b37 100644 --- a/packages/ui/src/components/InlineEdit/routeIdValidator.ts +++ b/packages/ui/src/components/InlineEdit/routeIdValidator.ts @@ -20,18 +20,13 @@ export class RouteIdValidator { const errMessages = []; const flowsIds = visualEntities.map((flow) => flow.getId()); - const isValidURI = RouteIdValidator.isNameValidCheck(flowName); - if (!isValidURI) { - errMessages.push('Name should only contain lowercase letters, numbers, and dashes'); - } - const isUnique = !flowsIds.includes(flowName); if (!isUnique) { errMessages.push('Name must be unique'); } return { - status: isValidURI && isUnique ? ValidationStatus.Success : ValidationStatus.Error, + status: isUnique ? ValidationStatus.Success : ValidationStatus.Error, errMessages, }; }