Переглянути джерело

Merge remote-tracking branch 'github/2.0' into github

jqh 4 роки тому
батько
коміт
d9ba5360a4

+ 1 - 1
.github/workflows/dusk.yml

@@ -1,4 +1,4 @@
-name: Dcat Admin Dusk
+name: Laravel Dusk
 
 on:
   push:

+ 2 - 2
README.md

@@ -5,8 +5,8 @@
 <br>
 
 <p align="center">
-    <a href="https://travis-ci.org/jqhph/dcat-admin">
-        <img src="https://travis-ci.org/jqhph/dcat-admin.svg?branch=master" alt="Build Status">
+    <a href="https://github.com/jqhph/dcat-admin/actions">
+        <img src="https://github.com/jqhph/dcat-admin/workflows/Laravel%20Dusk/badge.svg" alt="Build Status">
     </a>
     <a href="https://styleci.io/repos/182349597">
         <img src="https://github.styleci.io/repos/182349597/shield" alt="StyleCI">

+ 5 - 65
src/Application.php

@@ -46,11 +46,11 @@ class Application
         return $this->apps ?: ($this->apps = (array) config('admin.multi_app'));
     }
 
-    /**
-     * 设置当前应用配置.
-     *
-     * @param string $app
-     */
+    public function getEnabledApps()
+    {
+        return array_filter($this->getApps());
+    }
+
     public function switch(string $app = null)
     {
         $this->withName($app);
@@ -58,29 +58,16 @@ class Application
         $this->withConfig($this->name);
     }
 
-    /**
-     * 设置应用名称.
-     *
-     * @param string $app
-     */
     public function withName(string $app)
     {
         $this->name = $app;
     }
 
-    /**
-     * 获取当前应用名称.
-     *
-     * @return string
-     */
     public function getName()
     {
         return $this->name ?: static::DEFAULT;
     }
 
-    /**
-     * 注册应用.
-     */
     public function boot()
     {
         $this->registerRoute(static::DEFAULT);
@@ -92,11 +79,6 @@ class Application
         }
     }
 
-    /**
-     * 注册路由.
-     *
-     * @param string|\Closure $pathOrCallback
-     */
     public function routes($pathOrCallback)
     {
         $this->loadRoutesFrom($pathOrCallback, static::DEFAULT);
@@ -123,31 +105,16 @@ class Application
         }
     }
 
-    /**
-     * @return string
-     */
     public function getCurrentApiRoutePrefix()
     {
         return $this->getApiRoutePrefix($this->getName());
     }
 
-    /**
-     * @param string|null $app
-     *
-     * @return string
-     */
     public function getApiRoutePrefix(?string $app = null)
     {
         return $this->getRoutePrefix($app).'dcat-api.';
     }
 
-    /**
-     * 获取路由别名前缀.
-     *
-     * @param string|null $app
-     *
-     * @return string
-     */
     public function getRoutePrefix(?string $app = null)
     {
         $app = $app ?: $this->getName();
@@ -155,25 +122,11 @@ class Application
         return 'dcat.'.$app.'.';
     }
 
-    /**
-     * 获取路由别名.
-     *
-     * @param string|null $route
-     * @param array $params
-     * @param bool $absolute
-     *
-     * @return string
-     */
     public function getRoute(?string $route, array $params = [], $absolute = true)
     {
         return route($this->getRoutePrefix().$route, $params, $absolute);
     }
 
-    /**
-     * 注册应用路由.
-     *
-     * @param string|null $app
-     */
     protected function registerRoute(?string $app)
     {
         $this->switch($app);
@@ -187,11 +140,6 @@ class Application
         }
     }
 
-    /**
-     * 设置应用配置.
-     *
-     * @param string $app
-     */
     protected function withConfig(string $app)
     {
         if (! isset($this->configs[$app])) {
@@ -201,14 +149,6 @@ class Application
         config(['admin' => $this->configs[$app]]);
     }
 
-    /**
-     * 加载路由文件.
-     *
-     * @param  string  $path
-     * @param  string  $app
-     *
-     * @return void
-     */
     protected function loadRoutesFrom($path, ?string $app)
     {
         Route::group(array_filter([

+ 1 - 1
src/Grid/Concerns/HasFilter.php

@@ -154,7 +154,7 @@ $('.async-{$this->getTableId()}').find('.filter-count').text(count > 0 ? ('('+co
 JS
         );
 
-        $url = Helper::fullUrlWithoutQuery(['_pjax']);
+        $url = Helper::urlWithoutQuery($this->filter()->urlWithoutFilters(), ['_pjax', static::ASYNC_NAME]);
 
         Admin::script("$('.grid-filter-form').attr('action', '{$url}');", true);
     }

+ 6 - 1
src/Grid/Concerns/HasQuickSearch.php

@@ -331,7 +331,12 @@ trait HasQuickSearch
     protected function addQuickSearchScript()
     {
         if ($this->isAsyncRequest()) {
-            $url = Helper::fullUrlWithoutQuery(['_pjax']);
+            $url = Helper::fullUrlWithoutQuery([
+                '_pjax',
+                $this->quickSearch->getQueryName(),
+                static::ASYNC_NAME,
+                $this->model()->getPageName(),
+            ]);
 
             Admin::script("$('.quick-search-form').attr('action', '{$url}');", true);
         }

+ 5 - 2
src/Http/Controllers/AuthController.php

@@ -31,7 +31,7 @@ class AuthController extends Controller
     /**
      * Show the login page.
      *
-     * @return Content
+     * @return Content|\Illuminate\Http\RedirectResponse
      */
     public function getLogin(Content $content)
     {
@@ -241,9 +241,12 @@ class AuthController extends Controller
     {
         $request->session()->regenerate();
 
+        $path = $this->getRedirectPath();
+
         return $this->response()
             ->success(trans('admin.login_successful'))
-            ->locationToIntended($this->getRedirectPath())
+            ->locationToIntended($path)
+            ->locationIf(Admin::app()->getEnabledApps(), $path)
             ->send();
     }
 

+ 4 - 0
src/Support/Helper.php

@@ -97,6 +97,10 @@ class Helper
             $value = $value(...(array) $params);
         }
 
+        if ($value instanceof Grid) {
+            return (string) $value->render();
+        }
+
         if ($value instanceof Renderable) {
             return (string) $value->render();
         }

+ 1 - 3
src/Traits/HasPermissions.php

@@ -136,10 +136,8 @@ trait HasPermissions
      *
      * @return void
      */
-    protected static function boot()
+    protected static function bootHasPermissions()
     {
-        parent::boot();
-
         static::deleting(function ($model) {
             $model->roles()->detach();
         });