diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 432e72f39..e56edf17b 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -3,15 +3,16 @@ namespace App\Http\Controllers; use App\Models\Project; +use App\Models\Server; class ProjectController extends Controller { public function all() { - $teamId = session('currentTeam')->id; - - $projects = Project::where('team_id', $teamId)->get(); - return view('projects', ['projects' => $projects]); + return view('projects', [ + 'projects' => Project::ownedByCurrentTeam()->get(), + 'servers' => Server::ownedByCurrentTeam()->count(), + ]); } public function edit() @@ -34,9 +35,6 @@ public function show() return redirect()->route('dashboard'); } $project->load(['environments']); - if (count($project->environments) == 1) { - return redirect()->route('project.resources', ['project_uuid' => $project->uuid, 'environment_name' => $project->environments->first()->name]); - } return view('project.show', ['project' => $project]); } diff --git a/app/Http/Livewire/PrivateKey/Create.php b/app/Http/Livewire/PrivateKey/Create.php index af147a9e3..bfbf72e18 100644 --- a/app/Http/Livewire/PrivateKey/Create.php +++ b/app/Http/Livewire/PrivateKey/Create.php @@ -7,7 +7,7 @@ class Create extends Component { - protected string|null $from = null; + public string|null $from = null; public string $name; public string|null $description = null; public string $value; diff --git a/app/Http/Livewire/Project/AddEmpty.php b/app/Http/Livewire/Project/AddEmpty.php new file mode 100644 index 000000000..98136fb86 --- /dev/null +++ b/app/Http/Livewire/Project/AddEmpty.php @@ -0,0 +1,36 @@ + 'required|string|min:3', + 'description' => 'nullable|string', + ]; + protected $validationAttributes = [ + 'name' => 'Project Name', + 'description' => 'Project Description', + ]; + public function submit() + { + try { + $this->validate(); + $project = Project::create([ + 'name' => $this->name, + 'description' => $this->description, + 'team_id' => auth()->user()->currentTeam()->id, + ]); + return redirect()->route('project.show', $project->uuid); + } catch (\Exception $e) { + general_error_handler($e, $this); + } finally { + $this->name = ''; + } + } +} diff --git a/app/Http/Livewire/Project/AddEnvironment.php b/app/Http/Livewire/Project/AddEnvironment.php new file mode 100644 index 000000000..3ca6d8de3 --- /dev/null +++ b/app/Http/Livewire/Project/AddEnvironment.php @@ -0,0 +1,39 @@ + 'required|string|min:3', + ]; + protected $validationAttributes = [ + 'name' => 'Environment Name', + ]; + public function submit() + { + try { + $this->validate(); + $environment = Environment::create([ + 'name' => $this->name, + 'project_id' => $this->project->id, + ]); + + return redirect()->route('project.resources', [ + 'project_uuid' => $this->project->uuid, + 'environment_name' => $environment->name, + ]); + } catch (\Exception $e) { + general_error_handler($e, $this); + } finally { + $this->name = ''; + } + } +} diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepository.php b/app/Http/Livewire/Project/New/GithubPrivateRepository.php index 89dab6b72..d092670a3 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepository.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepository.php @@ -15,6 +15,7 @@ class GithubPrivateRepository extends Component { + public $current_step = 'github_apps'; public $github_apps; public GithubApp $github_app; public $parameters; @@ -90,6 +91,7 @@ public function loadRepositories($github_app_id) } } $this->selected_repository_id = $this->repositories[0]['id']; + $this->current_step = 'repository'; } public function loadBranches() { diff --git a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php index 8f8611c4d..cfb528f1e 100644 --- a/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php +++ b/app/Http/Livewire/Project/New/GithubPrivateRepositoryDeployKey.php @@ -14,6 +14,7 @@ class GithubPrivateRepositoryDeployKey extends Component { + public $current_step = 'private_keys'; public $parameters; public $query; public $private_keys; @@ -70,6 +71,7 @@ public function instantSave() public function setPrivateKey($private_key_id) { $this->private_key_id = $private_key_id; + $this->current_step = 'repository'; } private function get_git_source() { diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php index 8fbaf62fb..181a308bd 100644 --- a/app/Http/Livewire/Project/New/PublicGitRepository.php +++ b/app/Http/Livewire/Project/New/PublicGitRepository.php @@ -82,7 +82,9 @@ public function load_branch() $this->get_git_source(); try { $this->get_branch(); + $this->selected_branch = $this->git_branch; } catch (\Exception $e) { + return general_error_handler(err: $e, that: $this); } if (!$this->branch_found && $this->git_branch == 'main') { diff --git a/app/Http/Livewire/Project/New/Select.php b/app/Http/Livewire/Project/New/Select.php new file mode 100644 index 000000000..3e6137891 --- /dev/null +++ b/app/Http/Livewire/Project/New/Select.php @@ -0,0 +1,47 @@ +parameters = getRouteParameters(); + } + public function set_type(string $type) + { + $this->type = $type; + $this->current_step = 'servers'; + } + public function set_server(Server $server) + { + $this->server_id = $server->id; + $this->destinations = $server->destinations(); + $this->current_step = 'destinations'; + } + public function set_destination(string $destination_uuid) + { + $this->destination_uuid = $destination_uuid; + redirect()->route('project.resources.new', [ + 'project_uuid' => $this->parameters['project_uuid'], + 'environment_name' => $this->parameters['environment_name'], + 'type' => $this->type, + 'destination' => $this->destination_uuid, + ]); + } + public function load_servers() + { + $this->servers = Server::ownedByCurrentTeam()->get(); + } +} diff --git a/app/Models/Project.php b/app/Models/Project.php index 073c654b6..a0a342755 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -15,6 +15,10 @@ protected static function booted() 'project_id' => $project->id, ]); }); + static::deleted(function ($project) { + $project->environments()->delete(); + $project->settings()->delete(); + }); } protected $fillable = [ 'name', diff --git a/app/View/Components/Forms/Button.php b/app/View/Components/Forms/Button.php index 0f33192f7..b347fefd1 100644 --- a/app/View/Components/Forms/Button.php +++ b/app/View/Components/Forms/Button.php @@ -15,7 +15,7 @@ public function __construct( public bool $disabled = false, public bool $isModal = false, public string|null $modalId = null, - public string $defaultClass = "btn btn-primary btn-xs text-white normal-case no-animation rounded border-none" + public string $defaultClass = "btn btn-primary btn-sm font-normal text-white normal-case no-animation rounded border-none" ) { // } @@ -27,4 +27,4 @@ public function render(): View|Closure|string { return view('components.forms.button'); } -} \ No newline at end of file +} diff --git a/resources/css/app.css b/resources/css/app.css index 5bca7271f..979bc99aa 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -9,7 +9,7 @@ body { @apply text-sm antialiased scrollbar; } button[isError] { - @apply bg-red-600 hover:bg-red-500; + @apply bg-red-600 hover:bg-red-700; } .scrollbar { @apply scrollbar-thumb-coollabs-100 scrollbar-track-coolgray-200 scrollbar-w-2; @@ -17,37 +17,17 @@ .scrollbar { .main { @apply max-w-screen-xl pt-4 pl-24 pr-10 mx-auto; } -/* input { - @apply w-full text-white rounded outline-none input input-sm h-7 placeholder:text-neutral-700 bg-coolgray-200 read-only:bg-coolgray-200/50 read-only:text-opacity-25; -} -input:not(input[type="checkbox"]) { - @apply border-none disabled:border-none; -} -input[type="checkbox"] { - @apply rounded toggle toggle-warning toggle-xs disabled:toggle-warning; -} */ - -/* textarea { - @apply text-xs leading-5 text-white rounded textarea read-only:bg-coolgray-200/50 disabled:border-none read-only:text-opacity-25 placeholder:text-neutral-700 scrollbar bg-coolgray-200; -} -select { - @apply font-normal text-white border-none rounded h-7 select select-xs disabled:bg-coolgray-200 disabled:opacity-50 placeholder:text-neutral-700 bg-coolgray-200; -} */ .label-text, label { @apply text-neutral-400; } +.navbar-main { + @apply flex items-end gap-6 py-2 border-b-2 border-solid border-coolgray-200; +} .loading { @apply w-4 text-warning; } - -/* button[isWarning] { - @apply bg-red-600 hover:bg-red-500; -} -button[isHighlighted] { - @apply text-white btn-primary; -} */ h1 { @apply text-3xl font-bold text-white; } diff --git a/resources/views/components/applications/actions.blade.php b/resources/views/components/applications/advanced.blade.php similarity index 54% rename from resources/views/components/applications/actions.blade.php rename to resources/views/components/applications/advanced.blade.php index fe5b235fc..38410a026 100644 --- a/resources/views/components/applications/actions.blade.php +++ b/resources/views/components/applications/advanced.blade.php @@ -1,23 +1,12 @@
-