ref0-git 0.0.0 → 0.3.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/app/apps/github/.dev.vars.example +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +127 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +562 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +487 -0
- package/app/apps/github/src/palette/server.ts +107 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +606 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +528 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +69 -0
- package/dist/cli/helpers.mjs +184 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +136 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +80 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +203 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +460 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +384 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +48 -6
- package/README.md +0 -5
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { ShuffleIcon } from 'lucide-react';
|
|
3
|
+
import { type FormEvent, useState } from 'react';
|
|
4
|
+
import { toast } from 'sonner';
|
|
5
|
+
|
|
6
|
+
import { cn } from '#/lib/cn';
|
|
7
|
+
|
|
8
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
9
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
10
|
+
import { Button } from '../components/ui/button.tsx';
|
|
11
|
+
import {
|
|
12
|
+
Dialog,
|
|
13
|
+
DialogContent,
|
|
14
|
+
DialogDescription,
|
|
15
|
+
DialogFooter,
|
|
16
|
+
DialogHeader,
|
|
17
|
+
DialogTitle,
|
|
18
|
+
} from '../components/ui/dialog.tsx';
|
|
19
|
+
import {
|
|
20
|
+
Field,
|
|
21
|
+
FieldDescription,
|
|
22
|
+
FieldError,
|
|
23
|
+
FieldGroup,
|
|
24
|
+
FieldLabel,
|
|
25
|
+
} from '../components/ui/field.tsx';
|
|
26
|
+
import { Input } from '../components/ui/input.tsx';
|
|
27
|
+
import {
|
|
28
|
+
InputGroup,
|
|
29
|
+
InputGroupAddon,
|
|
30
|
+
InputGroupInput,
|
|
31
|
+
InputGroupText,
|
|
32
|
+
} from '../components/ui/input-group.tsx';
|
|
33
|
+
import { createLabel, editLabel, vocabularyOf, type Label } from './issues.ts';
|
|
34
|
+
import { LabelBadge } from './parts.tsx';
|
|
35
|
+
|
|
36
|
+
/** The swatches the colour offers: GitHub's label picker's sixteen, dark row then light. */
|
|
37
|
+
export const labelSwatches = [
|
|
38
|
+
'b60205',
|
|
39
|
+
'd93f0b',
|
|
40
|
+
'fbca04',
|
|
41
|
+
'0e8a16',
|
|
42
|
+
'006b75',
|
|
43
|
+
'1d76db',
|
|
44
|
+
'0052cc',
|
|
45
|
+
'5319e7',
|
|
46
|
+
'e99695',
|
|
47
|
+
'f9d0c4',
|
|
48
|
+
'fef2c0',
|
|
49
|
+
'c2e0c6',
|
|
50
|
+
'bfdadc',
|
|
51
|
+
'c5def5',
|
|
52
|
+
'bfd4f2',
|
|
53
|
+
'd4c5f9',
|
|
54
|
+
] as const;
|
|
55
|
+
|
|
56
|
+
/** A new label's first colour: one of the swatches, picked by its name, so a name keeps it. */
|
|
57
|
+
export const colorOf = (name: string) => {
|
|
58
|
+
let sum = 0;
|
|
59
|
+
|
|
60
|
+
for (const char of name) sum += char.codePointAt(0) ?? 0;
|
|
61
|
+
|
|
62
|
+
return labelSwatches[sum % labelSwatches.length] ?? 'ededed';
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Any of the colours a hex can name, as Randomize picks one. */
|
|
66
|
+
const randomColor = () =>
|
|
67
|
+
Math.floor(Math.random() * 0x1_00_00_00)
|
|
68
|
+
.toString(16)
|
|
69
|
+
.padStart(6, '0');
|
|
70
|
+
|
|
71
|
+
/** The reads that show issues' and pull requests' labels, by the first part of their keys. */
|
|
72
|
+
const labelled = new Set<unknown>(['issue', 'issues', 'pull', 'pulls']);
|
|
73
|
+
|
|
74
|
+
/** The longest name and description GitHub keeps for a label. */
|
|
75
|
+
const longest = { name: 50, description: 100 } as const;
|
|
76
|
+
|
|
77
|
+
/** What was typed as a colour, as six hex digits, or `undefined` when it isn't one. */
|
|
78
|
+
export const hexOf = (typed: string) => {
|
|
79
|
+
const digits = typed.trim().replace(/^#/, '').toLowerCase();
|
|
80
|
+
|
|
81
|
+
return /^[\da-f]{6}$/.test(digits) ? digits : undefined;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A label's Dialog, for a new one and for changing one, `editing`: its name, its description, and
|
|
86
|
+
* its colour, as a swatch, a hex, or Randomize, over a live preview of the label as issues show
|
|
87
|
+
* it. A new one starts from `name`, as a picker's typed text names it. `taken` is the repo's
|
|
88
|
+
* labels' names, which a new name can't be. `onSaved` hears the label the drop-in holds.
|
|
89
|
+
*/
|
|
90
|
+
export function LabelDialog({
|
|
91
|
+
place,
|
|
92
|
+
editing,
|
|
93
|
+
name = '',
|
|
94
|
+
taken,
|
|
95
|
+
open,
|
|
96
|
+
onOpenChange,
|
|
97
|
+
onSaved,
|
|
98
|
+
}: {
|
|
99
|
+
readonly place: RepoPlace;
|
|
100
|
+
readonly editing?: Label | undefined;
|
|
101
|
+
readonly name?: string;
|
|
102
|
+
readonly taken: readonly string[];
|
|
103
|
+
readonly open: boolean;
|
|
104
|
+
readonly onOpenChange: (open: boolean) => void;
|
|
105
|
+
readonly onSaved?: ((label: Label) => void) | undefined;
|
|
106
|
+
}) {
|
|
107
|
+
return (
|
|
108
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
109
|
+
<DialogContent className="sm:max-w-md">
|
|
110
|
+
<DialogHeader>
|
|
111
|
+
<DialogTitle>{editing === undefined ? 'New label' : 'Edit label'}</DialogTitle>
|
|
112
|
+
<DialogDescription>
|
|
113
|
+
Labels sort this repository's issues and pull requests.
|
|
114
|
+
</DialogDescription>
|
|
115
|
+
</DialogHeader>
|
|
116
|
+
{/* The form mounts with the dialog, so each opening starts from what it's given. */}
|
|
117
|
+
<LabelForm
|
|
118
|
+
place={place}
|
|
119
|
+
editing={editing}
|
|
120
|
+
name={name}
|
|
121
|
+
taken={taken}
|
|
122
|
+
onSaved={(label) => {
|
|
123
|
+
onOpenChange(false);
|
|
124
|
+
onSaved?.(label);
|
|
125
|
+
}}
|
|
126
|
+
onCancel={() => onOpenChange(false)}
|
|
127
|
+
/>
|
|
128
|
+
</DialogContent>
|
|
129
|
+
</Dialog>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The Dialog's form, which makes or changes the label, then hands it on. */
|
|
134
|
+
function LabelForm({
|
|
135
|
+
place,
|
|
136
|
+
editing,
|
|
137
|
+
name: typedName,
|
|
138
|
+
taken,
|
|
139
|
+
onSaved,
|
|
140
|
+
onCancel,
|
|
141
|
+
}: {
|
|
142
|
+
readonly place: RepoPlace;
|
|
143
|
+
readonly editing: Label | undefined;
|
|
144
|
+
readonly name: string;
|
|
145
|
+
readonly taken: readonly string[];
|
|
146
|
+
readonly onSaved: (label: Label) => void;
|
|
147
|
+
readonly onCancel: () => void;
|
|
148
|
+
}) {
|
|
149
|
+
const client = useQueryClient();
|
|
150
|
+
const [name, setName] = useState(editing?.name ?? typedName.trim());
|
|
151
|
+
const [description, setDescription] = useState(editing?.description ?? '');
|
|
152
|
+
const [hex, setHex] = useState(editing?.color ?? colorOf(typedName.trim()));
|
|
153
|
+
const [tried, setTried] = useState(false);
|
|
154
|
+
// The last colour typed in full, which the preview keeps while a hex is half typed.
|
|
155
|
+
const [shownColor, setShownColor] = useState(hex);
|
|
156
|
+
|
|
157
|
+
const trimmed = name.trim();
|
|
158
|
+
const color = hexOf(hex);
|
|
159
|
+
const clashes = taken.some(
|
|
160
|
+
(held) =>
|
|
161
|
+
held.toLowerCase() === trimmed.toLowerCase() &&
|
|
162
|
+
held.toLowerCase() !== editing?.name.toLowerCase(),
|
|
163
|
+
);
|
|
164
|
+
const nameProblem =
|
|
165
|
+
trimmed === ''
|
|
166
|
+
? 'Give the label a name.'
|
|
167
|
+
: clashes
|
|
168
|
+
? `There's a label named ${trimmed} already.`
|
|
169
|
+
: undefined;
|
|
170
|
+
const colorProblem = color === undefined ? 'Use six hex digits, such as d73a4a.' : undefined;
|
|
171
|
+
const label: Label = {
|
|
172
|
+
name: trimmed,
|
|
173
|
+
color: color ?? shownColor,
|
|
174
|
+
description: description.trim() === '' ? null : description.trim(),
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const save = useMutation({
|
|
178
|
+
mutationFn: () =>
|
|
179
|
+
editing === undefined ? createLabel(place, label) : editLabel(place, editing.name, label),
|
|
180
|
+
onSuccess: async (saved) => {
|
|
181
|
+
toast.success(
|
|
182
|
+
editing === undefined ? `Created the label ${saved.name}` : `Saved the label ${saved.name}`,
|
|
183
|
+
);
|
|
184
|
+
onSaved(saved);
|
|
185
|
+
await client.invalidateQueries({ queryKey: vocabularyOf(place).queryKey });
|
|
186
|
+
|
|
187
|
+
// A change shows on every issue and pull request that holds the label, so each is read again.
|
|
188
|
+
if (editing !== undefined)
|
|
189
|
+
await client.invalidateQueries({
|
|
190
|
+
predicate: ({ queryKey: [kind, owner, repo] }) =>
|
|
191
|
+
labelled.has(kind) && owner === place.owner && repo === place.repo,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const pick = (next: string) => {
|
|
197
|
+
setHex(next);
|
|
198
|
+
const full = hexOf(next);
|
|
199
|
+
if (full !== undefined) setShownColor(full);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const submit = (event: FormEvent<HTMLFormElement>) => {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
setTried(true);
|
|
205
|
+
|
|
206
|
+
if (nameProblem !== undefined || colorProblem !== undefined || save.isPending) return;
|
|
207
|
+
|
|
208
|
+
save.mutate();
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
// `min-w-0`: as the Dialog's grid item, the form would otherwise widen to a long name's badge.
|
|
213
|
+
<form noValidate aria-label="Label" onSubmit={submit} className="flex min-w-0 flex-col gap-4">
|
|
214
|
+
<div
|
|
215
|
+
aria-label="Preview"
|
|
216
|
+
role="group"
|
|
217
|
+
className="flex min-h-16 items-center justify-center rounded-lg border bg-muted/50 p-3"
|
|
218
|
+
>
|
|
219
|
+
<LabelBadge large label={{ ...label, name: trimmed === '' ? 'Label preview' : trimmed }} />
|
|
220
|
+
</div>
|
|
221
|
+
<FieldGroup>
|
|
222
|
+
<Field data-invalid={tried && nameProblem !== undefined}>
|
|
223
|
+
<FieldLabel htmlFor="label-name" required>
|
|
224
|
+
Name
|
|
225
|
+
</FieldLabel>
|
|
226
|
+
<Input
|
|
227
|
+
id="label-name"
|
|
228
|
+
required
|
|
229
|
+
autoComplete="off"
|
|
230
|
+
maxLength={longest.name}
|
|
231
|
+
aria-invalid={tried && nameProblem !== undefined}
|
|
232
|
+
value={name}
|
|
233
|
+
onChange={(event) => setName(event.target.value)}
|
|
234
|
+
/>
|
|
235
|
+
{tried && <FieldError>{nameProblem}</FieldError>}
|
|
236
|
+
</Field>
|
|
237
|
+
<Field>
|
|
238
|
+
<FieldLabel htmlFor="label-description">Description</FieldLabel>
|
|
239
|
+
<Input
|
|
240
|
+
id="label-description"
|
|
241
|
+
autoComplete="off"
|
|
242
|
+
maxLength={longest.description}
|
|
243
|
+
value={description}
|
|
244
|
+
onChange={(event) => setDescription(event.target.value)}
|
|
245
|
+
/>
|
|
246
|
+
<FieldDescription>Optional.</FieldDescription>
|
|
247
|
+
</Field>
|
|
248
|
+
<Field data-invalid={colorProblem !== undefined}>
|
|
249
|
+
<FieldLabel htmlFor="label-color" required>
|
|
250
|
+
Color
|
|
251
|
+
</FieldLabel>
|
|
252
|
+
<div role="group" aria-label="Colors" className="grid grid-cols-8 gap-1.5 sm:w-fit">
|
|
253
|
+
{labelSwatches.map((swatch) => (
|
|
254
|
+
<button
|
|
255
|
+
key={swatch}
|
|
256
|
+
type="button"
|
|
257
|
+
aria-label={`#${swatch}`}
|
|
258
|
+
aria-pressed={color === swatch}
|
|
259
|
+
onClick={() => pick(swatch)}
|
|
260
|
+
className={cn(
|
|
261
|
+
'size-7 rounded-md ring-1 ring-foreground/20 outline-none ring-inset focus-visible:ring-3 focus-visible:ring-ring pointer-coarse:size-9',
|
|
262
|
+
color === swatch &&
|
|
263
|
+
'ring-2 ring-foreground ring-offset-2 ring-offset-background ring-inset-0',
|
|
264
|
+
)}
|
|
265
|
+
style={{ backgroundColor: `#${swatch}` }}
|
|
266
|
+
/>
|
|
267
|
+
))}
|
|
268
|
+
</div>
|
|
269
|
+
{/* 12px from the swatches, where the Field's own gap is 8px. */}
|
|
270
|
+
<div className="mt-1 flex items-center gap-2">
|
|
271
|
+
<InputGroup className="w-36">
|
|
272
|
+
<InputGroupAddon>
|
|
273
|
+
<InputGroupText>#</InputGroupText>
|
|
274
|
+
</InputGroupAddon>
|
|
275
|
+
<InputGroupInput
|
|
276
|
+
id="label-color"
|
|
277
|
+
required
|
|
278
|
+
autoComplete="off"
|
|
279
|
+
spellCheck={false}
|
|
280
|
+
maxLength={7}
|
|
281
|
+
aria-invalid={colorProblem !== undefined}
|
|
282
|
+
className="font-mono"
|
|
283
|
+
value={hex}
|
|
284
|
+
onChange={(event) => pick(event.target.value)}
|
|
285
|
+
/>
|
|
286
|
+
</InputGroup>
|
|
287
|
+
<Button type="button" variant="outline" onClick={() => pick(randomColor())}>
|
|
288
|
+
<ShuffleIcon aria-hidden />
|
|
289
|
+
Randomize
|
|
290
|
+
</Button>
|
|
291
|
+
</div>
|
|
292
|
+
<FieldError>{colorProblem}</FieldError>
|
|
293
|
+
</Field>
|
|
294
|
+
</FieldGroup>
|
|
295
|
+
{save.isError && (
|
|
296
|
+
<Alert variant="destructive">
|
|
297
|
+
<AlertDescription>{save.error.message}</AlertDescription>
|
|
298
|
+
</Alert>
|
|
299
|
+
)}
|
|
300
|
+
<DialogFooter>
|
|
301
|
+
<Button type="button" variant="outline" onClick={onCancel}>
|
|
302
|
+
Cancel
|
|
303
|
+
</Button>
|
|
304
|
+
<Button type="submit" disabled={save.isPending}>
|
|
305
|
+
{editing === undefined ? 'Create label' : 'Save changes'}
|
|
306
|
+
</Button>
|
|
307
|
+
</DialogFooter>
|
|
308
|
+
</form>
|
|
309
|
+
);
|
|
310
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { PencilIcon, TagIcon } from 'lucide-react';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
6
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
7
|
+
import { Button } from '../components/ui/button.tsx';
|
|
8
|
+
import {
|
|
9
|
+
Empty,
|
|
10
|
+
EmptyDescription,
|
|
11
|
+
EmptyHeader,
|
|
12
|
+
EmptyMedia,
|
|
13
|
+
EmptyTitle,
|
|
14
|
+
} from '../components/ui/empty.tsx';
|
|
15
|
+
import { Skeleton } from '../components/ui/skeleton.tsx';
|
|
16
|
+
import { useAllowed } from '../hooks/allowed.ts';
|
|
17
|
+
import { vocabularyOf, type Label } from './issues.ts';
|
|
18
|
+
import { LabelDialog } from './label-dialog.tsx';
|
|
19
|
+
import { LabelBadge } from './parts.tsx';
|
|
20
|
+
import { CreateButton } from '../components/create-button.tsx';
|
|
21
|
+
import { ListToolbar } from '../components/list-toolbar.tsx';
|
|
22
|
+
|
|
23
|
+
/** What the page's Dialog is open on: a new label, or one of the repo's being changed. */
|
|
24
|
+
type Open = { readonly editing: Label | undefined } | undefined;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The repo's labels, by name, each with its description: someone the drop-in lets make one gets
|
|
28
|
+
* New label, and someone it lets change one gets each one's Edit. Both open the label's Dialog.
|
|
29
|
+
*/
|
|
30
|
+
export function LabelsPage({ place }: { readonly place: RepoPlace }) {
|
|
31
|
+
const vocabulary = useQuery(vocabularyOf(place));
|
|
32
|
+
const allowed = useAllowed(place);
|
|
33
|
+
const [open, setOpen] = useState<Open>();
|
|
34
|
+
const labels = [...(vocabulary.data?.labels ?? [])].sort((one, other) =>
|
|
35
|
+
one.name.localeCompare(other.name),
|
|
36
|
+
);
|
|
37
|
+
const canEdit = allowed.has('label.update');
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className="flex flex-col gap-3">
|
|
41
|
+
<ListToolbar
|
|
42
|
+
heading={
|
|
43
|
+
<h1 className="text-base font-semibold">
|
|
44
|
+
{vocabulary.data === undefined
|
|
45
|
+
? 'Labels'
|
|
46
|
+
: `${labels.length} ${labels.length === 1 ? 'label' : 'labels'}`}
|
|
47
|
+
</h1>
|
|
48
|
+
}
|
|
49
|
+
buttons={
|
|
50
|
+
allowed.has('label.create') ? (
|
|
51
|
+
<CreateButton onClick={() => setOpen({ editing: undefined })}>New label</CreateButton>
|
|
52
|
+
) : undefined
|
|
53
|
+
}
|
|
54
|
+
/>
|
|
55
|
+
{vocabulary.error !== null ? (
|
|
56
|
+
<Alert variant="destructive">
|
|
57
|
+
<AlertDescription>
|
|
58
|
+
{vocabulary.error.message}. Reload the page to try again.
|
|
59
|
+
</AlertDescription>
|
|
60
|
+
</Alert>
|
|
61
|
+
) : vocabulary.data === undefined ? (
|
|
62
|
+
<Skeleton className="h-40" />
|
|
63
|
+
) : labels.length === 0 ? (
|
|
64
|
+
<Empty>
|
|
65
|
+
<EmptyHeader>
|
|
66
|
+
<EmptyMedia variant="icon">
|
|
67
|
+
<TagIcon />
|
|
68
|
+
</EmptyMedia>
|
|
69
|
+
<EmptyTitle>No labels yet</EmptyTitle>
|
|
70
|
+
<EmptyDescription>
|
|
71
|
+
Labels sort this repository's issues and pull requests.
|
|
72
|
+
</EmptyDescription>
|
|
73
|
+
</EmptyHeader>
|
|
74
|
+
</Empty>
|
|
75
|
+
) : (
|
|
76
|
+
<div className="rounded-lg border">
|
|
77
|
+
<ul aria-label="Labels" className="divide-y">
|
|
78
|
+
{labels.map((label) => (
|
|
79
|
+
<li
|
|
80
|
+
key={label.name}
|
|
81
|
+
className="flex min-h-14 flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2"
|
|
82
|
+
>
|
|
83
|
+
<span className="flex min-w-0 sm:w-1/3">
|
|
84
|
+
<LabelBadge label={label} />
|
|
85
|
+
</span>
|
|
86
|
+
<span className="order-last min-w-0 basis-full text-sm text-muted-foreground sm:order-none sm:basis-0 sm:grow">
|
|
87
|
+
{label.description}
|
|
88
|
+
</span>
|
|
89
|
+
{canEdit && (
|
|
90
|
+
<Button
|
|
91
|
+
variant="ghost"
|
|
92
|
+
size="sm"
|
|
93
|
+
className="ms-auto"
|
|
94
|
+
aria-label={`Edit ${label.name}`}
|
|
95
|
+
onClick={() => setOpen({ editing: label })}
|
|
96
|
+
>
|
|
97
|
+
<PencilIcon aria-hidden />
|
|
98
|
+
Edit
|
|
99
|
+
</Button>
|
|
100
|
+
)}
|
|
101
|
+
</li>
|
|
102
|
+
))}
|
|
103
|
+
</ul>
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
106
|
+
{open !== undefined && (
|
|
107
|
+
<LabelDialog
|
|
108
|
+
place={place}
|
|
109
|
+
editing={open.editing}
|
|
110
|
+
taken={labels.map((label) => label.name)}
|
|
111
|
+
open
|
|
112
|
+
onOpenChange={(next) => {
|
|
113
|
+
if (!next) setOpen(undefined);
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useNavigate } from '@tanstack/react-router';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
6
|
+
import { HotkeyHint, hotkeys } from '../components/hotkeys/hotkeys.tsx';
|
|
7
|
+
import { Alert, AlertDescription } from '../components/ui/alert.tsx';
|
|
8
|
+
import { Button } from '../components/ui/button.tsx';
|
|
9
|
+
import { Field, FieldGroup, FieldLabel } from '../components/ui/field.tsx';
|
|
10
|
+
import { Input } from '../components/ui/input.tsx';
|
|
11
|
+
import { issueHref } from './issue-list.tsx';
|
|
12
|
+
import { createIssue } from './issues.ts';
|
|
13
|
+
import { MarkdownEditor } from '../components/markdown/editor.tsx';
|
|
14
|
+
|
|
15
|
+
/** A new issue's form: its title and text, previewed as it will show. */
|
|
16
|
+
export function NewIssue({ place }: { readonly place: RepoPlace }) {
|
|
17
|
+
const client = useQueryClient();
|
|
18
|
+
const navigate = useNavigate();
|
|
19
|
+
const [title, setTitle] = useState('');
|
|
20
|
+
const [body, setBody] = useState('');
|
|
21
|
+
const created = useMutation({
|
|
22
|
+
mutationFn: () => createIssue(place, { title: title.trim(), body }),
|
|
23
|
+
onSuccess: async (number) => {
|
|
24
|
+
await client.invalidateQueries({ queryKey: ['issues', place.owner, place.repo] });
|
|
25
|
+
await navigate({ href: issueHref(place, number) });
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<form
|
|
31
|
+
aria-label="New issue"
|
|
32
|
+
className="flex flex-col gap-3"
|
|
33
|
+
onSubmit={(event) => {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
|
|
36
|
+
if (title.trim() !== '') created.mutate();
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<FieldGroup>
|
|
40
|
+
<Field>
|
|
41
|
+
<FieldLabel htmlFor="issue-title" required>
|
|
42
|
+
Title
|
|
43
|
+
</FieldLabel>
|
|
44
|
+
<Input
|
|
45
|
+
id="issue-title"
|
|
46
|
+
value={title}
|
|
47
|
+
required
|
|
48
|
+
onChange={(event) => setTitle(event.target.value)}
|
|
49
|
+
/>
|
|
50
|
+
</Field>
|
|
51
|
+
<Field>
|
|
52
|
+
<FieldLabel>Description</FieldLabel>
|
|
53
|
+
<MarkdownEditor
|
|
54
|
+
repo={`${place.owner}/${place.repo}`}
|
|
55
|
+
label="Description"
|
|
56
|
+
value={body}
|
|
57
|
+
onChange={setBody}
|
|
58
|
+
placeholder="Add a description"
|
|
59
|
+
/>
|
|
60
|
+
</Field>
|
|
61
|
+
</FieldGroup>
|
|
62
|
+
<div className="flex justify-end">
|
|
63
|
+
<Button
|
|
64
|
+
type="submit"
|
|
65
|
+
disabled={created.isPending || title.trim() === ''}
|
|
66
|
+
data-hotkey={hotkeys.submit}
|
|
67
|
+
>
|
|
68
|
+
Create issue
|
|
69
|
+
<HotkeyHint keys={hotkeys.submit} />
|
|
70
|
+
</Button>
|
|
71
|
+
</div>
|
|
72
|
+
{created.error !== null && (
|
|
73
|
+
<Alert variant="destructive">
|
|
74
|
+
<AlertDescription>{created.error.message}</AlertDescription>
|
|
75
|
+
</Alert>
|
|
76
|
+
)}
|
|
77
|
+
</form>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CircleSlashIcon } from 'lucide-react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '#/lib/cn';
|
|
4
|
+
|
|
5
|
+
import { Badge } from '../components/ui/badge.tsx';
|
|
6
|
+
import {
|
|
7
|
+
Empty,
|
|
8
|
+
EmptyDescription,
|
|
9
|
+
EmptyHeader,
|
|
10
|
+
EmptyMedia,
|
|
11
|
+
EmptyTitle,
|
|
12
|
+
} from '../components/ui/empty.tsx';
|
|
13
|
+
import type { Label } from './issues.ts';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A label's dot of its colour, at `className`'s size. A faint inner ring keeps a dot as dark or as
|
|
17
|
+
* light as the page in view.
|
|
18
|
+
*/
|
|
19
|
+
export function LabelDot({
|
|
20
|
+
color,
|
|
21
|
+
className,
|
|
22
|
+
}: {
|
|
23
|
+
readonly color: string;
|
|
24
|
+
readonly className: string;
|
|
25
|
+
}) {
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
aria-hidden
|
|
29
|
+
className={cn('shrink-0 rounded-full ring-1 ring-foreground/20 ring-inset', className)}
|
|
30
|
+
style={{ backgroundColor: `#${color}` }}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A label as GitHub draws it: its name beside a dot of its color. `large` draws it bigger than an
|
|
37
|
+
* issue shows it, 28px tall at 14px, as the label Dialog's preview does.
|
|
38
|
+
*/
|
|
39
|
+
export function LabelBadge({
|
|
40
|
+
label,
|
|
41
|
+
large = false,
|
|
42
|
+
}: {
|
|
43
|
+
readonly label: Label;
|
|
44
|
+
readonly large?: boolean;
|
|
45
|
+
}) {
|
|
46
|
+
return (
|
|
47
|
+
<Badge
|
|
48
|
+
variant="outline"
|
|
49
|
+
className={cn('max-w-full', large && 'h-7 gap-1.5 px-3 text-sm')}
|
|
50
|
+
title={label.description ?? undefined}
|
|
51
|
+
>
|
|
52
|
+
<LabelDot color={label.color} className={large ? 'size-2.5' : 'size-2'} />
|
|
53
|
+
<span className="truncate">{label.name}</span>
|
|
54
|
+
</Badge>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** What an issue's page shows when the repo's Issues switch is off. */
|
|
59
|
+
export function IssuesOff() {
|
|
60
|
+
return (
|
|
61
|
+
<Empty>
|
|
62
|
+
<EmptyHeader>
|
|
63
|
+
<EmptyMedia variant="icon">
|
|
64
|
+
<CircleSlashIcon />
|
|
65
|
+
</EmptyMedia>
|
|
66
|
+
<EmptyTitle>Issues are turned off for this repository</EmptyTitle>
|
|
67
|
+
<EmptyDescription>Its settings can turn them back on.</EmptyDescription>
|
|
68
|
+
</EmptyHeader>
|
|
69
|
+
</Empty>
|
|
70
|
+
);
|
|
71
|
+
}
|