setting page
|
1 |
<% |
add create repository tests
|
2 |
# API |
added description changed fe...
|
3 |
my $api = gitprep_api; |
revert encoding support
|
4 |
my $manager = app->manager; |
add create repository tests
|
5 |
|
6 |
# Parameters |
|
added description changed fe...
|
7 |
my $op = param('op') || ''; |
add create repository tests
|
8 |
my $user = param('user') || ''; |
added description changed fe...
|
9 |
|
add create repository tests
|
10 |
# Authentication |
11 |
unless ($api->logined($user)) { |
|
12 |
$self->redirect_to('/'); |
|
cleanup
|
13 |
return; |
14 |
} |
|
added description changed fe...
|
15 |
|
add create repository tests
|
16 |
# Rename project |
revert encoding support
|
17 |
my $git = app->git; |
simplify rename project
|
18 |
my $errors; |
19 |
my $post = lc $self->req->method eq 'post'; |
|
20 |
if ($op eq 'rename-project' && $post) { |
|
added project rename feature
|
21 |
|
22 |
# Validation |
|
23 |
my $params = $api->params; |
|
24 |
my $rule = [ |
|
simplify rename project
|
25 |
'to-project' => [ |
add rename project and suppr...
|
26 |
['not_blank' => 'Repository name is empty.'], |
27 |
['project_name' => 'Repository name contains invalid charactor.'] |
|
added project rename feature
|
28 |
] |
29 |
]; |
|
rename validator to vc to up...
|
30 |
my $vresult = app->vc->validate($params, $rule); |
added project rename feature
|
31 |
|
32 |
if ($vresult->is_ok) { |
|
33 |
# Valida parameters |
|
34 |
my $data = $vresult->data; |
|
simplify rename project
|
35 |
my $to_project = $data->{'to-project'}; |
added project rename feature
|
36 |
|
37 |
# Rename |
|
revert encoding support
|
38 |
if (app->manager->exists_project($user, $to_project)) { |
simplify rename project
|
39 |
$errors = ["$to_project is already exists"]; |
added project rename feature
|
40 |
} |
41 |
else { |
|
revert encoding support
|
42 |
eval { app->manager->rename_project($user, $project, $to_project) }; |
add private checkbox
|
43 |
if (my $e = $@) { |
44 |
app->log->error($e); |
|
simplify rename project
|
45 |
$errors = ['Internal Error']; |
46 |
} |
|
47 |
else { |
|
48 |
flash(message => "Repository name is renamed to $to_project"); |
|
49 |
$self->redirect_to("/$user/$to_project/settings"); |
|
50 |
return; |
|
51 |
} |
|
added project rename feature
|
52 |
} |
53 |
} |
|
simplify rename project
|
54 |
else { $errors = $vresult->messages } |
added project rename feature
|
55 |
} |
add create repository tests
|
56 |
|
57 |
# Change description |
|
simplify rename project
|
58 |
elsif ($op eq 'change-description' && $post) { |
added description changed fe...
|
59 |
my $description = param('description'); |
60 |
$description = '' unless defined $description; |
|
61 |
|
|
simplify rename project
|
62 |
eval { $git->description($user, $project, $description) }; |
add private checkbox
|
63 |
if (my $e = $@) { |
64 |
app->log->error("/$user/$project/settings?op=description: $e"); |
|
simplify rename project
|
65 |
$errors = ['Internal Error']; |
66 |
} |
|
67 |
else { |
|
68 |
flash(message => 'Description is saved.'); |
|
69 |
$self->redirect_to('current'); |
|
70 |
return; |
|
71 |
} |
|
added description changed fe...
|
72 |
} |
add create repository tests
|
73 |
|
added default branch change ...
|
74 |
# Change default branch |
75 |
elsif ($op eq 'default-branch' && $post) { |
|
76 |
my $default_branch = param('default-branch'); |
|
revert encoding support
|
77 |
eval { app->manager->default_branch($user, $project, $default_branch) }; |
add private checkbox
|
78 |
if (my $e = $@) { |
79 |
app->log->error("/$user/$project/settings?op=default-branch: $e"); |
|
added default branch change ...
|
80 |
$errors = ['Internal Error']; |
81 |
} |
|
82 |
else { |
|
83 |
flash(message => "Default branch is changed to $default_branch."); |
|
84 |
$self->redirect_to('current'); |
|
85 |
return; |
|
86 |
} |
|
87 |
} |
|
revert encoding support
|
88 |
|
add private checkbox
|
89 |
# Private repository |
90 |
elsif ($op eq 'private' && $post) { |
|
91 |
my $private = param('private') ? 1 : 0; |
|
92 |
|
|
93 |
eval { |
|
94 |
app->dbi->model('project')->update( |
|
95 |
{private => $private}, |
|
96 |
id => [$user, $project] |
|
97 |
); |
|
98 |
}; |
|
99 |
if (my $e = $@) { |
|
100 |
app->log->error("/$user/$project/settings?op=private: $e"); |
|
101 |
$errors = ['Internal Error']; |
|
102 |
} |
|
103 |
else { |
|
add private repository and c...
|
104 |
my $message = 'Private status is saved. Repository is ' |
105 |
. ($private ? 'private' : 'public'); |
|
106 |
flash(message => $message); |
|
add private checkbox
|
107 |
$self->redirect_to('current'); |
108 |
return; |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
add create repository tests
|
112 |
# Delete project |
simplify rename project
|
113 |
elsif ($op eq 'delete-project' && $post) { |
added project delete feature
|
114 |
|
add delete project test
|
115 |
my $user = param('user'); |
116 |
my $project = param('project'); |
|
117 |
|
|
revert encoding support
|
118 |
eval { app->manager->delete_project($user, $project) }; |
add private checkbox
|
119 |
if (my $e = $@) { |
120 |
app->log->error("/$user/$project/settings: $e"); |
|
add delete project test
|
121 |
$errors = ['Internal Error']; |
122 |
} |
|
123 |
else { |
|
124 |
flash(message => "Repository $project is deleted."); |
|
125 |
$self->redirect_to("/$user"); |
|
126 |
return; |
|
added project delete feature
|
127 |
} |
128 |
} |
|
setting page
|
129 |
%> |
130 | ||
add title
|
131 |
% layout 'common', title => 'Options'; |
setting page
|
132 |
|
added description changed fe...
|
133 |
%= javascript begin |
added project delete feature
|
134 |
|
added description changed fe...
|
135 |
$(document).ready(function () { |
added project delete feature
|
136 |
|
simplify rename project
|
137 |
// Rename project |
added project rename feature
|
138 |
$('#rename').on('click', function () { |
simplify rename project
|
139 |
$('#form-rename-project').submit(); |
added description changed fe...
|
140 |
}); |
141 |
|
|
added default branch change ...
|
142 |
// Select default branch |
143 |
$('[name=default-branch]').on('change', function () { |
|
144 |
$('#form-default-branch').submit(); |
|
145 |
}); |
|
146 | ||
added project delete feature
|
147 |
// Check matching deleted project |
148 |
$('input[name="deleted-project"]').on('keyup', function () { |
|
149 |
var deleted_project = $(this).val(); |
|
150 |
var project = "<%= $project %>"; |
|
151 |
|
|
152 |
if (deleted_project == project) { |
|
153 |
$('#delete').attr('class', 'btn btn-danger') |
|
154 |
.removeAttr('disabled'); |
|
155 |
} |
|
156 |
else { |
|
157 |
$('#delete').attr('class', 'btn btn-danger disabled') |
|
158 |
.attr('disabled', 'disabled'); |
|
159 |
} |
|
160 |
}); |
|
added default branch change ...
|
161 |
|
added project delete feature
|
162 |
// Delete project |
163 |
$('#delete').on('click', function () { |
|
simplify delete project
|
164 |
$('#form-delete-project').submit(); |
added project delete feature
|
165 |
}); |
added description changed fe...
|
166 |
}); |
167 |
% end |
|
168 |
|
|
setting page
|
169 |
%= include '/include/header'; |
170 |
|
|
171 |
<div class="container"> |
|
simplify rename project
|
172 |
%= include '/include/errors', errors => $errors; |
173 |
%= include '/include/message', message => flash('message'); |
|
setting page
|
174 |
%= include '/include/project_header'; |
175 |
|
|
add collaboration page
|
176 |
<div class="row"> |
177 |
<div class="span2"> |
|
178 |
<ul class="unstyled" style="font-size:13px;"> |
|
179 |
<li class="border-gray" style="padding:5px;"><b>Options</b></li> |
|
180 |
<li class="border-gray" style="border-top:none;padding:6px;"><a href="<%= url_for("/$user/$project/settings/collaboration") %>">Collaborators</a></li> |
|
181 |
</ul> |
|
setting page
|
182 |
</div> |
add collaboration page
|
183 |
<div class="span10"> |
184 |
<div style="margin-bottom:20px"> |
|
185 |
<div class="border-gray bk-gray-light radius-top" style="padding-left:5px"> |
|
186 |
<h4> |
|
187 |
Settings |
|
188 |
</h4> |
|
simplify rename project
|
189 |
</div> |
add collaboration page
|
190 |
<div class="border-gray" style="padding:5px 10px;border-top:none"> |
191 |
<form id="form-rename-project" action="<%= url_for->query(op => 'rename-project') %>" method="post" style="margin-bottom:0px"> |
|
192 |
<div >Repository Name</div> |
|
193 |
<div> |
|
194 |
%= text_field 'to-project' => $project, style => 'margin-top:9px'; |
|
195 |
<a href="#rename-confirm" role="button" class="btn" data-toggle="modal"> |
|
196 |
Rename |
|
197 |
</a> |
|
198 |
</div> |
|
199 |
</form> |
|
simplify rename project
|
200 |
</div> |
add collaboration page
|
201 |
<div class="border-gray" style="padding:5px 10px;border-top:none"> |
202 |
<form action="<%= url_for->query(op => 'change-description') %>" method="post" style="margin-bottom:0px"> |
|
203 |
<div >Description</div> |
|
204 |
<div> |
|
205 |
% my $description = $git->description($user, $project); |
|
206 |
% $description = '' unless defined $description; |
|
207 |
%= text_field 'description' => $description, class => 'span8', style => 'margin-top:9px'; |
|
208 |
<input type="submit" class="btn" value="Save"> |
|
209 |
</div> |
|
210 |
</form> |
|
211 |
</div> |
|
revert encoding support
|
212 |
<div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;"> |
add collaboration page
|
213 |
<form id="form-default-branch" action="<%= url_for->query(op => 'default-branch') %>" method="post" style="margin-bottom:0px"> |
214 |
Default Branch |
|
215 |
% my $branches = $git->branches($user, $project); |
|
216 |
% my $branch_names = [map { $_->{name} } @$branches]; |
|
revert encoding support
|
217 |
% my $default_branch = app->manager->default_branch($user, $project); |
add collaboration page
|
218 |
% push @$branch_names, $default_branch unless @$branch_names; |
219 |
% param('default-branch', $default_branch); |
|
220 |
%= select_field 'default-branch' => $branch_names, style => 'margin-top:5px'; |
|
221 |
</form> |
|
222 |
</div> |
|
223 |
<div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;"> |
|
revert encoding support
|
224 |
<form id="form-default-branch" action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px"> |
add collaboration page
|
225 |
<span>Make this repository private</span> |
revert encoding support
|
226 |
% my $private = app->manager->is_private_project($user, $project); |
add collaboration page
|
227 |
% if ($private) { |
228 |
% param('private', 1); |
|
229 |
% } |
|
230 |
%= check_box 'private' => 1, style => 'margin-top:0px;margin-left:5px;margin-right:10px'; |
|
231 |
<input type="submit" class="btn" value="Save"> |
|
232 |
</form> |
|
233 |
</div> |
|
234 |
</div> |
|
235 |
|
|
236 |
<div style="margin-bottom:30px"> |
|
237 |
<div class="border-gray bk-gray-light radius-top" style="background:red;padding-left:5px"> |
|
238 |
<h4 style="color:white">Danger Zone</h4> |
|
239 |
</div> |
|
240 |
<div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none"> |
|
241 |
<form id="form-delete-project" action="<%= url_for->query(op => 'delete-project') %>" method="post"> |
|
242 |
<div><b>Delete this repository</b></div> |
|
243 |
<span class="muted"> |
|
244 |
Once you delete a repository, there is no going back. |
|
245 |
</span> |
|
246 |
<a style="color:red" href="#delete-confirm" role="button" class="btn" data-toggle="modal"> |
|
247 |
Delete this repository |
|
248 |
</a> |
|
249 |
%= hidden_field user => $user; |
|
250 |
%= hidden_field project => $project; |
|
251 |
</form> |
|
252 |
</div> |
|
253 |
</div> |
|
simplify delete project
|
254 |
</div> |
setting page
|
255 |
</div> |
256 |
</div> |
|
257 |
|
|
move project delete feature ...
|
258 |
<div id="modal-message" class="modal hide"> |
added description changed fe...
|
259 |
<div class="modal-header"> |
move project delete feature ...
|
260 |
<div id="modal-message-text" style="font-weight:bold"></div> |
added description changed fe...
|
261 |
</div> |
262 |
<div class="modal-body"> |
|
263 |
<button class="btn" data-dismiss="modal" aria-hidden="true">OK</button> |
|
264 |
</div> |
|
265 |
</div> |
|
added project rename feature
|
266 | |
267 |
<div id="rename-confirm" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="rename-confirm-label" aria-hidden="true"> |
|
268 |
<div class="modal-header"> |
|
revert encoding support
|
269 |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
move project delete feature ...
|
270 |
<div style="font-weight:bold">Are you sure you want to rename?</div> |
added project rename feature
|
271 |
</div> |
272 |
<div class="modal-body"> |
|
273 |
<p> |
|
274 |
Unexpected bad things will happen if you don't read this |
|
275 |
</p> |
|
276 |
<ul> |
|
277 |
<li> |
|
278 |
We will not set up any redirects from the old location |
|
279 |
</li> |
|
280 |
<li> |
|
281 |
You will need to update your local repositories to point to the new location |
|
282 |
</li> |
|
283 |
</ul> |
|
284 |
</div> |
|
285 |
<div class="modal-footer"> |
|
286 |
<button id="rename" class="btn" data-dismiss="modal" aria-hidden="true"> |
|
287 |
I understand, rename this repository |
|
288 |
</button> |
|
289 |
</div> |
|
290 |
</div> |
|
291 | ||
added project delete feature
|
292 |
<div id="delete-confirm" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="delete-confirm-label" aria-hidden="true"> |
293 |
<div class="modal-header"> |
|
revert encoding support
|
294 |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
move project delete feature ...
|
295 |
<div style="font-weight:bold">Are you ABSOLUTELY sure?</div> |
added project delete feature
|
296 |
</div> |
297 |
<div class="modal-body"> |
|
298 |
<p> |
|
299 |
Unexpected bad things will happen if you don't read this. |
|
300 |
</p> |
|
301 |
<p> |
|
302 |
This action <b>CANNOT</b> be undone. This will delete the <b><%= "$user/$project" %></b> |
|
303 |
repository, wiki, issues, and comments permanently. |
|
304 |
</p> |
|
305 |
<p> |
|
306 |
Please type in the name of the repository(<b><%= $project %></b>) to confirm. |
|
307 |
</p> |
|
308 |
%= text_field 'deleted-project', class => 'span5'; |
|
309 |
</div> |
|
310 |
<div class="modal-footer"> |
|
311 |
<button id="delete" class="btn btn-danger disabled" disabled data-dismiss="modal" aria-hidden="true"> |
|
312 |
I understand the consequences, delete this repository |
|
313 |
</button> |
|
314 |
</div> |
|
315 |
</div> |
|
added description changed fe...
|
316 | |
setting page
|
317 |
%= include '/include/footer'; |