<?php
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
$canPurge = (bool) ($pageAuth['can_purge'] ?? 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 : [];
$filterChipMeta = is_array($filterChipMeta ?? null) ? $filterChipMeta : [];
$clientFilterSchema = is_array($clientFilterSchema ?? null) ? $clientFilterSchema : [];
$searchConfig = is_array($searchConfig ?? null) ? $searchConfig : null;
?>
<?php
$listTitle = t('Scheduled jobs');
ob_start();
?>
<?php
$listPurgeEnabled = $canPurge;
$listPurgeFormId = 'scheduled-jobs-purge-form';
$listPurgeAction = 'admin/scheduled-jobs/purge-runs';
$listPurgeConfirmMessage = t('Purge run logs older than 90 days?');
$listPurgeButtonLabel = t('Purge scheduler logs');
require templatePath('partials/app-list-purge-action.phtml');
?>
<?php
$listTitleActionsHtml = ob_get_clean();
require templatePath('partials/app-list-titlebar.phtml');
?>

<?php
$filterUiNamespace = 'scheduled-jobs';
require templatePath('partials/app-list-filters.phtml');
?>

<div class="app-list-table">
  <div id="scheduled-jobs-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' => [
    'job' => t('Job'),
    'enabled' => t('Enabled'),
    'disabled' => t('Disabled'),
    'nextRun' => t('Next run'),
    'schedule' => t('Schedule'),
    'lastRun' => t('Last run'),
    'status' => t('Status'),
    'lastError' => t('Last error'),
  ],
];
?>
<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
<script type="application/json" id="page-config-admin-scheduled-jobs-index"><?php gridJsonForJs($pageConfig); ?></script>
<script type="module" src="<?php e(assetVersion('js/pages/admin-scheduled-jobs-index.js')); ?>"></script>
