MCPcopy Index your code
hub / github.com/coder/coder / Workspace

Function Workspace

site/src/pages/WorkspacePage/Workspace.tsx:48–256  ·  view source on GitHub ↗
({
	workspace,
	isUpdating,
	isRestarting,
	template,
	buildLogs,
	latestVersion,
	permissions,
	timings,
	handleStart,
	handleStop,
	handleRestart,
	handleUpdate,
	handleCancel,
	handleDormantActivate,
	handleToggleFavorite,
	handleRetry,
	handleDebug,
})

Source from the content-addressed store, hash-verified

46 * Workspace is the top-level component for viewing an individual workspace
47 */
48export const Workspace: FC<WorkspaceProps> = ({
49 workspace,
50 isUpdating,
51 isRestarting,
52 template,
53 buildLogs,
54 latestVersion,
55 permissions,
56 timings,
57 handleStart,
58 handleStop,
59 handleRestart,
60 handleUpdate,
61 handleCancel,
62 handleDormantActivate,
63 handleToggleFavorite,
64 handleRetry,
65 handleDebug,
66}) => {
67 const getLink = useLinks();
68 const createWorkspaceLink = `${getLink(
69 linkToTemplate(workspace.organization_name, workspace.template_name),
70 )}/workspace`;
71 const templateName =
72 workspace.template_display_name || workspace.template_name;
73
74 const transitionStats =
75 template !== undefined
76 ? getActiveTransitionStats(template, workspace)
77 : undefined;
78
79 const sidebarOption = useSearchParamsKey({ key: "sidebar" });
80 const setSidebarOption = (newOption: string) => {
81 if (sidebarOption.value === newOption) {
82 sidebarOption.deleteValue();
83 } else {
84 sidebarOption.setValue(newOption);
85 }
86 };
87
88 const resources = [...workspace.latest_build.resources].sort(
89 (a, b) => countAgents(b) - countAgents(a),
90 );
91 const resourcesNav = useResourcesNav(resources);
92 const selectedResource = resources.find(
93 (r) => resourceOptionValue(r) === resourcesNav.value,
94 );
95
96 const workspaceRunning = workspace.latest_build.status === "running";
97 const workspacePending = workspace.latest_build.status === "pending";
98 const haveBuildLogs = (buildLogs ?? []).length > 0;
99 const shouldShowBuildLogs = haveBuildLogs && !workspaceRunning;
100 const provisionersHealthy =
101 (workspace.latest_build.matched_provisioners?.available ?? 1) > 0;
102 const shouldShowProvisionerAlert =
103 workspacePending && !haveBuildLogs && !provisionersHealthy && !isRestarting;
104
105 return (

Callers

nothing calls this directly

Calls 10

useLinksFunction · 0.90
linkToTemplateFunction · 0.90
getActiveTransitionStatsFunction · 0.90
useSearchParamsKeyFunction · 0.90
useResourcesNavFunction · 0.90
resourceOptionValueFunction · 0.90
setSidebarOptionFunction · 0.85
findMethod · 0.80
filterMethod · 0.80
countAgentsFunction · 0.70

Tested by

no test coverage detected