Skip to content

Commit

Permalink
fix(Designer): Added connection name check to avoid known connection …
Browse files Browse the repository at this point in the history
…name strings (#4104)

Will avoid checking for known connection name strings
  • Loading branch information
rllyy97 committed Feb 2, 2024
1 parent 213b5f0 commit 3fc73e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions libs/services/designer-client-services/src/lib/base/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,25 +336,24 @@ export abstract class BaseConnectionService implements IConnectionService {
async getUniqueConnectionName(connectorId: string, connectionNames: string[], connectorName: string): Promise<string> {
const { name: connectionName, index } = getUniqueName(connectionNames, connectorName);
return isArmResourceId(connectorId)
? this._getUniqueConnectionNameInApiHub(connectorName, connectorId, connectionName, index)
? this._getUniqueConnectionNameInApiHub(connectorName, connectorId, connectionName, index, connectionNames)
: connectionName;
}

protected async _getUniqueConnectionNameInApiHub(
connectorName: string,
connectorId: string,
connectionName: string,
i: number
i: number,
connectionNames: string[] = []
): Promise<string> {
const connectionId = this.getAzureConnectionRequestPath(connectionName);
const isUnique = await this._testConnectionIdUniquenessInApiHub(connectionId);

if (isUnique) {
return connectionName;
} else {
connectionName = `${connectorName}-${i++}`;
return this._getUniqueConnectionNameInApiHub(connectorName, connectorId, connectionName, i);
if (!connectionNames.includes(connectionName)) {
const connectionId = this.getAzureConnectionRequestPath(connectionName);
const isUnique = await this._testConnectionIdUniquenessInApiHub(connectionId);
if (isUnique) return connectionName;
}
connectionName = `${connectorName}-${++i}`;
return this._getUniqueConnectionNameInApiHub(connectorName, connectorId, connectionName, i, connectionNames);
}

protected _testConnectionIdUniquenessInApiHub(id: string): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion libs/utils/src/lib/helpers/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function _isConnectionParameterHidden(connectionParameter: ConnectionParameter):
export const getUniqueName = (keys: string[], prefix: string): { name: string; index: number } => {
const set = new Set(keys.map((name) => name.split('::')[0]));

let index = 1;
let index = 0;
let name = prefix;
while (set.has(name)) {
name = `${prefix}-${++index}`;
Expand Down

0 comments on commit 3fc73e5

Please sign in to comment.