diff --git a/web/src/components/DashboardWrapper/DashboardWrapper.tsx b/web/src/components/DashboardWrapper/DashboardWrapper.tsx
index 9703bc91e5..9da66617d3 100644
--- a/web/src/components/DashboardWrapper/DashboardWrapper.tsx
+++ b/web/src/components/DashboardWrapper/DashboardWrapper.tsx
@@ -1,6 +1,7 @@
import {useMemo} from 'react';
import {useNavigate} from 'react-router-dom';
import DashboardProvider from 'providers/Dashboard';
+import {getServerBaseUrl} from 'utils/Common';
interface IProps {
children: React.ReactNode;
@@ -8,7 +9,7 @@ interface IProps {
const DashboardWrapper = ({children}: IProps) => {
const navigate = useNavigate();
- const dashboardProviderValue = useMemo(() => ({baseUrl: '', navigate}), [navigate]);
+ const dashboardProviderValue = useMemo(() => ({baseUrl: '', dashboardUrl: getServerBaseUrl(), navigate}), [navigate]);
return {children};
};
diff --git a/web/src/components/RunDetailAutomateMethods/methods/DeepLink/hooks/useDeepLink.ts b/web/src/components/RunDetailAutomateMethods/methods/DeepLink/hooks/useDeepLink.ts
index 684a7a969b..9034cbd0fb 100644
--- a/web/src/components/RunDetailAutomateMethods/methods/DeepLink/hooks/useDeepLink.ts
+++ b/web/src/components/RunDetailAutomateMethods/methods/DeepLink/hooks/useDeepLink.ts
@@ -1,13 +1,18 @@
import {useCallback, useState} from 'react';
import DeepLinkService, {TDeepLinkConfig} from 'services/DeepLink.service';
+import {useDashboard} from 'providers/Dashboard/Dashboard.provider';
const useDeepLink = () => {
const [deepLink, setDeepLink] = useState('');
+ const {dashboardUrl} = useDashboard();
- const onGetDeepLink = useCallback((config: TDeepLinkConfig) => {
- const link = DeepLinkService.getLink(config);
- setDeepLink(link);
- }, []);
+ const onGetDeepLink = useCallback(
+ (config: TDeepLinkConfig) => {
+ const link = DeepLinkService.getLink({...config, baseUrl: dashboardUrl});
+ setDeepLink(link);
+ },
+ [dashboardUrl]
+ );
return {deepLink, onGetDeepLink};
};
diff --git a/web/src/providers/Dashboard/Dashboard.provider.tsx b/web/src/providers/Dashboard/Dashboard.provider.tsx
index 6f349a314a..0423bbf16c 100644
--- a/web/src/providers/Dashboard/Dashboard.provider.tsx
+++ b/web/src/providers/Dashboard/Dashboard.provider.tsx
@@ -4,11 +4,13 @@ import {NavigateFunction} from 'react-router-dom';
interface IContext {
baseUrl: string;
+ dashboardUrl: string;
navigate: NavigateFunction;
}
export const Context = createContext({
baseUrl: '',
+ dashboardUrl: '',
navigate: noop,
});
diff --git a/web/src/services/DeepLink.service.ts b/web/src/services/DeepLink.service.ts
index 7d82c26316..02626a0043 100644
--- a/web/src/services/DeepLink.service.ts
+++ b/web/src/services/DeepLink.service.ts
@@ -1,17 +1,23 @@
import {TVariableSetValue} from 'models/VariableSet.model';
import Test from 'models/Test.model';
-import {getServerBaseUrl} from '../utils/Common';
+import {getServerBaseUrl} from 'utils/Common';
export type TDeepLinkConfig = {
variables: TVariableSetValue[];
useVariableSetId: boolean;
test: Test;
variableSetId?: string;
+ baseUrl?: string;
};
const DeepLinkService = () => ({
- getLink({variables, useVariableSetId, test: {id: testId}, variableSetId}: TDeepLinkConfig) {
- const baseUrl = getServerBaseUrl();
+ getLink({
+ baseUrl = getServerBaseUrl(),
+ variables,
+ useVariableSetId,
+ test: {id: testId},
+ variableSetId,
+ }: TDeepLinkConfig) {
const filteredVariables = variables.filter(variable => !!variable && variable.key);
const stringVariables = encodeURI(JSON.stringify(filteredVariables));