Skip to content

Commit

Permalink
chore(Canvas): Remove Route name restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
lordrip committed May 3, 2024
1 parent 062330e commit 1dd7bf2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
25 changes: 0 additions & 25 deletions packages/ui/src/components/InlineEdit/routeIdValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
});
});
7 changes: 1 addition & 6 deletions packages/ui/src/components/InlineEdit/routeIdValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
Expand Down

0 comments on commit 1dd7bf2

Please sign in to comment.