Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added breadcrumbs to user account pages #65

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"illuminate/support": "5.5.*",
"laravel/passport": "^4.0",
"robclancy/presenter": "1.3.2",
"bkwld/croppa": "~4.0"
"bkwld/croppa": "~4.0",
"davejamesmiller/laravel-breadcrumbs": "3.0.*"
},
"require-dev": {
"codeception/codeception": "^2.3",
Expand Down
4 changes: 4 additions & 0 deletions resources/views/account/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

@component('gzero-core::account._menu')@endcomponent

@section('breadcrumbs')
{!! Breadcrumbs::render() !!}
@stop

@component('gzero-core::layouts._contentSection', ['class' => 'col-sm-8'])
<h1 class="mt-4">@lang('gzero-core::user.edit_account')</h1>
@if(!$isUserEmailSet)
Expand Down
4 changes: 4 additions & 0 deletions resources/views/account/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

@component('gzero-core::account._menu')@endcomponent

@section('breadcrumbs')
{!! Breadcrumbs::render() !!}
@stop

@component('gzero-core::layouts._contentSection', ['class' => 'col-sm-8'])
<h1 class="mt-4">@lang('gzero-core::user.my_account')</h1>

Expand Down
4 changes: 4 additions & 0 deletions resources/views/account/oauth.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

@component('gzero-core::account._menu')@endcomponent

@section('breadcrumbs')
{!! Breadcrumbs::render() !!}
@stop

@component('gzero-core::layouts._contentSection', ['class' => 'col-sm-8'])
<h1 class="mt-4">@lang('gzero-core::user.oauth')</h1>

Expand Down
29 changes: 29 additions & 0 deletions routes/breadcrumbs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
// Home
Breadcrumbs::register('home', function ($breadcrumbs) {
$breadcrumbs->push(trans('gzero-core::common.home'), routeMl('home'));
});

// Home > Account
Breadcrumbs::register('account', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('gzero-core::user.my_account'), routeMl('account'));
});

// Home > Account > Edit Account
Breadcrumbs::register('account.edit', function ($breadcrumbs) {
$breadcrumbs->parent('account');
$breadcrumbs->push(trans('gzero-core::user.edit_account'), routeMl('account.edit'));
});

// Home > Account > OAuth
Breadcrumbs::register('account.oauth', function ($breadcrumbs) {
$breadcrumbs->parent('account');
$breadcrumbs->push(trans('gzero-core::user.oauth'), routeMl('account.oauth'));
});

// Error 404
Breadcrumbs::register('errors.404', function ($breadcrumbs) {
$breadcrumbs->parent('home');
$breadcrumbs->push(trans('gzero-core::common.page_not_found'));
});
12 changes: 10 additions & 2 deletions src/Gzero/Core/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use Laravel\Passport\Http\Middleware\CreateFreshApiToken;
use Laravel\Passport\Passport;
use Robbo\Presenter\PresenterServiceProvider;
use DaveJamesMiller\Breadcrumbs\Facade as BreadcrumbsFacade;
use DaveJamesMiller\Breadcrumbs\ServiceProvider as BreadcrumbServiceProvider;

class ServiceProvider extends AbstractServiceProvider {

Expand All @@ -35,7 +37,8 @@ class ServiceProvider extends AbstractServiceProvider {
* @var array
*/
protected $providers = [
PresenterServiceProvider::class
PresenterServiceProvider::class,
BreadcrumbServiceProvider::class,
];

/**
Expand All @@ -45,7 +48,8 @@ class ServiceProvider extends AbstractServiceProvider {
*/
protected $aliases = [
'options' => OptionService::class,
'timezones' => TimezoneService::class
'timezones' => TimezoneService::class,
'Breadcrumbs' => BreadcrumbsFacade::class
];

/**
Expand Down Expand Up @@ -107,6 +111,10 @@ public function boot()
$this->registerViews();
$this->registerPublishes();
$this->registerTranslations();

if (class_exists('Breadcrumbs')) {
require __DIR__ . '/../../../routes/breadcrumbs.php';
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/functional/AccountCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,19 @@ public function canAccessWelcomePage(FunctionalTester $I)
$I->seeLink('My Account', route('account'));
$I->seeLink('Return to the homepage', routeMl('home'));
}

public function canSeeBreadcrumbs(FunctionalTester $I)
{
$user = $I->haveUser();

$I->login($user->email, 'secret');

$I->amOnPage(route('account.edit'));
$I->seeResponseCodeIs(200);

$I->seeLink('Home', routeMl('home'), ['css' => '.breadcrumb li']);
$I->seeLink('My Account', routeMl('account'), ['css' => '.breadcrumb li']);
$I->see('Edit Account', ['css' => '.breadcrumb li.active']);
}
}