Skip to content

Commit

Permalink
refs #1073 Replace breadcrumbs package
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Jun 4, 2020
1 parent ce0e7d0 commit f65c6ea
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 157 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
"require": {
"ext-json": "*",
"davejamesmiller/laravel-breadcrumbs": "^5.3",
"tabuna/breadcrumbs": "^1.0",
"laravel/framework": "^7.0",
"laravel/scout": "^8.0",
"myclabs/php-enum": "^1.7",
Expand Down
56 changes: 0 additions & 56 deletions install-stubs/routes/breadcrumbs.php

This file was deleted.

81 changes: 70 additions & 11 deletions install-stubs/routes/platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Orchid\Screens\User\UserEditScreen;
use App\Orchid\Screens\User\UserListScreen;
use Illuminate\Support\Facades\Route;
use Tabuna\Breadcrumbs\Trail;

/*
|--------------------------------------------------------------------------
Expand All @@ -28,21 +29,79 @@
*/

// Main
Route::screen('/main', PlatformScreen::class)->name('platform.main');
Route::screen('/main', PlatformScreen::class)
->name('platform.main');

// Users...
Route::screen('users/{users}/edit', UserEditScreen::class)->name('platform.systems.users.edit');
Route::screen('users', UserListScreen::class)->name('platform.systems.users');
// Platform > System > Users
Route::screen('users/{users}/edit', UserEditScreen::class)
->name('platform.systems.users.edit')
->breadcrumbs(function (Trail $trail, $user) {
return $trail
->parent('platform.systems.users')
->push(__('Edit'), route('platform.systems.users.edit', $user));
});

// Roles...
Route::screen('roles/{roles}/edit', RoleEditScreen::class)->name('platform.systems.roles.edit');
Route::screen('roles/create', RoleEditScreen::class)->name('platform.systems.roles.create');
Route::screen('roles', RoleListScreen::class)->name('platform.systems.roles');
// Platform > System > Users > User
Route::screen('users', UserListScreen::class)
->name('platform.systems.users')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.systems.index')
->push(__('Users'), route('platform.systems.users'));
});

// Platform > System > Roles > Role
Route::screen('roles/{roles}/edit', RoleEditScreen::class)
->name('platform.systems.roles.edit')
->breadcrumbs(function (Trail $trail, $role) {
return $trail
->parent('platform.systems.roles')
->push(__('Role'), route('platform.systems.roles.edit', $role));
});

// Platform > System > Roles > Create
Route::screen('roles/create', RoleEditScreen::class)
->name('platform.systems.roles.create')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.systems.roles')
->push(__('Create'), route('platform.systems.roles.create'));
});

// Platform > System > Roles
Route::screen('roles', RoleListScreen::class)
->name('platform.systems.roles')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.systems.index')
->push(__('Roles'), route('platform.systems.roles'));
});

// Example...
Route::screen('example', ExampleScreen::class)->name('platform.example');
Route::screen('example-fields', ExampleFieldsScreen::class)->name('platform.example.fields');
Route::screen('example-layouts', ExampleLayoutsScreen::class)->name('platform.example.layouts');
Route::screen('example', ExampleScreen::class)
->name('platform.example')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.index')
->push(__('Example screen'));
});

Route::screen('example-fields', ExampleFieldsScreen::class)
->name('platform.example.fields')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.index')
->push(__('Form controls'));
});

Route::screen('example-layouts', ExampleLayoutsScreen::class)
->name('platform.example.layouts')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.index')
->push(__('Overview layouts'));
});

Route::screen('example-charts', ExampleChartsScreen::class)->name('platform.example.charts');
Route::screen('example-editors', ExampleTextEditorsScreen::class)->name('platform.example.editors');
Route::screen('example-cards', ExampleCardsScreen::class)->name('platform.example.cards');
Expand Down
6 changes: 2 additions & 4 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@
</div>
</div>

@if (Breadcrumbs::exists())
{{ Breadcrumbs::view('platform::partials.breadcrumbs') }}
@endif
@includeWhen(Breadcrumbs::has(), 'platform::partials.breadcrumbs')

<div class="d-flex @if (!Breadcrumbs::exists()) border-top @endif">
<div class="d-flex @if (!Breadcrumbs::has()) border-top @endif">
<div class="app-content-body" id="app-content-body">
@include('platform::partials.alert')
@yield('content')
Expand Down
30 changes: 17 additions & 13 deletions resources/views/partials/breadcrumbs.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
@if (count($breadcrumbs) > 1)
<nav aria-label="breadcrumb">
<ol class="breadcrumb padder m-0">
@foreach ($breadcrumbs as $breadcrumb)
@if ($breadcrumb->url && !$loop->last)
<li class="breadcrumb-item"><a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a></li>
@else
<li class="breadcrumb-item active">{{ $breadcrumb->title }}</li>
@endif
@endforeach
</ol>
</nav>
@endif
<nav aria-label="breadcrumb">
<ol class="breadcrumb padder m-0">
@foreach (Breadcrumbs::current() as $crumbs)
@if ($crumbs->url() && !$loop->last)
<li class="breadcrumb-item">
<a href="{{ $crumbs->url() }}">
{{ $crumbs->title() }}
</a>
</li>
@else
<li class="breadcrumb-item active">
{{ $crumbs->title() }}
</li>
@endif
@endforeach
</ol>
</nav>
30 changes: 0 additions & 30 deletions routes/breadcrumbs.php

This file was deleted.

38 changes: 23 additions & 15 deletions routes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,32 @@
use Orchid\Platform\Http\Controllers\Systems\IndexController;
use Orchid\Platform\Http\Screens\NotificationScreen;
use Orchid\Platform\Http\Screens\SearchScreen;

/*
|--------------------------------------------------------------------------
| Dashboard Web Routes
|--------------------------------------------------------------------------
|
| Base route
|
*/
use Tabuna\Breadcrumbs\Trail;

// Index and default...
$this->router->get('/', [IndexController::class, 'index'])->name('index');
$this->router->post('/async/{screen}/{method?}/{template?}', [AsyncController::class, 'load'])->name('async');
$this->router->get('/', [IndexController::class, 'index'])
->name('index')
->breadcrumbs(function (Trail $trail) {
return $trail->push(__('Main'), route('platform.index'));
});

$this->router->fallback([IndexController::class, 'fallback']);
$this->router->screen('search/{query}', SearchScreen::class)
->name('search')
->breadcrumbs(function (Trail $trail, string $query) {
return $trail->parent('platform.index')
->push(__('Search'))
->push($query);
});

$this->router->screen('search/{query}', SearchScreen::class)->name('search');
$this->router->screen('notifications/{id?}', NotificationScreen::class)->name('notifications');
$this->router->screen('notifications/{id?}', NotificationScreen::class)
->name('notifications')
->breadcrumbs(function (Trail $trail) {
return $trail->parent('platform.index')
->push(__('Notifications'));
});

$this->router->post('/api/notifications', [NotificationScreen::class, 'unreadNotification'])
$this->router->post('api/notifications', [NotificationScreen::class, 'unreadNotification'])
->name('api.notifications');

$this->router->post('async/{screen}/{method?}/{template?}', [AsyncController::class, 'load'])->name('async');
$this->router->fallback([IndexController::class, 'fallback']);
17 changes: 7 additions & 10 deletions routes/systems.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
use Orchid\Platform\Http\Controllers\Systems\AttachmentController;
use Orchid\Platform\Http\Controllers\Systems\RelationController;
use Orchid\Platform\Http\Controllers\Systems\SystemController;

/*
|--------------------------------------------------------------------------
| Systems Web Routes
|--------------------------------------------------------------------------
|
| Base route
|
*/
use Tabuna\Breadcrumbs\Trail;

$this->router->get('/', [SystemController::class, 'index'])
->name('systems.index');
->name('systems.index')
->breadcrumbs(function (Trail $trail) {
return $trail
->parent('platform.index')
->push(__('Systems'), route('platform.systems.index'));
});

$this->router->post('files', [AttachmentController::class, 'upload'])
->name('systems.files.upload');
Expand Down
3 changes: 0 additions & 3 deletions src/Platform/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public function boot()
]);

$this->binding();

require Dashboard::path('routes/breadcrumbs.php');

parent::boot();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Screen/Screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function handle(...$parameters)
);

$query = request()->query();
$query = !is_array($query) ? [] : $query;
$query = ! is_array($query) ? [] : $query;

$parameters = array_filter($parameters);
$parameters = array_merge(array_keys($query), $parameters);
Expand Down
16 changes: 3 additions & 13 deletions tests/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

namespace Orchid\Tests;

use DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator;
use DaveJamesMiller\Breadcrumbs\BreadcrumbsManager;
use DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs;
use Tabuna\Breadcrumbs\Breadcrumbs;
use Orchid\Database\Seeds\OrchidDatabaseSeeder;
use Orchid\Platform\Models\User;
use Orchid\Platform\Providers\FoundationServiceProvider;
use Orchid\Support\Facades\Alert;
use Orchid\Support\Facades\Dashboard;
use Orchid\Tests\App\ExemplarServiceProvider;
use Sti3bas\ScoutArray\ScoutArrayEngineServiceProvider;
use Tabuna\Breadcrumbs\BreadcrumbsServiceProvider;
use Watson\Active\Active;

/**
Expand Down Expand Up @@ -73,16 +72,6 @@ protected function getEnvironmentSetUp($app)
]);
$config->set('scout.driver', 'array');
$config->set('database.default', 'orchid');

$config->set('breadcrumbs', [
'view' => 'breadcrumbs::bootstrap4',
'files' => base_path('routes/breadcrumbs.php'),
'unnamed-route-exception' => false,
'missing-route-bound-breadcrumb-exception' => false,
'invalid-named-breadcrumb-exception' => false,
'manager-class' => BreadcrumbsManager::class,
'generator-class' => BreadcrumbsGenerator::class,
]);
}

/**
Expand All @@ -93,6 +82,7 @@ protected function getEnvironmentSetUp($app)
protected function getPackageProviders($app)
{
return [
BreadcrumbsServiceProvider::class,
FoundationServiceProvider::class,
ExemplarServiceProvider::class,
ScoutArrayEngineServiceProvider::class,
Expand Down

0 comments on commit f65c6ea

Please sign in to comment.