Skip to content
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
5 changes: 5 additions & 0 deletions app/Filament/Resources/PluginResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ public static function table(Table $table): Table
})
->sortable(),

Tables\Columns\TextColumn::make('mobile_min_version')
->label('Mobile SDK')
->placeholder('-')
->toggleable(isToggledHiddenByDefault: true),

Tables\Columns\ToggleColumn::make('featured')
->sortable(),

Expand Down
4 changes: 4 additions & 0 deletions app/Services/PluginSyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public function sync(Plugin $plugin): bool
$updateData['android_version'] = $this->extractAndroidVersion($nativephpData);
}

if ($composerData) {
$updateData['mobile_min_version'] = $composerData['require']['nativephp/mobile'] ?? null;
}

if ($readme) {
$updateData['readme_html'] = CommonMark::convertToHtml($readme);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('plugins', function (Blueprint $table) {
$table->string('mobile_min_version')->nullable()->after('android_version');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('plugins', function (Blueprint $table) {
$table->dropColumn('mobile_min_version');
});
}
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions resources/views/components/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class="mx-auto w-full max-w-5xl px-5 lg:px-3 xl:max-w-7xl 2xl:max-w-360"
</div>

<x-footer />

<x-impersonate::banner/>

@livewireScriptConfig
@fluxScripts
@vite('resources/js/app.js')
Expand Down
2 changes: 1 addition & 1 deletion resources/views/customer/ultra/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
</div>
@endif
</div>
<div>
<div class="min-w-0">
<a href="{{ route('plugins.show', $plugin->routeParams()) }}" class="font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300">
{{ $plugin->name }}
</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/customer/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Upgrade to NativePHP Ultra
</h3>
<p class="mt-1 text-sm text-zinc-600 dark:text-zinc-400">
Get all first-party plugins for free, premium support, team management, and more.
Access all first-party plugins at no extra cost, premium support, team management, and more.
</p>
<div class="mt-4">
<a href="{{ route('pricing') }}" class="inline-flex items-center rounded-md border border-transparent bg-black px-4 py-2 text-sm font-medium text-white transition hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-zinc-500 focus:ring-offset-2 dark:bg-white dark:text-black dark:hover:bg-zinc-200">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/mobile-pricing.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class="grid size-7 shrink-0 place-items-center rounded-xl bg-[#D4FD7D] dark:bg-[
>
<x-icons.checkmark class="size-5 shrink-0" />
</div>
<div class="font-medium">All first-party plugins for free</div>
<div class="font-medium">All first-party plugins at no extra cost</div>
</div>
<div class="flex items-center gap-2">
<div
Expand Down
8 changes: 8 additions & 0 deletions resources/views/plugin-show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ class="inline-flex items-center gap-1 text-sm font-medium text-indigo-600 hover:
</dd>
</div>

{{-- NativePHP Mobile --}}
<div class="col-span-2 rounded-xl bg-gray-50 p-3 dark:bg-slate-700/30">
<dt class="text-xs font-medium text-gray-500 dark:text-gray-400">NativePHP Mobile</dt>
<dd class="mt-1 text-sm font-medium text-gray-900 dark:text-white">
{{ $plugin->mobile_min_version ?? '—' }}
</dd>
</div>

{{-- iOS Version --}}
<div class="rounded-xl bg-gray-50 p-3 dark:bg-slate-700/30">
<dt class="text-xs font-medium text-gray-500 dark:text-gray-400">iOS</dt>
Expand Down
44 changes: 44 additions & 0 deletions tests/Feature/PluginShowMobileVersionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Tests\Feature;

use App\Features\ShowPlugins;
use App\Models\Plugin;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Pennant\Feature;
use Tests\TestCase;

class PluginShowMobileVersionTest extends TestCase
{
use RefreshDatabase;

protected function setUp(): void
{
parent::setUp();

Feature::define(ShowPlugins::class, true);
}

public function test_plugin_show_displays_mobile_min_version(): void
{
$plugin = Plugin::factory()->approved()->create([
'mobile_min_version' => '^3.0.0',
]);

$this->get(route('plugins.show', $plugin->routeParams()))
->assertStatus(200)
->assertSee('NativePHP Mobile')
->assertSee('^3.0.0');
}

public function test_plugin_show_displays_dash_when_mobile_min_version_is_null(): void
{
$plugin = Plugin::factory()->approved()->create([
'mobile_min_version' => null,
]);

$this->get(route('plugins.show', $plugin->routeParams()))
->assertStatus(200)
->assertSee('NativePHP Mobile');
}
}
80 changes: 80 additions & 0 deletions tests/Feature/PluginSyncServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace Tests\Feature;

use App\Models\Plugin;
use App\Services\PluginSyncService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;

class PluginSyncServiceTest extends TestCase
{
use RefreshDatabase;

public function test_sync_extracts_mobile_min_version_from_composer_data(): void
{
$composerJson = json_encode([
'name' => 'acme/test-plugin',
'require' => [
'nativephp/mobile' => '^3.0.0',
],
]);

Http::fake([
'api.github.com/repos/acme/test-plugin/contents/composer.json' => Http::response([
'content' => base64_encode($composerJson),
]),
'api.github.com/repos/acme/test-plugin/contents/nativephp.json' => Http::response([], 404),
'raw.githubusercontent.com/*' => Http::response('', 404),
'api.github.com/repos/acme/test-plugin/releases/latest' => Http::response([], 404),
'api.github.com/repos/acme/test-plugin/tags*' => Http::response([]),
'api.github.com/repos/acme/test-plugin/contents/LICENSE*' => Http::response([], 404),
]);

$plugin = Plugin::factory()->create([
'name' => 'acme/test-plugin',
'repository_url' => 'https://github.com/acme/test-plugin',
'mobile_min_version' => null,
]);

$service = new PluginSyncService;
$result = $service->sync($plugin);

$this->assertTrue($result);
$this->assertEquals('^3.0.0', $plugin->fresh()->mobile_min_version);
}

public function test_sync_sets_mobile_min_version_to_null_when_not_in_composer_data(): void
{
$composerJson = json_encode([
'name' => 'acme/test-plugin',
'require' => [
'php' => '^8.2',
],
]);

Http::fake([
'api.github.com/repos/acme/test-plugin/contents/composer.json' => Http::response([
'content' => base64_encode($composerJson),
]),
'api.github.com/repos/acme/test-plugin/contents/nativephp.json' => Http::response([], 404),
'raw.githubusercontent.com/*' => Http::response('', 404),
'api.github.com/repos/acme/test-plugin/releases/latest' => Http::response([], 404),
'api.github.com/repos/acme/test-plugin/tags*' => Http::response([]),
'api.github.com/repos/acme/test-plugin/contents/LICENSE*' => Http::response([], 404),
]);

$plugin = Plugin::factory()->create([
'name' => 'acme/test-plugin',
'repository_url' => 'https://github.com/acme/test-plugin',
'mobile_min_version' => '^2.0.0',
]);

$service = new PluginSyncService;
$result = $service->sync($plugin);

$this->assertTrue($result);
$this->assertNull($plugin->fresh()->mobile_min_version);
}
}
Loading