Skip to content

Commit

Permalink
Merge pull request #39 from mertasan/nova4
Browse files Browse the repository at this point in the history
Nova 4 Compatibility
  • Loading branch information
llaski authored Apr 11, 2022
2 parents 7ec1500 + b74b681 commit 0065e3f
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
php: [ '7.3', '7.4', '8.0' ]

name: Tests

Expand All @@ -24,13 +24,13 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Setup Laravel Nova Credentials
run: composer config http-basic.nova.laravel.com ${NOVA_USERNAME} ${NOVA_PASSWORD}
env:
NOVA_PASSWORD: ${{ secrets.NOVA_PASSWORD }}
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}

- name: Cache composer dependencies
uses: actions/cache@v1
with:
Expand All @@ -39,6 +39,6 @@ jobs:

- name: Install composer dependencies
run: composer install --no-ansi --no-interaction --no-scripts --prefer-dist --no-progress

- name: Execute tests
run: vendor/bin/phpunit --verbose
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
}
],
"require": {
"php": ">=7.2.0",
"php": "^7.3|^8.0",
"dragonmantank/cron-expression": "^2.2|^3.0",
"laravel/nova": "^2.0|^3.0",
"laravel/nova": "^4.0",
"illuminate/console": "^6.0|^7.0|^8.0|^9.0"
},
"require-dev": {
Expand Down Expand Up @@ -53,4 +53,4 @@
"url": "https://nova.laravel.com"
}
]
}
}
3 changes: 2 additions & 1 deletion dist/js/app.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/js/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! moment.js

//! moment.js locale configuration
3 changes: 3 additions & 0 deletions dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"/js/app.js": "/js/app.js"
}
2 changes: 1 addition & 1 deletion mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"/dist/js/app.js": "/dist/js/app.js"
}
}
31 changes: 31 additions & 0 deletions nova.mix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const mix = require('laravel-mix');
const webpack = require('webpack');

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

register(name) {
this.name = name
}

webpackPlugins() {
return new webpack.ProvidePlugin({
_: 'lodash',
Errors: 'form-backend-validation'
})
}

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

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

mix.extend('nova', new NovaExtension());
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +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"
},
"devDependencies": {
"cross-env": "^5.0.0",
"laravel-mix": "^1.0"
"laravel-mix": "^6.0",
"vue-loader": "^16.8.3"
},
"dependencies": {
"vue": "^2.5.0"
"moment": "^2.29.2",
"vue": "^3.0"
}
}
}
18 changes: 9 additions & 9 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Nova.booting((Vue, router) => {
Vue.component('nova-scheduled-jobs', require('./components/Card'))
Vue.component('dispatch-job-modal', require('./components/DispatchJobModal'))
import Card from './components/Card'
import DispatchJobModal from './components/DispatchJobModal'
import Tool from './components/Tool'

router.addRoutes([{
name: 'NovaScheduledJobs',
path: '/scheduled-jobs',
component: require('./components/Tool'),
}, ])
})
Nova.booting((app, router) => {
app.component('nova-scheduled-jobs', Card)
app.component('dispatch-job-modal', DispatchJobModal)

Nova.inertia('NovaScheduledJobs', Tool)
})
4 changes: 3 additions & 1 deletion resources/js/mixins/formatters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import moment from 'moment'

export default {

methods: {
Expand All @@ -8,4 +10,4 @@ export default {

}

}
}
8 changes: 8 additions & 0 deletions routes/inertia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

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

Route::get('/scheduled-jobs', function (Request $request) {
return inertia('NovaScheduledJobs');
});
17 changes: 17 additions & 0 deletions src/Http/Middleware/Authorize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Llaski\NovaScheduledJobs\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class Authorize
{
public function handle(Request $request, Closure $next): Response
{
return $next($request);
}
}
8 changes: 6 additions & 2 deletions src/NovaScheduledJobsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\ServiceProvider;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Nova;
use Llaski\NovaScheduledJobs\Http\Middleware\Authorize;

class NovaScheduledJobsServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -46,7 +47,10 @@ protected function routes()
return;
}

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

Route::middleware(['nova', Authorize::class])
->prefix('nova-vendor/llaski/nova-scheduled-jobs')
->group(__DIR__ . '/../routes/api.php');
}
Expand Down Expand Up @@ -75,4 +79,4 @@ protected function bootTranslations()
Nova::translations(__DIR__.'/../resources/lang/'.$currentLocale.'.json');
Nova::translations(resource_path('lang/vendor/nova-scheduled-jobs/'.$currentLocale.'.json'));
}
}
}
17 changes: 16 additions & 1 deletion src/NovaScheduledJobsTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

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

class NovaScheduledJobsTool extends Tool
{
Expand All @@ -16,4 +18,17 @@ public function renderNavigation()
{
return view('nova-scheduled-jobs::navigation');
}
}

/**
* Build the menu that renders the navigation links for the tool.
*
* @param Request $request
* @return mixed
*/
public function menu(Request $request)
{
return MenuSection::make('Scheduled Jobs')
->path('/scheduled-jobs')
->icon('calendar');
}
}
8 changes: 7 additions & 1 deletion webpack.mix.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
let mix = require('laravel-mix')
let path = require('path')

mix.js('resources/js/app.js', 'dist/js')
require('./nova.mix')

mix.setPublicPath('dist')
.js('resources/js/app.js', 'js')
.vue({ version: 3 })
.nova('llaski/nova-scheduled-jobs');

0 comments on commit 0065e3f

Please sign in to comment.