From c9fcdb08eb07bfbf78fe523d7598e7ade2d02d66 Mon Sep 17 00:00:00 2001 From: Sam Machin Date: Wed, 7 Jan 2026 13:01:12 +0000 Subject: [PATCH] Feature admin only numbers & carrier (#587) * Hide create carrier/number controls if ADMIN_CARRIER env var is set * hide add caririer button * add to example .env * hide delete phone number --- .env | 4 +- entrypoint.sh | 2 +- src/api/constants.ts | 3 + .../internal/views/carriers/index.tsx | 34 +++++---- .../internal/views/phone-numbers/index.tsx | 71 ++++++++++++------- 5 files changed, 74 insertions(+), 40 deletions(-) diff --git a/.env b/.env index a824370..9479d82 100644 --- a/.env +++ b/.env @@ -31,4 +31,6 @@ ## AWS region for enabling Recent Call Feature server logs #VITE_APP_AWS_REGION=us-west-2 ## enable lazy loading for phone numbers (improves performance when managing large quantities) -# VITE_APP_ENABLE_PHONE_NUMBER_LAZY_LOAD=true \ No newline at end of file +# VITE_APP_ENABLE_PHONE_NUMBER_LAZY_LOAD=true +# hides controlls to add Carrier and Phone number from non Admin/SP Users (also need to set flag on API server to block API calls) +#VITE_ADMIN_CARRIER=1 \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index b1a06d8..f76f964 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,7 +18,7 @@ DISABLE_CALL_RECORDING=${DISABLE_CALL_RECORDING:-false} # Serialize window global to provide the API URL to static frontend dist # This is declared and utilized in the web app: src/api/constants.ts -SCRIPT_TAG="" +SCRIPT_TAG="" sed -i -e "\@@i\ $SCRIPT_TAG" ./dist/index.html # Start the frontend web app static server diff --git a/src/api/constants.ts b/src/api/constants.ts index 3daf2c9..872710f 100644 --- a/src/api/constants.ts +++ b/src/api/constants.ts @@ -35,6 +35,7 @@ interface JambonzWindowObject { DISABLE_ADDITIONAL_SPEECH_VENDORS: string; AWS_REGION: string; ENABLE_PHONE_NUMBER_LAZY_LOAD: string; + ADMIN_CARRIER: string; } declare global { @@ -110,6 +111,8 @@ export const STRIPE_PUBLISHABLE_KEY: string = window.JAMBONZ?.STRIPE_PUBLISHABLE_KEY || import.meta.env.VITE_APP_STRIPE_PUBLISHABLE_KEY; +export const ADMIN_CARRIER: string = + window.JAMBONZ?.ADMIN_CARRIER || import.meta.env.VITE_ADMIN_CARRIER || "0"; /** TCP Max Port */ export const TCP_MAX_PORT = 65535; diff --git a/src/containers/internal/views/carriers/index.tsx b/src/containers/internal/views/carriers/index.tsx index 0ebaf91..7ac03d1 100644 --- a/src/containers/internal/views/carriers/index.tsx +++ b/src/containers/internal/views/carriers/index.tsx @@ -31,6 +31,9 @@ import { ENABLE_HOSTED_SYSTEM, PER_PAGE_SELECTION, USER_ACCOUNT, + ADMIN_CARRIER, + USER_ADMIN, + USER_SP, } from "src/api/constants"; import { DeleteCarrier } from "./delete"; @@ -202,13 +205,16 @@ export const Carriers = () => { )} - - - {" "} - - - - + {((ADMIN_CARRIER === "1" && + (user?.scope === USER_ADMIN || user?.scope === USER_SP)) || + ADMIN_CARRIER === "0") && ( + + {" "} + + + + + )}
{ )}
-
- -
+ {((ADMIN_CARRIER === "1" && + (user?.scope === USER_ADMIN || user?.scope === USER_SP)) || + ADMIN_CARRIER === "0") && ( +
+ +
+ )}