Skip to content

Commit a2e6ae4

Browse files
committed
Merge branch 'main' into we-need-more-tests
# Conflicts: # tests/Unit/CrudPanel/CrudPanelFiltersTest.php
2 parents a83b59a + 8f7686f commit a2e6ae4

File tree

6 files changed

+85
-66
lines changed

6 files changed

+85
-66
lines changed

package-lock.json

Lines changed: 55 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"lodash": "^4.17.21",
1717
"pace": "0.0.4",
1818
"resolve-url-loader": "^4.0.0",
19-
"sass": "^1.55.0",
19+
"sass": "^1.56.1",
2020
"sass-loader": "^9.0.3",
21-
"vue-template-compiler": "^2.7.8"
21+
"vue-template-compiler": "^2.7.14"
2222
},
2323
"dependencies": {
2424
"@coreui/coreui": "^2.1.16",
@@ -29,10 +29,10 @@
2929
"bootstrap-datepicker": "^1.9.0",
3030
"bootstrap-daterangepicker": "^3.1.0",
3131
"bootstrap-iconpicker": "^1.8.2",
32-
"ckeditor4": "^4.20.0",
32+
"ckeditor4": "^4.20.1",
3333
"cropperjs": "^1.5.12",
34-
"datatables.net": "^1.12.1",
35-
"datatables.net-bs4": "^1.12.1",
34+
"datatables.net": "^1.13.1",
35+
"datatables.net-bs4": "^1.13.1",
3636
"datatables.net-fixedheader": "^3.2.4",
3737
"datatables.net-fixedheader-bs4": "^3.2.4",
3838
"datatables.net-responsive": "^2.3.0",

src/BackpackServiceProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ class BackpackServiceProvider extends ServiceProvider
3030

3131
// Indicates if loading of the provider is deferred.
3232
protected $defer = false;
33+
3334
// Where the route file lives, both inside the package and in the app (if overwritten).
3435
public $routeFilePath = '/routes/backpack/base.php';
36+
3537
// Where custom routes can be written, and will be registered by Backpack.
3638
public $customRoutesFilePath = '/routes/backpack/custom.php';
3739

@@ -40,7 +42,7 @@ class BackpackServiceProvider extends ServiceProvider
4042
*
4143
* @return void
4244
*/
43-
public function boot(\Illuminate\Routing\Router $router)
45+
public function boot(Router $router)
4446
{
4547
$this->loadViewsWithFallbacks();
4648
$this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack');
@@ -259,8 +261,8 @@ public function loadConfigs()
259261
'backpack' => [
260262
'provider' => 'backpack',
261263
'table' => 'password_resets',
262-
'expire' => 60,
263-
'throttle' => config('backpack.base.password_recovery_throttle_notifications'),
264+
'expire' => config('backpack.base.password_recovery_token_expiration', 60),
265+
'throttle' => config('backpack.base.password_recovery_throttle_notifications'),
264266
],
265267
];
266268

src/app/Library/CrudPanel/CrudFilter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public function __construct($options, $values, $logic, $fallbackLogic)
6363
$this->fallbackLogic = $fallbackLogic;
6464
}
6565

66-
if (\Request::has($this->name)) {
67-
$this->currentValue = \Request::input($this->name);
66+
if ($this->crud()->getRequest()->has($this->name)) {
67+
$this->currentValue = $this->crud()->getRequest()->input($this->name);
6868
}
6969
}
7070

@@ -76,7 +76,7 @@ public function __construct($options, $values, $logic, $fallbackLogic)
7676
*/
7777
public function isActive()
7878
{
79-
if (\Request::has($this->name)) {
79+
if ($this->crud()->getRequest()->has($this->name)) {
8080
return true;
8181
}
8282

src/config/backpack/base.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@
236236
// password reset, before they can try again for the same email?
237237
'password_recovery_throttle_notifications' => 600, // time in seconds
238238

239+
// How much time should the token sent to the user email be considered valid?
240+
// After this time expires, user needs to request a new reset token.
241+
'password_recovery_token_expiration' => 60, // time in minutes
242+
239243
// Backpack will prevent an IP from trying to reset the password too many times,
240244
// so that a malicious actor cannot try too many emails, too see if they have
241245
// accounts or to increase the AWS/SendGrid/etc bill.

tests/Unit/CrudPanel/CrudPanelFiltersTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Backpack\CRUD\Tests\Unit\CrudPanel;
44

55
use Backpack\CRUD\app\Library\CrudPanel\CrudFilter;
6+
use Backpack\CRUD\Tests\Unit\Models\User;
67
use Config;
78

89
/**
@@ -42,6 +43,18 @@ public function testItCanClearFilters()
4243
$this->crudPanel->clearFilters();
4344
$this->assertCount(0, $this->crudPanel->filters());
4445
}
46+
47+
public function testItCanCheckIfFilterIsActiveFromRequest()
48+
{
49+
$this->crudPanel->setModel(User::class);
50+
$request = request()->create('/admin/users', 'GET', ['my_custom_filter' => 'foo']);
51+
$request->setRouteResolver(function () use ($request) {
52+
return (new Route('GET', 'admin/users', ['UserCrudController', 'index']))->bind($request);
53+
});
54+
$this->crudPanel->setRequest($request);
55+
56+
$isActive = CrudFilter::name('my_custom_filter')->isActive();
57+
$this->assertTrue($isActive);
4558

4659
public function testItCanCreateAFilterFluently()
4760
{

0 commit comments

Comments
 (0)