Skip to content

Commit c8abf58

Browse files
authored
chore: reduce prominence of Scratch starter and emphasize Docker in UI (#16665)
1 parent 658825c commit c8abf58

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
import CreateTemplateGalleryPage from "./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
return HttpResponse.json([
@@ -49,5 +49,5 @@ test("does not display the scratch template", async () => {
4949

5050
await screen.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-
import type { TemplateExample } from "api/typesGenerated";
32
import type { 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
const CreateTemplatesGalleryPage: FC = () => {
1110
const templateExamplesQuery = useQuery(templateExamples());
1211
const starterTemplatesByTag = 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-
const removeScratchExample = (data: TemplateExample[]) => {
31-
return data.filter((example) => example.id !== "scratch");
32-
};
33-
3428
export default CreateTemplatesGalleryPage;

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-
<Card variant="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-
<div css={styles.icon}>
57-
<ExternalImage
58-
src="/emojis/1f4c4.png"
59-
css={{ width: "100%", height: "100%" }}
60-
/>
61-
</div>
62-
<div>
63-
<h4 css={styles.cardTitle}>Scratch Template</h4>
64-
<span css={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
<Card variant="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
import type { Interpolation, Theme } from "@emotion/react";
2+
import type { TemplateExample } from "api/typesGenerated";
23
import { Stack } from "components/Stack/Stack";
34
import { TemplateExampleCard } from "modules/templates/TemplateExampleCard/TemplateExampleCard";
45
import type { FC } from "react";
@@ -21,6 +22,21 @@ const selectTags = (starterTemplatesByTag: StarterTemplatesByTag) => {
2122
: undefined;
2223
};
2324

25+
const sortVisibleTemplates = (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+
const dockerTemplateId = "docker";
29+
return templates.sort((a, b) => {
30+
if (a.id === dockerTemplateId) {
31+
return -1;
32+
}
33+
if (b.id === dockerTemplateId) {
34+
return 1;
35+
}
36+
return a.name.localeCompare(b.name);
37+
});
38+
};
39+
2440
export interface StarterTemplatesProps {
2541
starterTemplatesByTag?: StarterTemplatesByTag;
2642
}
@@ -34,7 +50,7 @@ export const StarterTemplates: FC<StarterTemplatesProps> = ({
3450
: undefined;
3551
const activeTag = urlParams.get("tag") ?? "all";
3652
const visibleTemplates = 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)
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