main
erb 107 lines 5.7 KB
Raw
1 <% content_for :title, "New repository" %>
2
3 <div class="max-w-2xl mx-auto px-4 sm:px-6 py-12">
4 <h1 class="text-xl font-semibold text-gray-100 mb-2">Create a new repository</h1>
5 <p class="text-sm text-gray-400 mb-8">All your files and their history, in one place.</p>
6
7 <%= form_with model: @repository, url: "/new", method: :post, class: "space-y-6" do |f| %>
8 <%# ── Repository type ── %>
9 <div>
10 <label class="form-label mb-2">Type</label>
11 <div class="grid grid-cols-2 gap-3">
12 <label class="card px-4 py-3 cursor-pointer hover:border-surface-400 flex items-start gap-3">
13 <%= f.radio_button :kind, "code", class: "mt-0.5", checked: @repository.code? %>
14 <div>
15 <div class="flex items-center gap-1.5 text-sm font-medium text-gray-100">
16 <svg class="w-4 h-4 text-gray-400" viewBox="0 0 16 16" fill="currentColor"><path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Z"/></svg>
17 Code
18 </div>
19 <p class="text-xs text-gray-400 mt-0.5">Source code with full git history.</p>
20 </div>
21 </label>
22 <label class="card px-4 py-3 cursor-pointer hover:border-surface-400 flex items-start gap-3">
23 <%= f.radio_button :kind, "model", class: "mt-0.5", checked: @repository.model? %>
24 <div>
25 <div class="flex items-center gap-1.5 text-sm font-medium text-gray-100">
26 <svg class="w-4 h-4 text-brand-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.27 6.96 8.73 5.05 8.73-5.05M12 22.08V12"/></svg>
27 Model
28 </div>
29 <p class="text-xs text-gray-400 mt-0.5">Open weights with a model card &amp; LFS files.</p>
30 </div>
31 </label>
32 </div>
33 </div>
34
35 <% if @repository.errors.any? %>
36 <div class="border border-red-800/40 bg-red-900/20 rounded px-4 py-3">
37 <p class="text-sm font-medium text-red-300 mb-1">Please fix the following errors:</p>
38 <ul class="list-disc pl-4 space-y-0.5">
39 <% @repository.errors.full_messages.each do |msg| %>
40 <li class="text-sm text-red-400"><%= msg %></li>
41 <% end %>
42 </ul>
43 </div>
44 <% end %>
45
46 <div class="flex items-end gap-2">
47 <div class="flex-1 min-w-0">
48 <label class="form-label">Owner</label>
49 <div class="flex items-center gap-2 form-input bg-surface-700 text-gray-400 cursor-not-allowed">
50 <img src="<%= current_user.avatar_url_or_default %>" class="w-4 h-4 rounded-full">
51 <span><%= current_user.username %></span>
52 </div>
53 </div>
54 <div class="flex items-center pb-2.5 text-gray-500 font-light text-lg">/</div>
55 <div class="flex-1 min-w-0">
56 <%= f.label :name, "Repository name", class: "form-label" %>
57 <%= f.text_field :name, class: "form-input", placeholder: "my-project", autofocus: true,
58 pattern: "[a-zA-Z0-9._-]+",
59 title: "Letters, numbers, hyphens, underscores, and dots only" %>
60 </div>
61 </div>
62
63 <div>
64 <%= f.label :description, "Description", class: "form-label" %>
65 <span class="text-xs text-gray-500 ml-1">(optional)</span>
66 <%= f.text_area :description, class: "form-input", rows: 2,
67 placeholder: "Short description of your project" %>
68 </div>
69
70 <div class="border border-surface-500 rounded divide-y divide-surface-600">
71 <label class="flex items-start gap-3 px-4 py-3 cursor-pointer hover:bg-surface-600">
72 <%= f.radio_button :is_private, false, class: "mt-0.5" %>
73 <div>
74 <div class="flex items-center gap-2">
75 <svg class="w-4 h-4 text-gray-400" viewBox="0 0 16 16" fill="currentColor">
76 <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8Z"/>
77 </svg>
78 <span class="text-sm font-medium text-gray-100">Public</span>
79 </div>
80 <p class="text-xs text-gray-400 mt-0.5">Anyone can see this repository.</p>
81 </div>
82 </label>
83 <label class="flex items-start gap-3 px-4 py-3 cursor-pointer hover:bg-surface-600">
84 <%= f.radio_button :is_private, true, class: "mt-0.5" %>
85 <div>
86 <div class="flex items-center gap-2">
87 <svg class="w-4 h-4 text-gray-400" viewBox="0 0 16 16" fill="currentColor">
88 <path d="M4 4a4 4 0 0 1 8 0v2h.25c.966 0 1.75.784 1.75 1.75v5.5A1.75 1.75 0 0 1 12.25 15h-8.5A1.75 1.75 0 0 1 2 13.25v-5.5C2 6.784 2.784 6 3.75 6H4Zm8.25 3.5h-8.5a.25.25 0 0 0-.25.25v5.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25v-5.5a.25.25 0 0 0-.25-.25ZM10.5 6V4a2.5 2.5 0 1 0-5 0v2Z"/>
89 </svg>
90 <span class="text-sm font-medium text-gray-100">Private</span>
91 </div>
92 <p class="text-xs text-gray-400 mt-0.5">Only you can see this repository.</p>
93 </div>
94 </label>
95 </div>
96
97 <div>
98 <%= f.label :default_branch, "Default branch", class: "form-label" %>
99 <%= f.text_field :default_branch, class: "form-input max-w-xs", value: "main" %>
100 </div>
101
102 <div class="pt-2 border-t border-surface-600 flex items-center gap-3">
103 <%= f.submit "Create repository", class: "btn-primary cursor-pointer" %>
104 <%= link_to "Cancel", root_path, class: "btn-ghost" %>
105 </div>
106 <% end %>
107 </div>