mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Switched singleton to static helper method
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
5217141dfb
commit
a14d1b981d
|
@ -1148,12 +1148,37 @@ class Helper
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This is a shorter way to see if the app is in demo mode.
|
||||
*
|
||||
* This makes it cleanly available in blades and in controllers, e.g.
|
||||
*
|
||||
* Blade:
|
||||
* {{ app('demo_mode') ? ' disabled' : ''}} for form blades where we need to disable a form
|
||||
*
|
||||
* Controller:
|
||||
* if (app('demo_mode')) {
|
||||
* // don't allow the thing
|
||||
* }
|
||||
* @todo - use this everywhere else in the app where we have very long if/else config('app.lock_passwords') stuff
|
||||
*/
|
||||
public function isDemoMode() {
|
||||
if (config('app.lock_passwords') === true) {
|
||||
return true;
|
||||
\Log::debug('app locked!');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* I know it's gauche to return a shitty HTML string, but this is just a helper and since it will be the same every single time,
|
||||
* it seemed pretty safe to do here. Don't you judge me.
|
||||
*/
|
||||
public function showDemoModeFieldWarning() {
|
||||
if (app('demo_mode')) {
|
||||
if (Helper::isDemoMode()) {
|
||||
return "<p class=\"text-warning\"><i class=\"fas fa-lock\"></i>" . trans('general.feature_disabled') . "</p>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,30 +152,6 @@ class SettingsServiceProvider extends ServiceProvider
|
|||
setlocale(LC_NUMERIC, config('app.locale'));
|
||||
|
||||
|
||||
/*
|
||||
* This is a shorter way to see if the app is in demo mode.
|
||||
*
|
||||
* This makes it cleanly available in blades and in controllers, e.g.
|
||||
*
|
||||
* Blade:
|
||||
* {{ app('demo_mode') ? ' disabled' : ''}} for form blades where we need to disable a form
|
||||
*
|
||||
* Controller:
|
||||
* if (app('demo_mode')) {
|
||||
* // don't allow the thing
|
||||
* }
|
||||
* @todo - use this everywhere else in the app where we have very long if/else config('app.lock_passwords') stuff
|
||||
*/
|
||||
\App::singleton('demo_mode', function () {
|
||||
if (config('app.lock_passwords') === true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,14 +58,14 @@
|
|||
</label>
|
||||
</div>
|
||||
<div class="col-md-9 required">
|
||||
<select wire:model="webhook_selected" aria-label="webhook_selected" class="form-control"{{ app('demo_mode') ? ' disabled' : ''}}>
|
||||
<select wire:model="webhook_selected" aria-label="webhook_selected" class="form-control"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
|
||||
<option value="slack">{{ trans('admin/settings/general.slack') }}</option>
|
||||
<option value="general">{{ trans('admin/settings/general.general_webhook') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (app('demo_mode'))
|
||||
@if (Helper::isDemoMode())
|
||||
@include('partials.forms.demo-mode')
|
||||
@endif
|
||||
|
||||
|
@ -75,12 +75,12 @@
|
|||
{{ Form::label('webhook_endpoint', trans('admin/settings/general.webhook_endpoint',['app' => $webhook_name ])) }}
|
||||
</div>
|
||||
<div class="col-md-9 required">
|
||||
<input type="text" wire:model="webhook_endpoint" class="form-control" placeholder="{{$webhook_placeholder}}" value="{{old('webhook_endpoint', $webhook_endpoint)}}"{{ app('demo_mode') ? ' disabled' : ''}}>
|
||||
<input type="text" wire:model="webhook_endpoint" class="form-control" placeholder="{{$webhook_placeholder}}" value="{{old('webhook_endpoint', $webhook_endpoint)}}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
|
||||
{!! $errors->first('webhook_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (app('demo_mode'))
|
||||
@if (Helper::isDemoMode())
|
||||
@include('partials.forms.demo-mode')
|
||||
@endif
|
||||
|
||||
|
@ -91,13 +91,13 @@
|
|||
{{ Form::label('webhook_channel', trans('admin/settings/general.webhook_channel',['app' => $webhook_name ])) }}
|
||||
</div>
|
||||
<div class="col-md-9 required">
|
||||
<input type="text" wire:model="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}"{{ app('demo_mode') ? ' disabled' : ''}}>
|
||||
<input type="text" wire:model="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
|
||||
|
||||
{!! $errors->first('webhook_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (!app('demo_mode'))
|
||||
@if (Helper::isDemoMode())
|
||||
@include('partials.forms.demo-mode')
|
||||
@endif
|
||||
|
||||
|
@ -107,12 +107,12 @@
|
|||
{{ Form::label('webhook_botname', trans('admin/settings/general.webhook_botname',['app' => $webhook_name ])) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<input type="text" wire:model="webhook_botname" class='form-control' placeholder="Snipe-Bot" {{ old('webhook_botname', $webhook_botname)}}{{ app('demo_mode') ? ' disabled' : ''}}>
|
||||
<input type="text" wire:model="webhook_botname" class='form-control' placeholder="Snipe-Bot" {{ old('webhook_botname', $webhook_botname)}}{{ Helper::isDemoMode() ? ' disabled' : ''}}>
|
||||
{!! $errors->first('webhook_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</div><!--col-md-10-->
|
||||
</div>
|
||||
|
||||
@if (app('demo_mode'))
|
||||
@if (!Helper::isDemoMode())
|
||||
@include('partials.forms.demo-mode')
|
||||
@endif
|
||||
|
||||
|
@ -140,13 +140,13 @@
|
|||
|
||||
<div class="box-footer">
|
||||
<div class="text-right col-md-12">
|
||||
|
||||
|
||||
<button type="reset" wire:click.prevent="clearSettings" class="col-md-2 text-left btn btn-danger pull-left">{{ trans('general.clear_and_save') }}</button>
|
||||
|
||||
<a class="btn btn-link pull-left" href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a>
|
||||
|
||||
|
||||
<button type="submit" {{$isDisabled}} class="btn btn-primary"{{ app('demo_mode') ? ' disabled' : ''}}>
|
||||
<button type="submit" {{$isDisabled}} class="btn btn-primary"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
|
||||
<i class="fas fa-check icon-white" aria-hidden="true"></i> {{ $save_button }}</button>
|
||||
|
||||
</div> <!-- /.col-md-12 -->
|
||||
|
|
Loading…
Reference in a new issue