NewRelease.tsx
| 1 | import type { RepositoryRow } from "../../db/index.ts"; |
| 2 | import type { SessionUser } from "../../middleware/session.ts"; |
| 3 | import { Layout } from "../layout.tsx"; |
| 4 | import { RepoHeader } from "../repos/RepoHeader.tsx"; |
| 5 | import { RepoNav } from "../repos/RepoNav.tsx"; |
| 6 | |
| 7 | interface NewReleaseProps { |
| 8 | user: SessionUser; |
| 9 | repo: RepositoryRow; |
| 10 | error?: string; |
| 11 | values?: { |
| 12 | tag_name?: string; |
| 13 | name?: string; |
| 14 | notes?: string; |
| 15 | commit_hash?: string; |
| 16 | include_source_code?: boolean; |
| 17 | }; |
| 18 | } |
| 19 | |
| 20 | export function NewRelease({ user, repo, error, values }: NewReleaseProps) { |
| 21 | return ( |
| 22 | <Layout user={user} title={`New Release — ${repo.name}`}> |
| 23 | <div class="container"> |
| 24 | <RepoHeader repo={repo} /> |
| 25 | <RepoNav repo={repo} active="releases" user={user} /> |
| 26 | <div class="form-page"> |
| 27 | <h2 class="page-title">New Release</h2> |
| 28 | {error && <div class="flash flash-error">{error}</div>} |
| 29 | <form |
| 30 | method="post" |
| 31 | action={`/${repo.name}/releases`} |
| 32 | enctype="multipart/form-data" |
| 33 | class="form" |
| 34 | > |
| 35 | <div class="form-group"> |
| 36 | <label class="form-label" for="tag_name"> |
| 37 | Tag name <span class="form-required">*</span> |
| 38 | </label> |
| 39 | <input |
| 40 | type="text" |
| 41 | id="tag_name" |
| 42 | name="tag_name" |
| 43 | class="form-input" |
| 44 | required |
| 45 | value={values?.tag_name ?? ""} |
| 46 | placeholder="v1.0.0" |
| 47 | /> |
| 48 | </div> |
| 49 | <div class="form-group"> |
| 50 | <label class="form-label" for="name"> |
| 51 | Release title |
| 52 | </label> |
| 53 | <input |
| 54 | type="text" |
| 55 | id="name" |
| 56 | name="name" |
| 57 | class="form-input" |
| 58 | value={values?.name ?? ""} |
| 59 | placeholder="Optional display name" |
| 60 | /> |
| 61 | </div> |
| 62 | <div class="form-group"> |
| 63 | <label class="form-label" for="commit_hash"> |
| 64 | Commit hash <span class="form-required">*</span> |
| 65 | </label> |
| 66 | <input |
| 67 | type="text" |
| 68 | id="commit_hash" |
| 69 | name="commit_hash" |
| 70 | class="form-input monospace" |
| 71 | required |
| 72 | value={values?.commit_hash ?? ""} |
| 73 | placeholder="Full or abbreviated commit SHA" |
| 74 | /> |
| 75 | </div> |
| 76 | <div class="form-group"> |
| 77 | <label class="form-label" for="notes"> |
| 78 | Release notes |
| 79 | </label> |
| 80 | <textarea |
| 81 | id="notes" |
| 82 | name="notes" |
| 83 | class="form-input form-textarea" |
| 84 | rows="8" |
| 85 | > |
| 86 | {values?.notes ?? ""} |
| 87 | </textarea> |
| 88 | </div> |
| 89 | <div class="form-group"> |
| 90 | <label class="checkbox-label"> |
| 91 | <input |
| 92 | type="checkbox" |
| 93 | name="include_source_code" |
| 94 | value="on" |
| 95 | checked={ |
| 96 | values?.include_source_code ?? false |
| 97 | } |
| 98 | /> |
| 99 | <span> |
| 100 | Include source code archives (zip, tar.gz, |
| 101 | tar.zst) |
| 102 | </span> |
| 103 | </label> |
| 104 | </div> |
| 105 | <div class="form-group"> |
| 106 | <label class="form-label" for="files"> |
| 107 | Attach files |
| 108 | </label> |
| 109 | <input |
| 110 | type="file" |
| 111 | id="files" |
| 112 | name="files" |
| 113 | class="form-input" |
| 114 | multiple |
| 115 | /> |
| 116 | <p class="form-hint"> |
| 117 | You can attach multiple files to this release. |
| 118 | </p> |
| 119 | </div> |
| 120 | <div class="form-actions"> |
| 121 | <button type="submit" class="btn btn-primary"> |
| 122 | Create release |
| 123 | </button> |
| 124 | <a |
| 125 | href={`/${repo.name}/releases`} |
| 126 | class="btn btn-secondary" |
| 127 | > |
| 128 | Cancel |
| 129 | </a> |
| 130 | </div> |
| 131 | </form> |
| 132 | </div> |
| 133 | </div> |
| 134 | </Layout> |
| 135 | ); |
| 136 | } |
| 137 |