Skip to content

Commit

Permalink
Merge pull request #46 from anditsung/support-nova-4
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI authored Apr 29, 2022
2 parents c93b336 + b163456 commit bc10cc8
Show file tree
Hide file tree
Showing 15 changed files with 5,484 additions and 7,666 deletions.
10 changes: 2 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
}
],
"require": {
"php": ">=7.1.0",
"php": ">=8",
"kabbouchi/laravel-ward": "^0.5.0",
"laravel/nova": "^1.0|^2.0|^3.0"
"laravel/nova": "^4"
},
"require-dev": {
"orchestra/testbench": "^3.6",
Expand All @@ -40,12 +40,6 @@
]
}
},
"repositories": [
{
"type": "path",
"url": "../nova-lib"
}
],
"config": {
"sort-packages": true
},
Expand Down
1 change: 1 addition & 0 deletions dist/css/tool.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 2 additions & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions mix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const mix = require('laravel-mix')
const webpack = require('webpack')
const path = require('path')

class NovaExtension {
name() {
return 'nova-extension'
}

register(name) {
this.name = name
}

webpackConfig(webpackConfig) {
webpackConfig.externals = {
vue: 'Vue',
}

webpackConfig.resolve.alias = {
...(webpackConfig.resolve.alias || {}),
'laravel-nova': path.join(
__dirname,
'../../vendor/laravel/nova/resources/js/mixins/packages.js'
),
}

webpackConfig.output = {
uniqueName: this.name,
}
}
}

mix.extend('nova', new NovaExtension())
23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "mix --production",
"format": "prettier --single-quote --write 'resources/**/*.{css,js,vue}'"
},
"devDependencies": {
"cross-env": "^5.0.0",
"laravel-mix": "^1.0",
"@vue/compiler-sfc": "^3.2.22",
"laravel-mix": "^6.0.41",
"prettier": "^1.14.0",
"vue-template-compiler": "^2.5.17"
"vue-loader": "^16.8.3",
"prismjs": "^1.21.0"
},
"dependencies": {
"animated-scroll-to": "^1.2.2",
"prismjs": "^1.21.0",
"vue": "^2.5.0"
}
"dependencies": {}
}
313 changes: 164 additions & 149 deletions resources/js/components/LogsTool.vue

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions resources/js/tool.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
Nova.booting((Vue, router) => {
router.addRoutes([
{
name: 'LogsTool',
path: '/logs',
component: require('./components/LogsTool.vue')
}
]);
});
import LogsTool from "./components/LogsTool";

Nova.booting((app, store) => {
Nova.inertia('Logs', LogsTool)
})
1 change: 0 additions & 1 deletion resources/sass/tool.scss

This file was deleted.

8 changes: 0 additions & 8 deletions resources/views/navigation.blade.php

This file was deleted.

11 changes: 6 additions & 5 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Support\Facades\Route;
use KABBOUCHI\LogsTool\Http\Controllers\LogsController;

/*
|--------------------------------------------------------------------------
Expand All @@ -13,8 +14,8 @@
|
*/

Route::get('logs', \KABBOUCHI\LogsTool\Http\Controllers\LogsController::class.'@index');
Route::get('logs/permissions', \KABBOUCHI\LogsTool\Http\Controllers\LogsController::class.'@permissions');
Route::get('logs/{log}', \KABBOUCHI\LogsTool\Http\Controllers\LogsController::class.'@show');
Route::get('daily-log-files', \KABBOUCHI\LogsTool\Http\Controllers\LogsController::class.'@dailyLogFiles');
Route::delete('logs', \KABBOUCHI\LogsTool\Http\Controllers\LogsController::class.'@destroy');
Route::get('logs', [LogsController::class, 'index']);
Route::get('logs/permissions', [LogsController::class, 'permissions']);
Route::get('logs/{log}', [LogsController::class, 'show']);
Route::get('daily-log-files', [LogsController::class, 'dailyLogFiles']);
Route::delete('logs', [LogsController::class, 'destroy']);
19 changes: 19 additions & 0 deletions routes/inertia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Tool Routes
|--------------------------------------------------------------------------
|
| Here is where you may register Inertia routes for your tool. These are
| loaded by the ServiceProvider of the tool. The routes are protected
| by your tool's "Authorize" middleware by default. Now - go build!
|
*/

Route::get('/', function (Request $request) {
return inertia('Logs');
});
12 changes: 8 additions & 4 deletions src/LogsTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace KABBOUCHI\LogsTool;

use Illuminate\Http\Request;
use Laravel\Nova\Menu\MenuSection;
use Laravel\Nova\Nova;
use Laravel\Nova\Tool as BaseTool;

Expand All @@ -22,13 +23,16 @@ public function boot()
}

/**
* Build the view that renders the navigation links for the tool.
* Build the menu that renders the navigation links for the tool.
*
* @return \Illuminate\View\View
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function renderNavigation()
public function menu(Request $request)
{
return view('LogsTool::navigation');
return MenuSection::make('Logs')
->path('/logs-tool')
->icon('document-duplicate');
}

public static function authorizedToDownload(Request $request)
Expand Down
15 changes: 8 additions & 7 deletions src/LogsToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ class LogsToolServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'LogsTool');

$this->publishes([__DIR__.'/../config/nova-logs-tool.php' => config_path('nova-logs-tool.php'),
], 'nova-logs-tool-config');

$this->app->booted(function () {
$this->routes();
});

$this->publishes([__DIR__.'/../config/nova-logs-tool.php' => config_path('nova-logs-tool.php'),
], 'nova-logs-tool-config');

Nova::serving(function (ServingNova $event) {
//
});
Expand All @@ -42,9 +40,12 @@ protected function routes()
return;
}

Nova::router(['nova', Authorize::class], 'logs-tool')
->group(__DIR__.'/../routes/inertia.php');

Route::middleware(['nova', Authorize::class])
->prefix('nova-vendor/KABBOUCHI/logs-tool')
->group(__DIR__.'/../routes/api.php');
->prefix('nova-vendor/KABBOUCHI/logs-tool')
->group(__DIR__.'/../routes/api.php');
}

/**
Expand Down
9 changes: 7 additions & 2 deletions webpack.mix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
let mix = require('laravel-mix')

mix.js('resources/js/tool.js', 'dist/js')
.sass('resources/sass/tool.scss', 'dist/css');
require('./mix')

mix
.setPublicPath('dist')
.js('resources/js/tool.js', 'js')
.vue({ version: 3 })
.nova('kabbouchi/nova-logs-tool')
Loading

0 comments on commit bc10cc8

Please sign in to comment.