Skip to content

Commit d487b08

Browse files
committed
fix: Show correct 'no results' message on workspace filters
1 parent a860b86 commit d487b08

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("WorkspacesPage", () => {
2323
render(<WorkspacesPage />)
2424

2525
// Then
26-
await screen.findByText(Language.emptyMessage)
26+
await screen.findByText(Language.emptyCreateWorkspaceMessage)
2727
})
2828

2929
it("renders a filled workspaces page", async () => {

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ const WorkspacesPage: FC = () => {
136136
</Button>
137137
</Link>
138138
</Stack>
139-
<WorkspacesPageView loading={workspacesState.hasTag("loading")} workspaces={workspacesState.context.workspaces} />
139+
<WorkspacesPageView
140+
loading={workspacesState.hasTag("loading")}
141+
workspaces={workspacesState.context.workspaces}
142+
query={workspacesState.context.filter}
143+
/>
140144
</Margins>
141145
)
142146
}

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ import { getDisplayStatus } from "../../util/workspace"
2222
dayjs.extend(relativeTime)
2323

2424
export const Language = {
25-
createButton: "Create workspace",
26-
emptyMessage: "Create your first workspace",
27-
emptyDescription: "Start editing your source code and building your software",
25+
createWorkspaceButton: "Create workspace",
26+
emptyCreateWorkspaceMessage: "Create your first workspace",
27+
emptyCreateWorkspaceDescription: "Start editing your source code and building your software",
28+
emptyResultsMessage: "No results matched your search",
2829
}
2930

3031
export interface WorkspacesPageViewProps {
3132
loading?: boolean
3233
workspaces?: TypesGen.Workspace[]
34+
query?: string
3335
}
3436

35-
export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, workspaces }) => {
37+
export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, workspaces, query }) => {
3638
useStyles()
3739
const theme: Theme = useTheme()
3840

@@ -51,19 +53,31 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
5153
<TableBody>
5254
{!workspaces && loading && <TableLoader />}
5355
{workspaces && workspaces.length === 0 && (
54-
<TableRow>
55-
<TableCell colSpan={999}>
56-
<EmptyState
57-
message={Language.emptyMessage}
58-
description={Language.emptyDescription}
59-
cta={
60-
<Link underline="none" component={RouterLink} to="/workspaces/new">
61-
<Button startIcon={<AddCircleOutline />}>{Language.createButton}</Button>
62-
</Link>
63-
}
64-
/>
65-
</TableCell>
66-
</TableRow>
56+
<>
57+
{query === "owner:me" || query === "" ? (
58+
<TableRow>
59+
<TableCell colSpan={999}>
60+
<EmptyState
61+
message={Language.emptyCreateWorkspaceMessage}
62+
description={Language.emptyCreateWorkspaceDescription}
63+
cta={
64+
<Link underline="none" component={RouterLink} to="/workspaces/new">
65+
<Button startIcon={<AddCircleOutline />}>{Language.createWorkspaceButton}</Button>
66+
</Link>
67+
}
68+
/>
69+
</TableCell>
70+
</TableRow>
71+
) : (
72+
<TableRow>
73+
<TableCell colSpan={999}>
74+
<EmptyState
75+
message={Language.emptyResultsMessage}
76+
/>
77+
</TableCell>
78+
</TableRow>
79+
)}
80+
</>
6781
)}
6882
{workspaces &&
6983
workspaces.map((workspace) => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy