History has restore button now.

master
Manager Bot 3 years ago
parent f08a530c9f
commit c154d006e6
  1. 4
      Web/lib/MJB/Web/Controller/Dashboard.pm
  2. 2
      Web/templates/blog/domain_hosted.html.ep
  3. 2
      Web/templates/dashboard/blog_history.html.ep
  4. 25
      libs/MJB-Backend-Jekyll/lib/MJB/Backend/Jekyll.pm

@ -382,11 +382,11 @@ sub do_blog_history ( $c ) {
my ( $old_commit ) = grep { $_->{commit} eq $commit } @{$history};
if ( $old_commit ) {
$jekyll->revert_commit( $commit );
$jekyll->restore_commit( $commit );
$c->sync_blog( $blog );
$c->flash( confirmation => "Undid $commit!" );
$c->flash( confirmation => "Restored from $commit!" );
$c->redirect_to( $c->url_for( 'show_dashboard_blog_history', { id => $blog->id } ) );
}
}

@ -35,7 +35,7 @@
<span class="input-group-text" id="domain-addon-2">.
<select name="hosted_domain_id" class="form-select" aria-label="Select Domain Name">
% foreach my $hosted_domain ( $c->db->hosted_domains->all ) {
<option name="hosted_domain_id" value="<%= $hosted_domain->id %>" <%= $c->stash->{form}->{hdid} == $hosted_domain->id ? 'selected' : '' %>><%= $hosted_domain->name %></option>
<option name="hosted_domain_id" value="<%= $hosted_domain->id %>" <%= $c->stash->{form}->{hdid} && $c->stash->{form}->{hdid} == $hosted_domain->id ? 'selected' : '' %>><%= $hosted_domain->name %></option>
% }
</select>
</span>

@ -21,7 +21,7 @@
<td>
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_dashboard_blog_history' ) %>">
<input type="hidden" name="commit_hash" value="<%= $change->{commit} %>">
<button type="submit" class="btn btn-sm btn-primary">Undo Change</button>
<button type="submit" class="btn btn-sm btn-primary">Restore</button>
</form>
</td>
</tr>

@ -368,6 +368,31 @@ sub revert_commit {
}
sub restore_commit {
my ( $self, $commit ) = @_;
# Check that the repo exists and is latest.
$self->_ensure_repository_is_latest;
# Restore the commit.
$self->system_command( [ qw( git restore --source ), $commit, qw( -W -S --theirs :/ ) ], {
chdir => $self->repo_path,
});
# Restore the commit.
$self->system_command( [ qw( git commit -m ), "Restored from $commit" ], {
chdir => $self->repo_path,
});
# Push the repo to the store server
$self->system_command( [ qw( git push origin master ) ], {
chdir => $self->repo_path,
});
return 1;
}
sub delete_post {
my ( $self, $title, $file ) = @_;

Loading…
Cancel
Save