better boarding flow
This commit is contained in:
@@ -7,15 +7,19 @@ use App\Models\GithubApp;
|
||||
use App\Models\Project;
|
||||
use App\Models\StandaloneDocker;
|
||||
use App\Models\SwarmDocker;
|
||||
use App\Traits\SaveFromRedirect;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Component;
|
||||
use Route;
|
||||
|
||||
class GithubPrivateRepository extends Component
|
||||
{
|
||||
use SaveFromRedirect;
|
||||
public $current_step = 'github_apps';
|
||||
public $github_apps;
|
||||
public GithubApp $github_app;
|
||||
public $parameters;
|
||||
public $currentRoute;
|
||||
public $query;
|
||||
public $type;
|
||||
|
||||
@@ -36,14 +40,30 @@ class GithubPrivateRepository extends Component
|
||||
public string|null $publish_directory = null;
|
||||
protected int $page = 1;
|
||||
|
||||
// public function saveFromRedirect(string $route, ?Collection $parameters = null){
|
||||
// session()->forget('from');
|
||||
// if (!$parameters || $parameters->count() === 0) {
|
||||
// $parameters = $this->parameters;
|
||||
// }
|
||||
// $parameters = collect($parameters) ?? collect([]);
|
||||
// $queries = collect($this->query) ?? collect([]);
|
||||
// $parameters = $parameters->merge($queries);
|
||||
// session(['from'=> [
|
||||
// 'back'=> $this->currentRoute,
|
||||
// 'route' => $route,
|
||||
// 'parameters' => $parameters
|
||||
// ]]);
|
||||
// return redirect()->route($route);
|
||||
// }
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->currentRoute = Route::currentRouteName();
|
||||
$this->parameters = get_route_parameters();
|
||||
$this->query = request()->query();
|
||||
$this->repositories = $this->branches = collect();
|
||||
$this->github_apps = GithubApp::private();
|
||||
}
|
||||
|
||||
public function loadRepositories($github_app_id)
|
||||
{
|
||||
$this->repositories = collect();
|
||||
|
||||
@@ -39,7 +39,6 @@ class Change extends Component
|
||||
{
|
||||
if (is_cloud() && !isDev()) {
|
||||
$this->webhook_endpoint = config('app.url');
|
||||
ray($this->webhook_endpoint);
|
||||
} else {
|
||||
$this->webhook_endpoint = $this->ipv4;
|
||||
$this->is_system_wide = $this->github_app->is_system_wide;
|
||||
|
||||
@@ -42,6 +42,9 @@ class Create extends Component
|
||||
'is_system_wide' => $this->is_system_wide,
|
||||
'team_id' => currentTeam()->id,
|
||||
]);
|
||||
if (session('from')) {
|
||||
session(['from' => session('from') + ['source_id' => $github_app->id]]);
|
||||
}
|
||||
redirect()->route('source.github.show', ['github_app_uuid' => $github_app->uuid]);
|
||||
} catch (\Exception $e) {
|
||||
return general_error_handler(err: $e, that: $this);
|
||||
|
||||
25
app/Traits/SaveFromRedirect.php
Normal file
25
app/Traits/SaveFromRedirect.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
trait SaveFromRedirect
|
||||
{
|
||||
public function saveFromRedirect(string $route, ?Collection $parameters = null)
|
||||
{
|
||||
session()->forget('from');
|
||||
if (!$parameters || $parameters->count() === 0) {
|
||||
$parameters = $this->parameters;
|
||||
}
|
||||
$parameters = collect($parameters) ?? collect([]);
|
||||
$queries = collect($this->query) ?? collect([]);
|
||||
$parameters = $parameters->merge($queries);
|
||||
session(['from' => [
|
||||
'back' => $this->currentRoute,
|
||||
'route' => $route,
|
||||
'parameters' => $parameters
|
||||
]]);
|
||||
return redirect()->route($route);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class Button extends Component
|
||||
public bool $disabled = false,
|
||||
public bool $isModal = false,
|
||||
public bool $noStyle = false,
|
||||
public string|null $modalId = null,
|
||||
public ?string $modalId = null,
|
||||
public string $defaultClass = "btn btn-primary btn-sm font-normal text-white normal-case no-animation rounded border-none"
|
||||
) {
|
||||
if ($this->noStyle) {
|
||||
@@ -23,9 +23,6 @@ class Button extends Component
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.forms.button');
|
||||
|
||||
Reference in New Issue
Block a user