<?php
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
$canPurgeSystemAudit = (bool) ($pageAuth['can_purge_system_audit'] ?? false);
$toolbarFilterSchema = is_array($toolbarFilterSchema ?? null) ? $toolbarFilterSchema : [];
$searchToolbarFilterSchema = is_array($searchToolbarFilterSchema ?? null) ? $searchToolbarFilterSchema : [];
$drawerToolbarFilterSchema = is_array($drawerToolbarFilterSchema ?? null) ? $drawerToolbarFilterSchema : [];
$toolbarFilterState = is_array($toolbarFilterState ?? null) ? $toolbarFilterState : [];
$toolbarOptionSets = is_array($toolbarOptionSets ?? null) ? $toolbarOptionSets : [];
$filterChipMeta = is_array($filterChipMeta ?? null) ? $filterChipMeta : [];
$clientFilterSchema = is_array($clientFilterSchema ?? null) ? $clientFilterSchema : [];
$searchConfig = is_array($searchConfig ?? null) ? $searchConfig : null;

?>
<?php
$breadcrumbs = [
  ['label' => t('Home'), 'path' => 'admin'],
  ['label' => t('System audit logs')],
];
require templatePath('partials/app-breadcrumb.phtml');
?>
<?php
$listTitle = t('System audit logs');
ob_start();
?>
<?php
$listPurgeEnabled = $canPurgeSystemAudit;
$listPurgeFormId = 'system-audit-purge-form';
$listPurgeAction = 'admin/system-audit/purge';
$listPurgeConfirmMessage = t('Purge expired system audit entries?');
$listPurgeButtonLabel = t('Purge system audit logs');
require templatePath('partials/app-list-purge-action.phtml');
?>
<?php
$listTitleActionsHtml = ob_get_clean();
require templatePath('partials/app-list-titlebar.phtml');
?>
<?php
$filterUiNamespace = 'system-audit';
require templatePath('partials/app-list-filters.phtml');
?>
<div class="app-list-table">
  <div id="system-audit-grid"></div>
</div>

<?php
$gridLang = json_decode(appBufferValue('grid_lang'), true);
if (!is_array($gridLang)) {
  $gridLang = [];
}
$pageConfig = [
  'gridSearch' => $searchConfig,
  'filterSchema' => $clientFilterSchema,
  'filterChipMeta' => $filterChipMeta,
  'gridLang' => $gridLang,
  'labels' => [
    'created' => t('Created'),
    'status' => t('Status'),
    'event' => t('Event'),
    'channel' => t('Channel'),
    'actor' => t('Actor'),
    'targetType' => t('Target type'),
    'requestId' => t('Request ID'),
    'errorCode' => t('Error code'),
  ],
];
?>
<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
<script type="application/json" id="page-config-admin-system-audit-index"><?php gridJsonForJs($pageConfig); ?></script>
<script type="module" src="<?php e(assetVersion('js/pages/admin-system-audit-index.js')); ?>"></script>
