Skip to content

Commit 68c7b3f

Browse files
committed
feat(site): display builds logs by default
1 parent f3edc42 commit 68c7b3f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

site/src/hooks/useWorkspaceBuildLogs.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { ProvisionerJobLog } from "api/typesGenerated";
33
import { displayError } from "components/GlobalSnackbar/utils";
44
import { useState, useEffect } from "react";
55

6-
// buildId is optional because sometimes the build is not loaded yet
7-
export const useWorkspaceBuildLogs = (buildId?: string) => {
6+
export const useWorkspaceBuildLogs = (
7+
// buildId is optional because sometimes the build is not loaded yet
8+
buildId: string | undefined,
9+
enabled: boolean = true,
10+
) => {
811
const [logs, setLogs] = useState<ProvisionerJobLog[]>();
912
useEffect(() => {
10-
if (!buildId) {
13+
if (!buildId || !enabled) {
1114
return;
1215
}
1316

site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Helmet } from "react-helmet-async";
55
import { useNavigate } from "react-router-dom";
66
import { Workspace } from "./Workspace";
77
import { pageTitle } from "utils/page";
8-
import { hasJobError } from "utils/workspace";
98
import { UpdateBuildParametersDialog } from "./UpdateBuildParametersDialog";
109
import { ChangeVersionDialog } from "./ChangeVersionDialog";
1110
import { useMutation, useQuery, useQueryClient } from "react-query";
@@ -67,12 +66,11 @@ export const WorkspaceReadyPage = ({
6766
});
6867

6968
// Build logs
70-
const buildLogs = useWorkspaceBuildLogs(workspace.latest_build.id);
71-
const shouldDisplayBuildLogs =
72-
hasJobError(workspace) ||
73-
["canceling", "deleting", "pending", "starting", "stopping"].includes(
74-
workspace.latest_build.status,
75-
);
69+
const shouldDisplayBuildLogs = workspace.latest_build.status !== "running";
70+
const buildLogs = useWorkspaceBuildLogs(
71+
workspace.latest_build.id,
72+
shouldDisplayBuildLogs,
73+
);
7674

7775
// Restart
7876
const [confirmingRestart, setConfirmingRestart] = useState<{

0 commit comments

Comments
 (0)