orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Fix: change default value for metrics layout to be compatible with modals #2787

Closed czernika closed 5 months ago

czernika commented 5 months ago

This PR fixes error when using metrics and modals are presents at the same time (not within modal)

I will not open issue, basically steps to reproduce

  1. Install Orchid, go to users list, click on "edit email" modal - everything is OK
  2. Add dummy metric layout
public function query(): iterable
{
  return [
     // ...
     'metrics' => 1,
  ];
}

public function layout(): iterable
{
 // ...
 Layout::metrics(['Metrics' => 'metrics']),
}
  1. Click same button again - modal data was not loaded (we can see skeleton and 500 error in a console)

Proposed Changes

Default data for metrics currently is empty array so it is passes is_array() check within layouts/metric.blade.php (currently line 13) and expects value key to be present. This PR should fix it