Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
put back alert error for non validation errors
  • Loading branch information
Emyrk committed Aug 30, 2024
commit ec2f4b240d1056222642e2e3f1495e7839b0f431
19 changes: 19 additions & 0 deletions site/src/pages/TemplatesPage/TemplatesPageView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,22 @@ export const WithError: Story = {
canCreateTemplates: false,
},
};

export const WithValidationError: Story = {
args: {
error: mockApiError({
message: "Something went wrong fetching templates.",
detail:
"This is a more detailed error message that should help you understand what went wrong.",
validations: [
{
field: "search",
detail: "That search query was invalid, why did you do that?",
},
],
}),
templates: undefined,
examples: undefined,
canCreateTemplates: false,
},
};
5 changes: 5 additions & 0 deletions site/src/pages/TemplatesPage/TemplatesPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import { hasError, isApiValidationError } from "api/errors";
import type { Template, TemplateExample } from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { ExternalAvatar } from "components/Avatar/Avatar";
Expand Down Expand Up @@ -228,6 +229,10 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = ({
</PageHeaderSubtitle>
</PageHeader>

{/* Validation errors are shown on the filter, other errors are an alert box. */}
{hasError(error) && !isApiValidationError(error) && (
<ErrorAlert error={error} />
)}
<TemplatesFilter filter={filter} error={error} />

<TableContainer>
Expand Down
Loading