diff --git a/.github/workflows/build-assets.yml b/.github/workflows/build-assets.yml index f0ec2c8..2df5113 100644 --- a/.github/workflows/build-assets.yml +++ b/.github/workflows/build-assets.yml @@ -2,8 +2,14 @@ name: "Build Assets" on: pull_request: + branches: + - 2.x types: - closed + paths: + - 'resources/views/**.php' + - 'resources/js/**.js' + - 'resources/css/**.css' jobs: if_merged: @@ -12,6 +18,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: Setup Node uses: actions/setup-node@v4 diff --git a/.github/workflows/fix-php-code-styling.yml b/.github/workflows/lint.yml similarity index 82% rename from .github/workflows/fix-php-code-styling.yml rename to .github/workflows/lint.yml index a428b70..aec9c9c 100644 --- a/.github/workflows/fix-php-code-styling.yml +++ b/.github/workflows/lint.yml @@ -2,17 +2,22 @@ name: "Fix PHP code styling" on: pull_request: + branches: + - 2.x types: - closed + paths: + - '**.php' jobs: if_merged: if: github.event.pull_request.merged == true runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: Fix PHP code style issues uses: aglipanci/laravel-pint-action@2.3.1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..a63a689 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,54 @@ +name: "Tests" + +on: + pull_request: + types: + - opened + branches: + - 2.x + paths: + - '**.php' + - '.github/workflows/run-tests.yml' + - 'phpunit.xml.dist' + - 'composer.json' + - 'composer.lock' + +jobs: + run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [8.2, 8.1] + laravel: [10.*] + dependency-version: [prefer-stable] + include: + - laravel: 10.* + testbench: 8.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: "Checkout code" + uses: actions/checkout@v4 + + - name: "Cache dependencies" + uses: actions/cache@v3 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, pdo, pdo_sqlite + coverage: none + + - name: "Install dependencies" + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "filament/filament" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: "Execute tests" + run: ./vendor/bin/pest diff --git a/composer.json b/composer.json index a71a52c..409ef74 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^8.1", - "filament/filament": "^3.0", + "filament/filament": "^3.1", "spatie/laravel-package-tools": "^1.13.5" }, "require-dev": { @@ -25,6 +25,7 @@ "nunomaduro/collision": "^7.0", "orchestra/testbench": "^8.0", "pestphp/pest": "^2.0", + "pestphp/pest-plugin-faker": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "pestphp/pest-plugin-livewire": "^2.0", "phpunit/phpunit": "^10.0", @@ -37,7 +38,8 @@ }, "autoload-dev": { "psr-4": { - "Awcodes\\FilamentTableRepeater\\Tests\\": "tests" + "Awcodes\\FilamentTableRepeater\\Tests\\": "tests/src", + "Awcodes\\FilamentTableRepeater\\Tests\\Database\\Factories\\": "tests/database/factories" } }, "scripts": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fcf08db..4d05e38 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,26 @@ - - tests + + ./tests/ - - - ./src - - - - - - - + + + + + diff --git a/resources/views/components/table-repeater.blade.php b/resources/views/components/table-repeater.blade.php index c059417..e73a086 100644 --- a/resources/views/components/table-repeater.blade.php +++ b/resources/views/components/table-repeater.blade.php @@ -1,5 +1,6 @@ @php use Filament\Forms\Components\Actions\Action; + $containers = $getChildComponentContainers(); $addAction = $getAction($getAddActionName()); @@ -20,7 +21,7 @@ $emptyLabel = $getEmptyLabel(); - $hasActions = $reorderAction->isVisible() || $cloneAction->isVisible() || $deleteAction->isVisible() || $moveUpAction->isVisible() || $moveDownAction->isVisible() || count($visibleExtraItemActions); + $visibleExtraItemActions = []; foreach ($containers as $uuid => $row) { $visibleExtraItemActions = array_filter( @@ -28,6 +29,13 @@ fn (Action $action): bool => $action(['item' => $uuid])->isVisible(), ); } + + $hasActions = $reorderAction->isVisible() + || $cloneAction->isVisible() + || $deleteAction->isVisible() + || $moveUpAction->isVisible() + || $moveDownAction->isVisible() + || filled($visibleExtraItemActions); @endphp @@ -45,7 +53,7 @@ ]) }} > @if (count($containers) || $emptyLabel !== false) -