mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
adds notifications for deprecation
This commit is contained in:
parent
b987b3dc00
commit
ed81973fe6
|
@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Crypt;
|
|||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
|
@ -708,6 +709,23 @@ class Helper
|
|||
|
||||
return $randomString;
|
||||
}
|
||||
/**
|
||||
* A method to be used to handle deprecations and giving notifications, currently handling MS Teams. more can be added when needed.
|
||||
*
|
||||
*
|
||||
* @author [Godfrey Martinez]
|
||||
* @since [v7.0.14]
|
||||
* @return array
|
||||
*/
|
||||
public static function deprecationCheck(){
|
||||
$deprecations = [
|
||||
'ms_teams_deprecated' => array(
|
||||
'check' => Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'),
|
||||
'message' => 'The Microsoft Teams webhook URL being used will be deprecated Jan 31st, 2025. <a class="btn btn-primary" href="' . route('settings.slack.index') . '">Change your webhook URL</a>'),
|
||||
];
|
||||
|
||||
return $deprecations;
|
||||
}
|
||||
|
||||
/**
|
||||
* This nasty little method gets the low inventory info for the
|
||||
|
|
|
@ -81,15 +81,17 @@ class SlackSettingsForm extends Component
|
|||
$this->webhook_channel = $this->setting->webhook_channel;
|
||||
$this->webhook_botname = $this->setting->webhook_botname;
|
||||
$this->webhook_options = $this->setting->webhook_selected;
|
||||
if($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){
|
||||
$this->teams_webhook_deprecated = Str::contains($this->webhook_endpoint, 'workflows');
|
||||
if($this->webhook_selected === 'microsoft' || $this->webhook_selected === 'google'){
|
||||
$this->webhook_channel = '#NA';
|
||||
}
|
||||
|
||||
|
||||
if($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null){
|
||||
$this->isDisabled= '';
|
||||
}
|
||||
|
||||
if($this->webhook_selected === 'microsoft' && !$this->teams_webhook_deprecated) {
|
||||
session()->flash('warning', 'The selected Microsoft Teams webhook URL will be deprecated Jan 31st, 2025. Please use a workflow URL. Microsofts Documentation on creating a workflow can be found <a href="https://support.microsoft.com/en-us/office/create-incoming-webhooks-with-workflows-for-microsoft-teams-8ae491c7-0394-4861-ba59-055e33f75498" target="_blank"> here.</a>');
|
||||
}
|
||||
}
|
||||
public function updated($field) {
|
||||
|
||||
|
@ -111,7 +113,6 @@ class SlackSettingsForm extends Component
|
|||
if($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){
|
||||
$this->webhook_channel = '#NA';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function isButtonDisabled() {
|
||||
|
@ -128,7 +129,9 @@ class SlackSettingsForm extends Component
|
|||
public function render()
|
||||
{
|
||||
$this->isButtonDisabled();
|
||||
|
||||
return view('livewire.slack-settings-form');
|
||||
|
||||
}
|
||||
|
||||
public function testWebhook(){
|
||||
|
@ -237,7 +240,7 @@ class SlackSettingsForm extends Component
|
|||
}
|
||||
}
|
||||
public function msTeamTestWebhook(){
|
||||
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
|
||||
|
||||
try {
|
||||
|
||||
if($this->teams_webhook_deprecated){
|
||||
|
|
|
@ -268,17 +268,20 @@ dir="{{ Helper::determineLanguageDirection() }}">
|
|||
@can('admin')
|
||||
@if ($snipeSettings->show_alerts_in_menu=='1')
|
||||
<!-- Tasks: style can be found in dropdown.less -->
|
||||
<?php $alert_items = Helper::checkLowInventory(); ?>
|
||||
<?php $alert_items = Helper::checkLowInventory(); $deprecations = Helper::deprecationCheck()?>
|
||||
|
||||
<li class="dropdown tasks-menu">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<x-icon type="alerts" />
|
||||
<span class="sr-only">{{ trans('general.alerts') }}</span>
|
||||
@if (count($alert_items))
|
||||
<span class="label label-danger">{{ count($alert_items) }}</span>
|
||||
@if (count($alert_items) || count($deprecations))
|
||||
<span class="label label-danger">{{ count($alert_items) + count($deprecations) }}</span>
|
||||
@endif
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
@if($snipeSettings->webhook_selected === 'microsoft' && $deprecations['ms_teams_deprecated']['check'])
|
||||
<li class="header alert-warning">{!! $deprecations['ms_teams_deprecated']['message'] !!}</li>
|
||||
@endif
|
||||
<li class="header">{{ trans_choice('general.quantity_minimum', count($alert_items)) }}</li>
|
||||
<li>
|
||||
<!-- inner menu: contains the actual data -->
|
||||
|
|
|
@ -15,7 +15,14 @@
|
|||
<div><!-- livewire div - do not remove -->
|
||||
<form class="form-horizontal" role="form" wire:submit="submit">
|
||||
{{csrf_field()}}
|
||||
|
||||
@if (session()->has('warning'))
|
||||
<div class="alert alert-warning">
|
||||
{!! session('warning') !!}
|
||||
@php
|
||||
session()->forget('warning'); // Clear the session flash immediately
|
||||
@endphp
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
|
||||
|
|
Loading…
Reference in a new issue