mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 12:44:35 -04:00
Refactor for admin links
This commit is contained in:
parent
23a88f5a99
commit
c3189183a5
@ -49,6 +49,12 @@ class CreditCreatedNotification implements ShouldQueue
|
|||||||
/* The User */
|
/* The User */
|
||||||
$user = $company_user->user;
|
$user = $company_user->user;
|
||||||
|
|
||||||
|
$use_react_link = false;
|
||||||
|
|
||||||
|
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
||||||
|
$use_react_link = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* This is only here to handle the alternate message channels - ie Slack */
|
/* This is only here to handle the alternate message channels - ie Slack */
|
||||||
// $notification = new EntitySentNotification($event->invitation, 'credit');
|
// $notification = new EntitySentNotification($event->invitation, 'credit');
|
||||||
|
|
||||||
@ -60,7 +66,7 @@ class CreditCreatedNotification implements ShouldQueue
|
|||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo = new NinjaMailerObject;
|
||||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($credit, 'credit'))->build());
|
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($credit, 'credit', $use_react_link))->build());
|
||||||
$nmo->company = $credit->company;
|
$nmo->company = $credit->company;
|
||||||
$nmo->settings = $credit->company->settings;
|
$nmo->settings = $credit->company->settings;
|
||||||
$nmo->to_user = $user;
|
$nmo->to_user = $user;
|
||||||
|
@ -24,7 +24,7 @@ class InvoiceCreatedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
public $delay = 7;
|
public $delay = 3;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -53,8 +53,8 @@ class InvoiceCreatedNotification implements ShouldQueue
|
|||||||
if (! $user) {
|
if (! $user) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
if(isset($company_user->react_settings->react_notification_link) && $company_user->react_settings->react_notification_link) {
|
||||||
$use_react_link = true;
|
$use_react_link = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,13 @@ class PurchaseOrderCreatedListener implements ShouldQueue
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$use_react_link = false;
|
||||||
|
|
||||||
|
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
||||||
|
$use_react_link = true;
|
||||||
|
nlog("inside");
|
||||||
|
}
|
||||||
|
|
||||||
/* This is only here to handle the alternate message channels - ie Slack */
|
/* This is only here to handle the alternate message channels - ie Slack */
|
||||||
// $notification = new EntitySentNotification($event->invitation, 'purchase_order');
|
// $notification = new EntitySentNotification($event->invitation, 'purchase_order');
|
||||||
|
|
||||||
@ -66,7 +73,7 @@ class PurchaseOrderCreatedListener implements ShouldQueue
|
|||||||
unset($methods[$key]);
|
unset($methods[$key]);
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo = new NinjaMailerObject;
|
||||||
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($purchase_order, 'purchase_order'))->build());
|
$nmo->mailable = new NinjaMailer((new EntityCreatedObject($purchase_order, 'purchase_order', $use_react_link))->build());
|
||||||
$nmo->company = $purchase_order->company;
|
$nmo->company = $purchase_order->company;
|
||||||
$nmo->settings = $purchase_order->company->settings;
|
$nmo->settings = $purchase_order->company->settings;
|
||||||
|
|
||||||
|
@ -54,6 +54,12 @@ class QuoteCreatedNotification implements ShouldQueue
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$use_react_link = false;
|
||||||
|
|
||||||
|
if($company_user->react_settings && property_exists($company_user->react_settings, 'react_notification_link') && $company_user->react_settings->react_notification_link) {
|
||||||
|
$use_react_link = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* This is only here to handle the alternate message channels - ie Slack */
|
/* This is only here to handle the alternate message channels - ie Slack */
|
||||||
// $notification = new EntitySentNotification($event->invitation, 'quote');
|
// $notification = new EntitySentNotification($event->invitation, 'quote');
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class EntityCreatedObject
|
|||||||
|
|
||||||
private $template_body;
|
private $template_body;
|
||||||
|
|
||||||
private $use_react_link;
|
protected bool $use_react_link;
|
||||||
|
|
||||||
public function __construct($entity, $entity_type, $use_react_link = false)
|
public function __construct($entity, $entity_type, $use_react_link = false)
|
||||||
{
|
{
|
||||||
@ -168,7 +168,7 @@ class EntityCreatedObject
|
|||||||
return [
|
return [
|
||||||
'title' => $this->getSubject(),
|
'title' => $this->getSubject(),
|
||||||
'message' => $this->getMessage(),
|
'message' => $this->getMessage(),
|
||||||
'url' => $this->entity->invitations()->first()->getAdminLink(),
|
'url' => $this->entity->invitations()->first()->getAdminLink($this->use_react_link),
|
||||||
'button' => ctrans("texts.view_{$this->entity_type}"),
|
'button' => ctrans("texts.view_{$this->entity_type}"),
|
||||||
'signature' => $settings->email_signature,
|
'signature' => $settings->email_signature,
|
||||||
'logo' => $this->company->present()->logo(),
|
'logo' => $this->company->present()->logo(),
|
||||||
|
@ -35,7 +35,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||||||
* @property int|null $updated_at
|
* @property int|null $updated_at
|
||||||
* @property int $permissions_updated_at
|
* @property int $permissions_updated_at
|
||||||
* @property string $ninja_portal_url
|
* @property string $ninja_portal_url
|
||||||
* @property string|null $react_settings
|
* @property object|null $react_settings
|
||||||
* @property-read \App\Models\Account $account
|
* @property-read \App\Models\Account $account
|
||||||
* @property-read \App\Models\Company $company
|
* @property-read \App\Models\Company $company
|
||||||
* @property-read \App\Models\CompanyUser $cu
|
* @property-read \App\Models\CompanyUser $cu
|
||||||
|
@ -112,7 +112,14 @@ class CreditInvitation extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Credit::class)->withTrashed();
|
return $this->belongsTo(Credit::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function entity()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Credit::class)->withTrashed();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -115,6 +115,14 @@ class InvoiceInvitation extends BaseModel
|
|||||||
return $this->belongsTo(Invoice::class)->withTrashed();
|
return $this->belongsTo(Invoice::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function entity()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Invoice::class)->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -110,6 +110,14 @@ class PurchaseOrderInvitation extends BaseModel
|
|||||||
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function entity()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(PurchaseOrder::class)->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -113,6 +113,14 @@ class QuoteInvitation extends BaseModel
|
|||||||
return $this->belongsTo(Quote::class)->withTrashed();
|
return $this->belongsTo(Quote::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function entity()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Quote::class)->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -104,6 +104,14 @@ class RecurringInvoiceInvitation extends BaseModel
|
|||||||
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function entity()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(RecurringInvoice::class)->withTrashed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -141,11 +141,13 @@ trait Inviteable
|
|||||||
|
|
||||||
public function getAdminLink($use_react_link = false) :string
|
public function getAdminLink($use_react_link = false) :string
|
||||||
{
|
{
|
||||||
return $this->getLink().'?silent=true';
|
return $use_react_link ? $this->getReactLink() : $this->getLink().'?silent=true';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getReactLink(): string
|
private function getReactLink(): string
|
||||||
{
|
{
|
||||||
return config('ninja.app_url')."/#/{$entity}/{$hash}/edit";
|
$entity_type = Str::snake(class_basename($this->entityType()));
|
||||||
|
|
||||||
|
return config('ninja.app_url')."/#/{$entity_type}/{$this->invoice->hashed_id}/edit";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user