๐ (repo): Draw the fork action as an icon, not a text glyph
Changes
3 files changed, +30 -4
MODIFY
docs/users/forking.md
+3 -3
@@ -6,9 +6,9 @@
6
6
7
7
## How to fork
8
8
9
-Open any repository you can see and click the **fork** button (โ) in the
10
-repository sidebar, next to Clone and Pin. git-shark creates a new repository at
11
-`/<your-handle>/<name>` and sends you straight to it.
9
+Open any repository you can see and click the **fork** button (the branch icon)
10
+in the repository sidebar, next to Clone and Pin. git-shark creates a new
11
+repository at `/<your-handle>/<name>` and sends you straight to it.
12
12
13
13
The fork starts as a faithful copy of the source at that moment:
14
14
MODIFY
src/main/resources/templates/RepositoryResource/sidebar.html
+1 -1
@@ -15,7 +15,7 @@
15
15
{#if nav.loggedIn}
16
16
<form class="inline" method="post" action="/repos/{nav.repo.ownerHandle}/{nav.repo.name}/fork">
17
17
<button class="btn-icon" type="submit" title="Fork repository" aria-label="Fork repository">
18
- <span class="g">โ</span>
18
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="18" r="3"/><circle cx="6" cy="6" r="3"/><circle cx="18" cy="6" r="3"/><path d="M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"/><path d="M12 12v3"/></svg>
19
19
</button>
20
20
</form>
21
21
<form class="inline" method="post" action="/repos/{nav.repo.ownerHandle}/{nav.repo.name}/{#if nav.pinned}unpin{#else}pin{/if}">
MODIFY
src/test/java/de/workaround/web/RepositoryForkUiTest.java
+26 -0
@@ -16,6 +16,8 @@
16
16
import static io.restassured.RestAssured.given;
17
17
import static org.hamcrest.CoreMatchers.containsString;
18
18
import static org.hamcrest.CoreMatchers.not;
19
+import static org.junit.jupiter.api.Assertions.assertFalse;
20
+import static org.junit.jupiter.api.Assertions.assertTrue;
19
21
20
22
@QuarkusTest
21
23
class RepositoryForkUiTest
@@ -81,6 +83,30 @@
81
83
.then().statusCode(403);
82
84
}
83
85
86
+ @Test
87
+ @TestSecurity(user = "fork-icon")
88
+ void forkActionRendersAnInlineSvgIconLikeThePinAction()
89
+ {
90
+ persistUser("fork-icon");
91
+ User owner = persistUser("fork-icon-owner-" + unique());
92
+ service.create(owner, "iconrepo", Repository.Visibility.PUBLIC, null);
93
+
94
+ String body = given().when().get("/repos/" + owner.username + "/iconrepo")
95
+ .then().statusCode(200)
96
+ .extract().body().asString();
97
+
98
+ String forkAction = actionForm(body, "/fork");
99
+ assertTrue(forkAction.contains("<svg"), "fork button must use an inline svg icon: " + forkAction);
100
+ assertFalse(forkAction.contains("\u2442"), "fork button must not fall back to a text glyph: " + forkAction);
101
+ }
102
+
103
+ private static String actionForm(String body, String actionSuffix)
104
+ {
105
+ int start = body.indexOf(actionSuffix + "\">");
106
+ assertTrue(start >= 0, "no form posting to " + actionSuffix);
107
+ return body.substring(start, body.indexOf("</form>", start));
108
+ }
109
+
84
110
private static String unique()
85
111
{
86
112
return UUID.randomUUID().toString().substring(0, 8);