Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ef8514

Browse files
authored
chore: match templates search error with workspace search error (#14479)
* chore: make templates search error the same as workspaces
1 parent0f8251b commit0ef8514

File tree

3 files changed

+62
-37
lines changed

3 files changed

+62
-37
lines changed

‎site/src/pages/TemplatesPage/TemplatesFilter.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import type { FC } from "react";
1616

1717
interfaceTemplatesFilterProps{
1818
filter:ReturnType<typeofuseFilter>;
19+
error?:unknown;
1920
}
2021

21-
exportconstTemplatesFilter:FC<TemplatesFilterProps>=({ filter})=>{
22+
exportconstTemplatesFilter:FC<TemplatesFilterProps>=({
23+
filter,
24+
error,
25+
})=>{
2226
constorganizationMenu=useFilterMenu({
2327
onChange:(option)=>
2428
filter.update({ ...filter.values,organization:option?.value}),
@@ -48,6 +52,7 @@ export const TemplatesFilter: FC<TemplatesFilterProps> = ({ filter }) => {
4852
// learnMoreLink={docs("/templates#template-filtering")}
4953
isLoading={false}
5054
filter={filter}
55+
error={error}
5156
options={
5257
<>
5358
<SelectFilter

‎site/src/pages/TemplatesPage/TemplatesPageView.stories.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,22 @@ export const WithError: Story = {
112112
canCreateTemplates:false,
113113
},
114114
};
115+
116+
exportconstWithValidationError:Story={
117+
args:{
118+
error:mockApiError({
119+
message:"Something went wrong fetching templates.",
120+
detail:
121+
"This is a more detailed error message that should help you understand what went wrong.",
122+
validations:[
123+
{
124+
field:"search",
125+
detail:"That search query was invalid, why did you do that?",
126+
},
127+
],
128+
}),
129+
templates:undefined,
130+
examples:undefined,
131+
canCreateTemplates:false,
132+
},
133+
};

‎site/src/pages/TemplatesPage/TemplatesPageView.tsx

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import TableCell from "@mui/material/TableCell";
99
importTableContainerfrom"@mui/material/TableContainer";
1010
importTableHeadfrom"@mui/material/TableHead";
1111
importTableRowfrom"@mui/material/TableRow";
12+
import{hasError,isApiValidationError}from"api/errors";
1213
importtype{Template,TemplateExample}from"api/typesGenerated";
1314
import{ErrorAlert}from"components/Alert/ErrorAlert";
1415
import{ExternalAvatar}from"components/Avatar/Avatar";
@@ -228,45 +229,45 @@ export const TemplatesPageView: FC<TemplatesPageViewProps> = ({
228229
</PageHeaderSubtitle>
229230
</PageHeader>
230231

231-
<TemplatesFilterfilter={filter}/>
232-
233-
{error ?(
232+
<TemplatesFilterfilter={filter}error={error}/>
233+
{/* Validation errors are shown on the filter, other errors are an alert box. */}
234+
{hasError(error)&&!isApiValidationError(error)&&(
234235
<ErrorAlerterror={error}/>
235-
) :(
236-
<TableContainer>
237-
<Table>
238-
<TableHead>
239-
<TableRow>
240-
<TableCellwidth="35%">{Language.nameLabel}</TableCell>
241-
<TableCellwidth="15%">
242-
{showOrganizations ?"Organization" :Language.usedByLabel}
243-
</TableCell>
244-
<TableCellwidth="10%">{Language.buildTimeLabel}</TableCell>
245-
<TableCellwidth="15%">{Language.lastUpdatedLabel}</TableCell>
246-
<TableCellwidth="1%"/>
247-
</TableRow>
248-
</TableHead>
249-
<TableBody>
250-
{isLoading&&<TableLoader/>}
236+
)}
251237

252-
{isEmpty ?(
253-
<EmptyTemplates
254-
canCreateTemplates={canCreateTemplates}
255-
examples={examples??[]}
238+
<TableContainer>
239+
<Table>
240+
<TableHead>
241+
<TableRow>
242+
<TableCellwidth="35%">{Language.nameLabel}</TableCell>
243+
<TableCellwidth="15%">
244+
{showOrganizations ?"Organization" :Language.usedByLabel}
245+
</TableCell>
246+
<TableCellwidth="10%">{Language.buildTimeLabel}</TableCell>
247+
<TableCellwidth="15%">{Language.lastUpdatedLabel}</TableCell>
248+
<TableCellwidth="1%"/>
249+
</TableRow>
250+
</TableHead>
251+
<TableBody>
252+
{isLoading&&<TableLoader/>}
253+
254+
{isEmpty ?(
255+
<EmptyTemplates
256+
canCreateTemplates={canCreateTemplates}
257+
examples={examples??[]}
258+
/>
259+
) :(
260+
templates?.map((template)=>(
261+
<TemplateRow
262+
key={template.id}
263+
showOrganizations={showOrganizations}
264+
template={template}
256265
/>
257-
) :(
258-
templates?.map((template)=>(
259-
<TemplateRow
260-
key={template.id}
261-
showOrganizations={showOrganizations}
262-
template={template}
263-
/>
264-
))
265-
)}
266-
</TableBody>
267-
</Table>
268-
</TableContainer>
269-
)}
266+
))
267+
)}
268+
</TableBody>
269+
</Table>
270+
</TableContainer>
270271
</Margins>
271272
);
272273
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp