Skip to content

Commit 9abc482

Browse files
tabacitupxpmStyleCIBotjcastroa87zachweix
authored
v7 - Next CRUD Version (#5715)
* Uploaders - Refactor and fixes (#5478) * add method to get ajax uploaders * Apply fixes from StyleCI [ci skip] [skip ci] * use an abstract class * wip * Apply fixes from StyleCI [ci skip] [skip ci] * refactor uploaders * Apply fixes from StyleCI [ci skip] [skip ci] * refactor rules * Apply fixes from StyleCI [ci skip] [skip ci] * move ajax to PRO, cleanup * Apply fixes from StyleCI [ci skip] [skip ci] * make attributes available for all subfields * fix tests * wip * Apply fixes from StyleCI [ci skip] [skip ci] * upload multiple and upload properly working 🙏 * fixes * Apply fixes from StyleCI [ci skip] [skip ci] * allow the configuration of valueWithoutPath call. * fix valid upload inside repeatables * Apply fixes from StyleCI [ci skip] [skip ci] * fix condition * cleanup * fix * Apply fixes from StyleCI [ci skip] [skip ci] * fix use case for enabling validation after entry is created * Apply fixes from StyleCI [ci skip] [skip ci] * dont save array keys * fix ajax validation * fix validation messages * Apply fixes from StyleCI [ci skip] [skip ci] * fixes ValidUpload * Apply fixes from StyleCI [ci skip] [skip ci] * dont json encode if casted in the model * Apply fixes from StyleCI [ci skip] [skip ci] * fix previous file identification in repeatable * Apply fixes from StyleCI [ci skip] [skip ci] * fix getting values * Apply fixes from StyleCI [ci skip] [skip ci] * add fake fields support * Apply fixes from StyleCI [ci skip] [skip ci] * wip add uploaders tests * Apply fixes from StyleCI [ci skip] [skip ci] * wip * Apply fixes from StyleCI [ci skip] [skip ci] * add pro columns * fix test suite * fix tests * ffix tests * remove unused test views * add uploaders to test coverage * Apply fixes from StyleCI [ci skip] [skip ci] * add coverage folder to gitignore * make tests run faster by not reloading db when not necessary * add coverage to validation tests * add fake tests to uploaders * Apply fixes from StyleCI [ci skip] [skip ci] * add more tests * Apply fixes from StyleCI [ci skip] [skip ci] * wip * Apply fixes from StyleCI [ci skip] [skip ci] * wip * wip * Apply fixes from StyleCI [ci skip] [skip ci] * wip * Apply fixes from StyleCI [ci skip] [skip ci] * add more upload assets * fixes * Apply fixes from StyleCI [ci skip] [skip ci] * fix single file * Apply fixes from StyleCI [ci skip] [skip ci] * add image column * fix tests * Apply fixes from StyleCI [ci skip] [skip ci] * remove hardcoded macro names * Apply fixes from StyleCI [ci skip] [skip ci] * remove double loop, fix single file uploader * Apply fixes from StyleCI [ci skip] [skip ci] * use a big increments and unsigned for primary key * handle pivot file deletion * Apply fixes from StyleCI [ci skip] [skip ci] * register events for relation models * Apply fixes from StyleCI [ci skip] [skip ci] * fix typo * Apply fixes from StyleCI [ci skip] [skip ci] * fix relationship uploaders * Apply fixes from StyleCI [ci skip] [skip ci] * wip * Apply fixes from StyleCI [ci skip] [skip ci] * wip * Apply fixes from StyleCI [ci skip] [skip ci] * update temporary time key * save objects in the macro --------- Co-authored-by: StyleCI Bot <[email protected]> * trigger testing forkflow on PR * Clean up uploaders (#5725) * wip * clean up * add get uploadedFilesFromRequest to clean up uploaders * Apply fixes from StyleCI [ci skip] [skip ci] * fix type cast * add summernote uploader * update summernote * add summernote * add more test assets --------- Co-authored-by: StyleCI Bot <[email protected]> * allow datatable url configuration (#5713) * use next branch for basset * require alpha version * bump basset version * Lifecycle hooks for CRUD operations (#5687) * wip * Apply fixes from StyleCI [ci skip] [skip ci] * tidy up * Apply fixes from StyleCI [ci skip] [skip ci] * panel hooks * Apply fixes from StyleCI [ci skip] [skip ci] * refactoring :broom * finish implementing hooks * Apply fixes from StyleCI [ci skip] [skip ci] * refactoring hooks * Apply fixes from StyleCI [ci skip] [skip ci] * add hook to delete * allow empty parameters * wip --------- Co-authored-by: StyleCI Bot <[email protected]> * "Agnostic" filters - decouple filters from datatables (#5714) * wip * wip * Apply fixes from StyleCI [ci skip] [skip ci] * wip * Apply fixes from StyleCI [ci skip] [skip ci] * remove filters navbar component --------- Co-authored-by: StyleCI Bot <[email protected]> * bump basset version * Update composer.json * Apply fixes from StyleCI [ci skip] [skip ci] * datatable component (#5688) Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Cristian Tabacitu <[email protected]> * move the list heading to the datatable component (#5808) * add Datagrid and Datalist components (#5810) Co-authored-by: StyleCI Bot <[email protected]> * Form component (no ajax form) (#5814) Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Cristian Tabacitu <[email protected]> * dataform component fixes (#5816) Co-authored-by: StyleCI Bot <[email protected]> * Added general chip blade file and chip widget (#5815) * Fix Form issues, Add *name* argument to forms (#5817) Co-authored-by: StyleCI Bot <[email protected]> * Drop support for Laravel 10 and 11 (#5819) * Fix hooks at setup level (#5818) Co-authored-by: StyleCI Bot <[email protected]> * install dev-next version of generators * require basset beta version (#5821) * fix scripts on table * fix the keyboard shortcuts on forms * ensure proper crud identification * fix hooks * fix crud field javacript issue * pass the form id to form content * add error page translations * fix export buttons * wip * wip * wip * map the ui files * fix table without export buttons * always focus on error field * delete button redirect * Apply fixes from StyleCI [ci skip] [skip ci] * Fix padding in name * Fix checkbox padding * Background of select2 * multiple fixes * fix form error highlight * wip * Add toggle to JSON * allow user to choose locale and timezone * fixes bulk actions * fix the filter navbar * fix line buttons dropdown * wip * wip * wip * wip * wip * DataFormModal component (#5863) Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Cristian Tabacitu <[email protected]> Co-authored-by: Cristian Tăbăcitu <[email protected]> * wip * wip * wip * Save action classes (#5878) Enable the usage of classes to describe the save actions. This allow more flexibility and easy to extend and/or configure behaviour. * add cancel button option to modal form (#5881) * fix problem with checklist_dependency field in Update operation * fix indentation * Update src/app/Console/Commands/Install.php * Update composer.json --------- Co-authored-by: Pedro Martins <[email protected]> Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: jcastroa87 <[email protected]> Co-authored-by: zachweix <[email protected]>
1 parent cb4bdb4 commit 9abc482

File tree

183 files changed

+9431
-2084
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+9431
-2084
lines changed

.github/workflows/testing.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: PHP Tests
22

33
on:
44
push:
5+
pull_request:
56
schedule:
67
- cron: '0 0 * * *'
78

@@ -19,25 +20,11 @@ jobs:
1920
# run all combinations of the following, to make sure they're working together
2021
matrix:
2122
# os: [ubuntu-latest, macos-latest, windows-latest]
22-
php: ['8.1', '8.2', '8.3', '8.4']
23-
laravel: [^10.0, ^11.0, ^12.0]
24-
dbal: [^3.0]
25-
phpunit: [10.*, 11.*]
23+
php: ['8.2', '8.3', '8.4']
24+
laravel: [^12.0]
25+
dbal: [^4.0]
26+
phpunit: [11.*]
2627
dependency-version: [stable] # to add: lowest
27-
exclude:
28-
- laravel: "^11.0"
29-
php: "8.1"
30-
dbal: "^3.0"
31-
- laravel: "^12.0"
32-
php: "8.1"
33-
dbal: "^3.0"
34-
- laravel: "^12.0"
35-
php: "8.2"
36-
dbal: "^3.0"
37-
- phpunit: "11.*"
38-
laravel: "^10.0"
39-
- phpunit: "10.*"
40-
laravel: "^12.0"
4128

4229
name: PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}, PHPUnit ${{ matrix.phpunit }}, DBAL ${{ matrix.dbal }} --prefer-${{ matrix.dependency-version }}
4330

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ composer.lock
77
.phpunit.result.cache
88
src/public/packages/
99
/.phpunit.cache
10+
coverage/
1011

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@
3535
}
3636
],
3737
"require": {
38-
"laravel/framework": "^10.0|^11.0|^12",
39-
"backpack/basset": "^1.1.1|^1.3.2",
38+
"laravel/framework": "^12",
39+
"backpack/basset": "^2.0.",
4040
"creativeorange/gravatar": "^1.0",
4141
"prologue/alerts": "^1.0",
42-
"doctrine/dbal": "^3.0|^4.0",
42+
"doctrine/dbal": "^4.0",
4343
"guzzlehttp/guzzle": "^7.0"
4444
},
4545
"require-dev": {
46-
"phpunit/phpunit": "^10.0|^9.0|^11.0",
47-
"orchestra/testbench": "^8.0|^9.0|^10.0",
46+
"phpunit/phpunit": "^11.0",
47+
"orchestra/testbench": "^10.0",
4848
"spatie/laravel-translatable": "^6.0"
4949
},
5050
"autoload": {
@@ -62,9 +62,12 @@
6262
]
6363
},
6464
"scripts": {
65-
"test": "vendor/bin/phpunit --testdox",
65+
"test": [
66+
"@putenv XDEBUG_MODE=off",
67+
"vendor/bin/phpunit"
68+
],
6669
"test-failing": "vendor/bin/phpunit --order-by=defects --stop-on-failure",
67-
"test-coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text"
70+
"test-coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage"
6871
},
6972
"extra": {
7073
"branch-alias": {

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<include>
2424
<directory suffix=".php">./src/app/Library/CrudPanel/Traits/</directory>
2525
<directory>./src/app/Library/Validation/</directory>
26+
<directory>./src/app/Library/Uploaders/</directory>
2627
<directory suffix=".php">./src/app/Library/CrudPanel/</directory>
2728
<directory suffix=".php">./src/app/Models/Traits/</directory>
2829
<file>./src/app/Library/Widget.php</file>
@@ -35,9 +36,11 @@
3536
</source>
3637
<php>
3738
<env name="APP_ENV" value="testing"/>
39+
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
3840
<env name="BCRYPT_ROUNDS" value="12"/>
3941
<env name="CACHE_DRIVER" value="array"/>
4042
<env name="DB_CONNECTION" value="sqlite"/>
43+
<env name="DB_FOREIGN_KEYS" value="true"/>
4144
<env name="DB_DATABASE" value=":memory:"/>
4245
<env name="MAIL_MAILER" value="array"/>
4346
<env name="QUEUE_CONNECTION" value="sync"/>

src/BackpackServiceProvider.php

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use Backpack\Basset\Facades\Basset;
66
use Backpack\CRUD\app\Http\Middleware\EnsureEmailVerification;
77
use Backpack\CRUD\app\Http\Middleware\ThrottlePasswordRecovery;
8-
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
98
use Backpack\CRUD\app\Library\Database\DatabaseSchema;
109
use Backpack\CRUD\app\Library\Uploaders\Support\UploadersRepository;
1110
use Illuminate\Contracts\Debug\ExceptionHandler;
1211
use Illuminate\Routing\Router;
1312
use Illuminate\Support\Collection;
1413
use Illuminate\Support\Facades\Blade;
14+
use Illuminate\Support\Facades\File;
1515
use Illuminate\Support\ServiceProvider;
1616
use Illuminate\Support\Str;
1717
use Illuminate\View\Compilers\BladeCompiler;
@@ -64,6 +64,26 @@ public function boot(Router $router)
6464
$this->sendUsageStats();
6565

6666
Basset::addViewPath(realpath(__DIR__.'/resources/views'));
67+
68+
foreach (config('backpack.ui.styles', []) as $style) {
69+
if (is_array($style)) {
70+
foreach ($style as $file) {
71+
Basset::map($file);
72+
}
73+
} else {
74+
Basset::map($style);
75+
}
76+
}
77+
78+
foreach (config('backpack.ui.scripts', []) as $script) {
79+
if (is_array($script)) {
80+
foreach ($script as $file) {
81+
Basset::map($file);
82+
}
83+
} else {
84+
Basset::map($script);
85+
}
86+
}
6787
}
6888

6989
/**
@@ -79,19 +99,29 @@ public function register()
7999
$this->loadViewsWithFallbacks('crud');
80100
$this->loadViewsWithFallbacks('ui', 'backpack.ui');
81101
$this->loadViewNamespace('widgets', 'backpack.ui::widgets');
102+
ViewNamespaces::addFor('widgets', 'crud::widgets');
103+
82104
$this->loadViewComponents();
105+
$this->registerDynamicBladeComponents();
83106

84107
$this->registerBackpackErrorViews();
85108

86-
// Bind the CrudPanel object to Laravel's service container
87-
$this->app->scoped('crud', function ($app) {
88-
return new CrudPanel();
109+
$this->app->bind('crud', function ($app) {
110+
return CrudManager::identifyCrudPanel();
111+
});
112+
113+
$this->app->scoped('CrudManager', function ($app) {
114+
return new CrudPanelManager();
89115
});
90116

91117
$this->app->scoped('DatabaseSchema', function ($app) {
92118
return new DatabaseSchema();
93119
});
94120

121+
$this->app->scoped('BackpackLifecycleHooks', function ($app) {
122+
return new app\Library\CrudPanel\Hooks\LifecycleHooks();
123+
});
124+
95125
$this->app->singleton('BackpackViewNamespaces', function ($app) {
96126
return new ViewNamespaces();
97127
});
@@ -178,7 +208,7 @@ public function publishFiles()
178208
/**
179209
* Define the routes for the application.
180210
*
181-
* @param \Illuminate\Routing\Router $router
211+
* @param Router $router
182212
* @return void
183213
*/
184214
public function setupRoutes(Router $router)
@@ -197,7 +227,7 @@ public function setupRoutes(Router $router)
197227
/**
198228
* Load custom routes file.
199229
*
200-
* @param \Illuminate\Routing\Router $router
230+
* @param Router $router
201231
* @return void
202232
*/
203233
public function setupCustomRoutes(Router $router)
@@ -315,6 +345,38 @@ public function loadViewComponents()
315345
});
316346
}
317347

348+
/**
349+
* Register dynamic Blade components from the Components directory.
350+
*
351+
* Any Blade component classes that are in that directory will be registered
352+
* as dynamic components with the 'bp-{component-name}' prefix.
353+
*/
354+
private function registerDynamicBladeComponents()
355+
{
356+
$path = __DIR__.'/app/View/Components';
357+
$namespace = 'Backpack\\CRUD\\app\\View\\Components';
358+
359+
if (! is_dir($path)) {
360+
return;
361+
}
362+
363+
foreach (File::allFiles($path) as $file) {
364+
$relativePath = str_replace(
365+
['/', '.php'],
366+
['\\', ''],
367+
Str::after($file->getRealPath(), realpath($path).DIRECTORY_SEPARATOR)
368+
);
369+
370+
$class = $namespace.'\\'.$relativePath;
371+
372+
// Check if the class exists and is a subclass of Illuminate\View\Component
373+
// This ensures that only valid Blade components are registered.
374+
if (class_exists($class) && is_subclass_of($class, \Illuminate\View\Component::class)) {
375+
Blade::component('bp-'.Str::kebab(class_basename($class)), $class);
376+
}
377+
}
378+
}
379+
318380
/**
319381
* Load the Backpack helper methods, for convenience.
320382
*/
@@ -330,7 +392,7 @@ public function loadHelpers()
330392
*/
331393
public function provides()
332394
{
333-
return ['crud', 'widgets', 'BackpackViewNamespaces', 'DatabaseSchema', 'UploadersRepository'];
395+
return ['widgets', 'BackpackViewNamespaces', 'DatabaseSchema', 'UploadersRepository', 'CrudManager'];
334396
}
335397

336398
private function registerBackpackErrorViews()

src/CrudManager.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Backpack\CRUD;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
/**
8+
* @see CrudPanelManager
9+
*/
10+
class CrudManager extends Facade
11+
{
12+
protected static function getFacadeAccessor()
13+
{
14+
return 'CrudManager';
15+
}
16+
}

0 commit comments

Comments
 (0)