Added +add flows everywhere

ui: changed vibrant button to not so vibrant
This commit is contained in:
Andras Bacsai
2023-07-26 13:23:47 +02:00
parent 8deeb59d5c
commit fd89735521
40 changed files with 578 additions and 274 deletions

View File

@@ -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 @@ class ProjectController extends Controller
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]);
}

View File

@@ -7,7 +7,7 @@ use Livewire\Component;
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;

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Http\Livewire\Project;
use App\Models\Project;
use Livewire\Component;
class AddEmpty extends Component
{
public string $name = '';
public string $description = '';
protected $rules = [
'name' => '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 = '';
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Livewire\Project;
use App\Models\Environment;
use App\Models\Project;
use Livewire\Component;
class AddEnvironment extends Component
{
public Project $project;
public string $name = '';
public string $description = '';
protected $rules = [
'name' => '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 = '';
}
}
}

View File

@@ -15,6 +15,7 @@ use Livewire\Component;
class GithubPrivateRepository extends Component
{
public $current_step = 'github_apps';
public $github_apps;
public GithubApp $github_app;
public $parameters;
@@ -90,6 +91,7 @@ class GithubPrivateRepository extends Component
}
}
$this->selected_repository_id = $this->repositories[0]['id'];
$this->current_step = 'repository';
}
public function loadBranches()
{

View File

@@ -14,6 +14,7 @@ use Spatie\Url\Url;
class GithubPrivateRepositoryDeployKey extends Component
{
public $current_step = 'private_keys';
public $parameters;
public $query;
public $private_keys;
@@ -70,6 +71,7 @@ class GithubPrivateRepositoryDeployKey extends Component
public function setPrivateKey($private_key_id)
{
$this->private_key_id = $private_key_id;
$this->current_step = 'repository';
}
private function get_git_source()
{

View File

@@ -82,7 +82,9 @@ class PublicGitRepository extends Component
$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') {

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Http\Livewire\Project\New;
use App\Models\Server;
use Livewire\Component;
class Select extends Component
{
public $current_step = 'type';
public string $type;
public string $server_id;
public string $destination_uuid;
public $servers = [];
public $destinations = [];
public array $parameters;
public function mount()
{
$this->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();
}
}

View File

@@ -15,6 +15,10 @@ class Project extends BaseModel
'project_id' => $project->id,
]);
});
static::deleted(function ($project) {
$project->environments()->delete();
$project->settings()->delete();
});
}
protected $fillable = [
'name',

View File

@@ -15,7 +15,7 @@ class Button extends Component
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 @@ class Button extends Component
{
return view('components.forms.button');
}
}
}