Skip to content

Commit 6c952fc

Browse files
authored
Merge pull request #45 from cms-multi/feature/4.x
Add support for Filament v4 and v5
2 parents a10de3c + c27be2c commit 6c952fc

14 files changed

Lines changed: 301 additions & 110 deletions

.github/workflows/phpstan.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ on:
88

99
jobs:
1010
phpstan:
11-
name: phpstan
1211
runs-on: ubuntu-latest
12+
name: PHPStan Latest
1313
steps:
1414
- uses: actions/checkout@v4
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.1'
19+
php-version: 8.5
2020
coverage: none
2121

22-
- name: Install composer dependencies
23-
uses: ramsey/composer-install@v3
22+
- name: Install dependencies
23+
env:
24+
XDEBUG_MODE: off
25+
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --ansi
2426

2527
- name: Run PHPStan
26-
run: ./vendor/bin/phpstan --error-format=github
28+
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist --error-format=github

.github/workflows/run-tests.yml

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,112 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
11+
runs-on: ubuntu-latest
1212
strategy:
1313
fail-fast: true
1414
matrix:
15-
os: [ubuntu-latest]
16-
php: [8.1, 8.2]
17-
laravel: [10.*, 11.*, 12.*]
18-
stability: [prefer-stable]
1915
include:
20-
- laravel: 10.*
21-
testbench: 8.*
22-
php: 8.1
23-
- laravel: 11.*
16+
- php: 8.2
17+
laravel: 11.*
18+
filament: 4.*
2419
testbench: 9.*
25-
php: 8.2
26-
- laravel: 12.*
20+
livewire: ^3.0
21+
pest: ^3.8
22+
pest_plugin_laravel: ^3.1
23+
pest_plugin_livewire: ^3.1
24+
- php: 8.2
25+
laravel: 12.*
26+
filament: 4.*
2727
testbench: 10.*
28-
php: 8.2
28+
livewire: ^3.0
29+
pest: ^3.8
30+
pest_plugin_laravel: ^3.1
31+
pest_plugin_livewire: ^3.1
32+
- php: 8.3
33+
laravel: 12.*
34+
filament: 5.*
35+
testbench: 10.*
36+
livewire: ^4.0
37+
pest: ^4.0
38+
pest_plugin_laravel: ^4.0
39+
pest_plugin_livewire: ^4.0
40+
- php: 8.4
41+
laravel: 12.*
42+
filament: 5.*
43+
testbench: 10.*
44+
livewire: ^4.0
45+
pest: ^4.0
46+
pest_plugin_laravel: ^4.0
47+
pest_plugin_livewire: ^4.0
48+
- php: 8.5
49+
laravel: 12.*
50+
filament: 5.*
51+
testbench: 10.*
52+
livewire: ^4.0
53+
pest: ^4.0
54+
pest_plugin_laravel: ^4.0
55+
pest_plugin_livewire: ^4.0
2956

30-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
57+
name: P${{ matrix.php }} - L${{ matrix.laravel }}
3158

3259
steps:
3360
- name: Checkout code
3461
uses: actions/checkout@v4
3562

63+
- name: Validate composer.json and composer.lock
64+
run: composer validate --strict
65+
66+
- name: Cache Composer dependencies
67+
uses: actions/cache@v4
68+
with:
69+
path: vendor
70+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.filament }}-${{ matrix.testbench }}-${{ matrix.livewire }}-${{ hashFiles('**/composer.lock') }}
71+
restore-keys: |
72+
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.filament }}-${{ matrix.testbench }}-${{ matrix.livewire }}-
73+
${{ runner.os }}-composer-
74+
3675
- name: Setup PHP
3776
uses: shivammathur/setup-php@v2
3877
with:
3978
php-version: ${{ matrix.php }}
40-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
41-
coverage: none
79+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, pcov
80+
coverage: pcov
4281

4382
- name: Setup problem matchers
4483
run: |
4584
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
4685
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
4786
4887
- name: Install dependencies
88+
env:
89+
XDEBUG_MODE: off
4990
run: |
50-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
51-
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
91+
composer require \
92+
"laravel/framework:${{ matrix.laravel }}" \
93+
"orchestra/testbench:${{ matrix.testbench }}" \
94+
"filament/filament:${{ matrix.filament }}" \
95+
"livewire/livewire:${{ matrix.livewire }}" \
96+
"pestphp/pest:${{ matrix.pest }}" \
97+
"pestphp/pest-plugin-laravel:${{ matrix.pest_plugin_laravel }}" \
98+
"pestphp/pest-plugin-livewire:${{ matrix.pest_plugin_livewire }}" \
99+
--no-interaction --no-update --no-progress --ansi
100+
composer update --prefer-stable --prefer-dist --no-interaction --no-progress --ansi
52101
53-
- name: Execute tests
54-
run: vendor/bin/pest
102+
- name: Prepare coverage directory
103+
run: mkdir -p build/logs
104+
105+
- name: Execute tests with coverage
106+
run: vendor/bin/pest --coverage --coverage-clover build/logs/clover.xml
107+
108+
- name: Sanitize artifact name
109+
run: |
110+
LARAVEL_SAFE=$(echo "${{ matrix.laravel }}" | tr '*' 'x')
111+
FILAMENT_SAFE=$(echo "${{ matrix.filament }}" | tr '*' 'x')
112+
echo "ARTIFACT_NAME=coverage-${{ matrix.php }}-${LARAVEL_SAFE}-${FILAMENT_SAFE}" >> $GITHUB_ENV
113+
114+
- name: Upload coverage artifact
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: ${{ env.ARTIFACT_NAME }}
118+
path: build/logs/clover.xml
119+
if-no-files-found: error

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.DS_Store
1+
**/.DS_Store
22
.idea
33
.phpunit.result.cache
4+
.phpunit.cache
45
.vscode
56
build
67
composer.lock

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ Add a button to easily clear the cache from your filament admin.
1212

1313
#### Compatibility
1414

15-
| Plugin Version | Filament Version | PHP Version |
16-
|----------------|-----------------|-------------|
17-
| [1.x](https://github.com/cms-multi/filament-clear-cache/tree/1.x) | 2.x | \> 8.0 |
18-
| [2.x](https://github.com/cms-multi/filament-clear-cache/tree/2.x) | 3.x | \> 8.1 |
15+
| Plugin Version | Filament Version | PHP Version |
16+
|-------------------------------------------------------------------|------------------|-------------|
17+
| [1.x](https://github.com/cms-multi/filament-clear-cache/tree/1.x) | 2.x | \> 8.0 |
18+
| [2.x](https://github.com/cms-multi/filament-clear-cache/tree/2.x) | 3.x | \> 8.1 |
19+
| [3.x](https://github.com/cms-multi/filament-clear-cache/tree/3.x) | 4.x + 5.x | \> 8.2 |
20+
1921

2022
## Installation
2123

@@ -67,7 +69,7 @@ To increment the button count call Livewire event `clearCacheIncrement`.
6769
// Livewire v2
6870
$this->emit('clearCacheIncrement');
6971

70-
// Livewire v3
72+
// Livewire v3+
7173
$this->dispatch('clearCacheIncrement')->to(\CmsMulti\FilamentClearCache\Http\Livewire\ClearCache::class);
7274
```
7375

composer.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "cms-multi/filament-clear-cache",
33
"description": "Clear your cache easily from within filament",
44
"keywords": [
5-
"filament",
6-
"laravel",
7-
"filament-clear-cache"
5+
"filament-clear-cache",
6+
"filamentphp",
7+
"laravel"
88
],
99
"homepage": "https://github.com/cms-multi/filament-clear-cache",
1010
"support": {
@@ -20,25 +20,23 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^8.1",
24-
"filament/filament": "^3.0",
25-
"filament/notifications": "^3.0",
26-
"spatie/laravel-package-tools": "^1.15.0",
27-
"illuminate/contracts": "^10.0|^11.0|^12.0"
23+
"php": "^8.2",
24+
"filament/filament": "^4.0 || ^5.0",
25+
"filament/notifications": "^4.0 || ^5.0",
26+
"spatie/laravel-package-tools": "^1.15",
27+
"illuminate/contracts": "^11.0 || ^12.0"
2828
},
2929
"require-dev": {
3030
"laravel/pint": "^1.0",
31-
"nunomaduro/collision": "^7.9",
32-
"nunomaduro/larastan": "^2.0.1",
33-
"orchestra/testbench": "^8.0",
34-
"pestphp/pest": "^2.0",
35-
"pestphp/pest-plugin-arch": "^2.0",
36-
"pestphp/pest-plugin-laravel": "^2.0",
37-
"pestphp/pest-plugin-livewire": "^2.1",
38-
"phpstan/extension-installer": "^1.1",
39-
"phpstan/phpstan-deprecation-rules": "^1.0",
40-
"phpstan/phpstan-phpunit": "^1.0",
41-
"spatie/laravel-ray": "^1.26"
31+
"larastan/larastan": "^3.0",
32+
"orchestra/testbench": "^10.0",
33+
"pestphp/pest": "^4.0",
34+
"pestphp/pest-plugin-laravel": "^4.0",
35+
"pestphp/pest-plugin-livewire": "^4.0",
36+
"phpstan/phpstan": "^2.1",
37+
"phpstan/extension-installer": "^1.4",
38+
"phpstan/phpstan-deprecation-rules": "^2.0",
39+
"phpstan/phpstan-phpunit": "^2.0"
4240
},
4341
"autoload": {
4442
"psr-4": {
@@ -52,14 +50,16 @@
5250
},
5351
"scripts": {
5452
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
55-
"analyse": "vendor/bin/phpstan analyse",
56-
"test": "vendor/bin/pest",
57-
"test-coverage": "vendor/bin/pest --coverage",
58-
"format": "vendor/bin/pint"
53+
"analyse": "phpstan analyse",
54+
"lint": "pint",
55+
"test": "pest",
56+
"test:coverage": "pest --coverage",
57+
"test:lint": "pint --test"
5958
},
6059
"config": {
6160
"sort-packages": true,
6261
"allow-plugins": {
62+
"composer/package-versions-deprecated": true,
6363
"pestphp/pest-plugin": true,
6464
"phpstan/extension-installer": true
6565
}

phpstan-baseline.neon

Whitespace-only changes.

phpstan.neon.dist

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
includes:
2-
- phpstan-baseline.neon
3-
41
parameters:
52
level: 4
63
paths:
74
- src
5+
- config
86
tmpDir: build/phpstan
97
checkOctaneCompatibility: true
108
checkModelProperties: true
11-
checkMissingIterableValueType: false
129

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
1-
<button
2-
x-data="{{ json_encode(['visible' => $visible]) }}"
3-
x-show="visible"
4-
wire:click="clear"
5-
wire:loading.attr="disabled"
6-
wire:key="clear-cache-button"
7-
type="button"
8-
class="flex flex-shrink-0 w-10 h-10 rounded-full bg-gray-200 items-center justify-center relative dark:bg-gray-900"
9-
x-tooltip.raw="{{ __('filament-clear-cache::general.clear_cache') }}"
10-
>
11-
@svg('heroicon-s-trash', 'w-5 h-5', ['wire:loading.remove.delay'])
1+
<div class="relative">
2+
<x-filament::icon-button
3+
icon="heroicon-o-trash"
4+
color="gray"
5+
class="flex-shrink-0 w-10 h-10 rounded-full"
6+
tooltip="Clear Cache"
7+
wire:click="clear"
8+
wire:loading.attr="disabled"
9+
x-data="{ visible: true }"
10+
x-show="visible"
11+
wire:key="clear-cache-button"
12+
>
13+
<x-slot name="icon">
14+
<svg wire:loading.remove.delay class="w-5 h-5" xmlns="http://www.w3.org/2000/svg"
15+
viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
16+
<path fill-rule="evenodd"
17+
d="M16.5 4.478v.227a48.816 48.816 0 0 1 3.878.512.75.75 0 1 1-.256 1.478l-.209-.035-1.005 13.07a3 3 0 0 1-2.991 2.77H8.084a3 3 0 0 1-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 0 1-.256-1.478A48.567 48.567 0 0 1 7.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 0 1 3.369 0c1.603.051 2.815 1.387 2.815 2.951Zm-6.136-1.452a51.196 51.196 0 0 1 3.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 0 0-6 0v-.113c0-.794.609-1.428 1.364-1.452Zm-.355 5.945a.75.75 0 1 0-1.5.058l.347 9a.75.75 0 1 0 1.499-.058l-.346-9Zm5.48.058a.75.75 0 1 0-1.498-.058l-.347 9a.75.75 0 0 0 1.5.058l.345-9Z"
18+
clip-rule="evenodd" />
19+
</svg>
20+
</x-slot>
1221

13-
<x-filament::loading-indicator x-cloak wire:loading.delay wire:target="clear" class="filament-button-icon w-5 h-5"/>
14-
15-
@if ($cache_count)
16-
<span x-cloak
17-
@class([
18-
"flex items-center justify-center rounded-full bg-primary-500 text-white text-center overflow-hidden absolute text-xs font-bold",
19-
"w-5 h-5" => $cache_count <= 99,
20-
"w-6 h-6" => $cache_count > 99,
21-
])
22-
style="top:-0.4rem;right:-0.4rem;line-height:1;letter-spacing:-1px;font-size:10px;font-weight:600;word-spacing:-1px;"
23-
>
24-
@if($cache_count > 99)
25-
<span>99<span style="vertical-align:text-top;">+</span></span>
26-
@else
27-
{{ $cache_count }}
28-
@endif
22+
<svg wire:loading.delay wire:target="clear"
23+
class="fi-icon fi-loading-indicator fi-size-md filament-button-icon w-5 h-5"
24+
fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
25+
<path clip-rule="evenodd"
26+
d="M12 19C15.866 19 19 15.866 19 12C19 8.13401 15.866 5 12 5C8.13401 5 5 8.13401 5 12C5 15.866 8.13401 19 12 19ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"
27+
fill-rule="evenodd" fill="currentColor" opacity="0.2"/>
28+
<path d="M2 12C2 6.47715 6.47715 2 12 2V5C8.13401 5 5 8.13401 5 12H2Z"
29+
fill="currentColor"/>
30+
</svg>
31+
</x-filament::icon-button>
32+
@if($cache_count > 0)
33+
<span
34+
wire:loading.remove
35+
class="absolute -top-1 -right-1 bg-danger-500 text-white text-xs font-bold w-5 h-5 flex items-center justify-center rounded-full shadow">
36+
{{ $cache_count }}
2937
</span>
3038
@endif
31-
</button>
39+
</div>

0 commit comments

Comments
 (0)