Skip to content

Commit 878f995

Browse files
committed
Move deployment values fetching
1 parent 3c99474 commit 878f995

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { useWorkspaceBuildLogs } from "hooks/useWorkspaceBuildLogs";
3636
import { decreaseDeadline, increaseDeadline } from "api/queries/workspaces";
3737
import { getErrorMessage } from "api/errors";
3838
import { displaySuccess, displayError } from "components/GlobalSnackbar/utils";
39+
import { deploymentConfig } from "api/queries/deployment";
3940

4041
interface WorkspaceReadyPageProps {
4142
workspaceState: StateFrom<typeof workspaceMachine>;
@@ -63,7 +64,6 @@ export const WorkspaceReadyPage = ({
6364
const {
6465
workspace,
6566
template,
66-
deploymentValues,
6767
buildError,
6868
cancellationError,
6969
sshPrefix,
@@ -76,9 +76,13 @@ export const WorkspaceReadyPage = ({
7676
const deadline = getDeadline(workspace);
7777
const canUpdateWorkspace = Boolean(permissions?.updateWorkspace);
7878
const canUpdateTemplate = Boolean(permissions?.updateTemplate);
79-
const canRetryDebugMode =
80-
Boolean(permissions?.viewDeploymentValues) &&
81-
Boolean(deploymentValues?.enable_terraform_debug_mode);
79+
const { data: deploymentValues } = useQuery({
80+
...deploymentConfig(),
81+
enabled: permissions?.viewDeploymentValues,
82+
});
83+
const canRetryDebugMode = Boolean(
84+
deploymentValues?.config.enable_terraform_debug_mode,
85+
);
8286
const favicon = getFaviconByStatus(workspace.latest_build);
8387
const navigate = useNavigate();
8488
const [changeVersionDialogOpen, setChangeVersionDialogOpen] = useState(false);

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ export interface WorkspaceContext {
1111
orgId: string;
1212
username: string;
1313
workspaceName: string;
14-
1514
error?: unknown;
1615
// our server side events instance
1716
eventSource?: EventSource;
1817
workspace?: TypesGen.Workspace;
1918
template?: TypesGen.Template;
2019
permissions?: Permissions;
21-
deploymentValues?: TypesGen.DeploymentValues;
2220
build?: TypesGen.WorkspaceBuild;
2321
// Builds
2422
builds?: TypesGen.WorkspaceBuild[];
@@ -436,7 +434,6 @@ export const workspaceMachine = createMachine(
436434
workspace: (_, event) => event.data.workspace,
437435
template: (_, event) => event.data.template,
438436
permissions: (_, event) => event.data.permissions as Permissions,
439-
deploymentValues: (_, event) => event.data.deploymentValues,
440437
}),
441438
assignError: assign({
442439
error: (_, event) => event.data,
@@ -684,16 +681,9 @@ async function loadInitialWorkspaceData({
684681
checks: permissionsToCheck(workspace, template),
685682
});
686683

687-
const canViewDeploymentValues = Boolean(
688-
(permissions as Permissions)?.viewDeploymentValues,
689-
);
690-
const deploymentValues = canViewDeploymentValues
691-
? (await API.getDeploymentConfig())?.config
692-
: undefined;
693684
return {
694685
workspace,
695686
template,
696687
permissions,
697-
deploymentValues,
698688
};
699689
}

0 commit comments

Comments
 (0)