From d260edc18ac6484ce365cc018cd201ecdfcabcad Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Tue, 4 Feb 2025 11:55:15 +0000 Subject: [PATCH] MT#62062 Reload CF after amending source set Bugfix When a PBX Seat user tries to delete a sorce set that was previously added by a PBX admin the backend return an error as the entity doesn't belong to the Seat user. In this scenario the source set is not delete from the DB and it is removed from the relevant mapping. The missing try/catch didn't allow the code to reload the updated resources to show the changes. NGCP-Flow: mr13.1 Change-Id: I4b213a5857af25fe9264cbc9c695790e335b9ee9 (cherry picked from commit 433fa6cd68135910985e22054e352c62931e1ec6) --- src/store/call-forwarding/actions.js | 30 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/store/call-forwarding/actions.js b/src/store/call-forwarding/actions.js index 101e0cb2..237f3d6d 100644 --- a/src/store/call-forwarding/actions.js +++ b/src/store/call-forwarding/actions.js @@ -120,8 +120,8 @@ export async function deleteMapping ({ dispatch, commit, state, rootGetters }, p await cfDeleteDestinationSet(payload.destinationset_id) } catch (e) { if (e.code === 404 && e.message === 'Entity \'cfdestinationset\' not found.') { - // This happens when CF was set by Admin therefore current - // csc user doesn't have rights to delete the entity + // This happens when entity was set by Admin therefore current + // csc user doesn't have rights to delete the entity from DB. showGlobalWarning(i18n.global.tc('Entity belongs to admin')) } else { showGlobalError(e.message) @@ -309,7 +309,17 @@ export async function deleteSourceSet ({ dispatch, commit, rootGetters, state }, fieldPath: payload.mapping.type, value: updatedMapping }) - await cfDeleteSourceSet(payload.id) + try { + await cfDeleteSourceSet(payload.id) + } catch (e) { + if (e.code === 404 && e.message === 'Entity \'sourceset\' not found.') { + // This happens when entity was set by Admin therefore current + // csc user doesn't have rights to delete the entity from DB. + showGlobalWarning(i18n.global.tc('Entity belongs to admin')) + } else { + throw e + } + } const sourceSets = await cfLoadSourceSets() commit('dataSucceeded', { mappings: updatedMappings, @@ -410,8 +420,8 @@ export async function deleteTimeSet ({ dispatch, commit, rootGetters, state }, p await cfDeleteTimeSet(payload.id) } catch (e) { if (e.code === 404 && e.message === 'Entity \'cftimeset\' not found.') { - // This happens when CF was set by Admin therefore current - // csc user doesn't have rights to delete the entity + // This happens when entity was set by Admin therefore current + // csc user doesn't have rights to delete the entity from DB. showGlobalWarning(i18n.global.tc('Entity belongs to admin')) } else { showGlobalError(e.message) @@ -456,8 +466,6 @@ export async function doNotRingPrimaryNumber ({ commit, rootGetters, state }, pa } export async function updateRingTimeout ({ commit, rootGetters, state }, payload) { - // eslint-disable-next-line no-console - console.debug('aaa') const updatedMappings = await patchReplaceFull({ resource: 'cfmappings', resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'], @@ -494,8 +502,8 @@ export async function updateTimeSetDateRange ({ dispatch, commit }, payload) { await cfUpdateTimeSetDateRange(payload.id, payload.date) } catch (e) { if (e.code === 404 && e.message === 'Entity \'timeset\' not found.') { - // This happens when CF was set by Admin therefore current - // csc user doesn't have rights to delete the entity + // This happens when entity was set by Admin therefore current + // csc user doesn't have rights to edit the entity. showGlobalWarning(i18n.global.tc('Entity belongs to admin')) } else { showGlobalError(e.message) @@ -534,8 +542,8 @@ export async function updateTimeSetWeekdays ({ dispatch, commit }, payload) { await cfUpdateTimeSetWeekdays(payload.id, payload.weekdays) } catch (e) { if (e.code === 404 && e.message === 'Entity \'timeset\' not found.') { - // This happens when CF was set by Admin therefore current - // csc user doesn't have rights to delete the entity + // This happens when entity was set by Admin therefore current + // csc user doesn't have rights to delete the entity from DB. showGlobalWarning(i18n.global.tc('Entity belongs to admin')) } else { showGlobalError(e.message)