Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

add new resource

Andras Bacsai9f327307143d
diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php
index 710c10f830..1f234cdab8 100644
--- a/app/Http/Controllers/ProjectController.php
+++ b/app/Http/Controllers/ProjectController.php
@@ -19,6 +19,18 @@ class ProjectController extends Controller
return view('project.environments', ['project' => $project]);
}
+ public function resources_new()
+ {
+ $project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
+ if (!$project) {
+ return redirect()->route('dashboard');
+ }
+ $environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
+ if (!$environment) {
+ return redirect()->route('dashboard');
+ }
+ return view('project.new', ['project' => $project, 'environment' => $environment, 'type' => 'resource']);
+ }
public function resources()
{
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
diff --git a/app/Http/Livewire/Project/New/PublicGitRepository.php b/app/Http/Livewire/Project/New/PublicGitRepository.php
index 3fd272c012..98662f0564 100644
--- a/app/Http/Livewire/Project/New/PublicGitRepository.php
+++ b/app/Http/Livewire/Project/New/PublicGitRepository.php
@@ -2,15 +2,13 @@
namespace App\Http\Livewire\Project\New;
-use App\Http\Livewire\Application\Destination;
use App\Models\Application;
-use App\Models\Git;
use App\Models\GithubApp;
use App\Models\GitlabApp;
use App\Models\Project;
-use App\Models\Server;
use App\Models\StandaloneDocker;
use App\Models\SwarmDocker;
+use Illuminate\Support\Facades\Route;
use Livewire\Component;
use Spatie\Url\Url;
@@ -18,6 +16,8 @@ class PublicGitRepository extends Component
{
public string $public_repository_url;
public int $port;
+ public string $type;
+ public $parameters;
public $servers;
public $standalone_docker;
@@ -42,6 +42,7 @@ class PublicGitRepository extends Component
$this->public_repository_url = 'https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify';
$this->port = 3000;
}
+ $this->parameters = Route::current()->parameters();
$this->servers = session('currentTeam')->load(['servers'])->servers;
}
public function chooseServer($server_id)
@@ -76,12 +77,17 @@ class PublicGitRepository extends Component
$git_repository = $url->getSegment(1) . '/' . $url->getSegment(2);
$git_branch = $url->getSegment(4) ?? 'main';
- $project = Project::create([
- 'name' => fake()->company(),
- 'description' => fake()->sentence(),
- 'team_id' => session('currentTeam')->id,
- ]);
- $environment = $project->environments->first();
+ if ($this->type === 'project') {
+ $project = Project::create([
+ 'name' => fake()->company(),
+ 'description' => fake()->sentence(),
+ 'team_id' => session('currentTeam')->id,
+ ]);
+ $environment = $project->environments->first();
+ } else {
+ $project = Project::where('uuid', $this->parameters['project_uuid'])->firstOrFail();
+ $environment = $project->environments->where('name', $this->parameters['environment_name'])->firstOrFail();
+ }
$application_init = [
'name' => fake()->words(2, true),
'git_repository' => $git_repository,
diff --git a/resources/views/project/new.blade.php b/resources/views/project/new.blade.php
index c000d79918..48c0335edb 100644
--- a/resources/views/project/new.blade.php
+++ b/resources/views/project/new.blade.php
@@ -1,17 +1,23 @@
<x-layout>
- <h1>New Project</h1>
+ @if ($type === 'project')
+ <h1>New Project</h1>
+ @elseif ($type === 'resource')
+ <h1>New Resource</h1>
+ @endif
<div x-data="{ tab: window.location.hash ? window.location.hash.substring(1) : 'choose' }">
<div class="flex flex-col w-64 gap-2 mb-10">
<button @click.prevent="tab = 'public-repo'; window.location.hash = 'public-repo'">Public Repository
</button>
<button @click.prevent="tab = 'github-private-repo'; window.location.hash = 'github-private-repo'">Private
Repository (GitHub App)</button>
- <button @click.prevent="tab = 'empty-project'; window.location.hash = 'empty-project'">Empty
- Project</button>
+ @if ($type === 'project')
+ <button @click.prevent="tab = 'empty-project'; window.location.hash = 'empty-project'">Empty
+ Project</button>
+ @endif
</div>
<div x-cloak x-show="tab === 'public-repo'">
- <livewire:project.new.public-git-repository />
+ <livewire:project.new.public-git-repository :type="$type" />
</div>
<div x-cloak x-show="tab === 'github-private-repo'">
github-private-repo
diff --git a/resources/views/project/resources.blade.php b/resources/views/project/resources.blade.php
index 85ad66146b..d197cd3d8e 100644
--- a/resources/views/project/resources.blade.php
+++ b/resources/views/project/resources.blade.php
@@ -1,9 +1,11 @@
<x-layout>
- <h1>Resources</h1>
+ <h1>Resources <a href="{{ route('project.resources.new', Route::current()->parameters()) }}"><button>New</button></a>
+ </h1>
<div>
@foreach ($environment->applications as $application)
<p>
- <a href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}">
+ <a
+ href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}">
{{ $application->name }}
</a>
</p>
diff --git a/routes/web.php b/routes/web.php
index da324f4f00..ffdb7ed13e 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -67,12 +67,17 @@ Route::middleware(['auth'])->group(function () {
});
Route::middleware(['auth'])->group(function () {
- Route::get('/project/new', fn () => view('project.new'))->name('project.new');
+ Route::get('/project/new', fn () => view('project.new', ['type' => 'project']))->name('project.new');
Route::get(
'/project/{project_uuid}',
[ProjectController::class, 'environments']
)->name('project.environments');
+ Route::get(
+ '/project/{project_uuid}/{environment_name}/new',
+ [ProjectController::class, 'resources_new']
+ )->name('project.resources.new');
+
Route::get(
'/project/{project_uuid}/{environment_name}',
[ProjectController::class, 'resources']