From 4943a963226487f02d3d85fb505427fae4d44a88 Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Wed, 5 Jun 2024 10:59:52 +0100 Subject: [PATCH] MT#60150 sip username changes in pbx group creation sip username is created removing whitespaces and special chars from the name input. This logic was handled by a lodash method. This commit replaces the mentioned method with a custom function that mirrors the logic we use in ngcp-admin to handle the pbx group creation. The new method is less aggressive in fact it allows the use of underscores and doesn't dash numbers. As part of the change we also expose sip username as read-only field in the edit pbxGroupDetails page. Change-Id: I086b3a7011e47d8f542ac92f42bd923c38630331 (cherry picked from commit ccf2b82831ca1089b94a9b57e300b5d45d63574d) (cherry picked from commit 2003188754d1ad2874dce5819969d4fbabd6619d) --- src/api/pbx-groups.js | 12 ++++++++---- src/pages/CscPagePbxGroupDetails.vue | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/api/pbx-groups.js b/src/api/pbx-groups.js index 62485b83..d1246ca8 100644 --- a/src/api/pbx-groups.js +++ b/src/api/pbx-groups.js @@ -24,9 +24,7 @@ import { assignNumbers, getNumbers } from './user' -import { - getSeatsOnly -} from './pbx-seats' +import { getSeatsOnly } from './pbx-seats' export function getGroups (options) { return new Promise((resolve, reject) => { @@ -121,7 +119,7 @@ export function createGroup (group) { let subscriberId Promise.resolve().then(() => { return createSubscriber({ - username: _.kebabCase(group.name), + username: createUsername(group.name), password: createId(), is_pbx_group: true, display_name: group.name, @@ -306,3 +304,9 @@ export function setGroupSoundSet (options) { }) }) } + +// This mirrors the logic we use in ngcp-admin to handle the pbx groups creation +// If you change the logic below make sure you make the same changes in ngcp-admin too +function createUsername (name) { + return name.trim().replaceAll(' ', '-').replace(/[^a-zA-Z0-9\-_ ]/g, '') +} diff --git a/src/pages/CscPagePbxGroupDetails.vue b/src/pages/CscPagePbxGroupDetails.vue index d559775c..d1c4e181 100644 --- a/src/pages/CscPagePbxGroupDetails.vue +++ b/src/pages/CscPagePbxGroupDetails.vue @@ -67,6 +67,12 @@ /> +