Skip to content

Commit

Permalink
Fix enable/disable, fix improper config publish
Browse files Browse the repository at this point in the history
- [Fix] Enabling/disabling of the magic link usage was not saved correctly
- [Fix] Publishing of config file
  • Loading branch information
Holger Lösken committed Sep 18, 2020
1 parent 9e9cda9 commit 8d1199c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion public/js/statamic-magiclink.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions resources/js/components/SettingsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<form-group
class="toggle-fieldtype"
fieldtype="toggle"
handle="isEnabled"
handle="enabled"
:display="__('magiclink::cp.settings.ml_enabled')"
:instructions="__('magiclink::cp.settings.ml_enabled_instructions')"
v-model="isEnabled"
v-model="enabled"
/>

<form-group
handle="expireTime"
class="border-b"
handle="expireTime"
:display="__('magiclink::cp.settings.ml_expire_time')"
:errors="errors.expireTime"
:instructions="__('magiclink::cp.settings.ml_expire_time_instructions')"
Expand All @@ -38,7 +38,7 @@
type: Number,
required: true,
},
initialIsEnabled: {
initialEnabled: {
type: Boolean,
required: true,
},
Expand All @@ -56,7 +56,7 @@
return {
error: null,
errors: {},
isEnabled: this.initialIsEnabled,
enabled: this.initialEnabled,
expireTime: this.initialExpireTime,
}
},
Expand All @@ -68,7 +68,7 @@
payload() {
return {
isEnabled: this.isEnabled,
enabled: this.enabled,
expireTime: this.expireTime,
}
},
Expand Down
2 changes: 1 addition & 1 deletion resources/views/cp/settings/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
method="patch"
action="{{ cp_route('magiclink.update') }}"
index-url="{{ cp_route('dashboard') }}"
initial-is-enabled="{{ Statamic\Support\Str::bool($isEnabled) }}"
:initial-enabled="{{ Statamic\Support\Str::bool($enabled) }}"
initial-expire-time="{{ $expireTime }}"
></magiclink-settings>

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/Cp/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function update(Request $request)
$this->authorize('view settings');

$request->validate([
'isEnabled' => ['required', 'boolean'],
'enabled' => ['required', 'boolean'],
'expireTime' => ['required', 'numeric'],
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/SettingsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(Filesystem $files)
$this->path = storage_path('statamic-magiclink/settings.yaml');

$this->defaultValues = [
self::IS_ENABLED_KEY => true,
self::IS_ENABLED_KEY => false,
self::EXPIRE_TIME_KEY => config('statamic-magiclink.expire_time'),
];
}
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function boot() {

public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'statamic-magiclink');

/*
* Swap login controller to be able to inject custom template.
*/
Expand Down

0 comments on commit 8d1199c

Please sign in to comment.