Skip to content
Permalink
Browse files

Work on adding Nova Tool

  • Loading branch information...
mikebronner committed Nov 28, 2018
1 parent dccc4af commit d69e3a246b9ba291ba10a66a8681a83a16796dd5
@@ -1,4 +1,10 @@
/.idea
/vendor
/node_modules
package-lock.json
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
.DS_Store
Thumbs.db
@@ -38,11 +38,15 @@
"providers": [
"GeneaLabs\\LaravelGovernor\\Providers\\Auth",
"GeneaLabs\\LaravelGovernor\\Providers\\Route",
"GeneaLabs\\LaravelGovernor\\Providers\\Service"
"GeneaLabs\\LaravelGovernor\\Providers\\Service",
"GeneaLabs\\LaravelGovernor\\Providers\\Tool"
]
}
},
"config": {
"sort-packages": true,
"preferred-install": "dist"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
No changes.

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,4 @@
{
"/js/tool.js": "/js/tool.js",
"/css/tool.css": "/css/tool.css"
}
@@ -0,0 +1,19 @@
{
"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",
"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"
},
"devDependencies": {
"cross-env": "^5.0.0",
"laravel-mix": "^1.0"
},
"dependencies": {
"vue": "^2.5.0"
}
}
@@ -0,0 +1,30 @@
<template>
<div>
<heading class="mb-6">Laravel Nova Governor</heading>

<card class="bg-90 flex flex-col items-center justify-center" style="min-height: 300px">
<svg class="spin fill-80 mb-6" width="69" height="72" viewBox="0 0 23 24" xmlns="http://www.w3.org/2000/svg"><path d="M20.12 20.455A12.184 12.184 0 0 1 11.5 24a12.18 12.18 0 0 1-9.333-4.319c4.772 3.933 11.88 3.687 16.36-.738a7.571 7.571 0 0 0 0-10.8c-3.018-2.982-7.912-2.982-10.931 0a3.245 3.245 0 0 0 0 4.628 3.342 3.342 0 0 0 4.685 0 1.114 1.114 0 0 1 1.561 0 1.082 1.082 0 0 1 0 1.543 5.57 5.57 0 0 1-7.808 0 5.408 5.408 0 0 1 0-7.714c3.881-3.834 10.174-3.834 14.055 0a9.734 9.734 0 0 1 .03 13.855zM4.472 5.057a7.571 7.571 0 0 0 0 10.8c3.018 2.982 7.912 2.982 10.931 0a3.245 3.245 0 0 0 0-4.628 3.342 3.342 0 0 0-4.685 0 1.114 1.114 0 0 1-1.561 0 1.082 1.082 0 0 1 0-1.543 5.57 5.57 0 0 1 7.808 0 5.408 5.408 0 0 1 0 7.714c-3.881 3.834-10.174 3.834-14.055 0a9.734 9.734 0 0 1-.015-13.87C5.096 1.35 8.138 0 11.5 0c3.75 0 7.105 1.68 9.333 4.319C16.06.386 8.953.632 4.473 5.057z" fill-rule="evenodd"/></svg>

<h1 class="text-white text-4xl text-90 font-light mb-6">
We're in a black hole.
</h1>

<p class="text-white-50% text-lg">
You can edit this tool's component at:
<code class="ml-1 border border-80 text-sm font-mono text-white bg-black rounded px-2 py-1">/nova-components/LaravelNovaGovernor/resources/js/components/Tool.vue</code>
</p>
</card>
</div>
</template>

<script>
export default {
mounted() {
//
},
}
</script>

<style>
/* Scoped Styles */
</style>
@@ -0,0 +1,9 @@
Nova.booting((Vue, router) => {
router.addRoutes([
{
name: 'laravel-nova-governor',
path: '/laravel-nova-governor',
component: require('./components/Tool'),
},
])
})
@@ -0,0 +1 @@
// Nova Tool CSS
@@ -0,0 +1,6 @@
<router-link tag="h3" :to="{name: 'laravel-nova-governor'}" class="cursor-pointer flex items-center font-normal dim text-white mb-6 text-base no-underline">
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill="var(--sidebar-icon)" d="M3 1h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2V3c0-1.1045695.8954305-2 2-2zm0 2v4h4V3h-4zM3 11h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2H3c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4H3zm10-2h4c1.1045695 0 2 .8954305 2 2v4c0 1.1045695-.8954305 2-2 2h-4c-1.1045695 0-2-.8954305-2-2v-4c0-1.1045695.8954305-2 2-2zm0 2v4h4v-4h-4z"/></svg>
<span class="sidebar-label">
Laravel Nova Governor
</span>
</router-link>
@@ -16,9 +16,16 @@
</div>
<div class="panel-body">

@model($role, ['route' => ['genealabs.laravel-governor.roles.update', $role->name], 'method' => 'PUT', 'framework' => 'bootstrap3', 'class' => 'form-horizontal', 'id' => 'editForm', 'labelWidth' => 2, 'fieldWidth' => 10, 'onsubmit' => 'enableFields();'])
@text('name', null, ['disabled' => ($role->name === 'Member' ? 'disabled' : '')])
@textarea('description', null, ['disabled' => ($role->name === 'Member' ? 'disabled' : '')])
@form ($role, ['route' => ['genealabs.laravel-governor.roles.update', $role->name], 'method' => 'PUT', 'framework' => 'bootstrap3', 'class' => 'form-horizontal', 'id' => 'editForm', 'labelWidth' => 2, 'fieldWidth' => 10, 'onsubmit' => 'enableFields();'])

@if ($role->name === "Member")
@text ('name', null, ['readonly'])
@textarea ('description', null, ['readonly', "rows" => 5])
@else
@text ('name')
@textarea ('description', null, ["rows" => 5])
@endif

<div class="form-group">
@label('permissions', 'Permissions', ['class' => 'control-label col-sm-2'])
<div class="col-sm-10">
@@ -0,0 +1,21 @@
<?php namespace GeneaLabs\LaravelGovernor\Http\Middleware;
use Genealabs\LaravelGovernor\Nova\Tools\LaravelNovaGovernor;
class Authorize
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Illuminate\Http\Response
*/
public function handle($request, $next)
{
return resolve(LaravelNovaGovernor::class)
->authorize($request)
? $next($request)
: abort(403);
}
}
@@ -22,7 +22,7 @@ public function rules() : array
{
return [
'name' => 'required|string',
"description" => "string",
"description" => "string|nullable",
"permissions" => "array",
];
}
@@ -0,0 +1,28 @@
<?php namespace GeneaLabs\LaravelGovernor\Nova\Tools;
use Laravel\Nova\Nova;
use Laravel\Nova\Tool;
class LaravelNovaGovernor extends Tool
{
/**
* Perform any tasks that need to happen when the tool is booted.
*
* @return void
*/
public function boot()
{
Nova::script('laravel-nova-governor', __DIR__.'/../../../dist/js/tool.js');
Nova::style('laravel-nova-governor', __DIR__.'/../../../dist/css/tool.css');
}
/**
* Build the view that renders the navigation links for the tool.
*
* @return \Illuminate\View\View
*/
public function renderNavigation()
{
return view('genealabs-laravel-governor::navigation');
}
}
@@ -0,0 +1,54 @@
<?php namespace GeneaLabs\LaravelGovernor\Providers;
use Genealabs\LaravelGovernor\Http\Middleware\Authorize;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Nova;
class Tool extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'genealabs-laravel-governor');
$this->app->booted(function () {
$this->routes();
});
Nova::serving(function (ServingNova $event) {
//
});
}
/**
* Register the tool's routes.
*
* @return void
*/
protected function routes()
{
if ($this->app->routesAreCached()) {
return;
}
Route::middleware(['nova', Authorize::class])
->prefix('genealabs/laravel-governor')
->group(__DIR__.'/../../routes/api.php');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
@@ -0,0 +1,5 @@
let mix = require('laravel-mix')

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

0 comments on commit d69e3a2

Please sign in to comment.
You can’t perform that action at this time.