From 39647367a5bd50c356c6857b41df0129ecd15aa9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 25 Jan 2024 15:57:04 +0100 Subject: [PATCH] Add build pack selection and update related fields --- .../Project/New/GithubPrivateRepository.php | 16 +++++++ .../New/GithubPrivateRepositoryDeployKey.php | 20 +++++++++ ...ub-private-repository-deploy-key.blade.php | 28 +++++++----- .../new/github-private-repository.blade.php | 43 +++++++++++-------- .../new/public-git-repository.blade.php | 11 +++-- 5 files changed, 84 insertions(+), 34 deletions(-) diff --git a/app/Livewire/Project/New/GithubPrivateRepository.php b/app/Livewire/Project/New/GithubPrivateRepository.php index 9ae9aeb57..012325ff1 100644 --- a/app/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Livewire/Project/New/GithubPrivateRepository.php @@ -39,6 +39,8 @@ class GithubPrivateRepository extends Component public bool $is_static = false; public string|null $publish_directory = null; protected int $page = 1; + public $build_pack = 'nixpacks'; + public bool $show_is_static = true; public function mount() @@ -49,6 +51,20 @@ class GithubPrivateRepository extends Component $this->repositories = $this->branches = collect(); $this->github_apps = GithubApp::private(); } + public function updatedBuildPack() + { + if ($this->build_pack === 'nixpacks') { + $this->show_is_static = true; + $this->port = 3000; + } else if ($this->build_pack === 'static') { + $this->show_is_static = false; + $this->is_static = false; + $this->port = 80; + } else { + $this->show_is_static = false; + $this->is_static = false; + } + } public function loadRepositories($github_app_id) { $this->repositories = collect(); diff --git a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index ba403ca1c..723d4bb60 100644 --- a/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -29,12 +29,17 @@ class GithubPrivateRepositoryDeployKey extends Component public string $repository_url; public string $branch; + + public $build_pack = 'nixpacks'; + public bool $show_is_static = true; + protected $rules = [ 'repository_url' => 'required', 'branch' => 'required|string', 'port' => 'required|numeric', 'is_static' => 'required|boolean', 'publish_directory' => 'nullable|string', + 'build_pack' => 'required|string', ]; protected $validationAttributes = [ 'repository_url' => 'Repository', @@ -42,6 +47,7 @@ class GithubPrivateRepositoryDeployKey extends Component 'port' => 'Port', 'is_static' => 'Is static', 'publish_directory' => 'Publish directory', + 'build_pack' => 'Build pack', ]; private object $repository_url_parsed; private GithubApp|GitlabApp|string $git_source = 'other'; @@ -62,6 +68,20 @@ class GithubPrivateRepositoryDeployKey extends Component } } + public function updatedBuildPack() + { + if ($this->build_pack === 'nixpacks') { + $this->show_is_static = true; + $this->port = 3000; + } else if ($this->build_pack === 'static') { + $this->show_is_static = false; + $this->is_static = false; + $this->port = 80; + } else { + $this->show_is_static = false; + $this->is_static = false; + } + } public function instantSave() { if ($this->is_static) { diff --git a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php index f7fe57ac2..ed18da484 100644 --- a/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php +++ b/resources/views/livewire/project/new/github-private-repository-deploy-key.blade.php @@ -40,23 +40,29 @@
  • Select a Private Key
  • Select a Repository, Branch & Save
  • -
    + +
    - + + + + + + @if ($is_static) - @else - @endif
    -
    - -
    - - Save New Application + + @if ($show_is_static) +
    + +
    + @endif + + Continue @endif diff --git a/resources/views/livewire/project/new/github-private-repository.blade.php b/resources/views/livewire/project/new/github-private-repository.blade.php index 082decd22..d20f24bc7 100644 --- a/resources/views/livewire/project/new/github-private-repository.blade.php +++ b/resources/views/livewire/project/new/github-private-repository.blade.php @@ -4,8 +4,16 @@ + Add New GitHub App + @if ($repositories->count() > 0) + + + Change Repositories on GitHub + + + + @endif -
    Deploy any public or private git repositories through a GitHub App.
    +
    Deploy any public or private Git repositories through a GitHub App.
    @if ($github_apps->count() !== 0)
    @if ($current_step === 'github_apps') @@ -53,14 +61,8 @@ @endif @endforeach - Load Repository Details - - - Change Repositories on GitHub - - - + Load Repository +
    @else
    No repositories found. Check your GitHub App configuration.
    @@ -84,21 +86,28 @@ @endif @endforeach + + + + + + @if ($is_static) - @else - @endif -
    - -
    + + @if ($show_is_static) +
    + +
    + @endif - Save New Application + Continue @endif @endif diff --git a/resources/views/livewire/project/new/public-git-repository.blade.php b/resources/views/livewire/project/new/public-git-repository.blade.php index 5efeaa392..c01cbc9c9 100644 --- a/resources/views/livewire/project/new/public-git-repository.blade.php +++ b/resources/views/livewire/project/new/public-git-repository.blade.php @@ -11,7 +11,7 @@
    @if (!$branch_found) -
    +

    Public repositories: https://...

    Private repositories: git@...

    Preselect branch: Dockerfile -

    - @if ($show_is_static) @if ($is_static) - @else - @endif +
    + + @if ($show_is_static)