gitprep / templates / branches.html.ep /
Newer Older
226 lines | 7.662kb
added Tags link
Yuki Kimoto authored on 2012-11-28
1
<%
added branch status to branc...
Yuki Kimoto authored on 2013-05-06
2

            
added Tags link
Yuki Kimoto authored on 2012-11-28
3
  # API
cleanup
Yuki Kimoto authored on 2013-03-19
4
  my $api = gitprep_api;
added Tags link
Yuki Kimoto authored on 2012-11-28
5

            
cleanup branches page
Yuki Kimoto authored on 2013-01-29
6
  # Parameters
added Tags link
Yuki Kimoto authored on 2012-11-28
7
  my $user = param('user');
cleanup, rename repository t...
Yuki Kimoto authored on 2013-01-29
8
  my $project = param('project');
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
9
  my $op = param('op') || '';
added Tags link
Yuki Kimoto authored on 2012-11-28
10
  
11
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
12
  my $git = $self->app->git;
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
13

            
14
  # Delete
15
  my $errors;
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
16
  if ($op eq 'delete' && lc $self->req->method eq 'post') {
17
    
18
    # Forbbiden
19
    unless ($api->logined($user)) {
20
      $self->redirect_to('/');
21
      return;    
22
    }
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
23

            
24
    # Validation
25
    my $params = $api->params;
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
26
    my $vc = $self->app->vc;
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
27
    my $rule = [
28
      branch => [
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
29
        [not_blank => 'Branch name is empty']
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
30
      ]
31
    ];
rename validator to vc to up...
Yuki Kimoto authored on 2013-12-02
32
    my $vresult = $vc->validate($params, $rule);
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
33

            
34
    if ($vresult->is_ok) {
35
      # Valid parameters
36
      my $params = $vresult->data;
37
      my $branch = $params->{branch};
38
      
39
      # Delete branch
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
40
      eval { $git->delete_branch($user, $project, $branch) };
41
      if ($@) {
42
        app->log->error(url_with . ":$@");
43
        $errors = ['Internal Error'];
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
44
      }
45
      else {
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
46
        $self->flash(message => "Branch $branch is deleted.");
47
        $self->redirect_to;
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
48
        return;
49
      }
50
    }
51
    else { $errors = $vresult->messages }
52
  }
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
53
  
54
  # Default branch
revert encoding support
Yuki Kimoto authored on 2013-11-22
55
  my $base_branch_name = param('base_branch') || app->manager->default_branch($user, $project);
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
56
  my $base_branch = $git->branch($user, $project, $base_branch_name);
57
  
58
  # No merged branches
59
  my $branches = $git->branches($user, $project);
60
  my $max = 0;
61
  for my $branch (@$branches) {
62
    $branch->{status} = $git->branch_status($user, $project, $base_branch->{name}, $branch->{name});
63
    $max = $branch->{status}{ahead} if $max < $branch->{status}{ahead};
64
    $max = $branch->{status}{behind} if $max < $branch->{status}{behind};
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
65
  }
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
66
  my $branches_count = $git->branches_count($user, $project);
67
  my $no_merged_branches_count = $git->no_merged_branches_count($user, $project);
68
  my $merged_branches_count = $branches_count - $no_merged_branches_count - 1;
improved code_menu links
Yuki Kimoto authored on 2013-05-11
69
  
70
  # Global variable
71
  stash(rev => $base_branch_name);
added Tags link
Yuki Kimoto authored on 2012-11-28
72
%>
73

            
add title
Yuki Kimoto authored on 2013-06-12
74
% layout 'common', title => "branches  \x{30fb} $user/$project";
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
75

            
76
  %= javascript begin
77
    $('document').ready(function () {
78
      
79
      // Swich merged branch or not merged branch
80
      var display_no_merged = true;
81
      $('#toggle-branch').on('click', function () {
82
        if (display_no_merged) {
83
          $(this).text('View unmerged branches');
84
          $('#no-merged-branch-message').hide();
85
          $('#merged-branch-message').show();
86
          $('.no-merged-branch').css('display', 'none');
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
87
          $('.merged-branch').css('display', 'block');
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
88
        }
89
        else {
90
          $(this).text('View merged branches');
91
          $('#no-merged-branch-message').show();
92
          $('#merged-branch-message').hide();
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
93
          $('.no-merged-branch').css('display', 'block');
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
94
          $('.merged-branch').css('display', 'none');
95
        }
96
        display_no_merged = !display_no_merged;
97
      });
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
98
      
99
      // Click delete button
100
      $('.delete-branch').on('click', function () {
101
        if (window.confirm('Are you sure you want to remove this branch?')) {
102
          return true;
103
        }
104
        else {
105
          return false;
106
        }
107
      });
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
108
    });
109
  % end
design branches page
Yuki Kimoto authored on 2012-12-06
110
  
cleanup
Yuki Kimoto authored on 2013-01-28
111
  %= include '/include/header';
cleanup
Yuki Kimoto authored on 2013-03-15
112
  
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
113
  <div class="container" style="padding-bottom:30px">
fix branch not deleted bug a...
Yuki Kimoto authored on 2013-05-29
114
    %= include '/include/errors', errors => $errors;
115
    %= include '/include/message', message => flash('message');
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
116
    
cleanup branches page
Yuki Kimoto authored on 2013-03-15
117
    %= include '/include/project_header';
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
118
    %= include '/include/code_menu', display => 'branches', branches => $branches;
design branches page
Yuki Kimoto authored on 2012-12-06
119
    
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
120
    <h3 style="font-size:19px">Branches</h3>
design branches page
Yuki Kimoto authored on 2012-12-06
121
    
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
122
    <div style="margin-bottom:10px">
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
123
      Showing
124
      <span id="no-merged-branch-message">
125
         <%= $no_merged_branches_count %> branches not merged
126
      </span>
127
      <span style="display:none" id="merged-branch-message">
128
        <%= $merged_branches_count %> branches merged
129
      </span>
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
130
      into <%= $base_branch->{name} %>.
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
131
      <a id="toggle-branch" href="#">View merged branches</a>
cleanup branches page
Yuki Kimoto authored on 2013-03-15
132
    </div>
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
133
    <div class="bk-black" style="padding:5px 10px">
cleanup
Yuki Kimoto authored on 2013-03-15
134
      <div class="row">
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
135
        <div class="span8" style="line-height:1.2em">
136
          <div style="color:white;font-size:16px;">
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
137
            <b><%= $base_branch->{name} %></b>
cleanup branches page
Yuki Kimoto authored on 2013-03-15
138
          </div>
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
139
          <div class="muted" style="font-size:12px">
cleanup
Yuki Kimoto authored on 2013-03-15
140
            Last updated
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
141
            <span title="<%= $base_branch->{commit}{age_string_datetime} %>">
142
              <%= $base_branch->{commit}{age_string} %>
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
143
            </span>
cleanup
Yuki Kimoto authored on 2013-03-15
144
            by
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
145
            <span title="<%= $base_branch->{commit}{author_email} %>" style="color:white">
146
              <%= $base_branch->{commit}{author_name} %>
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
147
            </span>
cleanup branches page
Yuki Kimoto authored on 2013-03-15
148
          </div>
149
        </div>
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
150
        <div class="text-right font-white" style="padding-top:6px">
cleanup
Yuki Kimoto authored on 2013-03-15
151
          Base branch
152
        </div>
cleanup branches page
Yuki Kimoto authored on 2013-03-15
153
      </div>
154
    </div>
155
    % for (my $i = 0; $i < @$branches; $i++) {
156
      % my $branch = $branches->[$i];
fixed branch page bug
Yuki Kimoto authored on 2013-04-18
157
      % my $bname = $branch->{name};
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
158
      % next if $bname eq $base_branch->{name};
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
159
      <div class="<%= $branch->{no_merged} ? 'no-merged-branch' : 'merged-branch' %> border-bottom-gray" style="padding:10px 0px 5px 0px;<%= $branch->{no_merged} ? '' : 'display:none' %>">
cleanup
Yuki Kimoto authored on 2013-03-15
160
        <div class="row">
added branch status to branc...
Yuki Kimoto authored on 2013-05-06
161
          <div class="span5" style="line-height:1.2em">
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
162
            <div style="font-size:16px;">
fixed branch page bug
Yuki Kimoto authored on 2013-04-18
163
              <a href="<%= url_for("/$user/$project/tree/$bname") %>">
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
164
                <b><%= $bname %></b>
design branches page
Yuki Kimoto authored on 2012-12-06
165
              </a>
166
            </div>
improved branches page desig...
Yuki Kimoto authored on 2013-05-06
167
            <div style="font-size:12px">
cleanup
Yuki Kimoto authored on 2013-03-15
168
              Last updated
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
169
              <span title="<%= $branch->{commit}{age_string_datetime} %>">
170
                <%= $branch->{commit}{age_string} %>
171
              </span>
cleanup
Yuki Kimoto authored on 2013-03-15
172
              by
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
173
              <span title="<%= $branch->{commit}{author_email} %>">
174
                <%= $branch->{commit}{author_name} %>
175
              </span>
cleanup
Yuki Kimoto authored on 2013-03-15
176
            </div>
177
          </div>
added branch status to branc...
Yuki Kimoto authored on 2013-05-06
178
          <div class="span3 muted" style="line-height:1em;font-size:11px">
179
            <table>
180
              <tr>
181
                <td>
182
                </td>
183
                <td style="background:#333">
184
                </td>
185
                <td style="padding-left:3px">
186
                  <%= $branch->{status}{ahead} %> ahead
187
                </td>
188
              </tr>
189
              <tr>
190
                <td style="width:100px">
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
191
                  <div style="margin-left:auto;margin-right:0;background:#b2d0dd;width:<%= $max != 0 ? 100 * ($branch->{status}{behind} / $max) : 0 %>%;height:8px"></div>
added branch status to branc...
Yuki Kimoto authored on 2013-05-06
192
                </td>
193
                <td style="background:#333">
194
                </td>
195
                <td style="width:100px">
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
196
                  <div style="background:#b2d0dd;width:<%= $max != 0 ? 100 * ($branch->{status}{ahead} / $max) : 0 %>%;height:8px"></div>
added branch status to branc...
Yuki Kimoto authored on 2013-05-06
197
                </td>
198
              </tr>
199
              <tr>
200
                <td>
201
                  <%= $branch->{status}{behind} %> behind
202
                </td>
203
                <td style="background:#333">
204
                </td>
205
                <td>
206
                </td>
207
              </tr>
208
            </table>
209
          </div>
210
          <div class="span4 text-right" style="padding-top:0px">
added branch deleting featur...
Yuki Kimoto authored on 2013-05-05
211
            % if ($api->logined($user)) {
212
              <form action="<%= url_for->query(op => 'delete') %>" method="post" style="display:inline-block">
213
                <input type="submit" class="btn delete-branch" style="color:#900;" value="Delete branch">
214
                %= hidden_field branch => $bname;
215
              </form>
216
            % }
added change base branch fea...
Yuki Kimoto authored on 2013-05-11
217
            <a class="btn" href="<%= url_for("/$user/$project/compare/$base_branch->{name}...$bname") %>">
cleanup
Yuki Kimoto authored on 2013-03-15
218
              Compare
219
            </a>
cleanup branches page
Yuki Kimoto authored on 2013-03-15
220
          </div>
221
        </div>
222
      </div>
223
    % }
added branches link
Yuki Kimoto authored on 2012-11-28
224
  </div>
design branches page
Yuki Kimoto authored on 2012-12-06
225
  
226
  %= include '/include/footer';