From 291b9a84ef7d4e66fe5947bcf070769cf2a62126 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 29 Aug 2023 14:36:17 +0200 Subject: [PATCH] refactoring --- app/Http/Controllers/Controller.php | 34 ++--- app/Http/Livewire/Dashboard.php | 32 ++++ app/Http/Livewire/Dev/S3Test.php | 41 ----- app/Http/Livewire/Server/All.php | 20 +++ app/Http/Livewire/Server/Show.php | 19 +++ app/Http/Middleware/IsBoardingFlow.php | 2 +- app/Models/User.php | 17 +-- composer.json | 2 +- composer.lock | 142 +++++++++--------- config/session.php | 2 +- database/seeders/UserSeeder.php | 2 + phpunit.xml | 55 ++++--- resources/views/layouts/app.blade.php | 133 ++++++++++++++++ .../views/{ => livewire}/dashboard.blade.php | 9 +- resources/views/livewire/server/all.blade.php | 54 +++++++ .../views/livewire/server/show.blade.php | 4 + resources/views/server/all.blade.php | 52 +------ routes/web.php | 15 +- ...andsTest.php => DockerCommandsTest.phpold} | 0 tests/Feature/ExampleTest.php | 7 + ...ocessTest.php => RemoteProcessTest.phpold} | 0 tests/Unit/ExampleTest.php | 5 + tests/Unit/RulesTest.php | 2 +- 23 files changed, 409 insertions(+), 240 deletions(-) create mode 100644 app/Http/Livewire/Dashboard.php delete mode 100644 app/Http/Livewire/Dev/S3Test.php create mode 100644 app/Http/Livewire/Server/All.php create mode 100644 app/Http/Livewire/Server/Show.php create mode 100644 resources/views/layouts/app.blade.php rename resources/views/{ => livewire}/dashboard.blade.php (84%) create mode 100644 resources/views/livewire/server/all.blade.php create mode 100644 resources/views/livewire/server/show.blade.php rename tests/Feature/{DockerCommandsTest.php => DockerCommandsTest.phpold} (100%) create mode 100644 tests/Feature/ExampleTest.php rename tests/Feature/{RemoteProcessTest.php => RemoteProcessTest.phpold} (100%) create mode 100644 tests/Unit/ExampleTest.php diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 4fd997055..e92a29fc2 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -48,23 +48,23 @@ public function license() public function force_passoword_reset() { return view('auth.force-password-reset'); } - public function dashboard() - { - $projects = Project::ownedByCurrentTeam()->get(); - $servers = Server::ownedByCurrentTeam()->get(); - $s3s = S3Storage::ownedByCurrentTeam()->get(); - $resources = 0; - foreach ($projects as $project) { - $resources += $project->applications->count(); - $resources += $project->postgresqls->count(); - } - return view('dashboard', [ - 'servers' => $servers->count(), - 'projects' => $projects->count(), - 'resources' => $resources, - 's3s' => $s3s, - ]); - } + // public function dashboard() + // { + // $projects = Project::ownedByCurrentTeam()->get(); + // $servers = Server::ownedByCurrentTeam()->get(); + // $s3s = S3Storage::ownedByCurrentTeam()->get(); + // $resources = 0; + // foreach ($projects as $project) { + // $resources += $project->applications->count(); + // $resources += $project->postgresqls->count(); + // } + // return view('dashboard', [ + // 'servers' => $servers->count(), + // 'projects' => $projects->count(), + // 'resources' => $resources, + // 's3s' => $s3s, + // ]); + // } public function boarding() { if (currentTeam()->boarding || isDev()) { return view('boarding'); diff --git a/app/Http/Livewire/Dashboard.php b/app/Http/Livewire/Dashboard.php new file mode 100644 index 000000000..874e389e0 --- /dev/null +++ b/app/Http/Livewire/Dashboard.php @@ -0,0 +1,32 @@ +servers = Server::ownedByCurrentTeam()->get()->count(); + $this->s3s = S3Storage::ownedByCurrentTeam()->get()->count(); + $projects = Project::ownedByCurrentTeam()->get(); + foreach ($projects as $project) { + $this->resources += $project->applications->count(); + $this->resources += $project->postgresqls->count(); + } + $this->projects = $projects->count(); + } + public function render() + { + return view('livewire.dashboard'); + } +} diff --git a/app/Http/Livewire/Dev/S3Test.php b/app/Http/Livewire/Dev/S3Test.php deleted file mode 100644 index 3a20224cd..000000000 --- a/app/Http/Livewire/Dev/S3Test.php +++ /dev/null @@ -1,41 +0,0 @@ -s3 = S3Storage::first(); - } - - public function save() - { - try { - $this->validate([ - 'file' => 'required|max:150', // 1MB Max - ]); - set_s3_target($this->s3); - $this->file->storeAs('files', $this->file->getClientOriginalName(), 'custom-s3'); - $this->emit('success', 'File uploaded successfully.'); - } catch (\Throwable $th) { - return general_error_handler($th, $this, false); - } - } - - public function get_files() - { - set_s3_target($this->s3); - dd(Storage::disk('custom-s3')->files('files')); - } -} diff --git a/app/Http/Livewire/Server/All.php b/app/Http/Livewire/Server/All.php new file mode 100644 index 000000000..94db86f34 --- /dev/null +++ b/app/Http/Livewire/Server/All.php @@ -0,0 +1,20 @@ +servers = Server::ownedByCurrentTeam()->get(); + } + public function render() + { + return view('livewire.server.all'); + } +} diff --git a/app/Http/Livewire/Server/Show.php b/app/Http/Livewire/Server/Show.php new file mode 100644 index 000000000..b54b98fea --- /dev/null +++ b/app/Http/Livewire/Server/Show.php @@ -0,0 +1,19 @@ +server = Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail(); + } + public function render() + { + return view('livewire.server.show'); + } +} diff --git a/app/Http/Middleware/IsBoardingFlow.php b/app/Http/Middleware/IsBoardingFlow.php index 83662a073..e0542a57a 100644 --- a/app/Http/Middleware/IsBoardingFlow.php +++ b/app/Http/Middleware/IsBoardingFlow.php @@ -15,7 +15,7 @@ class IsBoardingFlow */ public function handle(Request $request, Closure $next): Response { - // ray('IsBoardingFlow Middleware'); + ray()->showQueries()->color('orange'); if (showBoarding() && !in_array($request->path(), allowedPathsForBoardingAccounts())) { return redirect('boarding'); } diff --git a/app/Models/User.php b/app/Models/User.php index 13140f133..ccbfd14df 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -91,29 +91,20 @@ public function isInstanceAdmin() return $found_root_team->count() > 0; } - public function personalTeam() - { - return $this->teams()->where('personal_team', true)->first(); - } - public function currentTeam() { - return $this->teams()->where('team_id', session('currentTeam')->id)->first(); + return session('currentTeam'); } public function otherTeams() { - $team_id = currentTeam()->id; - return auth()->user()->teams->filter(function ($team) use ($team_id) { - return $team->id != $team_id; + return auth()->user()->teams->filter(function ($team) { + return $team->id != currentTeam()->id; }); } public function role() { - if ($this->teams()->where('team_id', 0)->first()) { - return 'admin'; - } - return $this->teams()->where('team_id', currentTeam()->id)->first()->pivot->role; + return session('currentTeam')->pivot->role; } } diff --git a/composer.json b/composer.json index bcb74242b..b4164bade 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "laravel/pint": "^v1.8.0", "mockery/mockery": "^1.5.1", "nunomaduro/collision": "^v7.4.0", - "pestphp/pest": "^v2.4.0", + "pestphp/pest": "^2.16", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^10.0.19", "serversideup/spin": "^v1.1.0", diff --git a/composer.lock b/composer.lock index 871f9f577..3ab2d9fa4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "da14dce99d76abcaaa6393166eda049a", + "content-hash": "dbb08df7a80c46ce2b9b9fa397ed71c1", "packages": [ { "name": "aws/aws-crt-php", @@ -6654,16 +6654,16 @@ }, { "name": "symfony/console", - "version": "v6.3.2", + "version": "v6.3.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "aa5d64ad3f63f2e48964fc81ee45cb318a723898" + "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/aa5d64ad3f63f2e48964fc81ee45cb318a723898", - "reference": "aa5d64ad3f63f2e48964fc81ee45cb318a723898", + "url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6", + "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6", "shasum": "" }, "require": { @@ -6724,7 +6724,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.3.2" + "source": "https://github.com/symfony/console/tree/v6.3.4" }, "funding": [ { @@ -6740,7 +6740,7 @@ "type": "tidelift" } ], - "time": "2023-07-19T20:17:28+00:00" + "time": "2023-08-16T10:10:12+00:00" }, { "name": "symfony/css-selector", @@ -7761,16 +7761,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "shasum": "" }, "require": { @@ -7785,7 +7785,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -7823,7 +7823,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -7839,7 +7839,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-iconv", @@ -7926,16 +7926,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354" + "reference": "875e90aeea2777b6f135677f618529449334a612" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", + "reference": "875e90aeea2777b6f135677f618529449334a612", "shasum": "" }, "require": { @@ -7947,7 +7947,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -7987,7 +7987,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" }, "funding": [ { @@ -8003,7 +8003,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-idn", @@ -8094,16 +8094,16 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "shasum": "" }, "require": { @@ -8115,7 +8115,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -8158,7 +8158,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" }, "funding": [ { @@ -8174,20 +8174,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -8202,7 +8202,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -8241,7 +8241,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" }, "funding": [ { @@ -8257,7 +8257,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php72", @@ -8337,16 +8337,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -8355,7 +8355,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -8400,7 +8400,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -8416,7 +8416,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-php83", @@ -8579,16 +8579,16 @@ }, { "name": "symfony/process", - "version": "v6.3.2", + "version": "v6.3.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d" + "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d", - "reference": "c5ce962db0d9b6e80247ca5eb9af6472bd4d7b5d", + "url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54", + "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54", "shasum": "" }, "require": { @@ -8620,7 +8620,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.3.2" + "source": "https://github.com/symfony/process/tree/v6.3.4" }, "funding": [ { @@ -8636,7 +8636,7 @@ "type": "tidelift" } ], - "time": "2023-07-12T16:00:22+00:00" + "time": "2023-08-07T10:39:22+00:00" }, { "name": "symfony/psr-http-message-bridge", @@ -9982,16 +9982,16 @@ "packages-dev": [ { "name": "brianium/paratest", - "version": "v7.2.5", + "version": "v7.2.6", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "4d7ad5b6564f63baa1b948ecad05439f22880942" + "reference": "7f372b5bb59b4271adedc67d3129df29b84c4173" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/4d7ad5b6564f63baa1b948ecad05439f22880942", - "reference": "4d7ad5b6564f63baa1b948ecad05439f22880942", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/7f372b5bb59b4271adedc67d3129df29b84c4173", + "reference": "7f372b5bb59b4271adedc67d3129df29b84c4173", "shasum": "" }, "require": { @@ -10005,19 +10005,19 @@ "phpunit/php-code-coverage": "^10.1.3", "phpunit/php-file-iterator": "^4.0.2", "phpunit/php-timer": "^6.0", - "phpunit/phpunit": "^10.3.1", + "phpunit/phpunit": "^10.3.2", "sebastian/environment": "^6.0.1", - "symfony/console": "^6.3.2", - "symfony/process": "^6.3.2" + "symfony/console": "^6.3.4", + "symfony/process": "^6.3.4" }, "require-dev": { "doctrine/coding-standard": "^12.0.0", "ext-pcov": "*", "ext-posix": "*", "infection/infection": "^0.27.0", - "phpstan/phpstan": "^1.10.26", - "phpstan/phpstan-deprecation-rules": "^1.1.3", - "phpstan/phpstan-phpunit": "^1.3.13", + "phpstan/phpstan": "^1.10.32", + "phpstan/phpstan-deprecation-rules": "^1.1.4", + "phpstan/phpstan-phpunit": "^1.3.14", "phpstan/phpstan-strict-rules": "^1.5.1", "squizlabs/php_codesniffer": "^3.7.2", "symfony/filesystem": "^6.3.1" @@ -10061,7 +10061,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.2.5" + "source": "https://github.com/paratestphp/paratest/tree/v7.2.6" }, "funding": [ { @@ -10073,7 +10073,7 @@ "type": "paypal" } ], - "time": "2023-08-08T13:23:59+00:00" + "time": "2023-08-29T07:47:39+00:00" }, { "name": "fakerphp/faker", @@ -10707,24 +10707,24 @@ }, { "name": "pestphp/pest", - "version": "v2.16.0", + "version": "v2.16.1", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "cbd6a650576714c673dbb0575989663f7f5c8b6d" + "reference": "55b92666482b7d4320b7869c4eea7333d35c5631" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/cbd6a650576714c673dbb0575989663f7f5c8b6d", - "reference": "cbd6a650576714c673dbb0575989663f7f5c8b6d", + "url": "https://api.github.com/repos/pestphp/pest/zipball/55b92666482b7d4320b7869c4eea7333d35c5631", + "reference": "55b92666482b7d4320b7869c4eea7333d35c5631", "shasum": "" }, "require": { - "brianium/paratest": "^7.2.5", + "brianium/paratest": "^7.2.6", "nunomaduro/collision": "^7.8.1", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest-plugin": "^2.0.1", - "pestphp/pest-plugin-arch": "^2.3.1", + "pestphp/pest-plugin": "^2.1.1", + "pestphp/pest-plugin-arch": "^2.3.3", "php": "^8.1.0", "phpunit/phpunit": "^10.3.2" }, @@ -10734,8 +10734,8 @@ }, "require-dev": { "pestphp/pest-dev-tools": "^2.16.0", - "pestphp/pest-plugin-type-coverage": "^2.0.0", - "symfony/process": "^6.3.2" + "pestphp/pest-plugin-type-coverage": "^2.2.0", + "symfony/process": "^6.3.4" }, "bin": [ "bin/pest" @@ -10793,7 +10793,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.16.0" + "source": "https://github.com/pestphp/pest/tree/v2.16.1" }, "funding": [ { @@ -10805,7 +10805,7 @@ "type": "github" } ], - "time": "2023-08-21T08:42:07+00:00" + "time": "2023-08-29T09:30:36+00:00" }, { "name": "pestphp/pest-plugin", diff --git a/config/session.php b/config/session.php index e15cee1f4..447670931 100644 --- a/config/session.php +++ b/config/session.php @@ -18,7 +18,7 @@ | */ - 'driver' => env('SESSION_DRIVER', 'database'), + 'driver' => env('SESSION_DRIVER', 'redis'), /* |-------------------------------------------------------------------------- diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index 19d3aa42e..2ac615cc0 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -15,10 +15,12 @@ public function run(): void 'email' => 'test@example.com', ]); User::factory()->create([ + 'id' => 1, 'name' => 'Normal User (but in root team)', 'email' => 'test2@example.com', ]); User::factory()->create([ + 'id' => 2, 'name' => 'Normal User (not in root team)', 'email' => 'test3@example.com', ]); diff --git a/phpunit.xml b/phpunit.xml index eb13aff19..45cb69439 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,31 +1,28 @@ - - - - ./tests/Unit - - - ./tests/Feature - - - - - ./app - - - - - - - - - - - - - + + + + ./tests/Unit + + + ./tests/Feature + + + + + + + + + + + + + + + + + ./app + + diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 000000000..32fc1c73f --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,133 @@ + + + + + + + + + @env('local') + Coolify - localhost + +@else + {{ $title ?? 'Coolify' }} + + @endenv + + @vite(['resources/js/app.js', 'resources/css/app.css']) + + @livewireStyles + + + + @livewireScripts + @auth + + +
+ +
+
+ {{ $slot }} +
+ + + @endauth + @guest + {{ $slot }} + @endguest + + + diff --git a/resources/views/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php similarity index 84% rename from resources/views/dashboard.blade.php rename to resources/views/livewire/dashboard.blade.php index 4e83f41b3..44e9452a1 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/livewire/dashboard.blade.php @@ -1,4 +1,4 @@ - +

Dashboard

Something useful will be here.
@@ -19,10 +19,7 @@
S3 Storages
-
{{ $s3s->count() }}
+
{{ $s3s }}
- @if (isDev()) - {{-- --}} - @endif -
+ diff --git a/resources/views/livewire/server/all.blade.php b/resources/views/livewire/server/all.blade.php new file mode 100644 index 000000000..8ad9c82a3 --- /dev/null +++ b/resources/views/livewire/server/all.blade.php @@ -0,0 +1,54 @@ +
+
+

Servers

+ + + Add + +
+
All Servers
+ +
diff --git a/resources/views/livewire/server/show.blade.php b/resources/views/livewire/server/show.blade.php new file mode 100644 index 000000000..59f6868a4 --- /dev/null +++ b/resources/views/livewire/server/show.blade.php @@ -0,0 +1,4 @@ +
+ + +
diff --git a/resources/views/server/all.blade.php b/resources/views/server/all.blade.php index 048fb311c..a9b0a4a1f 100644 --- a/resources/views/server/all.blade.php +++ b/resources/views/server/all.blade.php @@ -1,53 +1,3 @@ -
-

Servers

- + Add - -
-
All Servers
-
- @forelse ($servers as $server) -
$server->settings->is_reachable, - 'border-red-500' => !$server->settings->is_reachable, - ])> -
-
- {{ $server->name }} -
-
- {{ $server->description }}
-
- @if (!$server->settings->is_reachable) - Not reachable - @endif - @if (!$server->settings->is_reachable && !$server->settings->is_usable) - & - @endif - @if (!$server->settings->is_usable) - Not usable by Coolify - @endif -
-
-
-
- @empty -
-
No servers found. Without a server, you won't be able to do much.
- -
- @endforelse - @isset($error) -
- {{ $error }} -
- @endisset - -
+
diff --git a/routes/web.php b/routes/web.php index ce98b65b7..2824a0be1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,6 +6,9 @@ use App\Http\Controllers\MagicController; use App\Http\Controllers\ProjectController; use App\Http\Controllers\ServerController; +use App\Http\Livewire\Dashboard; +use App\Http\Livewire\Server\All; +use App\Http\Livewire\Server\Show; use App\Models\GithubApp; use App\Models\GitlabApp; use App\Models\InstanceSettings; @@ -71,13 +74,9 @@ }); Route::middleware(['auth'])->group(function () { - Route::get('/servers', fn () => view('server.all', [ - 'servers' => Server::ownedByCurrentTeam()->get() - ]))->name('server.all'); + Route::get('/servers', All::class)->name('server.all'); Route::get('/server/new', [ServerController::class, 'new_server'])->name('server.create'); - Route::get('/server/{server_uuid}', fn () => view('server.show', [ - 'server' => Server::ownedByCurrentTeam(['name', 'description', 'ip', 'port', 'user', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail(), - ]))->name('server.show'); + Route::get('/server/{server_uuid}', Show::class)->name('server.show'); Route::get('/server/{server_uuid}/proxy', fn () => view('server.proxy', [ 'server' => Server::ownedByCurrentTeam(['name', 'proxy'])->whereUuid(request()->server_uuid)->firstOrFail(), ]))->name('server.proxy'); @@ -92,9 +91,9 @@ Route::middleware(['auth'])->group(function () { - Route::get('/', [Controller::class, 'dashboard'])->name('dashboard'); + Route::get('/', Dashboard::class)->name('dashboard'); Route::get('/boarding', [Controller::class, 'boarding'])->name('boarding'); - Route::middleware(['throttle:force-password-reset'])->group(function() { + Route::middleware(['throttle:force-password-reset'])->group(function () { Route::get('/force-password-reset', [Controller::class, 'force_passoword_reset'])->name('auth.force-password-reset'); }); Route::get('/subscription', [Controller::class, 'subscription'])->name('subscription.show'); diff --git a/tests/Feature/DockerCommandsTest.php b/tests/Feature/DockerCommandsTest.phpold similarity index 100% rename from tests/Feature/DockerCommandsTest.php rename to tests/Feature/DockerCommandsTest.phpold diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php new file mode 100644 index 000000000..e07cdfb06 --- /dev/null +++ b/tests/Feature/ExampleTest.php @@ -0,0 +1,7 @@ +get('/api/health'); + + $response->assertStatus(200); +}); diff --git a/tests/Feature/RemoteProcessTest.php b/tests/Feature/RemoteProcessTest.phpold similarity index 100% rename from tests/Feature/RemoteProcessTest.php rename to tests/Feature/RemoteProcessTest.phpold diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php new file mode 100644 index 000000000..44a4f337a --- /dev/null +++ b/tests/Unit/ExampleTest.php @@ -0,0 +1,5 @@ +toBeTrue(); +}); diff --git a/tests/Unit/RulesTest.php b/tests/Unit/RulesTest.php index 02e14ba48..585e7126c 100644 --- a/tests/Unit/RulesTest.php +++ b/tests/Unit/RulesTest.php @@ -1,5 +1,5 @@ expect(['dd', 'dump', 'ray']) + ->expect(['dd', 'dump']) ->not->toBeUsed();