2026-02-04 23:31:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
use MintyPHP\Domain\Taxonomy\TenantStatus;
|
2026-02-24 08:49:40 +01:00
|
|
|
use MintyPHP\Service\Access\TenantAuthorizationPolicy;
|
2026-02-23 12:58:19 +01:00
|
|
|
use MintyPHP\Support\Guard;
|
2026-02-04 23:31:53 +01:00
|
|
|
|
|
|
|
|
Guard::requireLogin();
|
2026-03-04 15:56:58 +01:00
|
|
|
gridRequireGetRequest();
|
2026-02-24 08:49:40 +01:00
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
$decision = Guard::requireAbilityDecisionOrForbidden(TenantAuthorizationPolicy::ABILITY_ADMIN_TENANTS_VIEW);
|
2026-02-24 08:49:40 +01:00
|
|
|
$capabilities = $decision->attribute('capabilities', []);
|
|
|
|
|
$allowedTenantIds = is_array($capabilities) ? array_values(array_unique(array_map('intval', (array) ($capabilities['allowed_tenant_ids'] ?? [])))) : [];
|
|
|
|
|
$isStrictScope = is_array($capabilities) ? (bool) ($capabilities['is_strict_scope'] ?? false) : false;
|
|
|
|
|
$hasGlobalAccess = is_array($capabilities) ? (bool) ($capabilities['has_global_access'] ?? false) : false;
|
2026-02-04 23:31:53 +01:00
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
$filters = gridParseFiltersFromSchemaFile(__DIR__ . '/filter-schema.php');
|
|
|
|
|
|
|
|
|
|
$order = $filters['order'];
|
|
|
|
|
$dir = $filters['dir'];
|
refactor(admin-tenants): simplify list to 2 columns (avatar + name, users)
Reduce tenant grid from 8 columns to 2. Remove status, theme, sso,
active/inactive users, and created columns from the list view.
All details remain accessible on the edit page.
- filter-schema: allow order by description and users only
- data endpoint: return minimal row shape (id, uuid, description,
status metadata for badge only, is_default, has_avatar, total_users)
- JS grid: 2 visible columns + hidden UUID for navigation
- CSS: add .grid-tenant-profile utility for flex avatar+name layout
Refs: TENANT-LIST-MINIMAL-001
2026-04-22 19:10:48 +02:00
|
|
|
$computedOrderKeys = ['users'];
|
2026-03-04 15:56:58 +01:00
|
|
|
$userTenantRepository = app(\MintyPHP\Repository\Tenant\UserTenantRepository::class);
|
2026-03-05 11:17:42 +01:00
|
|
|
$tenantAvatarService = app(\MintyPHP\Service\Tenant\TenantAvatarService::class);
|
2026-03-06 00:44:52 +01:00
|
|
|
$settingsDefaultsGateway = app(\MintyPHP\Service\Settings\SettingsDefaultsGateway::class);
|
2026-02-23 12:58:19 +01:00
|
|
|
|
2026-03-13 12:05:11 +01:00
|
|
|
$gridUserCountEnricher = app(\MintyPHP\Service\Data\GridUserCountEnricher::class);
|
refactor(admin-tenants): simplify list to 2 columns (avatar + name, users)
Reduce tenant grid from 8 columns to 2. Remove status, theme, sso,
active/inactive users, and created columns from the list view.
All details remain accessible on the edit page.
- filter-schema: allow order by description and users only
- data endpoint: return minimal row shape (id, uuid, description,
status metadata for badge only, is_default, has_avatar, total_users)
- JS grid: 2 visible columns + hidden UUID for navigation
- CSS: add .grid-tenant-profile utility for flex avatar+name layout
Refs: TENANT-LIST-MINIMAL-001
2026-04-22 19:10:48 +02:00
|
|
|
$fetchRows = static function (array $tenantRows) use ($userTenantRepository, $tenantAvatarService, $settingsDefaultsGateway, $gridUserCountEnricher): array {
|
2026-03-13 12:05:11 +01:00
|
|
|
$userCounts = $gridUserCountEnricher->computeCounts(
|
|
|
|
|
$tenantRows,
|
|
|
|
|
$userTenantRepository->countUsersByTenantIds(...),
|
|
|
|
|
$userTenantRepository->countActiveUsersByTenantIds(...)
|
|
|
|
|
);
|
2026-03-06 00:44:52 +01:00
|
|
|
$defaultTenantId = $settingsDefaultsGateway->getDefaultTenantId();
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
$rows = [];
|
|
|
|
|
|
|
|
|
|
foreach ($tenantRows as $row) {
|
|
|
|
|
$tenantId = (int) ($row['id'] ?? 0);
|
2026-03-13 12:05:11 +01:00
|
|
|
$counts = $userCounts[$tenantId] ?? ['active_users' => 0, 'inactive_users' => 0];
|
2026-03-04 15:56:58 +01:00
|
|
|
$tenantStatus = TenantStatus::normalizeOr((string) ($row['status'] ?? ''), TenantStatus::Active);
|
2026-03-05 11:17:42 +01:00
|
|
|
$tenantUuid = (string) ($row['uuid'] ?? '');
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
|
|
|
|
|
$rows[] = [
|
|
|
|
|
'id' => $row['id'] ?? null,
|
2026-03-05 11:17:42 +01:00
|
|
|
'uuid' => $tenantUuid,
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
'is_default' => $tenantId > 0 && $defaultTenantId === $tenantId,
|
|
|
|
|
'description' => $row['description'] ?? '',
|
2026-03-04 15:56:58 +01:00
|
|
|
'status' => $tenantStatus->value,
|
|
|
|
|
'status_badge' => $tenantStatus->badgeVariant(),
|
|
|
|
|
'status_label' => t($tenantStatus->labelToken()),
|
refactor(admin-tenants): simplify list to 2 columns (avatar + name, users)
Reduce tenant grid from 8 columns to 2. Remove status, theme, sso,
active/inactive users, and created columns from the list view.
All details remain accessible on the edit page.
- filter-schema: allow order by description and users only
- data endpoint: return minimal row shape (id, uuid, description,
status metadata for badge only, is_default, has_avatar, total_users)
- JS grid: 2 visible columns + hidden UUID for navigation
- CSS: add .grid-tenant-profile utility for flex avatar+name layout
Refs: TENANT-LIST-MINIMAL-001
2026-04-22 19:10:48 +02:00
|
|
|
'total_users' => $counts['active_users'] + $counts['inactive_users'],
|
2026-03-05 11:17:42 +01:00
|
|
|
'has_avatar' => $tenantUuid !== '' && $tenantAvatarService->hasAvatar($tenantUuid),
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $rows;
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-24 08:49:40 +01:00
|
|
|
$listOptions = [
|
2026-03-04 15:56:58 +01:00
|
|
|
'limit' => $filters['limit'],
|
|
|
|
|
'offset' => $filters['offset'],
|
|
|
|
|
'search' => $filters['search'],
|
|
|
|
|
'status' => $filters['status'],
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
'order' => in_array($order, $computedOrderKeys, true) ? 'description' : $order,
|
2026-02-04 23:31:53 +01:00
|
|
|
'dir' => $dir,
|
2026-02-24 08:49:40 +01:00
|
|
|
];
|
|
|
|
|
if (!$hasGlobalAccess) {
|
|
|
|
|
if ($allowedTenantIds) {
|
|
|
|
|
$listOptions['tenantIds'] = $allowedTenantIds;
|
|
|
|
|
} elseif ($isStrictScope) {
|
|
|
|
|
$listOptions['tenantIds'] = [];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
$result = app(\MintyPHP\Service\Tenant\TenantService::class)->listPaged($listOptions);
|
2026-02-04 23:31:53 +01:00
|
|
|
|
|
|
|
|
$rows = [];
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
$total = (int) ($result['total'] ?? 0);
|
|
|
|
|
if (in_array($order, $computedOrderKeys, true)) {
|
2026-03-04 15:56:58 +01:00
|
|
|
$fullResult = app(\MintyPHP\Service\Tenant\TenantService::class)->listPaged([
|
2026-02-24 08:49:40 +01:00
|
|
|
...$listOptions,
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
'limit' => max(1, $total),
|
|
|
|
|
'offset' => 0,
|
|
|
|
|
'order' => 'description',
|
|
|
|
|
'dir' => 'asc',
|
|
|
|
|
]);
|
refactor(admin-tenants): simplify list to 2 columns (avatar + name, users)
Reduce tenant grid from 8 columns to 2. Remove status, theme, sso,
active/inactive users, and created columns from the list view.
All details remain accessible on the edit page.
- filter-schema: allow order by description and users only
- data endpoint: return minimal row shape (id, uuid, description,
status metadata for badge only, is_default, has_avatar, total_users)
- JS grid: 2 visible columns + hidden UUID for navigation
- CSS: add .grid-tenant-profile utility for flex avatar+name layout
Refs: TENANT-LIST-MINIMAL-001
2026-04-22 19:10:48 +02:00
|
|
|
$rows = $fetchRows($fullResult['rows'] ?? []);
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
|
refactor(admin-tenants): simplify list to 2 columns (avatar + name, users)
Reduce tenant grid from 8 columns to 2. Remove status, theme, sso,
active/inactive users, and created columns from the list view.
All details remain accessible on the edit page.
- filter-schema: allow order by description and users only
- data endpoint: return minimal row shape (id, uuid, description,
status metadata for badge only, is_default, has_avatar, total_users)
- JS grid: 2 visible columns + hidden UUID for navigation
- CSS: add .grid-tenant-profile utility for flex avatar+name layout
Refs: TENANT-LIST-MINIMAL-001
2026-04-22 19:10:48 +02:00
|
|
|
usort($rows, static function (array $a, array $b) use ($dir): int {
|
|
|
|
|
$cmp = ((int) $a['total_users']) <=> ((int) $b['total_users']);
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
if ($cmp === 0) {
|
2026-02-23 12:58:19 +01:00
|
|
|
$cmp = strcasecmp((string) $a['description'], (string) $b['description']);
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
}
|
|
|
|
|
return $dir === 'desc' ? -$cmp : $cmp;
|
|
|
|
|
});
|
2026-03-04 15:56:58 +01:00
|
|
|
$rows = array_slice($rows, $filters['offset'], $filters['limit']);
|
add composer-unused, comprehensive docs, and project restructure
- Add icanhazstring/composer-unused as dev dependency for dependency hygiene checks
- Add German documentation (docs/) covering architecture, conventions, workflows, and developer checklists
- Add API layer (ApiAuth, ApiBootstrap, ApiResponse), audit, scheduler, custom fields, and SSO services
- Add Microsoft OIDC SSO, API token management, and user lifecycle features
- Add swagger-ui vendor integration and OpenAPI spec
- Add production Docker setup and bin/ scripts
- Update composer dependencies, config, templates, and frontend assets throughout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:27:35 +01:00
|
|
|
} else {
|
refactor(admin-tenants): simplify list to 2 columns (avatar + name, users)
Reduce tenant grid from 8 columns to 2. Remove status, theme, sso,
active/inactive users, and created columns from the list view.
All details remain accessible on the edit page.
- filter-schema: allow order by description and users only
- data endpoint: return minimal row shape (id, uuid, description,
status metadata for badge only, is_default, has_avatar, total_users)
- JS grid: 2 visible columns + hidden UUID for navigation
- CSS: add .grid-tenant-profile utility for flex avatar+name layout
Refs: TENANT-LIST-MINIMAL-001
2026-04-22 19:10:48 +02:00
|
|
|
$rows = $fetchRows($result['rows'] ?? []);
|
2026-02-04 23:31:53 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-04 15:56:58 +01:00
|
|
|
gridJsonDataResult($rows, $total);
|