-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cda7b07
commit 1bc1496
Showing
91 changed files
with
1,825 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.repository-branch-list { | ||
.col-create-branch { | ||
width: 200px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230517064259 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql( | ||
'ALTER TABLE code_review ADD type ENUM(\'commits\', \'branch\') DEFAULT \'commits\' NOT NULL AFTER `description`' | ||
); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE code_review DROP type'); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/Controller/App/Review/CreateBranchReviewController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace DR\Review\Controller\App\Review; | ||
|
||
use DR\Review\Controller\AbstractController; | ||
use DR\Review\Doctrine\Type\CodeReviewType; | ||
use DR\Review\Entity\Repository\Repository; | ||
use DR\Review\Message\Review\ReviewCreated; | ||
use DR\Review\Repository\Review\CodeReviewRepository; | ||
use DR\Review\Security\Role\Roles; | ||
use DR\Review\Service\CodeReview\CodeReviewCreationService; | ||
use DR\Review\Service\CodeReview\CodeReviewRevisionService; | ||
use DR\Review\Utility\Arrays; | ||
use Symfony\Bridge\Doctrine\Attribute\MapEntity; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
use Throwable; | ||
|
||
class CreateBranchReviewController extends AbstractController | ||
{ | ||
public function __construct( | ||
private readonly CodeReviewCreationService $reviewCreationService, | ||
private readonly CodeReviewRevisionService $revisionService, | ||
private readonly CodeReviewRepository $reviewRepository, | ||
private readonly MessageBusInterface $messageBus, | ||
) { | ||
} | ||
|
||
/** | ||
* @throws Throwable | ||
*/ | ||
#[Route('app/review/{repositoryId<\d+>}/branch-review', name: self::class, methods: 'POST')] | ||
#[IsGranted(Roles::ROLE_USER)] | ||
public function __invoke(Request $request, #[MapEntity(expr: 'repository.find(repositoryId)')] Repository $repository): Response | ||
{ | ||
$branchName = (string)$request->request->get('branch', ''); | ||
if (trim($branchName) === '') { | ||
throw new BadRequestHttpException('Branch request property is mandatory'); | ||
} | ||
|
||
$review = $this->reviewRepository->findOneBy(['repository' => $repository, 'type' => CodeReviewType::BRANCH, 'referenceId' => $branchName]); | ||
if ($review !== null) { | ||
return $this->redirectToRoute(ReviewController::class, ['review' => $review]); | ||
} | ||
|
||
$review = $this->reviewCreationService->createFromBranch($repository, $branchName); | ||
$revision = Arrays::lastOrNull($this->revisionService->getRevisions($review)); | ||
$this->reviewRepository->save($review, true); | ||
|
||
$this->messageBus->dispatch(new ReviewCreated((int)$review->getId(), (int)$revision?->getId(), $this->getUser()->getId())); | ||
|
||
return $this->redirectToRoute(ReviewController::class, ['review' => $review]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace DR\Review\Doctrine\Type; | ||
|
||
class CodeReviewType extends AbstractEnumType | ||
{ | ||
public const COMMITS = 'commits'; | ||
public const BRANCH = 'branch'; | ||
|
||
public const TYPE = 'enum_code_review_type'; | ||
public const VALUES = [self::COMMITS, self::BRANCH]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.