@trebired/git-host 1.3.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +359 -27
- package/dist/api/forge/handler.d.ts +6 -0
- package/dist/api/forge/handler.d.ts.map +1 -0
- package/dist/api/forge/handler.js +260 -0
- package/dist/api/forge/handler.js.map +1 -0
- package/dist/api/forge/route.d.ts +34 -0
- package/dist/api/forge/route.d.ts.map +1 -0
- package/dist/api/forge/route.js +94 -0
- package/dist/api/forge/route.js.map +1 -0
- package/dist/api/handler/response.d.ts +6 -2
- package/dist/api/handler/response.d.ts.map +1 -1
- package/dist/api/handler/response.js +5 -0
- package/dist/api/handler/response.js.map +1 -1
- package/dist/browser/index.d.ts +65 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +778 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/styles.css +317 -0
- package/dist/core/create_git_forge.d.ts +4 -0
- package/dist/core/create_git_forge.d.ts.map +1 -0
- package/dist/core/create_git_forge.js +481 -0
- package/dist/core/create_git_forge.js.map +1 -0
- package/dist/core/git_forge/storage_memory.d.ts +4 -0
- package/dist/core/git_forge/storage_memory.d.ts.map +1 -0
- package/dist/core/git_forge/storage_memory.js +140 -0
- package/dist/core/git_forge/storage_memory.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/react/client/types.d.ts +45 -1
- package/dist/react/client/types.d.ts.map +1 -1
- package/dist/react/client.d.ts.map +1 -1
- package/dist/react/client.js +135 -2
- package/dist/react/client.js.map +1 -1
- package/dist/react/components.d.ts +44407 -0
- package/dist/react/components.d.ts.map +1 -0
- package/dist/react/components.js +733 -0
- package/dist/react/components.js.map +1 -0
- package/dist/react/hooks/query.d.ts +6 -2
- package/dist/react/hooks/query.d.ts.map +1 -1
- package/dist/react/hooks/query.js +71 -6
- package/dist/react/hooks/query.js.map +1 -1
- package/dist/react/hooks/resources.d.ts +50 -3
- package/dist/react/hooks/resources.d.ts.map +1 -1
- package/dist/react/hooks/resources.js +209 -2
- package/dist/react/hooks/resources.js.map +1 -1
- package/dist/react/hooks/types.d.ts +15 -2
- package/dist/react/hooks/types.d.ts.map +1 -1
- package/dist/react/hooks.d.ts +3 -3
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/hooks.js +2 -2
- package/dist/react/hooks.js.map +1 -1
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +3 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/ui/context.d.ts +1907 -0
- package/dist/react/ui/context.d.ts.map +1 -0
- package/dist/react/ui/context.js +186 -0
- package/dist/react/ui/context.js.map +1 -0
- package/dist/types/forge.d.ts +220 -0
- package/dist/types/forge.d.ts.map +1 -0
- package/dist/types/forge.js +2 -0
- package/dist/types/forge.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transports.d.ts +1 -1
- package/dist/types/transports.d.ts.map +1 -1
- package/package.json +11 -4
|
@@ -0,0 +1,778 @@
|
|
|
1
|
+
import { createElement, useDeferredValue, useState, } from "react";
|
|
2
|
+
import { createGitApiClient } from "../react/client.js";
|
|
3
|
+
import { GitActivityList, GitApiClientProvider, GitBlameView, GitBlobView, GitBranchList, GitBranchSelector, GitCommitList, GitCopyCloneUrlButton, GitDeleteReleaseButton, GitDiffView, GitDownloadArchiveButton, GitEditReleaseButton, GitForkButton, GitForkList, GitPathBreadcrumbs, GitReleaseList, GitRepositoryActionBar, GitRepositoryShell, GitRepositorySocialButtons, GitRepositoryUiProvider, GitSearchResults, GitTagList, GitTagSelector, GitTreeView, useGitActivity, useGitBlame, useGitBlob, useGitBranches, useGitCommit, useGitCommits, useGitDiff, useGitForks, useGitCreateRelease, useGitOverview, useGitRelease, useGitReleases, useGitSearch, useGitTags, useGitTree, useGitUpdateRelease, } from "../react/index.js";
|
|
4
|
+
import { text } from "../utils/text.js";
|
|
5
|
+
const h = createElement;
|
|
6
|
+
function joinClassNames(...values) {
|
|
7
|
+
return values.filter(Boolean).join(" ");
|
|
8
|
+
}
|
|
9
|
+
function findReadme(entries) {
|
|
10
|
+
const match = entries.find((entry) => entry.type === "blob" && /^readme(\.|$)/i.test(entry.name));
|
|
11
|
+
return match ? match.path : "";
|
|
12
|
+
}
|
|
13
|
+
function createClient(options) {
|
|
14
|
+
return options.client || createGitApiClient({
|
|
15
|
+
baseUrl: text(options.baseUrl),
|
|
16
|
+
headers: options.headers,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function resolveTheme(theme, unstyled) {
|
|
20
|
+
if (!unstyled)
|
|
21
|
+
return theme;
|
|
22
|
+
return {
|
|
23
|
+
...(theme || {}),
|
|
24
|
+
unstyled: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function GitBrowserProvider(props) {
|
|
28
|
+
const [client] = useState(() => createClient(props));
|
|
29
|
+
return h(GitApiClientProvider, {
|
|
30
|
+
client,
|
|
31
|
+
children: h(GitRepositoryUiProvider, {
|
|
32
|
+
branding: props.branding,
|
|
33
|
+
client,
|
|
34
|
+
diagnostics: props.diagnostics,
|
|
35
|
+
navigate: props.navigate,
|
|
36
|
+
policy: props.policy,
|
|
37
|
+
routeAdapter: props.routeAdapter,
|
|
38
|
+
theme: resolveTheme(props.theme, props.unstyled),
|
|
39
|
+
children: props.children,
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function withBrowserProvider(props, render) {
|
|
44
|
+
if (!props.client && !props.baseUrl)
|
|
45
|
+
return render();
|
|
46
|
+
return h(GitBrowserProvider, {
|
|
47
|
+
baseUrl: props.baseUrl,
|
|
48
|
+
branding: props.branding,
|
|
49
|
+
client: props.client,
|
|
50
|
+
diagnostics: props.diagnostics,
|
|
51
|
+
headers: props.headers,
|
|
52
|
+
navigate: props.navigate,
|
|
53
|
+
policy: props.policy,
|
|
54
|
+
routeAdapter: props.routeAdapter,
|
|
55
|
+
theme: resolveTheme(props.theme, props.unstyled),
|
|
56
|
+
unstyled: props.unstyled,
|
|
57
|
+
children: render(),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function overviewStats(overview) {
|
|
61
|
+
if (!overview)
|
|
62
|
+
return [];
|
|
63
|
+
return [
|
|
64
|
+
{ label: "Branch", value: overview.repository.repository.current_branch },
|
|
65
|
+
{ label: "Head", value: overview.repository.repository.head_short },
|
|
66
|
+
{ label: "Stars", value: String(overview.social.star_count) },
|
|
67
|
+
{ label: "Watchers", value: String(overview.social.watcher_count) },
|
|
68
|
+
{ label: "Releases", value: String(overview.release_count) },
|
|
69
|
+
{ label: "Forks", value: String(overview.fork_count) },
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function defaultSubtitle(repositoryKey, overview) {
|
|
73
|
+
if (!overview)
|
|
74
|
+
return `Repository workspace for ${repositoryKey}`;
|
|
75
|
+
return `${overview.repository.repository.current_branch} branch · ${overview.release_count} releases · ${overview.fork_count} forks`;
|
|
76
|
+
}
|
|
77
|
+
function defaultActionBar(repositoryKey, headers) {
|
|
78
|
+
return h(GitRepositoryActionBar, {
|
|
79
|
+
children: [
|
|
80
|
+
h(GitRepositorySocialButtons, { headers, key: "social", repositoryKey }),
|
|
81
|
+
h(GitForkButton, { headers, key: "fork", repositoryKey }),
|
|
82
|
+
h(GitCopyCloneUrlButton, { key: "clone", repositoryKey }),
|
|
83
|
+
h(GitDownloadArchiveButton, { key: "archive", repositoryKey }),
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function GitReleaseComposerCard(props) {
|
|
88
|
+
const createRelease = useGitCreateRelease(props.repositoryKey, { headers: props.headers });
|
|
89
|
+
const [title, setTitle] = useState("");
|
|
90
|
+
const [tagName, setTagName] = useState("");
|
|
91
|
+
const [notes, setNotes] = useState("");
|
|
92
|
+
return h("section", {
|
|
93
|
+
className: "git-browser-card",
|
|
94
|
+
children: [
|
|
95
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Publish a Release" }) }),
|
|
96
|
+
h("form", {
|
|
97
|
+
className: "git-browser-form",
|
|
98
|
+
key: "form",
|
|
99
|
+
onSubmit: async (event) => {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
await createRelease.mutate({
|
|
102
|
+
createTag: {
|
|
103
|
+
annotatedMessage: notes || title,
|
|
104
|
+
name: tagName,
|
|
105
|
+
targetRef: "HEAD",
|
|
106
|
+
},
|
|
107
|
+
notes,
|
|
108
|
+
title,
|
|
109
|
+
});
|
|
110
|
+
setTitle("");
|
|
111
|
+
setTagName("");
|
|
112
|
+
setNotes("");
|
|
113
|
+
props.onCreated?.();
|
|
114
|
+
},
|
|
115
|
+
children: [
|
|
116
|
+
h("input", {
|
|
117
|
+
className: "git-browser-input",
|
|
118
|
+
key: "title",
|
|
119
|
+
onChange: (event) => setTitle(text(event.target?.value)),
|
|
120
|
+
placeholder: "Release title",
|
|
121
|
+
value: title,
|
|
122
|
+
}),
|
|
123
|
+
h("input", {
|
|
124
|
+
className: "git-browser-input",
|
|
125
|
+
key: "tag",
|
|
126
|
+
onChange: (event) => setTagName(text(event.target?.value)),
|
|
127
|
+
placeholder: "Tag name",
|
|
128
|
+
value: tagName,
|
|
129
|
+
}),
|
|
130
|
+
h("textarea", {
|
|
131
|
+
className: "git-browser-input git-browser-textarea",
|
|
132
|
+
key: "notes",
|
|
133
|
+
onChange: (event) => setNotes(text(event.target?.value)),
|
|
134
|
+
placeholder: "Release notes",
|
|
135
|
+
value: notes,
|
|
136
|
+
}),
|
|
137
|
+
h("button", {
|
|
138
|
+
className: "git-browser-action-button is-primary",
|
|
139
|
+
disabled: createRelease.loading || !title || !tagName,
|
|
140
|
+
key: "submit",
|
|
141
|
+
type: "submit",
|
|
142
|
+
children: createRelease.loading ? "Publishing..." : "Publish Release",
|
|
143
|
+
}),
|
|
144
|
+
],
|
|
145
|
+
}),
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function GitReleaseEditorCard(props) {
|
|
150
|
+
const updateRelease = useGitUpdateRelease(props.repositoryKey, text(props.release?.id), { headers: props.headers });
|
|
151
|
+
const [editing, setEditing] = useState(false);
|
|
152
|
+
const [title, setTitle] = useState(text(props.release?.title));
|
|
153
|
+
const [notes, setNotes] = useState(text(props.release?.notes));
|
|
154
|
+
if (!props.release)
|
|
155
|
+
return null;
|
|
156
|
+
return h("section", {
|
|
157
|
+
className: "git-browser-card",
|
|
158
|
+
children: [
|
|
159
|
+
h("div", {
|
|
160
|
+
className: "git-browser-card-header",
|
|
161
|
+
key: "header",
|
|
162
|
+
children: [
|
|
163
|
+
h("h2", { className: "git-browser-card-title", key: "title", children: "Release Actions" }),
|
|
164
|
+
h("div", {
|
|
165
|
+
className: "git-browser-actions",
|
|
166
|
+
key: "actions",
|
|
167
|
+
children: [
|
|
168
|
+
h(GitEditReleaseButton, {
|
|
169
|
+
key: "edit",
|
|
170
|
+
onClick: () => setEditing((current) => !current),
|
|
171
|
+
}),
|
|
172
|
+
h(GitDeleteReleaseButton, {
|
|
173
|
+
headers: props.headers,
|
|
174
|
+
key: "delete",
|
|
175
|
+
onDeleted: props.onDeleted,
|
|
176
|
+
releaseId: props.release.id,
|
|
177
|
+
repositoryKey: props.repositoryKey,
|
|
178
|
+
}),
|
|
179
|
+
],
|
|
180
|
+
}),
|
|
181
|
+
],
|
|
182
|
+
}),
|
|
183
|
+
editing
|
|
184
|
+
? h("div", {
|
|
185
|
+
className: "git-browser-form",
|
|
186
|
+
key: "editor",
|
|
187
|
+
children: [
|
|
188
|
+
h("input", {
|
|
189
|
+
className: "git-browser-input",
|
|
190
|
+
key: "title",
|
|
191
|
+
onChange: (event) => setTitle(text(event.target?.value)),
|
|
192
|
+
value: title,
|
|
193
|
+
}),
|
|
194
|
+
h("textarea", {
|
|
195
|
+
className: "git-browser-input git-browser-textarea",
|
|
196
|
+
key: "notes",
|
|
197
|
+
onChange: (event) => setNotes(text(event.target?.value)),
|
|
198
|
+
value: notes,
|
|
199
|
+
}),
|
|
200
|
+
h("button", {
|
|
201
|
+
className: "git-browser-action-button is-primary",
|
|
202
|
+
disabled: updateRelease.loading,
|
|
203
|
+
key: "save",
|
|
204
|
+
onClick: async () => {
|
|
205
|
+
await updateRelease.mutate({ notes, title });
|
|
206
|
+
setEditing(false);
|
|
207
|
+
props.onUpdated?.();
|
|
208
|
+
},
|
|
209
|
+
type: "button",
|
|
210
|
+
children: updateRelease.loading ? "Saving..." : "Save Release",
|
|
211
|
+
}),
|
|
212
|
+
],
|
|
213
|
+
})
|
|
214
|
+
: h("p", { className: "git-browser-note", key: "summary", children: "Toggle edit mode to rename or rewrite release notes." }),
|
|
215
|
+
],
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function GitRepositoryOverviewPageInner(props) {
|
|
219
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
220
|
+
headers: props.headers,
|
|
221
|
+
initialData: props.initialData?.overview || null,
|
|
222
|
+
});
|
|
223
|
+
const tree = useGitTree(props.repositoryKey, {
|
|
224
|
+
enabled: Boolean(overview.data),
|
|
225
|
+
headers: props.headers,
|
|
226
|
+
icons: true,
|
|
227
|
+
recursive: true,
|
|
228
|
+
ref: overview.data?.repository.repository.current_branch || "HEAD",
|
|
229
|
+
});
|
|
230
|
+
const readmePath = tree.data ? findReadme(tree.data) : "";
|
|
231
|
+
const readme = useGitBlob(props.repositoryKey, {
|
|
232
|
+
enabled: Boolean(readmePath),
|
|
233
|
+
headers: props.headers,
|
|
234
|
+
path: readmePath,
|
|
235
|
+
ref: overview.data?.repository.repository.current_branch || "HEAD",
|
|
236
|
+
});
|
|
237
|
+
return h(GitRepositoryShell, {
|
|
238
|
+
actions: defaultActionBar(props.repositoryKey, props.headers),
|
|
239
|
+
className: props.className,
|
|
240
|
+
error: overview.error,
|
|
241
|
+
loading: overview.loading,
|
|
242
|
+
page: "overview",
|
|
243
|
+
repositoryKey: props.repositoryKey,
|
|
244
|
+
social: overview.data?.social,
|
|
245
|
+
stats: overviewStats(overview.data),
|
|
246
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
247
|
+
children: h("div", {
|
|
248
|
+
className: "git-browser-grid",
|
|
249
|
+
children: [
|
|
250
|
+
h("section", {
|
|
251
|
+
className: "git-browser-card git-browser-span-2",
|
|
252
|
+
key: "summary",
|
|
253
|
+
children: [
|
|
254
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Repository Summary" }) }),
|
|
255
|
+
h("p", { className: "git-browser-note", key: "path", children: overview.data?.repository.repository.path || "" }),
|
|
256
|
+
],
|
|
257
|
+
}),
|
|
258
|
+
h("section", {
|
|
259
|
+
className: "git-browser-card",
|
|
260
|
+
key: "latest-release",
|
|
261
|
+
children: [
|
|
262
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Latest Release" }) }),
|
|
263
|
+
overview.data?.latest_release
|
|
264
|
+
? h(GitReleaseList, { key: "list", releases: [overview.data.latest_release], repositoryKey: props.repositoryKey })
|
|
265
|
+
: h("p", { className: "git-browser-note", key: "empty", children: "No releases published yet." }),
|
|
266
|
+
],
|
|
267
|
+
}),
|
|
268
|
+
h("section", {
|
|
269
|
+
className: "git-browser-card git-browser-span-3",
|
|
270
|
+
key: "readme",
|
|
271
|
+
children: [
|
|
272
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "README" }) }),
|
|
273
|
+
h(GitBlobView, { content: readme.data?.content, key: "blob", path: readmePath || "README" }),
|
|
274
|
+
],
|
|
275
|
+
}),
|
|
276
|
+
],
|
|
277
|
+
}),
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function GitRepositoryCodePageInner(props) {
|
|
281
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
282
|
+
headers: props.headers,
|
|
283
|
+
initialData: props.initialData?.overview || null,
|
|
284
|
+
});
|
|
285
|
+
const [selectedPath, setSelectedPath] = useState(text(props.path));
|
|
286
|
+
const deferredPath = useDeferredValue(selectedPath);
|
|
287
|
+
const refName = props.refName || overview.data?.repository.repository.current_branch || "HEAD";
|
|
288
|
+
const tree = useGitTree(props.repositoryKey, {
|
|
289
|
+
headers: props.headers,
|
|
290
|
+
icons: true,
|
|
291
|
+
linguist: true,
|
|
292
|
+
recursive: true,
|
|
293
|
+
ref: refName,
|
|
294
|
+
});
|
|
295
|
+
const resolvedPath = deferredPath || (tree.data || []).find((entry) => entry.type === "blob")?.path || "";
|
|
296
|
+
const selectedEntry = (tree.data || []).find((entry) => entry.path === resolvedPath) || null;
|
|
297
|
+
const blob = useGitBlob(props.repositoryKey, {
|
|
298
|
+
enabled: Boolean(selectedEntry && selectedEntry.type === "blob"),
|
|
299
|
+
headers: props.headers,
|
|
300
|
+
path: resolvedPath,
|
|
301
|
+
ref: refName,
|
|
302
|
+
});
|
|
303
|
+
return h(GitRepositoryShell, {
|
|
304
|
+
actions: h(GitRepositoryActionBar, {
|
|
305
|
+
children: [
|
|
306
|
+
h(GitBranchSelector, { headers: props.headers, key: "branch", repositoryKey: props.repositoryKey, selectedBranch: overview.data?.repository.repository.current_branch }),
|
|
307
|
+
h(GitTagSelector, { headers: props.headers, key: "tag", repositoryKey: props.repositoryKey }),
|
|
308
|
+
],
|
|
309
|
+
}),
|
|
310
|
+
className: props.className,
|
|
311
|
+
error: tree.error || blob.error,
|
|
312
|
+
loading: overview.loading || tree.loading,
|
|
313
|
+
page: "code",
|
|
314
|
+
repositoryKey: props.repositoryKey,
|
|
315
|
+
social: overview.data?.social,
|
|
316
|
+
stats: overviewStats(overview.data),
|
|
317
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
318
|
+
children: h("div", {
|
|
319
|
+
className: "git-browser-split",
|
|
320
|
+
children: [
|
|
321
|
+
h("section", {
|
|
322
|
+
className: "git-browser-card",
|
|
323
|
+
key: "tree",
|
|
324
|
+
children: [
|
|
325
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Repository Tree" }) }),
|
|
326
|
+
h(GitTreeView, {
|
|
327
|
+
entries: tree.data || [],
|
|
328
|
+
key: "body",
|
|
329
|
+
onSelectPath: setSelectedPath,
|
|
330
|
+
selectedPath: resolvedPath,
|
|
331
|
+
}),
|
|
332
|
+
],
|
|
333
|
+
}),
|
|
334
|
+
h("div", {
|
|
335
|
+
className: "git-browser-grid",
|
|
336
|
+
key: "blob",
|
|
337
|
+
children: [
|
|
338
|
+
h(GitPathBreadcrumbs, { key: "crumbs", path: resolvedPath, refName, repositoryKey: props.repositoryKey }),
|
|
339
|
+
h(GitBlobView, {
|
|
340
|
+
content: blob.data?.content,
|
|
341
|
+
key: "view",
|
|
342
|
+
path: resolvedPath,
|
|
343
|
+
subtitle: selectedEntry?.language || "Plain text",
|
|
344
|
+
}),
|
|
345
|
+
],
|
|
346
|
+
}),
|
|
347
|
+
],
|
|
348
|
+
}),
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function GitRepositoryCommitsPageInner(props) {
|
|
352
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
353
|
+
headers: props.headers,
|
|
354
|
+
initialData: props.initialData?.overview || null,
|
|
355
|
+
});
|
|
356
|
+
const [limit, setLimit] = useState(20);
|
|
357
|
+
const commits = useGitCommits(props.repositoryKey, {
|
|
358
|
+
headers: props.headers,
|
|
359
|
+
initialData: props.initialData?.commits || null,
|
|
360
|
+
limit,
|
|
361
|
+
path: props.path,
|
|
362
|
+
ref: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
|
|
363
|
+
});
|
|
364
|
+
return h(GitRepositoryShell, {
|
|
365
|
+
actions: h(GitRepositoryActionBar, {
|
|
366
|
+
children: h(GitBranchSelector, { headers: props.headers, repositoryKey: props.repositoryKey, selectedBranch: overview.data?.repository.repository.current_branch }),
|
|
367
|
+
}),
|
|
368
|
+
className: props.className,
|
|
369
|
+
error: commits.error,
|
|
370
|
+
loading: overview.loading || commits.loading,
|
|
371
|
+
page: "commits",
|
|
372
|
+
repositoryKey: props.repositoryKey,
|
|
373
|
+
social: overview.data?.social,
|
|
374
|
+
stats: overviewStats(overview.data),
|
|
375
|
+
subtitle: props.path ? `History filtered to ${props.path}` : defaultSubtitle(props.repositoryKey, overview.data),
|
|
376
|
+
children: h("section", {
|
|
377
|
+
className: "git-browser-card",
|
|
378
|
+
children: [
|
|
379
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Commit History" }) }),
|
|
380
|
+
h(GitCommitList, { commits: commits.data || [], key: "list", repositoryKey: props.repositoryKey }),
|
|
381
|
+
(commits.data || []).length >= limit
|
|
382
|
+
? h("button", {
|
|
383
|
+
className: "git-browser-action-button",
|
|
384
|
+
key: "more",
|
|
385
|
+
onClick: () => setLimit((current) => current + 20),
|
|
386
|
+
type: "button",
|
|
387
|
+
children: "Load More Commits",
|
|
388
|
+
})
|
|
389
|
+
: null,
|
|
390
|
+
],
|
|
391
|
+
}),
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function GitRepositoryCommitPageInner(props) {
|
|
395
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
396
|
+
headers: props.headers,
|
|
397
|
+
initialData: props.initialData?.overview || null,
|
|
398
|
+
});
|
|
399
|
+
const commit = useGitCommit(props.repositoryKey, props.commitRef, {
|
|
400
|
+
headers: props.headers,
|
|
401
|
+
initialData: props.initialData?.commit || null,
|
|
402
|
+
});
|
|
403
|
+
return h(GitRepositoryShell, {
|
|
404
|
+
className: props.className,
|
|
405
|
+
error: commit.error,
|
|
406
|
+
loading: overview.loading || commit.loading,
|
|
407
|
+
page: "commit",
|
|
408
|
+
repositoryKey: props.repositoryKey,
|
|
409
|
+
social: overview.data?.social,
|
|
410
|
+
stats: overviewStats(overview.data),
|
|
411
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
412
|
+
children: commit.data ? h("div", {
|
|
413
|
+
className: "git-browser-grid",
|
|
414
|
+
children: [
|
|
415
|
+
h("section", {
|
|
416
|
+
className: "git-browser-card git-browser-span-3",
|
|
417
|
+
key: "meta",
|
|
418
|
+
children: [
|
|
419
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: commit.data.commit.subject }) }),
|
|
420
|
+
h("p", { className: "git-browser-note", key: "meta", children: `${commit.data.commit.short_hash} · ${commit.data.commit.author_name} · ${commit.data.file_count} files` }),
|
|
421
|
+
h("pre", { className: "git-browser-code-block", key: "diff", children: commit.data.diff }),
|
|
422
|
+
],
|
|
423
|
+
}),
|
|
424
|
+
],
|
|
425
|
+
}) : null,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function GitRepositoryReleasesPageInner(props) {
|
|
429
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
430
|
+
headers: props.headers,
|
|
431
|
+
initialData: props.initialData?.overview || null,
|
|
432
|
+
});
|
|
433
|
+
const releases = useGitReleases(props.repositoryKey, {
|
|
434
|
+
headers: props.headers,
|
|
435
|
+
initialData: props.initialData?.releases || null,
|
|
436
|
+
});
|
|
437
|
+
return h(GitRepositoryShell, {
|
|
438
|
+
actions: defaultActionBar(props.repositoryKey, props.headers),
|
|
439
|
+
className: props.className,
|
|
440
|
+
error: releases.error,
|
|
441
|
+
loading: overview.loading || releases.loading,
|
|
442
|
+
page: "releases",
|
|
443
|
+
repositoryKey: props.repositoryKey,
|
|
444
|
+
social: overview.data?.social,
|
|
445
|
+
stats: overviewStats(overview.data),
|
|
446
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
447
|
+
children: h("div", {
|
|
448
|
+
className: "git-browser-grid",
|
|
449
|
+
children: [
|
|
450
|
+
h(GitReleaseComposerCard, {
|
|
451
|
+
headers: props.headers,
|
|
452
|
+
key: "composer",
|
|
453
|
+
onCreated: releases.reload,
|
|
454
|
+
repositoryKey: props.repositoryKey,
|
|
455
|
+
}),
|
|
456
|
+
h("section", {
|
|
457
|
+
className: "git-browser-card git-browser-span-2",
|
|
458
|
+
key: "list-card",
|
|
459
|
+
children: [
|
|
460
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Releases" }) }),
|
|
461
|
+
h(GitReleaseList, { key: "list", releases: releases.data || [], repositoryKey: props.repositoryKey }),
|
|
462
|
+
],
|
|
463
|
+
}),
|
|
464
|
+
],
|
|
465
|
+
}),
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
function GitRepositoryReleasePageInner(props) {
|
|
469
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
470
|
+
headers: props.headers,
|
|
471
|
+
initialData: props.initialData?.overview || null,
|
|
472
|
+
});
|
|
473
|
+
const release = useGitRelease(props.repositoryKey, props.releaseId, {
|
|
474
|
+
headers: props.headers,
|
|
475
|
+
initialData: props.initialData?.release || null,
|
|
476
|
+
});
|
|
477
|
+
return h(GitRepositoryShell, {
|
|
478
|
+
actions: defaultActionBar(props.repositoryKey, props.headers),
|
|
479
|
+
className: props.className,
|
|
480
|
+
error: release.error,
|
|
481
|
+
loading: overview.loading || release.loading,
|
|
482
|
+
page: "release",
|
|
483
|
+
repositoryKey: props.repositoryKey,
|
|
484
|
+
social: overview.data?.social,
|
|
485
|
+
stats: overviewStats(overview.data),
|
|
486
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
487
|
+
children: release.data ? h("div", {
|
|
488
|
+
className: "git-browser-grid",
|
|
489
|
+
children: [
|
|
490
|
+
h("section", {
|
|
491
|
+
className: "git-browser-card git-browser-span-2",
|
|
492
|
+
key: "details",
|
|
493
|
+
children: [
|
|
494
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: `${release.data.title} · ${release.data.tag_name}` }) }),
|
|
495
|
+
h("p", { className: "git-browser-note", key: "notes", children: release.data.notes || "No release notes." }),
|
|
496
|
+
],
|
|
497
|
+
}),
|
|
498
|
+
h("section", {
|
|
499
|
+
className: "git-browser-card",
|
|
500
|
+
key: "assets",
|
|
501
|
+
children: [
|
|
502
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Assets" }) }),
|
|
503
|
+
h("ul", {
|
|
504
|
+
className: "git-browser-list",
|
|
505
|
+
key: "list",
|
|
506
|
+
children: release.data.assets.map((asset) => h("li", {
|
|
507
|
+
className: "git-browser-list-item",
|
|
508
|
+
key: asset.id,
|
|
509
|
+
children: `${asset.name}${asset.size ? ` · ${asset.size} bytes` : ""}`,
|
|
510
|
+
})),
|
|
511
|
+
}),
|
|
512
|
+
],
|
|
513
|
+
}),
|
|
514
|
+
h(GitReleaseEditorCard, {
|
|
515
|
+
headers: props.headers,
|
|
516
|
+
key: "editor",
|
|
517
|
+
onDeleted: release.reload,
|
|
518
|
+
onUpdated: release.reload,
|
|
519
|
+
release: release.data,
|
|
520
|
+
repositoryKey: props.repositoryKey,
|
|
521
|
+
}),
|
|
522
|
+
],
|
|
523
|
+
}) : null,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
function GitRepositoryForksPageInner(props) {
|
|
527
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
528
|
+
headers: props.headers,
|
|
529
|
+
initialData: props.initialData?.overview || null,
|
|
530
|
+
});
|
|
531
|
+
const forks = useGitForks(props.repositoryKey, {
|
|
532
|
+
headers: props.headers,
|
|
533
|
+
initialData: props.initialData?.forks || null,
|
|
534
|
+
});
|
|
535
|
+
return h(GitRepositoryShell, {
|
|
536
|
+
actions: defaultActionBar(props.repositoryKey, props.headers),
|
|
537
|
+
className: props.className,
|
|
538
|
+
error: forks.error,
|
|
539
|
+
loading: overview.loading || forks.loading,
|
|
540
|
+
page: "forks",
|
|
541
|
+
repositoryKey: props.repositoryKey,
|
|
542
|
+
social: overview.data?.social,
|
|
543
|
+
stats: overviewStats(overview.data),
|
|
544
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
545
|
+
children: h("section", {
|
|
546
|
+
className: "git-browser-card",
|
|
547
|
+
children: [
|
|
548
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Fork Network" }) }),
|
|
549
|
+
h(GitForkList, { forks: forks.data || [], headers: props.headers, key: "list", repositoryKey: props.repositoryKey }),
|
|
550
|
+
],
|
|
551
|
+
}),
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
function GitRepositoryActivityPageInner(props) {
|
|
555
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
556
|
+
headers: props.headers,
|
|
557
|
+
initialData: props.initialData?.overview || null,
|
|
558
|
+
});
|
|
559
|
+
const activity = useGitActivity(props.repositoryKey, {
|
|
560
|
+
headers: props.headers,
|
|
561
|
+
initialData: props.initialData?.activity || null,
|
|
562
|
+
});
|
|
563
|
+
return h(GitRepositoryShell, {
|
|
564
|
+
className: props.className,
|
|
565
|
+
error: activity.error,
|
|
566
|
+
loading: overview.loading || activity.loading,
|
|
567
|
+
page: "activity",
|
|
568
|
+
repositoryKey: props.repositoryKey,
|
|
569
|
+
social: overview.data?.social,
|
|
570
|
+
stats: overviewStats(overview.data),
|
|
571
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
572
|
+
children: h("section", {
|
|
573
|
+
className: "git-browser-card",
|
|
574
|
+
children: [
|
|
575
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Activity Timeline" }) }),
|
|
576
|
+
h(GitActivityList, { activity: activity.data || [], key: "body" }),
|
|
577
|
+
],
|
|
578
|
+
}),
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
function GitRepositoryBranchesPageInner(props) {
|
|
582
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
583
|
+
headers: props.headers,
|
|
584
|
+
initialData: props.initialData?.overview || null,
|
|
585
|
+
});
|
|
586
|
+
const branches = useGitBranches(props.repositoryKey, {
|
|
587
|
+
headers: props.headers,
|
|
588
|
+
initialData: props.initialData?.branches || null,
|
|
589
|
+
});
|
|
590
|
+
return h(GitRepositoryShell, {
|
|
591
|
+
actions: h(GitRepositoryActionBar, {
|
|
592
|
+
children: h(GitBranchSelector, { headers: props.headers, repositoryKey: props.repositoryKey, selectedBranch: overview.data?.repository.repository.current_branch }),
|
|
593
|
+
}),
|
|
594
|
+
className: props.className,
|
|
595
|
+
error: branches.error,
|
|
596
|
+
loading: overview.loading || branches.loading,
|
|
597
|
+
page: "branches",
|
|
598
|
+
repositoryKey: props.repositoryKey,
|
|
599
|
+
social: overview.data?.social,
|
|
600
|
+
stats: overviewStats(overview.data),
|
|
601
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
602
|
+
children: h("section", {
|
|
603
|
+
className: "git-browser-card",
|
|
604
|
+
children: [
|
|
605
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Branches" }) }),
|
|
606
|
+
h(GitBranchList, { branches: branches.data || [], key: "list", repositoryKey: props.repositoryKey }),
|
|
607
|
+
],
|
|
608
|
+
}),
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
function GitRepositoryTagsPageInner(props) {
|
|
612
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
613
|
+
headers: props.headers,
|
|
614
|
+
initialData: props.initialData?.overview || null,
|
|
615
|
+
});
|
|
616
|
+
const tags = useGitTags(props.repositoryKey, {
|
|
617
|
+
headers: props.headers,
|
|
618
|
+
initialData: props.initialData?.tags || null,
|
|
619
|
+
});
|
|
620
|
+
return h(GitRepositoryShell, {
|
|
621
|
+
actions: h(GitRepositoryActionBar, {
|
|
622
|
+
children: h(GitTagSelector, { headers: props.headers, repositoryKey: props.repositoryKey }),
|
|
623
|
+
}),
|
|
624
|
+
className: props.className,
|
|
625
|
+
error: tags.error,
|
|
626
|
+
loading: overview.loading || tags.loading,
|
|
627
|
+
page: "tags",
|
|
628
|
+
repositoryKey: props.repositoryKey,
|
|
629
|
+
social: overview.data?.social,
|
|
630
|
+
stats: overviewStats(overview.data),
|
|
631
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
632
|
+
children: h("section", {
|
|
633
|
+
className: "git-browser-card",
|
|
634
|
+
children: [
|
|
635
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Tags" }) }),
|
|
636
|
+
h(GitTagList, { key: "list", repositoryKey: props.repositoryKey, tags: tags.data || [] }),
|
|
637
|
+
],
|
|
638
|
+
}),
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function GitRepositorySearchPageInner(props) {
|
|
642
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
643
|
+
headers: props.headers,
|
|
644
|
+
initialData: props.initialData?.overview || null,
|
|
645
|
+
});
|
|
646
|
+
const [query, setQuery] = useState(text(props.query));
|
|
647
|
+
const results = useGitSearch(props.repositoryKey, {
|
|
648
|
+
enabled: Boolean(query),
|
|
649
|
+
headers: props.headers,
|
|
650
|
+
initialData: props.initialData?.search || null,
|
|
651
|
+
path: props.path,
|
|
652
|
+
query,
|
|
653
|
+
ref: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
|
|
654
|
+
});
|
|
655
|
+
return h(GitRepositoryShell, {
|
|
656
|
+
className: props.className,
|
|
657
|
+
error: results.error,
|
|
658
|
+
loading: overview.loading || results.loading,
|
|
659
|
+
page: "search",
|
|
660
|
+
repositoryKey: props.repositoryKey,
|
|
661
|
+
social: overview.data?.social,
|
|
662
|
+
stats: overviewStats(overview.data),
|
|
663
|
+
subtitle: defaultSubtitle(props.repositoryKey, overview.data),
|
|
664
|
+
children: h("section", {
|
|
665
|
+
className: "git-browser-card",
|
|
666
|
+
children: [
|
|
667
|
+
h("div", {
|
|
668
|
+
className: "git-browser-card-header",
|
|
669
|
+
key: "header",
|
|
670
|
+
children: [
|
|
671
|
+
h("h2", { className: "git-browser-card-title", key: "title", children: "Search" }),
|
|
672
|
+
h("input", {
|
|
673
|
+
className: "git-browser-input",
|
|
674
|
+
key: "input",
|
|
675
|
+
onChange: (event) => setQuery(text(event.target?.value)),
|
|
676
|
+
placeholder: "Search this repository",
|
|
677
|
+
value: query,
|
|
678
|
+
}),
|
|
679
|
+
],
|
|
680
|
+
}),
|
|
681
|
+
h(GitSearchResults, { key: "results", repositoryKey: props.repositoryKey, results: results.data }),
|
|
682
|
+
],
|
|
683
|
+
}),
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
function GitRepositoryBlamePageInner(props) {
|
|
687
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
688
|
+
headers: props.headers,
|
|
689
|
+
initialData: props.initialData?.overview || null,
|
|
690
|
+
});
|
|
691
|
+
const blame = useGitBlame(props.repositoryKey, {
|
|
692
|
+
headers: props.headers,
|
|
693
|
+
path: props.path,
|
|
694
|
+
ref: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
|
|
695
|
+
});
|
|
696
|
+
return h(GitRepositoryShell, {
|
|
697
|
+
className: props.className,
|
|
698
|
+
error: blame.error,
|
|
699
|
+
loading: overview.loading || blame.loading,
|
|
700
|
+
page: "blame",
|
|
701
|
+
repositoryKey: props.repositoryKey,
|
|
702
|
+
social: overview.data?.social,
|
|
703
|
+
stats: overviewStats(overview.data),
|
|
704
|
+
subtitle: props.path ? `Blame for ${props.path}` : defaultSubtitle(props.repositoryKey, overview.data),
|
|
705
|
+
children: h("section", {
|
|
706
|
+
className: "git-browser-card",
|
|
707
|
+
children: [
|
|
708
|
+
h("div", { className: "git-browser-card-header", key: "header", children: h("h2", { className: "git-browser-card-title", children: "Blame" }) }),
|
|
709
|
+
h(GitBlameView, { blame: blame.data, key: "view", refName: props.refName, repositoryKey: props.repositoryKey }),
|
|
710
|
+
],
|
|
711
|
+
}),
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
function GitRepositoryComparePageInner(props) {
|
|
715
|
+
const overview = useGitOverview(props.repositoryKey, {
|
|
716
|
+
headers: props.headers,
|
|
717
|
+
initialData: props.initialData?.overview || null,
|
|
718
|
+
});
|
|
719
|
+
const diff = useGitDiff(props.repositoryKey, {
|
|
720
|
+
baseRef: props.baseRef,
|
|
721
|
+
headRef: props.headRef,
|
|
722
|
+
headers: props.headers,
|
|
723
|
+
initialData: props.initialData?.compare || null,
|
|
724
|
+
path: props.path,
|
|
725
|
+
});
|
|
726
|
+
return h(GitRepositoryShell, {
|
|
727
|
+
className: props.className,
|
|
728
|
+
error: diff.error,
|
|
729
|
+
loading: overview.loading || diff.loading,
|
|
730
|
+
page: "compare",
|
|
731
|
+
repositoryKey: props.repositoryKey,
|
|
732
|
+
social: overview.data?.social,
|
|
733
|
+
stats: overviewStats(overview.data),
|
|
734
|
+
subtitle: `${props.baseRef} → ${props.headRef}`,
|
|
735
|
+
children: h(GitDiffView, { diff: diff.data }),
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
function GitRepositoryOverviewPage(props) {
|
|
739
|
+
return withBrowserProvider(props, () => h(GitRepositoryOverviewPageInner, props));
|
|
740
|
+
}
|
|
741
|
+
function GitRepositoryCodePage(props) {
|
|
742
|
+
return withBrowserProvider(props, () => h(GitRepositoryCodePageInner, props));
|
|
743
|
+
}
|
|
744
|
+
function GitRepositoryCommitsPage(props) {
|
|
745
|
+
return withBrowserProvider(props, () => h(GitRepositoryCommitsPageInner, props));
|
|
746
|
+
}
|
|
747
|
+
function GitRepositoryCommitPage(props) {
|
|
748
|
+
return withBrowserProvider(props, () => h(GitRepositoryCommitPageInner, props));
|
|
749
|
+
}
|
|
750
|
+
function GitRepositoryReleasesPage(props) {
|
|
751
|
+
return withBrowserProvider(props, () => h(GitRepositoryReleasesPageInner, props));
|
|
752
|
+
}
|
|
753
|
+
function GitRepositoryReleasePage(props) {
|
|
754
|
+
return withBrowserProvider(props, () => h(GitRepositoryReleasePageInner, props));
|
|
755
|
+
}
|
|
756
|
+
function GitRepositoryForksPage(props) {
|
|
757
|
+
return withBrowserProvider(props, () => h(GitRepositoryForksPageInner, props));
|
|
758
|
+
}
|
|
759
|
+
function GitRepositoryActivityPage(props) {
|
|
760
|
+
return withBrowserProvider(props, () => h(GitRepositoryActivityPageInner, props));
|
|
761
|
+
}
|
|
762
|
+
function GitRepositoryBranchesPage(props) {
|
|
763
|
+
return withBrowserProvider(props, () => h(GitRepositoryBranchesPageInner, props));
|
|
764
|
+
}
|
|
765
|
+
function GitRepositoryTagsPage(props) {
|
|
766
|
+
return withBrowserProvider(props, () => h(GitRepositoryTagsPageInner, props));
|
|
767
|
+
}
|
|
768
|
+
function GitRepositorySearchPage(props) {
|
|
769
|
+
return withBrowserProvider(props, () => h(GitRepositorySearchPageInner, props));
|
|
770
|
+
}
|
|
771
|
+
function GitRepositoryBlamePage(props) {
|
|
772
|
+
return withBrowserProvider(props, () => h(GitRepositoryBlamePageInner, props));
|
|
773
|
+
}
|
|
774
|
+
function GitRepositoryComparePage(props) {
|
|
775
|
+
return withBrowserProvider(props, () => h(GitRepositoryComparePageInner, props));
|
|
776
|
+
}
|
|
777
|
+
export { GitBrowserProvider, GitRepositoryActivityPage, GitRepositoryBlamePage, GitRepositoryBranchesPage, GitRepositoryCodePage, GitRepositoryCommitPage, GitRepositoryCommitsPage, GitRepositoryComparePage, GitRepositoryForksPage, GitRepositoryOverviewPage, GitRepositoryReleasePage, GitRepositoryReleasesPage, GitRepositorySearchPage, GitRepositoryTagsPage, };
|
|
778
|
+
//# sourceMappingURL=index.js.map
|