Merge pull request #12522 from snipe/fixes/slack_livewire_translations

Fixes slack livewire translations, UI
This commit is contained in:
snipe 2023-02-15 14:45:46 -08:00 committed by GitHub
commit 221f5f5ca7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 49 deletions

View file

@ -60,11 +60,11 @@ class SlackSettingsForm extends Component
return session()->flash('success' , 'Your Slack Integration works!'); return session()->flash('success' , 'Your Slack Integration works!');
} catch (\Exception $e) { } catch (\Exception $e) {
return session()->flash('error' , 'Please check the channel name and webhook endpoint URL ('.e($this->slack_endpoint).'). Slack responded with: '.$e->getMessage()); return session()->flash('error' , trans('admin/settings/message.slack.error', ['error_message' => $e->getMessage()]));
} }
//} //}
return session()->flash('message' , 'Something went wrong :( '); return session()->flash('message' , trans('admin/settings/message.slack.error_misc'));

View file

@ -38,6 +38,7 @@ return [
'success_pt1' => 'Success! Check the ', 'success_pt1' => 'Success! Check the ',
'success_pt2' => ' channel for your test message, and be sure to click SAVE below to store your settings.', 'success_pt2' => ' channel for your test message, and be sure to click SAVE below to store your settings.',
'500' => '500 Server Error.', '500' => '500 Server Error.',
'error' => 'Something went wrong.', 'error' => 'Something went wrong. Slack responded with: :error_message',
'error_misc' => 'Something went wrong. :( ',
] ]
]; ];

View file

@ -2,73 +2,75 @@
<div class="col-md-12" style="border-top: 0px;"> <div class="col-md-12" style="border-top: 0px;">
@if (session()->has('save')) @if (session()->has('save'))
<div class="alert alert-success"> <div class="alert alert-success fade in">
{{session('save')}} {{session('save')}}
</div> </div>
@endif @endif
@if(session()->has('success')) @if(session()->has('success'))
<div class="alert alert-success"> <div class="alert alert-success fade in">
{{session('success')}} {{session('success')}}
</div> </div>
@endif @endif
@if(session()->has('error')) @if(session()->has('error'))
<div class="alert alert-danger"> <div class="alert alert-danger fade in">
{{session('error')}} {{session('error')}}
</div> </div>
@endif @endif
@if(session()->has('message')) @if(session()->has('message'))
<div class="alert alert-danger"> <div class="alert alert-danger fade in">
{{session('message')}} {{session('message')}}
</div> </div>
@endif @endif
<form wire:submit.prevent ="submit">
<form class="form-horizontal" role="form" wire:submit.prevent="submit">
{{csrf_field()}} {{csrf_field()}}
<!--slack endpoint--> <!--slack endpoint-->
<div class="form-group required {{ $errors->has('slack_endpoint') ? 'error' : '' }}"> <div class="form-group{{ $errors->has('slack_endpoint') ? ' error' : '' }}">
<div class="col-md-2"> <div class="col-md-2">
{{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }} {{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }}
</div> </div>
<div class="col-md-10"> <div class="col-md-8 required">
@if (config('app.lock_passwords')===true) @if (config('app.lock_passwords')===true)
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p> <p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
<input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('slack_endpoint', $slack_endpoint)}} ><br> <input type="text" wire:model.lazy="slack_endpoint" class= 'form-control' placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('slack_endpoint', $slack_endpoint)}}>
@else @else
<input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('slack_endpoint', $slack_endpoint)}} ><br> <input type="text" wire:model.lazy="slack_endpoint" class= 'form-control' placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('slack_endpoint', $slack_endpoint)}}>
@endif @endif
{!! $errors->first('slack_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!} {!! $errors->first('slack_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div> </div>
</div> </div>
<!-- slack channel --> <!-- slack channel -->
<div class="form-group required {{ $errors->has('slack_channel') ? 'error' : '' }}"> <div class="form-group{{ $errors->has('slack_channel') ? ' error' : '' }}">
<div class="col-md-2"> <div class="col-md-2">
{{ Form::label('slack_channel', trans('admin/settings/general.slack_channel')) }} {{ Form::label('slack_channel', trans('admin/settings/general.slack_channel')) }}
</div> </div>
<div class="col-md-10"> <div class="col-md-8 required">
@if (config('app.lock_passwords')===true) @if (config('app.lock_passwords')===true)
<input type="text" wire:model.lazy="slack_channel" id="slack_channel" class='form-control' placeholder="#IT-Ops" value="{{old('slack_channel', $slack_channel)}}" ><br> <input type="text" wire:model.lazy="slack_channel" class='form-control' placeholder="#IT-Ops" value="{{old('slack_channel', $slack_channel)}}">
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p> <p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
@else @else
<input type="text" wire:model.lazy="slack_channel" id="slack_channel" class= 'form-control' placeholder="#IT-Ops" value="{{old('slack_channel', $slack_channel)}}" ><br> <input type="text" wire:model.lazy="slack_channel" class= 'form-control' placeholder="#IT-Ops" value="{{old('slack_channel', $slack_channel)}}">
@endif @endif
{!! $errors->first('slack_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!} {!! $errors->first('slack_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div> </div>
</div> </div>
<!-- slack botname --> <!-- slack botname -->
<div class="form-group required {{ $errors->has('slack_botname') ? 'error' : '' }}"> <div class="form-group{{ $errors->has('slack_botname') ? ' error' : '' }}">
<div class="col-md-2"> <div class="col-md-2">
{{ Form::label('slack_botname', trans('admin/settings/general.slack_botname')) }} {{ Form::label('slack_botname', trans('admin/settings/general.slack_botname')) }}
</div> </div>
<div class="col-md-10"> <div class="col-md-8 required">
@if (config('app.lock_passwords')===true) @if (config('app.lock_passwords')===true)
<input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="Snipe-Bot" {{old('slack_botname', $slack_botname)}} ><br> <input type="text" wire:model.lazy="slack_botname" class= 'form-control' placeholder="Snipe-Bot" {{old('slack_botname', $slack_botname)}}>
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p> <p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
@else @else
<input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="Snipe-Bot" {{old('slack_botname', $slack_botname)}} ><br> <input type="text" wire:model.lazy="slack_botname" class= 'form-control' placeholder="Snipe-Bot" {{old('slack_botname', $slack_botname)}}>
@endif @endif
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!} {!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div><!--col-md-10--> </div><!--col-md-10-->
@ -77,21 +79,17 @@
<!--Slack Integration Test--> <!--Slack Integration Test-->
@if($slack_endpoint != null && $slack_channel != null && $slack_botname != null) @if($slack_endpoint != null && $slack_channel != null && $slack_botname != null)
<div class="form-group"> <div class="form-group">
<div class="col-md-2"> <div class="col-md-offset-2 col-md-8">
{{ Form::label('test_slack', 'Test Slack') }} <a href="#" wire:click.prevent="testSlack" class="btn btn-default btn-sm pull-left"><span>{!! trans('admin/settings/general.slack_test') !!}</span></a>
</div> <div wire:loading><span style="padding-left: 5px; font-size: 20px"><i class="fas fa-spinner fa-spin"></i></span></div>
<div class="col-md-10">
<a href="#" wire:click.prevent="testSlack" id="test_slack" class="btn btn-default btn-sm pull-left"><span>{!! trans('admin/settings/general.slack_test') !!}</span></a>
<div wire:loading><i class="fas fa-spinner spin"></i></div>
</div> </div>
</div> </div>
@endif @endif
<div class="box-footer" style="margin-top: 45px;"> <div class="box-footer" style="margin-top: 45px;">
<div class="text-right col-md-12"> <div class="text-right col-md-12">
<a class="btn btn-link text-left" href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a> <a class="btn btn-link text-left" href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a>
<button type="submit" id="save_slack" class="btn btn-primary"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.save') }}</button> <button type="submit" class="btn btn-primary"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.save') }}</button>
</div> </div>
</div><!--box-footer--> </div><!--box-footer-->
</form> </form>

View file

@ -14,11 +14,6 @@
{{-- Page content --}} {{-- Page content --}}
@section('content') @section('content')
<style>
.checkbox label {
padding-right: 40px;
}
</style>
<div class="row"> <div class="row">
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2"> <div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
@ -30,10 +25,12 @@
</h2> </h2>
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="col-md-12">
<p style="padding: 20px;"> <p>
{!! trans('admin/settings/general.slack_integration_help',array('slack_link' => 'https://my.slack.com/services/new/incoming-webhook')) !!} {!! trans('admin/settings/general.slack_integration_help',array('slack_link' => 'https://my.slack.com/services/new/incoming-webhook')) !!}
</p> </p>
<br>
</div>
@livewire('slack-settings-form') @livewire('slack-settings-form')