diff --git a/apps/web/src/components/layout/components/v2/BridgeMenuItems.tsx b/apps/web/src/components/layout/components/v2/BridgeMenuItems.tsx index 8c5bae765d5..eb06bdce9ed 100644 --- a/apps/web/src/components/layout/components/v2/BridgeMenuItems.tsx +++ b/apps/web/src/components/layout/components/v2/BridgeMenuItems.tsx @@ -1,11 +1,17 @@ +import { useStudioState } from '../../../../studio/StudioStateProvider'; +import { When } from '../../../utils/When'; import { BridgeUpdateModalTrigger } from './BridgeUpdateModalTrigger'; import { SyncInfoModalTrigger } from './SyncInfoModalTrigger'; export function BridgeMenuItems() { + const { isLocalStudio } = useStudioState(); + return ( <> - + + + ); } diff --git a/apps/web/src/components/layout/components/v2/BridgeUpdateModal.tsx b/apps/web/src/components/layout/components/v2/BridgeUpdateModal.tsx index e43f11c247b..25cadfa9ca4 100644 --- a/apps/web/src/components/layout/components/v2/BridgeUpdateModal.tsx +++ b/apps/web/src/components/layout/components/v2/BridgeUpdateModal.tsx @@ -20,7 +20,7 @@ export type BridgeUpdateModalProps = { export const BridgeUpdateModal: FC = ({ isOpen, toggleOpen }) => { const segment = useSegment(); - const { local, bridgeURL, setBridgeURL } = useStudioState(); + const { isLocalStudio, bridgeURL, setBridgeURL } = useStudioState(); const [urlError, setUrlError] = useState(''); const [url, setUrl] = useState(bridgeURL); const [isUpdating, setIsUpdating] = useState(false); @@ -60,7 +60,7 @@ export const BridgeUpdateModal: FC = ({ isOpen, toggleOp const storeInProperLocation = async (newUrl: string) => { setBridgeURL(newUrl); - if (!local) { + if (!isLocalStudio) { await updateBridgeUrl({ url: newUrl }, environment?._id ?? ''); } }; diff --git a/apps/web/src/components/layout/components/v2/BridgeUpdateModalTrigger.tsx b/apps/web/src/components/layout/components/v2/BridgeUpdateModalTrigger.tsx index 516a49c984b..be2377a91d2 100644 --- a/apps/web/src/components/layout/components/v2/BridgeUpdateModalTrigger.tsx +++ b/apps/web/src/components/layout/components/v2/BridgeUpdateModalTrigger.tsx @@ -1,6 +1,6 @@ import { FC, useState } from 'react'; import { Tooltip } from '@novu/design-system'; -import { Text } from '@novu/novui'; +import { Text, Button } from '@novu/novui'; import { css } from '@novu/novui/css'; import { IconEdit, IconLink, IconLinkOff } from '@novu/novui/icons'; import { HStack } from '@novu/novui/jsx'; @@ -32,16 +32,9 @@ function BridgeUpdateModalTriggerControl({ onClick }: { onClick: () => void }) { const { status, bridgeURL } = useBridgeConnectionStatus(); const trigger = isHovered ? ( - + ) : ( ); diff --git a/apps/web/src/studio/LocalStudioAuthenticator.tsx b/apps/web/src/studio/LocalStudioAuthenticator.tsx index 8e0069f060c..c26bd85623f 100644 --- a/apps/web/src/studio/LocalStudioAuthenticator.tsx +++ b/apps/web/src/studio/LocalStudioAuthenticator.tsx @@ -111,7 +111,7 @@ export function LocalStudioAuthenticator() { const tunnelBridgeURL = buildBridgeURL(tunnelOrigin, tunnelPath); const state: StudioState = { - local: true, + isLocalStudio: true, devSecretKey: apiKey, testUser: { id: currentUser._id, diff --git a/apps/web/src/studio/StudioPageLayout.tsx b/apps/web/src/studio/StudioPageLayout.tsx index d0c3060404a..3a141ec3e3c 100644 --- a/apps/web/src/studio/StudioPageLayout.tsx +++ b/apps/web/src/studio/StudioPageLayout.tsx @@ -12,7 +12,7 @@ export function StudioPageLayout() { return ; } - if (state?.local) { + if (state?.isLocalStudio) { return ; } diff --git a/apps/web/src/studio/StudioStateProvider.tsx b/apps/web/src/studio/StudioStateProvider.tsx index a7995486040..63f830c898e 100644 --- a/apps/web/src/studio/StudioStateProvider.tsx +++ b/apps/web/src/studio/StudioStateProvider.tsx @@ -11,7 +11,7 @@ type BridgeURLGetterSetter = { bridgeURL: string; setBridgeURL: (url: string) => const StudioStateContext = React.createContext<(StudioState & BridgeURLGetterSetter) | undefined>(undefined); function computeBridgeURL(state: StudioState) { - return state.local ? state.localBridgeURL || state.tunnelBridgeURL : state.storedBridgeURL; + return state.isLocalStudio ? state.localBridgeURL || state.tunnelBridgeURL : state.storedBridgeURL; } function convertToTestUser(currentUser?: IUserEntity) { @@ -36,7 +36,7 @@ export const StudioStateProvider = ({ children }: { children: React.ReactNode }) } return { - local: false, + isLocalStudio: false, storedBridgeURL: environment?.echo?.url || '', testUser: convertToTestUser(currentUser), organizationName: currentOrganization?.name || '', @@ -46,15 +46,15 @@ export const StudioStateProvider = ({ children }: { children: React.ReactNode }) const [bridgeURL, setBridgeURL] = useState(computeBridgeURL(state)); useEffect(() => { - if (!state.local) { + if (!state.isLocalStudio) { setState({ - local: false, + isLocalStudio: false, storedBridgeURL: environment?.echo?.url || '', testUser: convertToTestUser(currentUser), organizationName: currentOrganization?.name || '', }); } - }, [environment, state?.local, currentUser, currentOrganization]); + }, [environment, state?.isLocalStudio, currentUser, currentOrganization]); useEffect(() => { setBridgeURL(computeBridgeURL(state)); diff --git a/apps/web/src/studio/components/workflows/step-editor/WorkflowTestStepButton.tsx b/apps/web/src/studio/components/workflows/step-editor/WorkflowTestStepButton.tsx index 87cfba2d763..1a363b3ffd3 100644 --- a/apps/web/src/studio/components/workflows/step-editor/WorkflowTestStepButton.tsx +++ b/apps/web/src/studio/components/workflows/step-editor/WorkflowTestStepButton.tsx @@ -21,7 +21,7 @@ export const WorkflowTestStepButton = ({ stepType: ChannelTypeEnum; }) => { const segment = useSegment(); - const { local, testUser } = useStudioState(); + const { isLocalStudio: local, testUser } = useStudioState(); const { mutateAsync: testSendEmailEvent, isLoading: isTestingEmail } = useMutation(testSendEmailMessage); const handleTestClick = async () => { diff --git a/apps/web/src/studio/components/workflows/test-workflow/WorkflowsTestPage.tsx b/apps/web/src/studio/components/workflows/test-workflow/WorkflowsTestPage.tsx index a7cfb90b1a5..ee722b7d23f 100644 --- a/apps/web/src/studio/components/workflows/test-workflow/WorkflowsTestPage.tsx +++ b/apps/web/src/studio/components/workflows/test-workflow/WorkflowsTestPage.tsx @@ -22,7 +22,7 @@ import { useApiKeys } from '../../../../hooks/useNovuAPI'; export const WorkflowsTestPage = () => { const segment = useSegment(); - const { local, testUser } = useStudioState() || {}; + const { isLocalStudio: local, testUser } = useStudioState() || {}; const { templateId = '' } = useParams<{ templateId: string }>(); const [payload, setPayload] = useState>({}); const [to, setTo] = useState({ diff --git a/apps/web/src/studio/hooks/useBridgeAPI.ts b/apps/web/src/studio/hooks/useBridgeAPI.ts index 410745705a7..6f002c2e84e 100644 --- a/apps/web/src/studio/hooks/useBridgeAPI.ts +++ b/apps/web/src/studio/hooks/useBridgeAPI.ts @@ -89,7 +89,7 @@ export const useWorkflowTrigger = () => { const { mutateAsync, ...rest } = useMutation(api.trigger); - const bridgeUrl = state.local ? state.tunnelBridgeURL : state.storedBridgeURL; + const bridgeUrl = state.isLocalStudio ? state.tunnelBridgeURL : state.storedBridgeURL; async function trigger(params: TriggerParams): Promise<{ data: { transactionId: string } }> { return mutateAsync({ ...params, bridgeUrl }); diff --git a/apps/web/src/studio/hooks/useBridgeURL.ts b/apps/web/src/studio/hooks/useBridgeURL.ts index 8fa5a770544..0d1364d9edb 100644 --- a/apps/web/src/studio/hooks/useBridgeURL.ts +++ b/apps/web/src/studio/hooks/useBridgeURL.ts @@ -5,7 +5,7 @@ export function useBridgeURL(tunnel = false) { let bridgeURL; - if (studioState.local) { + if (studioState.isLocalStudio) { /* * Local studio mode. * Prefer local host for bridge discovery as it's faster diff --git a/apps/web/src/studio/types.ts b/apps/web/src/studio/types.ts index 0afb9b8c920..a39e6c10d67 100644 --- a/apps/web/src/studio/types.ts +++ b/apps/web/src/studio/types.ts @@ -32,12 +32,12 @@ type BaseStudioState = { }; type CloudStudioState = BaseStudioState & { - local: false; + isLocalStudio: false; storedBridgeURL: string; }; type LocalStudioState = BaseStudioState & { - local: true; + isLocalStudio: true; localBridgeURL: string; tunnelBridgeURL: string; };