Merge pull request #12663 from Godmartinz/webhook_tweaks

fixes webhook variables to lowercase
This commit is contained in:
snipe 2023-03-13 16:55:32 -07:00 committed by GitHub
commit a2667a7520
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 31 deletions

View file

@ -17,6 +17,7 @@ class SlackSettingsForm extends Component
public $webhook_placeholder;
public $webhook_icon;
public $webhook_selected;
public array $webhook_text;
public Setting $setting;
@ -25,34 +26,29 @@ class SlackSettingsForm extends Component
'webhook_channel' => 'required_with:webhook_endpoint|starts_with:#|nullable',
'webhook_botname' => 'string|nullable',
];
static $webhook_text= [
"Slack" => array(
"name" => "Slack",
public function mount(){
$this->webhook_text= [
"slack" => array(
"name" => trans('admin/settings/general.slack') ,
"icon" => 'fab fa-slack',
"placeholder" => "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX",
"link" => 'https://api.slack.com/messaging/webhooks',
),
// "Discord" => array(
// "name" => "Discord",
// "icon" => 'fab fa-discord',
// "placeholder" => "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXXXXX",
// "link" => 'https://support.discord.com/hc/en-us/articles/360045093012-Server-Integrations-Page',
// ),
"General"=> array(
"name" => "General",
"icon" => "fab fa-hashtag",
"placeholder" => "",
"link" => "",
),
];
public function mount(){
"general"=> array(
"name" => trans('admin/settings/general.general_webhook'),
"icon" => "fab fa-hashtag",
"placeholder" => "",
"link" => "",
),
];
$this->setting = Setting::getSettings();
$this->webhook_selected = $this->setting->webhook_selected;
$this->webhook_placeholder = self::$webhook_text[$this->setting->webhook_selected]["placeholder"];
$this->webhook_name = self::$webhook_text[$this->setting->webhook_selected]["name"];
$this->webhook_icon = self::$webhook_text[$this->setting->webhook_selected]["icon"];
$this->webhook_placeholder = $this->webhook_text[$this->setting->webhook_selected]["placeholder"];
$this->webhook_name = $this->webhook_text[$this->setting->webhook_selected]["name"];
$this->webhook_icon = $this->webhook_text[$this->setting->webhook_selected]["icon"];
$this->webhook_endpoint = $this->setting->webhook_endpoint;
$this->webhook_channel = $this->setting->webhook_channel;
$this->webhook_botname = $this->setting->webhook_botname;
@ -61,15 +57,15 @@ class SlackSettingsForm extends Component
}
public function updated($field){
if($this->webhook_selected != 'General') {
if($this->webhook_selected != 'general') {
$this->validateOnly($field, $this->rules);
}
}
public function updatedWebhookSelected(){
$this->webhook_name = self::$webhook_text[$this->webhook_selected]['name'];
$this->webhook_icon = self::$webhook_text[$this->webhook_selected]["icon"]; ;
$this->webhook_placeholder = self::$webhook_text[$this->webhook_selected]["placeholder"];
$this->webhook_link = self::$webhook_text[$this->webhook_selected]["link"];
$this->webhook_name = $this->webhook_text[$this->webhook_selected]['name'];
$this->webhook_icon = $this->webhook_text[$this->webhook_selected]["icon"]; ;
$this->webhook_placeholder = $this->webhook_text[$this->webhook_selected]["placeholder"];
$this->webhook_link = $this->webhook_text[$this->webhook_selected]["link"];
}
@ -119,7 +115,7 @@ class SlackSettingsForm extends Component
}
public function submit()
{
if($this->webhook_selected != 'General') {
if($this->webhook_selected != 'general') {
$this->validate($this->rules);
}

View file

@ -14,7 +14,7 @@ class AddsWebhookOptionToSettingsTable extends Migration
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->string('webhook_selected')->after('slack_botname')->default('Slack')->nullable();
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
$table->renameColumn('slack_botname', 'webhook_botname');
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
$table->renameColumn('slack_channel', 'webhook_channel');

View file

@ -199,6 +199,8 @@ return [
'show_images_in_email_help' => 'Uncheck this box if your Snipe-IT installation is behind a VPN or closed network and users outside the network will not be able to load images served from this installation in their emails.',
'site_name' => 'Site Name',
'integrations' => 'Integrations',
'slack' => 'Slack',
'general_webhook' => 'General Webhook',
'webhook' => ':app',
'webhook_title' => 'Update Webhook Settings',
'webhook_help' => 'Integration settings',

View file

@ -24,7 +24,7 @@
</div>
<div class="box-body">
<div class="col-md-12">
@if($webhook_selected != 'General')
@if($webhook_selected != 'general')
<p>
{!! trans('admin/settings/general.webhook_integration_help',array('webhook_link' => $webhook_link, 'app' => $webhook_name)) !!}
</p>
@ -64,9 +64,9 @@
aria-label="webhook_selected"
class="form-control "
>
<option value="Slack">Slack</option>
<option value="slack">{{trans('admin/settings/general.slack')}}</option>
{{-- <option value="Discord">Discord</option>--}}
<option value="General">General Webhook</option>
<option value="general">{{trans('admin/settings/general.general_webhook')}}</option>
</select>
</div>
<br><br><br>