adds notifications for deprecation

This commit is contained in:
Godfrey M 2024-10-28 13:57:42 -07:00
parent b987b3dc00
commit ed81973fe6
4 changed files with 40 additions and 9 deletions

View file

@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Crypt;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Intervention\Image\ImageManagerStatic as Image; use Intervention\Image\ImageManagerStatic as Image;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
@ -708,6 +709,23 @@ class Helper
return $randomString; 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 * This nasty little method gets the low inventory info for the

View file

@ -81,15 +81,17 @@ class SlackSettingsForm extends Component
$this->webhook_channel = $this->setting->webhook_channel; $this->webhook_channel = $this->setting->webhook_channel;
$this->webhook_botname = $this->setting->webhook_botname; $this->webhook_botname = $this->setting->webhook_botname;
$this->webhook_options = $this->setting->webhook_selected; $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'; $this->webhook_channel = '#NA';
} }
if($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null){ if($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null){
$this->isDisabled= ''; $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) { public function updated($field) {
@ -111,7 +113,6 @@ class SlackSettingsForm extends Component
if($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){ if($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){
$this->webhook_channel = '#NA'; $this->webhook_channel = '#NA';
} }
} }
private function isButtonDisabled() { private function isButtonDisabled() {
@ -128,7 +129,9 @@ class SlackSettingsForm extends Component
public function render() public function render()
{ {
$this->isButtonDisabled(); $this->isButtonDisabled();
return view('livewire.slack-settings-form'); return view('livewire.slack-settings-form');
} }
public function testWebhook(){ public function testWebhook(){
@ -237,7 +240,7 @@ class SlackSettingsForm extends Component
} }
} }
public function msTeamTestWebhook(){ public function msTeamTestWebhook(){
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
try { try {
if($this->teams_webhook_deprecated){ if($this->teams_webhook_deprecated){

View file

@ -268,17 +268,20 @@ dir="{{ Helper::determineLanguageDirection() }}">
@can('admin') @can('admin')
@if ($snipeSettings->show_alerts_in_menu=='1') @if ($snipeSettings->show_alerts_in_menu=='1')
<!-- Tasks: style can be found in dropdown.less --> <!-- 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"> <li class="dropdown tasks-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<x-icon type="alerts" /> <x-icon type="alerts" />
<span class="sr-only">{{ trans('general.alerts') }}</span> <span class="sr-only">{{ trans('general.alerts') }}</span>
@if (count($alert_items)) @if (count($alert_items) || count($deprecations))
<span class="label label-danger">{{ count($alert_items) }}</span> <span class="label label-danger">{{ count($alert_items) + count($deprecations) }}</span>
@endif @endif
</a> </a>
<ul class="dropdown-menu"> <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 class="header">{{ trans_choice('general.quantity_minimum', count($alert_items)) }}</li>
<li> <li>
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->

View file

@ -15,7 +15,14 @@
<div><!-- livewire div - do not remove --> <div><!-- livewire div - do not remove -->
<form class="form-horizontal" role="form" wire:submit="submit"> <form class="form-horizontal" role="form" wire:submit="submit">
{{csrf_field()}} {{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="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">