Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Merge 0bf2c3c into 769302a
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Dec 2, 2017
2 parents 769302a + 0bf2c3c commit 7079221
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 109 deletions.
17 changes: 11 additions & 6 deletions src/AppContext/Domain/Entity/Inspection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class Inspection
private $status;
private $repository;
private $number;
/** @var \DateTime */
private $createdAt;
private $startedAt;
/** @var \DateTimeInterface|null */
private $finishedAt;
private $type;
private $base;
Expand Down Expand Up @@ -91,19 +92,23 @@ public function getStatus(): string
return $this->status;
}

public function getCreatedAt(): \DateTimeInterface
public function createdAt(): \DateTimeInterface
{
return $this->createdAt;
}

public function getStartedAt(): ?\DateTimeInterface
public function finished(): bool
{
return $this->startedAt;
return $this->finishedAt !== null;
}

public function getFinishedAt(): ?\DateTimeInterface
public function duration(): int
{
return $this->finishedAt;
if (!$this->finished()) {
throw new \LogicException('The inspection is not finished');
}

return $this->finishedAt->getTimestamp() - $this->createdAt->getTimestamp();
}

public function getHead(): string
Expand Down
3 changes: 0 additions & 3 deletions src/AppContext/Domain/Entity/config/Inspection.orm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ Regis\AppContext\Domain\Entity\Inspection:
column: build_number
createdAt:
type: datetimetz
startedAt:
type: datetimetz
nullable: true
finishedAt:
type: datetimetz
nullable: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public function detailAction(string $id)
]);
}

public function configurationAction(Entity\Repository $repository)
{
// TODO check access rights

return $this->render('@RegisApp/Repositories/configuration.html.twig', [
'repository' => $repository,
]);
}

public function setupWebhookAction(Entity\Repository $repository)
{
// TODO check access rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('logs.yml');
$loader->load('remote.yml');
$loader->load('repositories.yml');
$loader->load('twig.yml');
$loader->load('security.yml');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ repositories_detail:
defaults: { _controller: RegisAppBundle:Repositories:detail }
methods: GET

repositories_config:
path: /repositories/{id}/config
defaults: { _controller: RegisAppBundle:Repositories:configuration }
methods: GET

repositories_setup_webhook:
path: /repositories/{id}/webhook/setup
defaults: { _controller: RegisAppBundle:Repositories:setupWebhook }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
regis.twig_extension.date:
class: Regis\AppContext\Infrastructure\Symfony\Twig\DurationExtension
public: false
tags:
- { name: twig.extension }
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

<div class="table-responsive">
<table class="table table-striped table-hover">
<tr>
<th>Created at</th>
<td>
{{ inspection.createdAt|date }}
</td>
</tr>
<tr>
<th>Base</th>
<td><code>{{ inspection.base }}</code></td>
Expand All @@ -24,20 +18,16 @@
<td><code>{{ inspection.head }}</code></td>
</tr>
<tr>
<th>Started at</th>
<th>Created at</th>
<td>
{% if inspection.startedAt %}
{{ inspection.startedAt|date }}
{% else %}
-
{% endif %}
{{ inspection.createdAt|date }}
</td>
</tr>
<tr>
<th>Finished at</th>
<th>Duration</th>
<td>
{% if inspection.finishedAt %}
{{ inspection.finishedAt|date }}
{% if inspection.finished %}
{{ inspection.duration|duration}}
{% else %}
-
{% endif %}
Expand All @@ -60,7 +50,7 @@
<tr>
<th>Actions</th>
<td>
{% if inspection.status == 'failed' or inspection.status == 'finished' %}
{% if inspection.finished %}
<form method="POST" action="{{ path('inspection_retry', {'id': inspection.id}) }}">
<input type="submit" class="btn btn-warning btn-sm" value="Retry" />
</form>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="alert alert-warning" role="alert">
<p>
<b>This repository is in flight mode.</b>
</p>

<p>
Pull requests will still be inspected and the results will be available
using this interface but Regis will not send any comment to {{ repository.type }}.<br />
Usually, this mode is useful during the set-up phase and can be dismissed
after: it allows to configure Regis without bothering your teammates
with CI failures caused by a misconfiguration.
</p>

{% if is_granted('COMMAND_REPOSITORY::DISABLE_FLIGHT_MODE', repository) %}
<p>
<form method="POST" action="{{ path('repositories_disable_flight_mode', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Disable flight mode" />
</form>
</p>
{% endif %}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% extends '::layout.html.twig' %}

{% import '::utils.html.twig' as utils %}

{% block content %}
<h1 class="page-header">« {{ repository.name }} »</h1>

{% if repository.flightModeEnabled %}
{% include 'RegisAppBundle:Repositories:_flight_mode_notification.html.twig' %}
{% endif %}

<h2>Configuration</h2>

<div class="table-responsive">
<table class="table table-striped table-hover">
<tr>
<th>Type</th>
<td><span class="label label-primary">{{ utils.repository_type(repository) }}</span></td>
</tr>
<tr>
<th>Remote identifier</th>
<td><code>{{ repository.identifier }}</code></td>
</tr>
<tr>
<th>Shared secret</th>
<td><code>{{ repository.sharedSecret }}</code></td>
</tr>
<tr>
<th>Webhook URL</th>
<td><code>{{ url(repository.type~'_webhook') }}</code></td>
</tr>
<tr>
<th>Actions</th>
<td>
<form method="POST" action="{{ path('repositories_setup_webhook', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Setup webhook" />
</form>
{% if is_granted('COMMAND_REPOSITORY::ENABLE_INSPECTIONS', repository) or is_granted('COMMAND_REPOSITORY::DISABLE_INSPECTIONS', repository) %}
{% if repository.inspectionEnabled %}
<form method="POST" action="{{ path('repositories_disable_inspections', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Disable inspections" />
</form>
{% else %}
<form method="POST" action="{{ path('repositories_enable_inspections', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-primary btn-sm" value="Enable inspections" />
</form>
{% endif %}
{% endif %}

{% if is_granted('COMMAND_REPOSITORY::ENABLE_FLIGHT_MODE', repository) or is_granted('COMMAND_REPOSITORY::DISABLE_FLIGHT_MODE', repository) %}
{% if repository.flightModeEnabled %}
<form method="POST" action="{{ path('repositories_disable_flight_mode', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Disable flight mode" />
</form>
{% else %}
<form method="POST" action="{{ path('repositories_enable_flight_mode', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-primary btn-sm" value="Enable flight mode" />
</form>
{% endif %}
{% endif %}
</td>
</tr>
</table>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,15 @@
{% import '::utils.html.twig' as utils %}

{% block content %}
<h1 class="page-header">« {{ repository.name }} »</h1>

<h2>Configuration</h2>

<div class="table-responsive">
<table class="table table-striped table-hover">
<tr>
<th>Remote identifier</th>
<td><code>{{ repository.identifier }}</code></td>
</tr>
<tr>
<th>Shared secret</th>
<td><code>{{ repository.sharedSecret }}</code></td>
</tr>
<tr>
<th>Webhook URL</th>
<td><code>{{ url(repository.type~'_webhook') }}</code></td>
</tr>
<tr>
<th>Actions</th>
<td>
<form method="POST" action="{{ path('repositories_setup_webhook', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Setup webhook" />
</form>
{% if is_granted('COMMAND_REPOSITORY::ENABLE_INSPECTIONS', repository) or is_granted('COMMAND_REPOSITORY::DISABLE_INSPECTIONS', repository) %}
{% if repository.inspectionEnabled %}
<form method="POST" action="{{ path('repositories_disable_inspections', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Disable inspections" />
</form>
{% else %}
<form method="POST" action="{{ path('repositories_enable_inspections', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-primary btn-sm" value="Enable inspections" />
</form>
{% endif %}
{% endif %}

{% if is_granted('COMMAND_REPOSITORY::ENABLE_FLIGHT_MODE', repository) or is_granted('COMMAND_REPOSITORY::DISABLE_FLIGHT_MODE', repository) %}
{% if repository.flightModeEnabled %}
<form method="POST" action="{{ path('repositories_disable_flight_mode', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Disable flight mode" />
</form>
{% else %}
<form method="POST" action="{{ path('repositories_enable_flight_mode', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-primary btn-sm" value="Enable flight mode" />
</form>
{% endif %}
{% endif %}
</td>
</tr>
</table>
</div>
<h1 class="page-header">
« {{ repository.name }} »
<a href="{{ path('repositories_config', {id: repository.id}) }}" class="btn btn-default pull-right">
<i class="glyphicon glyphicon-cog"></i>
</a>
</h1>

{% if repository.flightModeEnabled %}
<div class="alert alert-warning" role="alert">
<p>
<b>This repository is in flight mode.</b>
</p>

<p>
Pull requests will still be inspected and the results will be available
using this interface but Regis will not send any comment to {{ repository.type }}.<br />
Usually, this mode is useful during the set-up phase and can be dismissed
after: it allows to configure Regis without bothering your teammates
with CI failures caused by a misconfiguration.
</p>

{% if is_granted('COMMAND_REPOSITORY::DISABLE_FLIGHT_MODE', repository) %}
<p>
<form method="POST" action="{{ path('repositories_disable_flight_mode', {'id': repository.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Disable flight mode" />
</form>
</p>
{% endif %}
</div>
{% include 'RegisAppBundle:Repositories:_flight_mode_notification.html.twig' %}
{% endif %}

<h2>Inspections</h2>
Expand All @@ -87,8 +22,7 @@
<tr>
<th>#</th>
<th>Created at</th>
<th>Started at</th>
<th>Finished at</th>
<th>Duration</th>
<th>Status</th>
<th>Result</th>
<th>Action</th>
Expand All @@ -103,15 +37,8 @@
</td>
<td>{{ inspection.createdAt|date }}</td>
<td>
{% if inspection.startedAt %}
{{ inspection.startedAt|date }}
{% else %}
-
{% endif %}
</td>
<td>
{% if inspection.finishedAt %}
{{ inspection.finishedAt|date }}
{% if inspection.finished %}
{{ inspection.duration|duration }}
{% else %}
-
{% endif %}
Expand All @@ -127,7 +54,7 @@
{% endif %}
</td>
<td>
{% if inspection.status == 'failed' or inspection.status == 'finished' %}
{% if inspection.finished %}
<form method="POST" action="{{ path('inspection_retry', {'id': inspection.id}) }}" class="force-inline">
<input type="submit" class="btn btn-warning btn-sm" value="Retry" />
</form>
Expand Down
Loading

0 comments on commit 7079221

Please sign in to comment.