diff --git a/src/api/types.ts b/src/api/types.ts index 9720b2f..d17ca17 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -522,6 +522,9 @@ export interface Client { username: null | string; password?: null | string; is_active: boolean; + allow_direct_app_calling: boolean; + allow_direct_queue_calling: boolean; + allow_direct_user_calling: boolean; } export interface PageQuery { diff --git a/src/containers/internal/views/accounts/form.tsx b/src/containers/internal/views/accounts/form.tsx index 36de3c5..4bce47f 100644 --- a/src/containers/internal/views/accounts/form.tsx +++ b/src/containers/internal/views/accounts/form.tsx @@ -693,7 +693,9 @@ export const AccountForm = ({ {isDeleteAccount && (
diff --git a/src/containers/internal/views/applications/form.tsx b/src/containers/internal/views/applications/form.tsx index 45662e5..a081b40 100644 --- a/src/containers/internal/views/applications/form.tsx +++ b/src/containers/internal/views/applications/form.tsx @@ -550,7 +550,12 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => { return (
- +
{MSG_REQUIRED_FIELDS}
diff --git a/src/containers/internal/views/carriers/form.tsx b/src/containers/internal/views/carriers/form.tsx index 685685a..06c0f5a 100644 --- a/src/containers/internal/views/carriers/form.tsx +++ b/src/containers/internal/views/carriers/form.tsx @@ -639,7 +639,12 @@ export const CarrierForm = ({ return (
- +
{MSG_REQUIRED_FIELDS}
diff --git a/src/containers/internal/views/clients/edit.tsx b/src/containers/internal/views/clients/edit.tsx index 2eaf471..ab72ebd 100644 --- a/src/containers/internal/views/clients/edit.tsx +++ b/src/containers/internal/views/clients/edit.tsx @@ -1,13 +1,15 @@ import { H1 } from "@jambonz/ui-kit"; import React, { useEffect } from "react"; -import { useParams } from "react-router-dom"; +import { useNavigate, useParams } from "react-router-dom"; import { useApiData } from "src/api"; import { Client } from "src/api/types"; import { toastError } from "src/store"; import ClientsForm from "./form"; +import { ROUTE_INTERNAL_CLIENTS } from "src/router/routes"; export const ClientsEdit = () => { const params = useParams(); + const navigate = useNavigate(); const [data, refetch, error] = useApiData( `Clients/${params.client_sid}` ); @@ -16,6 +18,7 @@ export const ClientsEdit = () => { useEffect(() => { if (error) { toastError(error.msg); + navigate(ROUTE_INTERNAL_CLIENTS); } }, [error]); diff --git a/src/containers/internal/views/clients/form.tsx b/src/containers/internal/views/clients/form.tsx index 286f1fc..4f01e11 100644 --- a/src/containers/internal/views/clients/form.tsx +++ b/src/containers/internal/views/clients/form.tsx @@ -9,7 +9,7 @@ import { } from "src/api"; import { USER_ACCOUNT } from "src/api/constants"; import { Account, Client, UseApiDataMap } from "src/api/types"; -import { Section } from "src/components"; +import { Section, Tooltip } from "src/components"; import { AccountSelect, Message, Passwd } from "src/components/forms"; import { MSG_REQUIRED_FIELDS } from "src/constants"; import { ROUTE_INTERNAL_CLIENTS } from "src/router/routes"; @@ -30,7 +30,12 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { const [accountSid, setAccountSid] = useState(""); const [password, setPassword] = useState(""); const [username, setUsername] = useState(""); - const [isActive, setIsActive] = useState(true); + const [isActive, setIsActive] = useState( + client ? client.data?.is_active : true + ); + const [allowDirectAppCalling, setAllowDirectAppCalling] = useState(true); + const [allowDirectQueueCalling, setAllowDirectQueueCalling] = useState(true); + const [allowDirectUserCalling, setAllowDirectUserCalling] = useState(true); const [modal, setModal] = useState(false); const [errorMessage, setErrorMessage] = useState(""); const handleSubmit = (e: React.FormEvent) => { @@ -42,6 +47,9 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { username: username, password: password, is_active: isActive, + allow_direct_app_calling: allowDirectAppCalling, + allow_direct_queue_calling: allowDirectQueueCalling, + allow_direct_user_calling: allowDirectUserCalling, }) .then(() => { toastSuccess("Client created successfully"); @@ -56,6 +64,9 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { username: username, ...(password && { password: password }), is_active: isActive, + allow_direct_app_calling: allowDirectAppCalling, + allow_direct_queue_calling: allowDirectQueueCalling, + allow_direct_user_calling: allowDirectUserCalling, }) .then(() => { toastSuccess("Client updated successfully"); @@ -99,6 +110,9 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { } setIsActive(client.data.is_active); + setAllowDirectAppCalling(client.data.allow_direct_app_calling); + setAllowDirectQueueCalling(client.data.allow_direct_queue_calling); + setAllowDirectUserCalling(client.data.allow_direct_user_calling); } }, [client]); @@ -114,7 +128,12 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { return ( <>
- +
{MSG_REQUIRED_FIELDS} {errorMessage && } @@ -136,18 +155,6 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { /> - -
-
@@ -160,12 +167,63 @@ export const ClientsForm = ({ client }: ClientsFormProps) => { setValue={setPassword} />
+
+ + + + +
{user?.scope !== USER_ACCOUNT && (
{ return ( <>
- +
{MSG_REQUIRED_FIELDS} {errorMessage && } diff --git a/src/containers/internal/views/ms-teams-tenants/form.tsx b/src/containers/internal/views/ms-teams-tenants/form.tsx index 8aeb6b1..fedddd4 100644 --- a/src/containers/internal/views/ms-teams-tenants/form.tsx +++ b/src/containers/internal/views/ms-teams-tenants/form.tsx @@ -120,7 +120,12 @@ export const MsTeamsTenantForm = ({ return (
- +
{MSG_REQUIRED_FIELDS}
diff --git a/src/containers/internal/views/phone-numbers/form.tsx b/src/containers/internal/views/phone-numbers/form.tsx index 1a74ad9..4fae7f4 100644 --- a/src/containers/internal/views/phone-numbers/form.tsx +++ b/src/containers/internal/views/phone-numbers/form.tsx @@ -141,7 +141,12 @@ export const PhoneNumberForm = ({ phoneNumber }: PhoneNumberFormProps) => { return ( <>
- +
{MSG_REQUIRED_FIELDS}
diff --git a/src/containers/internal/views/speech-services/form.tsx b/src/containers/internal/views/speech-services/form.tsx index 34beb3c..d673177 100644 --- a/src/containers/internal/views/speech-services/form.tsx +++ b/src/containers/internal/views/speech-services/form.tsx @@ -522,7 +522,12 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { return (
- +
{MSG_REQUIRED_FIELDS}
diff --git a/src/containers/internal/views/users/form.tsx b/src/containers/internal/views/users/form.tsx index f49a283..ff83459 100644 --- a/src/containers/internal/views/users/form.tsx +++ b/src/containers/internal/views/users/form.tsx @@ -183,7 +183,12 @@ export const UserForm = ({ user }: UserFormProps) => { return ( <>
- +
{MSG_REQUIRED_FIELDS}
diff --git a/src/styles/_forms.scss b/src/styles/_forms.scss index 07e5c1f..8519aac 100644 --- a/src/styles/_forms.scss +++ b/src/styles/_forms.scss @@ -105,6 +105,10 @@ fieldset { } } + &--blur { + pointer-events: none; + } + label { @include ui-mixins.m(); @include ui-mixins.font-medium();