Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44d0d6d

Browse files
committed
fix: Show correct 'no results' message on workspace filters
1 parent 2b0662b commit 44d0d6d

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
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/WorkspacesPageView.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ import { getDisplayStatus } from "../../util/workspace"
4040
dayjs.extend(relativeTime)
4141

4242
export const Language = {
43-
createButton: "Create workspace",
44-
emptyMessage: "Create your first workspace",
45-
emptyDescription: "Start editing your source code and building your software",
46-
filterName: "Filters",
4743
createWorkspaceButton: "Create workspace",
44+
emptyCreateWorkspaceMessage: "Create your first workspace",
45+
emptyCreateWorkspaceDescription: "Start editing your source code and building your software",
46+
emptyResultsMessage: "No results matched your search",
47+
filterName: "Filters",
4848
yourWorkspacesButton: "Your workspaces",
4949
allWorkspacesButton: "All workspaces",
5050
workspaceTooltipTitle: "What is workspace?",
@@ -200,19 +200,31 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
200200
<TableBody>
201201
{!workspaces && loading && <TableLoader />}
202202
{workspaces && workspaces.length === 0 && (
203-
<TableRow>
204-
<TableCell colSpan={999}>
205-
<EmptyState
206-
message={Language.emptyMessage}
207-
description={Language.emptyDescription}
208-
cta={
209-
<Link underline="none" component={RouterLink} to="/workspaces/new">
210-
<Button startIcon={<AddCircleOutline />}>{Language.createButton}</Button>
211-
</Link>
212-
}
213-
/>
214-
</TableCell>
215-
</TableRow>
203+
<>
204+
{filter === "owner:me" || filter === "" ? (
205+
<TableRow>
206+
<TableCell colSpan={999}>
207+
<EmptyState
208+
message={Language.emptyCreateWorkspaceMessage}
209+
description={Language.emptyCreateWorkspaceDescription}
210+
cta={
211+
<Link underline="none" component={RouterLink} to="/workspaces/new">
212+
<Button startIcon={<AddCircleOutline />}>{Language.createWorkspaceButton}</Button>
213+
</Link>
214+
}
215+
/>
216+
</TableCell>
217+
</TableRow>
218+
) : (
219+
<TableRow>
220+
<TableCell colSpan={999}>
221+
<EmptyState
222+
message={Language.emptyResultsMessage}
223+
/>
224+
</TableCell>
225+
</TableRow>
226+
)}
227+
</>
216228
)}
217229
{workspaces &&
218230
workspaces.map((workspace) => {

0 commit comments

Comments
 (0)