Skip to content

Commit f542eaa

Browse files
committed
Remove error logic from Resources
1 parent 3e15ee3 commit f542eaa

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

site/src/components/BuildsTable/BuildsTable.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const Language = {
2222

2323
export interface BuildsTableProps {
2424
builds?: TypesGen.WorkspaceBuild[]
25-
className?: string
2625
}
2726

2827
const groupBuildsByDate = (builds?: TypesGen.WorkspaceBuild[]) => {
@@ -48,13 +47,12 @@ const groupBuildsByDate = (builds?: TypesGen.WorkspaceBuild[]) => {
4847

4948
export const BuildsTable: FC<React.PropsWithChildren<BuildsTableProps>> = ({
5049
builds,
51-
className,
5250
}) => {
5351
const isLoading = !builds
5452
const buildsByDate = groupBuildsByDate(builds)
5553

5654
return (
57-
<TableContainer className={className}>
55+
<TableContainer>
5856
<Table data-testid="builds-table" aria-describedby="builds table">
5957
<TableBody>
6058
{isLoading && <TableLoader />}

site/src/components/Resources/Resources.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
WorkspaceResource,
1212
} from "../../api/typesGenerated"
1313
import { Stack } from "../Stack/Stack"
14-
import { AlertBanner } from "components/AlertBanner/AlertBanner"
1514
import { ResourceCard } from "./ResourceCard"
1615

1716
const countAgents = (resource: WorkspaceResource) => {
@@ -20,7 +19,6 @@ const countAgents = (resource: WorkspaceResource) => {
2019

2120
interface ResourcesProps {
2221
resources: WorkspaceResource[]
23-
getResourcesError?: Error | unknown
2422
workspace: Workspace
2523
canUpdateWorkspace: boolean
2624
buildInfo?: BuildInfoResponse | undefined
@@ -30,7 +28,7 @@ interface ResourcesProps {
3028

3129
export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
3230
resources,
33-
getResourcesError,
31+
3432
workspace,
3533
canUpdateWorkspace,
3634
hideSSHButton,
@@ -49,10 +47,6 @@ export const Resources: FC<React.PropsWithChildren<ResourcesProps>> = ({
4947
.sort((a, b) => countAgents(b) - countAgents(a))
5048
const hasHideResources = resources.some((r) => r.hide)
5149

52-
if (getResourcesError) {
53-
return <AlertBanner severity="error" error={getResourcesError} />
54-
}
55-
5650
return (
5751
<Stack direction="column" spacing={0}>
5852
{displayResources.map((resource) => {

site/src/components/Workspace/Workspace.tsx

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { WorkspaceActions } from "../WorkspaceActions/WorkspaceActions"
1616
import { WorkspaceDeletedBanner } from "../WorkspaceDeletedBanner/WorkspaceDeletedBanner"
1717
import { WorkspaceScheduleBanner } from "../WorkspaceScheduleBanner/WorkspaceScheduleBanner"
1818
import { WorkspaceScheduleButton } from "../WorkspaceScheduleButton/WorkspaceScheduleButton"
19-
import { WorkspaceSection } from "../WorkspaceSection/WorkspaceSection"
2019
import { WorkspaceStats } from "../WorkspaceStats/WorkspaceStats"
2120
import { AlertBanner } from "../AlertBanner/AlertBanner"
2221
import { useTranslation } from "react-i18next"
@@ -207,12 +206,16 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
207206
/>
208207
)}
209208

209+
{Boolean(workspaceErrors[WorkspaceErrors.GET_RESOURCES_ERROR]) && (
210+
<AlertBanner
211+
severity="error"
212+
error={workspaceErrors[WorkspaceErrors.GET_RESOURCES_ERROR]}
213+
/>
214+
)}
215+
210216
{typeof resources !== "undefined" && resources.length > 0 && (
211217
<Resources
212218
resources={resources}
213-
getResourcesError={
214-
workspaceErrors[WorkspaceErrors.GET_RESOURCES_ERROR]
215-
}
216219
workspace={workspace}
217220
canUpdateWorkspace={canUpdateWorkspace}
218221
buildInfo={buildInfo}
@@ -221,18 +224,14 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
221224
/>
222225
)}
223226

224-
<WorkspaceSection
225-
contentsProps={{ className: styles.timelineContents }}
226-
>
227-
{workspaceErrors[WorkspaceErrors.GET_BUILDS_ERROR] ? (
228-
<AlertBanner
229-
severity="error"
230-
error={workspaceErrors[WorkspaceErrors.GET_BUILDS_ERROR]}
231-
/>
232-
) : (
233-
<BuildsTable builds={builds} className={styles.timelineTable} />
234-
)}
235-
</WorkspaceSection>
227+
{workspaceErrors[WorkspaceErrors.GET_BUILDS_ERROR] ? (
228+
<AlertBanner
229+
severity="error"
230+
error={workspaceErrors[WorkspaceErrors.GET_BUILDS_ERROR]}
231+
/>
232+
) : (
233+
<BuildsTable builds={builds} />
234+
)}
236235
</Stack>
237236
</Margins>
238237
)
@@ -276,9 +275,5 @@ export const useStyles = makeStyles((theme) => {
276275
timelineContents: {
277276
margin: 0,
278277
},
279-
280-
timelineTable: {
281-
border: 0,
282-
},
283278
}
284279
})

0 commit comments

Comments
 (0)