From bb898ea2e44db5fe23a2a0a01082732e3c18ce35 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Thu, 19 Sep 2019 23:09:53 +0800 Subject: [PATCH] Use `message` to report plugin errors Instead of `notification` --- app/Listeners/NotifyFailedPlugin.php | 18 +++++++++--------- resources/assets/src/scripts/element.ts | 2 -- resources/assets/src/styles/element.scss | 1 - resources/lang/en/errors.yml | 4 +--- resources/lang/zh_CN/errors.yml | 4 +--- tests/ListenersTest/NotifyFailedPluginTest.php | 3 +-- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/Listeners/NotifyFailedPlugin.php b/app/Listeners/NotifyFailedPlugin.php index 2134177d..af8bafc5 100644 --- a/app/Listeners/NotifyFailedPlugin.php +++ b/app/Listeners/NotifyFailedPlugin.php @@ -9,17 +9,17 @@ class NotifyFailedPlugin public function handle($event) { $plugin = $event->plugin; - $user = auth()->user(); - if ($user && $user->isAdmin()) { - Event::listen(\App\Events\RenderingFooter::class, function ($event) use ($plugin) { + Event::listen(\App\Events\RenderingFooter::class, function ($event) use ($plugin) { + $user = auth()->user(); + if ($user && $user->isAdmin()) { $options = json_encode([ - 'type' => 'warning', - 'title' => trans('errors.plugins.boot.title'), - 'message' => trans('errors.plugins.boot.message', ['plugin' => trans($plugin->title)]), + 'type' => 'error', + 'message' => trans('errors.plugins.boot', ['plugin' => trans($plugin->title)]), 'duration' => 0, + 'showClose' => true, ]); - $event->addContent(''); - }); - } + $event->addContent(''); + } + }); } } diff --git a/resources/assets/src/scripts/element.ts b/resources/assets/src/scripts/element.ts index 9a0cabd3..c679c223 100644 --- a/resources/assets/src/scripts/element.ts +++ b/resources/assets/src/scripts/element.ts @@ -5,7 +5,6 @@ import { Message, MessageBox, Switch, - Notification, } from 'element-ui' Vue.use(Button) @@ -26,5 +25,4 @@ blessing.ui = { alert: MessageBox.alert, confirm: MessageBox.confirm, prompt: MessageBox.prompt, - notify: Notification, } diff --git a/resources/assets/src/styles/element.scss b/resources/assets/src/styles/element.scss index 42e6b3de..d8bce12c 100644 --- a/resources/assets/src/styles/element.scss +++ b/resources/assets/src/styles/element.scss @@ -2,5 +2,4 @@ @import '~element-theme-chalk/src/input.scss'; @import '~element-theme-chalk/src/message.scss'; @import '~element-theme-chalk/src/message-box.scss'; -@import '~element-theme-chalk/src/notification.scss'; @import '~element-theme-chalk/src/switch.scss'; diff --git a/resources/lang/en/errors.yml b/resources/lang/en/errors.yml index 852f47da..5668fb5a 100644 --- a/resources/lang/en/errors.yml +++ b/resources/lang/en/errors.yml @@ -19,9 +19,7 @@ exception: plugins: duplicate: The plugin [:dir1] has a duplicated plugin name definition which is same to plugin [:dir2]. Please check your plugins directory, remove one of them or use another name definition. directory: We can't approach the path for loading plugins specified by the PLUGINS_DIR in .env file. Please check your configuration. Error :msg - boot: - title: Failed to boot plugin. - message: There is something wrong with plugin ":plugin". Please check logs for detail. + boot: There is something wrong with plugin ":plugin". cipher: unsupported: Unsupported password hashing method `:cipher`, please check your `.env` configuration diff --git a/resources/lang/zh_CN/errors.yml b/resources/lang/zh_CN/errors.yml index 324209bd..67453582 100644 --- a/resources/lang/zh_CN/errors.yml +++ b/resources/lang/zh_CN/errors.yml @@ -20,9 +20,7 @@ exception: plugins: duplicate: 【插件定义重复】:dir1 目录下的插件与 :dir2 目录下的插件使用了相同的 name 定义并造成了冲突。请检查你的插件目录,移除其中一个插件或者使用不同的 name 属性。 directory: 配置文件 .env 中指定的插件加载目录(PLUGINS_DIR)不存在或无法打开,请检查你的配置。错误信息::msg - boot: - title: 插件加载失败 - message: 「:plugin」插件存在错误,无法加载。详细信息请见日志。 + boot: 「:plugin」插件存在错误,无法加载。 cipher: unsupported: 不支持的密码加密方式 `:cipher`,请检查你的 .env 配置文件 diff --git a/tests/ListenersTest/NotifyFailedPluginTest.php b/tests/ListenersTest/NotifyFailedPluginTest.php index d6d53f1c..c2d35ea3 100644 --- a/tests/ListenersTest/NotifyFailedPluginTest.php +++ b/tests/ListenersTest/NotifyFailedPluginTest.php @@ -24,7 +24,6 @@ class NotifyFailedPluginTest extends TestCase $this->actAs('admin'); event(new Events\PluginBootFailed($plugin)); event(new Events\RenderingFooter($content)); - $this->assertCount(1, $content); - $this->assertStringContainsString('blessing.ui.notify', $content[0]); + $this->assertStringContainsString('blessing.ui.message', $content[0]); } }