Skip to content

Commit

Permalink
updated component name
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenMelbz committed Dec 24, 2017
1 parent e290094 commit bec9230
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
16 changes: 14 additions & 2 deletions src/Services/VueImpersonateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ public function getRoutes()
return collect([
'take' => route('impersonate', '@userid'),
'leave' => route('impersonate.leave'),
'users' => route('impersonate.users'),
'users' => $this->getUsersRoute(),
]);
}

public function getUsersRoute()
{
if (config('vue_impersonate.custom_route')) {
return asset(
config('vue_impersonate.custom_route')
);
}

return route('impersonate.users');
}

public function getImpersonatable()
{
$model = config('auth.providers.' . config('vue_impersonate.provider') . '.model');
Expand All @@ -48,7 +59,8 @@ public function render()
if (optional(request()->user())->canImpersonate()) {
return view('vue_impersonate::vue-impersonate')
->with('is_impersonating', $this->isImpersonating())
->with('routes', $this->getRoutes());
->with('routes', $this->getRoutes())
->with('component_name', config('vue_impersonate.custom_directive'));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/VueImpersonateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function boot()
$this->publishes([
__DIR__ . '/config/vue_impersonate.php' => config_path($this->packageName . '.php'),
__DIR__ . '/resources/views/vue-impersonate.blade.php' => $this->resource_path('views/vue-impersonate.blade.php'),
__DIR__ . '/resources/js/vue-impersonate.vue' => $this->resource_path('js/vue-impersonate.vue'),
__DIR__ . '/resources/js/vue-impersonate.vue' => $this->resource_path('assets/js/components/vue-impersonate.vue'),
], 'vue-impersonate-all');

$this->publishes([
__DIR__ . '/resources/js/vue-impersonate.vue' => $this->resource_path('js/vue-impersonate.vue'),
__DIR__ . '/resources/js/vue-impersonate.vue' => $this->resource_path('assets/js/components/vue-impersonate.vue'),
], 'vue-impersonate-javascript (required)');

$this->publishes([
Expand Down
11 changes: 10 additions & 1 deletion src/config/vue_impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@
/*
|--------------------------------------------------------------------------
| If you want to use a custom route to return the user list, place the url
| here and we'll use it instead.
| here and we'll use it instead. defult (null)
|--------------------------------------------------------------------------
*/

'custom_route' => null,

/*
|--------------------------------------------------------------------------
| By default the view component is called `vue-impersonate` if you want a
| different directive name then place it here. default (vue-impersonate)
|--------------------------------------------------------------------------
*/

'custom_directive' => 'vue-impersonate',

];
9 changes: 5 additions & 4 deletions src/resources/js/vue-impersonate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
</style>

<script>
export default {
props: {
Expand All @@ -102,11 +103,11 @@
data() {
return {
show_menu: false,
loaded: false,
failed: false,
users: [],
user: null,
loaded: false,
failed: false,
show_menu: false,
}
},
Expand Down Expand Up @@ -134,7 +135,6 @@
},
updateUserList() {
const xhr = new XMLHttpRequest();
xhr.open('GET', this.routes.users);
Expand Down Expand Up @@ -166,4 +166,5 @@
}
}
</script>
4 changes: 2 additions & 2 deletions src/resources/views/vue-impersonate.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<vue-impersonator
<{{ $component_name }}
:is-impersonating="{{ $is_impersonating ? 'true' : 'false' }}"
:routes="{{ $routes }}"
></vue-impersonator>
></{{ $component_name }}>

0 comments on commit bec9230

Please sign in to comment.