Skip to content

Commit

Permalink
feat(web): refetch discovery after bridge url update (#6005)
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge authored Jul 7, 2024
1 parent bc0130e commit 688eee3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export class UpdateEnvironment {
updatePayload[`dns.inboundParseDomain`] = command.dns.inboundParseDomain;
}

if ((await this.shouldUpdateBridgeConfiguration(command)) && command.bridge) {
if ((await this.shouldUpdateBridgeConfiguration()) && command.bridge) {
updatePayload['echo.url'] = command.bridge?.url || '';
updatePayload['bridge.url'] = command.bridge?.url || '';
}

return await this.environmentRepository.update(
Expand All @@ -36,7 +37,7 @@ export class UpdateEnvironment {
{ $set: updatePayload }
);
}
async shouldUpdateBridgeConfiguration(command: UpdateEnvironmentCommand): Promise<boolean> {
async shouldUpdateBridgeConfiguration(): Promise<boolean> {
return process.env.NOVU_ENTERPRISE === 'true' || process.env.CI_EE_TEST === 'true';
}
}
11 changes: 9 additions & 2 deletions apps/web/src/studio/hooks/useBridgeAPI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useEffect, useMemo } from 'react';
import { useMutation, useQuery } from '@tanstack/react-query';
import {
buildBridgeHTTPClient,
Expand All @@ -18,9 +18,10 @@ function useBridgeAPI() {
const BRIDGE_STATUS_REFRESH_INTERVAL_IN_MS = 5 * 1000;

export const useDiscover = (options?: any) => {
const { bridgeURL, setBridgeURL } = useStudioState();
const api = useBridgeAPI();

return useQuery(
const discoverQuery = useQuery(
['bridge-workflows'],
async () => {
return api.discover();
Expand All @@ -30,6 +31,12 @@ export const useDiscover = (options?: any) => {
...(options || {}),
}
);

useEffect(() => {
discoverQuery.refetch();
}, [bridgeURL, setBridgeURL, discoverQuery]);

return discoverQuery;
};

export const useHealthCheck = (options?: any) => {
Expand Down

0 comments on commit 688eee3

Please sign in to comment.