Skip to content

Commit

Permalink
Clean up UI on main page to use links instead of buttons https://www.…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Jan 8, 2017
1 parent 988671d commit 5c3e787
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 50 deletions.
66 changes: 24 additions & 42 deletions delete.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,37 @@ require './virtualmin-git-lib.pl';
&ReadParse();

# Get the domain and repository
my ($repdom) = grep { $_ ne "confirm" && $_ ne "show" } (keys %in);
my $repdom = $in{'rep'};
my ($repname, $id) = split(/\@/, $repdom);
my $dom = &virtual_server::get_domain($id);
&can_edit_domain($dom) || &error($text{'add_edom'});
my @reps = &list_reps($dom);
my ($rep) = grep { $_->{'rep'} eq $repname } @reps;
$rep || &error($text{'delete_erep'});

my $button = $in{$repdom};
if ($button eq &entities_to_ascii($text{'delete'})) {
# Deleting repo
if ($in{'confirm'}) {
# Do it!
&delete_rep($dom, $rep);
&webmin_log("delete", "repo", $repname,
{ 'dom' => $dom->{'dom'} });
&redirect("index.cgi?show=$in{'show'}");
}
else {
# Ask first
&ui_print_header(&virtual_server::domain_in($dom),
$text{'delete_title'}, "");

print "<center>\n";
my $size = &disk_usage_kb($rep->{'dir'});
print &ui_form_start("delete.cgi");
print &ui_hidden($repdom, $in{$repdom});
print &ui_hidden("show", $in{'show'});
print &text('delete_rusure', "<tt>$repname</tt>",
&nice_size($size*1024)),"<p>\n";
print &ui_form_end([ [ "confirm", $text{'delete_ok'} ] ]);
print "</center>\n";

&ui_print_footer("index.cgi?show=$in{'show'}",
$text{'index_return'});
}
}
elsif ($button eq &entities_to_ascii($text{'index_browse'})) {
# Redirect to gitweb
my $proto = $dom->{'ssl'} ? "https" : "http";
&redirect("$proto://$dom->{'dom'}/git/gitweb.cgi?p=".
&urlize("$rep->{'rep'}.git"));
}
elsif ($button eq &entities_to_ascii($text{'index_help'})) {
# Redirect to help page
&redirect("help.cgi?dom=$dom->{'id'}&rep=".&urlize($rep->{'rep'}).
"&show=".&urlize($in{'show'}));
if ($in{'confirm'}) {
# Do it!
&delete_rep($dom, $rep);
&webmin_log("delete", "repo", $repname,
{ 'dom' => $dom->{'dom'} });
&redirect("index.cgi?show=$in{'show'}");
}
else {
&error($text{'delete_emode'});
}
# Ask first
&ui_print_header(&virtual_server::domain_in($dom),
$text{'delete_title'}, "");

print "<center>\n";
my $size = &disk_usage_kb($rep->{'dir'});
print &ui_form_start("delete.cgi");
print &ui_hidden("rep", $repdom);
print &ui_hidden("action", "delete");
print &ui_hidden("show", $in{'show'});
print &text('delete_rusure', "<tt>$repname</tt>",
&nice_size($size*1024)),"<p>\n";
print &ui_form_end([ [ "confirm", $text{'delete_ok'} ] ]);
print "</center>\n";

&ui_print_footer("index.cgi?show=$in{'show'}",
$text{'index_return'});
}
15 changes: 7 additions & 8 deletions index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,16 @@ foreach my $r (@reps) {
my $proto = $r->{'dom'}->{'ssl'} ? "https" : "http";
my $url = "$proto://$r->{'dom'}->{'dom'}/git/gitweb.cgi?p=".
&urlize("$r->{'rep'}.git");
my $ur = &urlize($r->{'rep'}."\@".$r->{'dom'}->{'id'});
my @actions = (
&ui_submit($text{'delete'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}),
&ui_submit($text{'index_browse'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}, 0,
"onClick='window.open(\"$url\"); return false;'"),
&ui_submit($text{'index_help'},
$r->{'rep'}."\@".$r->{'dom'}->{'id'}),
&ui_link("delete.cgi?show=$in{'show'}&rep=".$ur,
$text{'delete'}),
&ui_link($url, $text{'index_browse'}, undef, "target=_blank"),
&ui_link("help.cgi?show=$in{'show'}&dom=$r->{'dom'}->{'id'}&".
"rep=$r->{'rep'}", $text{'index_help'}),
);
push(@table, [ $r->{'rep'}, $showd ? ( ) : ( $dom ),
$r->{'desc'}, $r->{'dir'}, join(" ", @actions) ]);
$r->{'desc'}, $r->{'dir'}, &ui_links_row(\@actions) ]);
}

# Show table of repos
Expand Down

0 comments on commit 5c3e787

Please sign in to comment.