Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup before release #391

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions app/Actions/Server/CreateServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Enums\FirewallRuleStatus;
use App\Enums\ServerProvider;
use App\Enums\ServerStatus;
use App\Enums\ServerType;
use App\Facades\Notifier;
use App\Models\Project;
use App\Models\Server;
Expand Down Expand Up @@ -33,7 +34,7 @@ public function create(User $creator, Project $project, array $input): Server
'ip' => $input['ip'] ?? '',
'port' => $input['port'] ?? 22,
'os' => $input['os'],
'type' => $input['type'],
'type' => ServerType::REGULAR,
'provider' => $input['provider'],
'authentication' => [
'user' => config('core.ssh_user'),
Expand Down Expand Up @@ -124,10 +125,6 @@ public static function rules(Project $project, array $input): array
'required',
Rule::in(config('core.operating_systems')),
],
'type' => [
'required',
Rule::in(config('core.server_types')),
],
'server_provider' => [
Rule::when(function () use ($input) {
return isset($input['provider']) && $input['provider'] != ServerProvider::CUSTOM;
Expand Down
3 changes: 3 additions & 0 deletions app/Enums/ServerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace App\Enums;

/**
* @deprecated server types will be dropped
*/
final class ServerType
{
const REGULAR = 'regular';
Expand Down
34 changes: 0 additions & 34 deletions app/Helpers/HtmxResponse.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Http/Controllers/API/HealthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __invoke()
{
return response()->json([
'success' => true,
'version' => vito_version(),
'version' => config('app.version'),
]);
}
}
2 changes: 0 additions & 2 deletions app/Http/Controllers/API/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Enums\Database;
use App\Enums\PHP;
use App\Enums\ServerProvider;
use App\Enums\ServerType;
use App\Enums\Webserver;
use App\Http\Controllers\Controller;
use App\Http\Resources\ServerResource;
Expand Down Expand Up @@ -52,7 +51,6 @@ public function index(Project $project): ResourceCollection
#[BodyParam(name: 'port', description: 'SSH Port if the provider is custom')]
#[BodyParam(name: 'name', description: 'The name of the server.', required: true)]
#[BodyParam(name: 'os', description: 'The os of the server', required: true)]
#[BodyParam(name: 'type', description: 'Server type', required: true, enum: [ServerType::REGULAR, ServerType::DATABASE])]
#[BodyParam(name: 'webserver', description: 'Web server', required: true, enum: [Webserver::NONE, Webserver::NGINX])]
#[BodyParam(name: 'database', description: 'Database', required: true, enum: [Database::NONE, Database::MYSQL57, Database::MYSQL80, Database::MARIADB103, Database::MARIADB104, Database::MARIADB103, Database::POSTGRESQL12, Database::POSTGRESQL13, Database::POSTGRESQL14, Database::POSTGRESQL15, Database::POSTGRESQL16], )]
#[BodyParam(name: 'php', description: 'PHP version', required: true, enum: [PHP::V70, PHP::V71, PHP::V72, PHP::V73, PHP::V74, PHP::V80, PHP::V81, PHP::V82, PHP::V83])]
Expand Down
5 changes: 3 additions & 2 deletions app/ServerTypes/Regular.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ public function createRules(array $input): array
return [
'webserver' => [
'required',
'in:'.implode(',', config('core.webservers')),
Rule::in(config('core.webservers')),

],
'php' => [
'required',
Rule::in(config('core.php_versions')),
],
'database' => [
'required',
'in:'.implode(',', config('core.databases')),
Rule::in(config('core.databases')),
],
];
}
Expand Down
14 changes: 7 additions & 7 deletions app/Support/helpers.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use App\Exceptions\SSHError;
use App\Helpers\HtmxResponse;
use Filament\Notifications\Actions\Action;
use Filament\Notifications\Notification;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -32,14 +31,15 @@ function date_with_timezone($date, $timezone): string
return $dt->format('Y-m-d H:i:s');
}

function htmx(): HtmxResponse
function show_vito_version(): string
{
return new HtmxResponse;
}
$version = config('app.version');

function vito_version(): string
{
return config('app.version');
if (str($version)->contains('-beta')) {
return str($version)->before('-beta')->toString();
}

return $version;
}

function convert_time_format($string): string
Expand Down
2 changes: 1 addition & 1 deletion app/Web/Pages/Scripts/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/other/scripts.html')
->url('https://vitodeploy.com/scripts')
->openUrlInNewTab(),
Action::make('create')
->label('Create a Script')
Expand Down
4 changes: 2 additions & 2 deletions app/Web/Pages/Servers/CronJobs/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/servers/cronjobs.html')
->url('https://vitodeploy.com/servers/cronjobs')
->openUrlInNewTab(),
Action::make('create')
->authorize(fn () => auth()->user()?->can('create', [CronJob::class, $this->server]))
Expand All @@ -48,7 +48,7 @@ protected function getHeaderActions(): array
TextInput::make('command')
->rules(fn (callable $get) => CreateCronJob::rules($get())['command'])
->helperText(fn () => view('components.link', [
'href' => 'https://vitodeploy.com/servers/cronjobs.html',
'href' => 'https://vitodeploy.com/servers/cronjobs',
'external' => true,
'text' => 'How the command should look like?',
])),
Expand Down
2 changes: 1 addition & 1 deletion app/Web/Pages/Servers/Firewall/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/servers/firewall.html')
->url('https://vitodeploy.com/servers/firewall')
->openUrlInNewTab(),
Action::make('create')
->authorize(fn () => auth()->user()?->can('create', [FirewallRule::class, $this->server]))
Expand Down
111 changes: 57 additions & 54 deletions app/Web/Pages/Servers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
namespace App\Web\Pages\Servers;

use App\Actions\Server\CreateServer as CreateServerAction;
use App\Enums\Database;
use App\Enums\PHP;
use App\Enums\ServerProvider;
use App\Enums\ServerType;
use App\Enums\Webserver;
use App\Models\Server;
use App\Web\Components\Page;
use App\Web\Fields\AlertField;
use App\Web\Fields\ProviderField;
use App\Web\Pages\Settings\ServerProviders\Actions\Create;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
Expand Down Expand Up @@ -57,7 +60,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/servers/create-server.html')
->url('https://vitodeploy.com')
->openUrlInNewTab(),
\Filament\Actions\Action::make('create')
->label('Create a Server')
Expand Down Expand Up @@ -162,21 +165,11 @@ protected function getHeaderActions(): array
->helperText('Run this command on your server as root user')
->disabled()
->visible(fn ($get) => $get('provider') === ServerProvider::CUSTOM),
TextInput::make('name')
->label('Name')
->rules(fn ($get) => CreateServerAction::rules($project, $get())['name']),
Grid::make()
->schema([
TextInput::make('ip')
->label('SSH IP Address')
->rules(fn ($get) => CreateServerAction::rules($project, $get())['ip']),
TextInput::make('port')
->label('SSH Port')
->rules(fn ($get) => CreateServerAction::rules($project, $get())['port']),
])
->visible(fn ($get) => $get('provider') === ServerProvider::CUSTOM),
Grid::make()
->schema([
TextInput::make('name')
->label('Name')
->rules(fn ($get) => CreateServerAction::rules($project, $get())['name']),
Select::make('os')
->label('OS')
->native(false)
Expand All @@ -185,47 +178,57 @@ protected function getHeaderActions(): array
collect(config('core.operating_systems'))
->mapWithKeys(fn ($value) => [$value => $value])
),
Select::make('type')
->label('Server Type')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['type'])
->options(
collect(config('core.server_types'))
->mapWithKeys(fn ($value) => [$value => $value])
)
->default(ServerType::REGULAR),
]),
Grid::make(3)
Grid::make()
->schema([
Select::make('webserver')
->label('Webserver')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['webserver'] ?? [])
->options(
collect(config('core.webservers'))->mapWithKeys(fn ($value) => [$value => $value])
),
Select::make('database')
->label('Database')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['database'] ?? [])
->options(
collect(config('core.databases_name'))
->mapWithKeys(fn ($value, $key) => [
$key => $value.' '.config('core.databases_version')[$key],
])
),
Select::make('php')
->label('PHP')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['php'] ?? [])
->options(
collect(config('core.php_versions'))
->mapWithKeys(fn ($value) => [$value => $value])
),
TextInput::make('ip')
->label('SSH IP Address')
->rules(fn ($get) => CreateServerAction::rules($project, $get())['ip']),
TextInput::make('port')
->label('SSH Port')
->rules(fn ($get) => CreateServerAction::rules($project, $get())['port']),
])
->visible(fn ($get) => $get('provider') === ServerProvider::CUSTOM),
Fieldset::make('Services')
->columns(1)
->schema([
AlertField::make('alert')
->info()
->message('You can install/uninstall services later'),
Grid::make(3)
->schema([
Select::make('webserver')
->label('Webserver')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['webserver'] ?? [])
->default(Webserver::NONE)
->options(
collect(config('core.webservers'))->mapWithKeys(fn ($value) => [$value => $value])
),
Select::make('database')
->label('Database')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['database'] ?? [])
->default(Database::NONE)
->options(
collect(config('core.databases_name'))
->mapWithKeys(fn ($value, $key) => [
$key => $value.' '.config('core.databases_version')[$key],
])
),
Select::make('php')
->label('PHP')
->native(false)
->selectablePlaceholder(false)
->rules(fn ($get) => CreateServerAction::rules($project, $get())['php'] ?? [])
->default(PHP::NONE)
->options(
collect(config('core.php_versions'))
->mapWithKeys(fn ($value) => [$value => $value])
),
]),
]),
])
->modalSubmitActionLabel('Create')
Expand Down
2 changes: 1 addition & 1 deletion app/Web/Pages/Servers/Sites/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/sites/create-site.html')
->url('https://vitodeploy.com/sites/site-types')
->openUrlInNewTab(),
Action::make('create')
->label('Create a Site')
Expand Down
2 changes: 1 addition & 1 deletion app/Web/Pages/Servers/Sites/Pages/Queues/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/sites/queues.html')
->url('https://vitodeploy.com/sites/queues')
->openUrlInNewTab(),
CreateAction::make('create')
->icon('heroicon-o-plus')
Expand Down
2 changes: 1 addition & 1 deletion app/Web/Pages/Servers/Sites/Pages/SSL/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/sites/ssl.html')
->url('https://vitodeploy.com/sites/ssl')
->openUrlInNewTab(),
CreateAction::make('create')
->label('New Certificate')
Expand Down
2 changes: 1 addition & 1 deletion app/Web/Pages/Servers/Sites/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getHeaderActions(): array
->label('Read the Docs')
->icon('heroicon-o-document-text')
->color('gray')
->url('https://vitodeploy.com/sites/application.html')
->url('https://vitodeploy.com/sites/application')
->openUrlInNewTab(),
];
$actionsGroup = [];
Expand Down
Loading
Loading