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

Commit87364c4

Browse files
hugodutkaaslilac
authored andcommitted
chore: reduce prominence of Scratch starter and emphasize Docker in UI (#16665)
1 parentc522c7b commit87364c4

File tree

6 files changed

+20
-88
lines changed

6 files changed

+20
-88
lines changed

‎site/src/pages/CreateTemplateGalleryPage/CreateTemplateGalleryPage.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import{server}from"testHelpers/server";
1111
importCreateTemplateGalleryPagefrom"./CreateTemplateGalleryPage";
1212

13-
test("does not display the scratch template",async()=>{
13+
test("displays the scratch template",async()=>{
1414
server.use(
1515
http.get("api/v2/templates/examples",()=>{
1616
returnHttpResponse.json([
@@ -49,5 +49,5 @@ test("does not display the scratch template", async () => {
4949

5050
awaitscreen.findByText(MockTemplateExample.name);
5151
screen.getByText(MockTemplateExample2.name);
52-
expect(screen.queryByText("Scratch")).not.toBeInTheDocument();
52+
expect(screen.queryByText("Scratch")).toBeInTheDocument();
5353
});

‎site/src/pages/CreateTemplateGalleryPage/CreateTemplateGalleryPage.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import{templateExamples}from"api/queries/templates";
2-
importtype{TemplateExample}from"api/typesGenerated";
32
importtype{FC}from"react";
43
import{Helmet}from"react-helmet-async";
54
import{useQuery}from"react-query";
@@ -10,8 +9,7 @@ import { CreateTemplateGalleryPageView } from "./CreateTemplateGalleryPageView";
109
constCreateTemplatesGalleryPage:FC=()=>{
1110
consttemplateExamplesQuery=useQuery(templateExamples());
1211
conststarterTemplatesByTag=templateExamplesQuery.data
13-
?// Currently, the scratch template should not be displayed on the starter templates page.
14-
getTemplatesByTag(removeScratchExample(templateExamplesQuery.data))
12+
?getTemplatesByTag(templateExamplesQuery.data)
1513
:undefined;
1614

1715
return(
@@ -27,8 +25,4 @@ const CreateTemplatesGalleryPage: FC = () => {
2725
);
2826
};
2927

30-
constremoveScratchExample=(data:TemplateExample[])=>{
31-
returndata.filter((example)=>example.id!=="scratch");
32-
};
33-
3428
exportdefaultCreateTemplatesGalleryPage;

‎site/src/pages/CreateTemplateGalleryPage/CreateTemplateGalleryPageView.tsx‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,6 @@ export const CreateTemplateGalleryPageView: FC<
4141
height:"max-content",
4242
}}
4343
>
44-
<Cardvariant="outlined"css={{width:320,borderRadius:6}}>
45-
<CardActionArea
46-
component={RouterLink}
47-
to="/templates/new?exampleId=scratch"
48-
sx={{height:115,padding:1}}
49-
>
50-
<CardContent>
51-
<Stack
52-
direction="row"
53-
spacing={3}
54-
css={{alignItems:"center"}}
55-
>
56-
<divcss={styles.icon}>
57-
<ExternalImage
58-
src="/emojis/1f4c4.png"
59-
css={{width:"100%",height:"100%"}}
60-
/>
61-
</div>
62-
<div>
63-
<h4css={styles.cardTitle}>Scratch Template</h4>
64-
<spancss={styles.cardDescription}>
65-
Create a minimal starter template that you can customize
66-
</span>
67-
</div>
68-
</Stack>
69-
</CardContent>
70-
</CardActionArea>
71-
</Card>
7244
<Cardvariant="outlined"css={{width:320,borderRadius:6}}>
7345
<CardActionArea
7446
component={RouterLink}

‎site/src/pages/CreateTemplateGalleryPage/StarterTemplates.tsx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importtype{Interpolation,Theme}from"@emotion/react";
2+
importtype{TemplateExample}from"api/typesGenerated";
23
import{Stack}from"components/Stack/Stack";
34
import{TemplateExampleCard}from"modules/templates/TemplateExampleCard/TemplateExampleCard";
45
importtype{FC}from"react";
@@ -21,6 +22,21 @@ const selectTags = (starterTemplatesByTag: StarterTemplatesByTag) => {
2122
:undefined;
2223
};
2324

25+
constsortVisibleTemplates=(templates:TemplateExample[])=>{
26+
// The docker template should be the first template in the list,
27+
// as it's the easiest way to get started with Coder.
28+
constdockerTemplateId="docker";
29+
returntemplates.sort((a,b)=>{
30+
if(a.id===dockerTemplateId){
31+
return-1;
32+
}
33+
if(b.id===dockerTemplateId){
34+
return1;
35+
}
36+
returna.name.localeCompare(b.name);
37+
});
38+
};
39+
2440
exportinterfaceStarterTemplatesProps{
2541
starterTemplatesByTag?:StarterTemplatesByTag;
2642
}
@@ -34,7 +50,7 @@ export const StarterTemplates: FC<StarterTemplatesProps> = ({
3450
:undefined;
3551
constactiveTag=urlParams.get("tag")??"all";
3652
constvisibleTemplates=starterTemplatesByTag
37-
?starterTemplatesByTag[activeTag]
53+
?sortVisibleTemplates(starterTemplatesByTag[activeTag])
3854
:undefined;
3955

4056
return(

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ export const CreateTemplateButton: FC<CreateTemplateButtonProps> = ({
2626
</Button>
2727
</MoreMenuTrigger>
2828
<MoreMenuContent>
29-
<MoreMenuItem
30-
onClick={()=>{
31-
onNavigate("/templates/new?exampleId=scratch");
32-
}}
33-
>
34-
<NoteAddOutlined/>
35-
From scratch
36-
</MoreMenuItem>
3729
<MoreMenuItem
3830
onClick={()=>{
3931
onNavigate("/templates/new");

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

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp