Skip to content

Commit c8d3174

Browse files
NicolappsConvex, Inc.
authored andcommitted
Make the history link go to the real dashboard for cloud deployments (#36346)
GitOrigin-RevId: 487a5af5e90a5c52e2d5c8ecfd8c8f1d99b85b9d
1 parent 64399bd commit c8d3174

File tree

3 files changed

+54
-45
lines changed

3 files changed

+54
-45
lines changed

npm-packages/dashboard-common/src/layouts/DeploymentDashboardLayout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Sidebar } from "@common/elements/Sidebar";
2020
import { FunctionRunnerWrapper } from "@common/features/functionRunner/components/FunctionRunnerWrapper";
2121
import { FunctionsProvider } from "@common/lib/functions/FunctionsProvider";
2222
import { useIsGlobalRunnerShown } from "@common/features/functionRunner/lib/functionRunner";
23+
import { useIsCloudDeploymentInSelfHostedDashboard } from "@common/lib/useIsCloudDeploymentInSelfHostedDashboard";
2324

2425
type LayoutProps = {
2526
children: JSX.Element;
@@ -36,6 +37,8 @@ export function DeploymentDashboardLayout({
3637
const [isRunnerExpanded, setIsRunnerExpanded] = useState(false);
3738
const isGlobalRunnerShown = useIsGlobalRunnerShown();
3839
const { deploymentsURI: uriPrefix } = useContext(DeploymentInfoContext);
40+
const { isCloudDeploymentInSelfHostedDashboard, deploymentName } =
41+
useIsCloudDeploymentInSelfHostedDashboard();
3942

4043
const exploreDeploymentPages = [
4144
{
@@ -90,7 +93,10 @@ export function DeploymentDashboardLayout({
9093
key: "history",
9194
label: "History",
9295
Icon: CounterClockwiseClockIcon,
93-
href: `${uriPrefix}/history`,
96+
href: isCloudDeploymentInSelfHostedDashboard
97+
? `https://dashboard.convex.dev/d/${deploymentName}/history`
98+
: `${uriPrefix}/history`,
99+
target: isCloudDeploymentInSelfHostedDashboard ? "_blank" : undefined,
94100
disabled: !auditLogsEnabled,
95101
tooltip: auditLogsEnabled
96102
? undefined

npm-packages/dashboard-common/src/layouts/SettingsSidebar.tsx

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DeploymentPageTitle } from "@common/elements/DeploymentPageTitle";
55
import { DeploymentInfoContext } from "@common/lib/deploymentContext";
66
import { SidebarLink } from "@common/elements/Sidebar";
77
import { useNents } from "@common/lib/useNents";
8+
import { useIsCloudDeploymentInSelfHostedDashboard } from "@common/lib/useIsCloudDeploymentInSelfHostedDashboard";
89

910
export const DEPLOYMENT_SETTINGS_PAGES_AND_NAMES = {
1011
"url-and-deploy-key": "URL & Deploy Key",
@@ -182,47 +183,3 @@ function useAllowedPages() {
182183

183184
return pages;
184185
}
185-
186-
/**
187-
* Determines if the deployment URL is a default cloud deployment URL.
188-
*
189-
* This gives a false negative if the deployment is a cloud deployment with a custom domain.
190-
*/
191-
function useIsCloudDeploymentInSelfHostedDashboard():
192-
| {
193-
isCloudDeploymentInSelfHostedDashboard: false;
194-
deploymentName: undefined;
195-
}
196-
| {
197-
isCloudDeploymentInSelfHostedDashboard: true;
198-
deploymentName: string;
199-
} {
200-
const context = useContext(DeploymentInfoContext);
201-
202-
if (
203-
!context.isSelfHosted ||
204-
!("deploymentUrl" in context) ||
205-
!context.deploymentUrl
206-
) {
207-
return {
208-
isCloudDeploymentInSelfHostedDashboard: false,
209-
deploymentName: undefined,
210-
};
211-
}
212-
213-
const match = context.deploymentUrl.match(
214-
/^https:\/\/([a-z]+-[a-z]+-[0-9]{3})\.convex\.cloud$/,
215-
);
216-
217-
if (!match) {
218-
return {
219-
isCloudDeploymentInSelfHostedDashboard: false,
220-
deploymentName: undefined,
221-
};
222-
}
223-
224-
return {
225-
isCloudDeploymentInSelfHostedDashboard: true,
226-
deploymentName: match[1],
227-
};
228-
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useContext } from "react";
2+
import { DeploymentInfoContext } from "./deploymentContext";
3+
4+
/**
5+
* Determines if the deployment URL is a default cloud deployment URL.
6+
*
7+
* This gives a false negative if the deployment is a cloud deployment with a custom domain.
8+
*/
9+
export function useIsCloudDeploymentInSelfHostedDashboard():
10+
| {
11+
isCloudDeploymentInSelfHostedDashboard: false;
12+
deploymentName: undefined;
13+
}
14+
| {
15+
isCloudDeploymentInSelfHostedDashboard: true;
16+
deploymentName: string;
17+
} {
18+
const context = useContext(DeploymentInfoContext);
19+
20+
if (
21+
!context.isSelfHosted ||
22+
!("deploymentUrl" in context) ||
23+
!context.deploymentUrl
24+
) {
25+
return {
26+
isCloudDeploymentInSelfHostedDashboard: false,
27+
deploymentName: undefined,
28+
};
29+
}
30+
31+
const match = context.deploymentUrl.match(
32+
/^https:\/\/([a-z]+-[a-z]+-[0-9]{3})\.convex\.cloud$/,
33+
);
34+
35+
if (!match) {
36+
return {
37+
isCloudDeploymentInSelfHostedDashboard: false,
38+
deploymentName: undefined,
39+
};
40+
}
41+
42+
return {
43+
isCloudDeploymentInSelfHostedDashboard: true,
44+
deploymentName: match[1],
45+
};
46+
}

0 commit comments

Comments
 (0)