Skip to content

Commit

Permalink
Merge branch '3.x' into fix-availability-override
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel authored May 29, 2024
2 parents 84eeb57 + 33cad70 commit 5171e5f
Show file tree
Hide file tree
Showing 68 changed files with 841 additions and 395 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ jobs:
matrix:
os: [ubuntu-latest]
php: [8.3, 8.2, 8.1, 8.0]
laravel: [9.*, 10.*]
laravel: [9.*, 10.*, 11.*]
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*

steps:
- name: Set timezone?
Expand Down Expand Up @@ -115,6 +121,15 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "doctrine/dbal:^3.0" --no-interaction --no-update
composer install --prefer-dist --no-interaction --no-plugins
- name: Patch TestCase files for PHP < 8.1
run: |
if php -r 'exit(version_compare(PHP_VERSION, "8.1.0", "<") ? 0 : 1);'; then
for file in tests/integration/TestCase.php tests/Browser/BrowserTestCase.php; do
sed -i 's/protected function onNotSuccessfulTest(Throwable \$t): never/protected function onNotSuccessfulTest(Throwable \$t): void/' "$file";
echo "Patched $file for PHP < 8.1";
done
fi
- name: Setup Node.js
uses: actions/setup-node@v1
with:
Expand All @@ -130,15 +145,25 @@ jobs:
- name: Build twill.
run: ./vendor/bin/testbench twill:build --forTesting
env:
CACHE_STORE: array

- name: Upgrade Chrome
uses: browser-actions/setup-chrome@latest

- name: Upgrade Chrome Driver
run: ./vendor/bin/testbench dusk:chrome-driver --detect

- name: Prepare Testbench Dusk
run: ./vendor/bin/testbench-dusk package:discover

- name: Set PHPUnit config for Laravel 9
if: matrix.laravel == '9.*'
run: |
cp phpunit-legacy.xml phpunit.xml
- name: Execute all tests
run: vendor/bin/phpunit
run: vendor/bin/phpunit --stop-on-error
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}

Expand Down
25 changes: 12 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,37 @@
"ext-json": "*",
"ext-pdo": "*",
"astrotomic/laravel-translatable": "^v11.12",
"cartalyst/tags": "^12.0|^13.0",
"cartalyst/tags": "^12.0 || ^13.0 || ^14.0",
"doctrine/dbal": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"imgix/imgix-php": "^3.0",
"kalnoy/nestedset": "^6.0",
"laravel/framework": "^9.0|^10.0",
"laravel/framework": "^9.0 || ^10.0 || ^11.0",
"laravel/socialite": "^5.3",
"laravel/ui": "^4.0",
"league/flysystem-aws-s3-v3": "^3.0",
"league/glide-laravel": "^1.0",
"league/glide-symfony": "^1.0 || ^2.0",
"matthewbdaly/laravel-azure-storage": "^2.0",
"myclabs/php-enum": "^1.5",
"pragmarx/google2fa-qrcode": "^2.0",
"spatie/laravel-activitylog": "^4.0",
"spatie/laravel-analytics": "^4.0|^5.0",
"spatie/laravel-analytics": "^4.0 || ^5.0",
"spatie/once": "^3.0"
},
"require-dev": {
"area17/phptorch": "dev-main",
"chillerlan/php-qrcode": "~4.0",
"friendsofphp/php-cs-fixer": "^3.0",
"nette/php-generator": "^4.0.3",
"nunomaduro/collision": "^6.0|^7.0|^8.0",
"nunomaduro/collision": "^6.0 || ^7.0 || ^8.0",
"nunomaduro/larastan": "^2.0",
"orchestra/testbench": "^7.8|^8.0",
"orchestra/testbench-dusk": "^7.8|^8.0",
"phpunit/php-invoker": "^3.1",
"phpunit/phpunit": "~9.0",
"rector/rector": "^0.12.15",
"orchestra/testbench": "^7.8 || ^8.0 || ^9.0",
"orchestra/testbench-dusk": "^7.8 || ^8.0 || ^9.0",
"phpunit/php-invoker": "^3.1 || ^4.0",
"phpunit/phpunit": "~9.0 || ~10.0",
"rector/rector": "^0.19.2 || ^1.0 ",
"spatie/invade": "^1.1",
"squizlabs/php_codesniffer": "*",
"torchlight/torchlight-commonmark": "^0.5"
"squizlabs/php_codesniffer": "*"
},
"autoload": {
"psr-4": {
Expand All @@ -71,7 +70,7 @@
"A17\\Twill\\Tests\\Integration\\": "tests/integration",
"A17\\Twill\\Tests\\Browser\\": "tests/Browser",
"A17\\Docs\\": "docs/generator",
"App\\": "vendor/orchestra/testbench-core/laravel/app"
"App\\": "vendor/orchestra/testbench-dusk/laravel/app"
}
},
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion config/twill.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
|--------------------------------------------------------------------------
|
*/
'auth_login_redirect_path' => '/',
'auth_login_redirect_path' => null,

'templates_on_frontend_domain' => false,

Expand Down Expand Up @@ -282,6 +282,14 @@
*/
'debug' => env('APP_DEBUG', false),

/*
|--------------------------------------------------------------------------
| This parameter will throw errors if some error occurs instead of failing
| silently (eg. when rendering blocks)
|--------------------------------------------------------------------------
*/
'strict' => env('TWILL_STRICT', false),

/*
|--------------------------------------------------------------------------
| Base classes for automatic generation of Modules and Capsules
Expand Down
4 changes: 2 additions & 2 deletions docs/content/1_docs/2_getting-started/2_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The starter kit setup is a basic page builder. It comes with:
You can install it in a Laravel application using:

```bash
composer require area17/twill:"^3.0"
composer require area17/twill:"^3.2"
```

:::alert=type.warning:::
Expand All @@ -40,7 +40,7 @@ See [`examples/basic-page-builder`](https://github.com/area17/twill/tree/3.x/exa
Twill package can be added to your application using Composer:

```bash
composer require area17/twill:"^3.0"
composer require area17/twill:"^3.2"
```

:::alert=type.warning:::
Expand Down
153 changes: 141 additions & 12 deletions docs/content/1_docs/4_form-fields/15_conditional-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ You can conditionally display fields based on the values of other fields in your
display a video embed text field only if the type of article, a radio field, is "video" you'd do something like the
following:


:::tabs=currenttab.FormBuilder&items.FormBuilder|FormView:::
:::tab=name.FormBuilder:::

```php
$form->add(\A17\Twill\Services\Forms\Fields\Radios::make()
->name('type')
->label('Article type')
->inline()
->default('long_form')
->options([
[
'value' => 'long_form',
'label' => 'Long form article'
],
[
'value' => 'video',
'label' => 'Video article'
]
])
);

$form->add(\A17\Twill\Services\Forms\Fields\Input::make()
->name('video_embed')
->label('Video embed')
->connectedTo('type', 'video')
);
```

:::#tab:::
:::tab=name.FormView:::

```blade
<x-twill::radios
name="type"
Expand Down Expand Up @@ -34,8 +66,30 @@ following:
</x-twill::formConnectedFields>
```

:::#tab:::
:::#tabs:::

Here's an example based on a checkbox field where the value is either true or false:


:::tabs=currenttab.FormBuilder&items.FormBuilder|FormView:::
:::tab=name.FormBuilder:::

```php
$form->add(\A17\Twill\Services\Forms\Fields\Checkbox::make()
->name('vertical_article')
->label('Vertical story')
);

$form->add(\A17\Twill\Services\Forms\Fields\Medias::make()
->name('vertical_image')
->label('Vertical Image')
->connectedTo('vertical_article', true)
);
```

:::#tab:::
:::tab=name.FormView:::
```blade
<x-twill::checkbox
name="vertical_article"
Expand All @@ -54,8 +108,47 @@ Here's an example based on a checkbox field where the value is either true or fa
</x-twill::formConnectedFields>
```

:::#tab:::
:::#tabs:::

Here's an example based on a checkboxes field where the values are stored in a json field:

:::tabs=currenttab.FormBuilder&items.FormBuilder|Directive:::
:::tab=name.FormBuilder:::

```php
$form->add(\A17\Twill\Services\Forms\Fields\Checkboxes::make()
->name('article_target')
->label('Target')
->min(1)->max(3)->inline()
->options([
[
'value' => 'students',
'label' => 'Students'
],
[
'value' => 'teachers',
'label' => 'Teachers'
],
[
'value' => 'administration',
'label' => 'Administration'
]
])
);

$form->add(\A17\Twill\Services\Forms\Fields\Files::make()
->name('attachment')
->label('Attachment')
->connectedTo('article_target', ['teachers', 'administration'], [
'keepAlive' => true,
'arrayContains' => true, // If you don't pass an array as fieldValues, set to false
])
);
```

:::#tab:::
:::tab=name.Directive:::
```blade
@formField('checkboxes', [
'name' => 'article_target',
Expand All @@ -81,8 +174,9 @@ Here's an example based on a checkboxes field where the values are stored in a j
@formConnectedFields([
'fieldName' => 'article_target',
'fieldValues' => 'administration',
'arrayContains' => false,
'fieldValues' => ['administration', 'teachers'],
'arrayContains' => true, // If you don't pass an array as fieldValues, set to false
'keepAlive' => true,
'renderForBlocks' => true/false # (depending on regular form vs block form)
])
@formField('files', [
Expand All @@ -91,9 +185,42 @@ Here's an example based on a checkboxes field where the values are stored in a j
])
@endformConnectedFields
```
:::#tab:::
:::#tabs:::

Here's an example based on a browser field where the fields are displayed only when the browser field is not empty:

:::tabs=currenttab.FormBuilder&items.FormBuilder|FormView:::
:::tab=name.FormBuilder:::

```php
$form->add(\A17\Twill\Services\Forms\Fields\Browser::make()
->name('related_publications')
->label('Related publications')
->max(4)
->modules([Publications::class]))
);

$form->add(\A17\Twill\Services\Forms\Fields\Input::make()
->name('related_publications_header')
->label('Related publications header')
->connectedTo('article_publications', true, [
'isBrowser' => true,
'keepAlive' => true,
])
);
$form->add(\A17\Twill\Services\Forms\Fields\Input::make()
->name('related_publications_copy')
->label('Related publications copy')
->connectedTo('article_publications', true, [
'isBrowser' => true,
'keepAlive' => true,
])
);
```

:::#tab:::
:::tab=name.FormView:::
```blade
<x-twill::browser
module-name="publication"
Expand All @@ -117,14 +244,16 @@ Here's an example based on a browser field where the fields are displayed only w
/>
</x-twill::formConnectedFields>
```
:::#tab:::
:::#tabs:::

| Option | Description | Type | Default value |
|:------------------|:-------------------------------------------------------------------------------------------------|:------------------|:--------------|
| fieldName | Name of the connected field | string | |
| fieldValues | Value or values of the connected field that will reveal the fields in this component's slot | string&vert;array | |
| isEqual | Controls how `fieldValues` are evaluated against the connected field | boolean | true |
| isBrowser | Indicates that the connected field is a `browser` field | boolean | false |
| arrayContains | Controls how `fieldValues` are evaluated when connected field is an array | boolean | true |
| matchEmptyBrowser | When set to true, the fields in this component's slot will be revealed when the browser is empty | boolean | false |
| keepAlive | When set to true, the state of the hidden fields is preserved | boolean | false |
| renderForBlocks | When used inside a block, this needs to be set to true | string | false |
| Option | Description | Type | Default value |
|:------------------|:--------------------------------------------------------------------------------------------------------------|:------------------|:--------------|
| fieldName | Name of the connected field | string | |
| fieldValues | Value or values of the connected field that will reveal the fields in this component's slot | string&vert;array | |
| isEqual | Controls how `fieldValues` are evaluated against the connected field | boolean | true |
| isBrowser | Indicates that the connected field is a `browser` field | boolean | false |
| arrayContains | Controls how `fieldValues` are evaluated when connected field is an array | boolean | true |
| matchEmptyBrowser | When set to true, the fields in this component's slot will be revealed when the browser is empty | boolean | false |
| keepAlive | When set to true, the state of the hidden fields is preserved | boolean | false |
| renderForBlocks | When used inside a block, this needs to be set to true (this is automatically set when using the FormBuilder) | string | false |
4 changes: 2 additions & 2 deletions docs/content/1_docs/9_buckets/1_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ Finally, add a link to your buckets page in your CMS navigation:
return [
'featured' => [
'title' => 'Features',
'route' => 'admin.featured.homepage',
'route' => 'twill.featured.homepage',
'primary_navigation' => [
'homepage' => [
'title' => 'Homepage',
'route' => 'admin.featured.homepage',
'route' => 'twill.featured.homepage',
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Twill is a standard Laravel package, that means, we only have to require it (and

So, before we get to the process of building our CMS, let's install Twill.

We can do this using `composer require area17/twill:"^3.0"`.
We can do this using `composer require area17/twill:"^3.2"`.

This will install Twill 3 alongside all other required packages.

Expand Down
2 changes: 1 addition & 1 deletion examples/basic-page-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The [Laravel documentation](https://laravel.com/docs/10.x) is far more extensive
Lets require Twill:

```
composer require area17/twill:"^3.0"
composer require area17/twill:"^3.2"
```

And then, install this example:
Expand Down
Loading

0 comments on commit 5171e5f

Please sign in to comment.