Skip to content

Commit

Permalink
fix: don't add a trailing slash
Browse files Browse the repository at this point in the history
Use the same kind of algorithm as in the gateway to build the flow name. This way, it will reflect a little bit better what the user can expect.
https://gravitee.atlassian.net/browse/APIM-3569
  • Loading branch information
phiz71 committed Dec 13, 2023
1 parent 2326422 commit 811b1e4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
25 changes: 17 additions & 8 deletions src/lib/studio.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,23 @@ export function getFlowTitle(flow, collectionName, withMethods = true, draggable
rendering.push(html`<div class="${classMap(classes)}">${flow.name}</div>`);
}
} else if (flow['path-operator']) {
const path = flow['path-operator'].path || '/';
if (path) {
const pathWithOperator = flow['path-operator'].operator === 'STARTS_WITH' ? `${path.endsWith('/') ? path : `${path}/`}**` : path;
if (flow._dirty) {
rendering.push(html`<div class="${classMap(classes)}"><mark>${pathWithOperator}</mark></div>`);
} else {
rendering.push(html`<div class="${classMap(classes)}">${pathWithOperator}</div>`);
}
let pathWithOperator = '/';
if (flow['path-operator'].path && flow['path-operator'].path.length > 1) {
flow['path-operator'].path.split('/').forEach((pathPart) => {
if (pathPart !== '') {
pathWithOperator += `${pathPart}/`;
}
});
pathWithOperator = pathWithOperator.substring(0, pathWithOperator.length - 1);
}
if (flow['path-operator'].operator === 'STARTS_WITH') {
pathWithOperator += '**';
}

if (flow._dirty) {
rendering.push(html`<div class="${classMap(classes)}"><mark>${pathWithOperator}</mark></div>`);
} else {
rendering.push(html`<div class="${classMap(classes)}">${pathWithOperator}</div>`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/organisms/gv-schema-form/gv-schema-form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe('S C H E M A F O R M', () => {
path: ['path-operator', 'path'],
property: 'instance.path-operator.path',
schema: {
description: 'The path of flow (must start by /)',
description: 'The path of flow (must start by /). Trailing slash is ignored.',
pattern: '^/',
title: 'Path',
type: 'string',
Expand Down
2 changes: 1 addition & 1 deletion src/policy-studio/gv-design/gv-design.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('D E S I G N', () => {
},
path: {
title: 'Path',
description: 'The path of flow (must start by /)',
description: 'The path of flow (must start by /). Trailing slash is ignored.',
type: 'string',
pattern: '^/',
default: '/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('P O L I C Y S T U D I O', () => {
},
path: {
title: 'Path',
description: 'The path of flow (must start by /)',
description: 'The path of flow (must start by /). Trailing slash is ignored.',
type: 'string',
pattern: '^/',
default: '/',
Expand Down
2 changes: 1 addition & 1 deletion testing/resources/schemas/apim-flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"path": {
"title": "Path",
"description": "The path of flow (must start by /)",
"description": "The path of flow (must start by /). Trailing slash is ignored.",
"type": "string",
"pattern": "^/",
"default": "/"
Expand Down
2 changes: 1 addition & 1 deletion testing/resources/schemas/fields-dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"path": {
"title": "Path",
"description": "The path of flow (must start by /)",
"description": "The path of flow (must start by /). Trailing slash is ignored.",
"type": "string",
"pattern": "^/",
"x-schema-form": {
Expand Down
2 changes: 1 addition & 1 deletion testing/resources/schemas/mixed.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
},
"path": {
"title": "Path",
"description": "The path of flow (must start by /)",
"description": "The path of flow (must start by /). Trailing slash is ignored.",
"type": "string",
"pattern": "^/",
"x-schema-form": {
Expand Down

0 comments on commit 811b1e4

Please sign in to comment.