empty states

This commit is contained in:
2026-03-13 09:49:11 +01:00
parent cb7256aebc
commit 082fa4c9a5
12 changed files with 174 additions and 46 deletions

View File

@@ -315,7 +315,8 @@ foreach ($tenants as $tenant) {
<?php if (!$passwordResets): ?>
<?php
$emptyState = [
'message' => t('No entries found'),
'message' => t('No password reset requests'),
'hint' => t('No reset has been requested for this account yet.'),
'size' => 'compact',
];
require templatePath('partials/app-empty-state.phtml');
@@ -380,7 +381,8 @@ foreach ($tenants as $tenant) {
<?php if (!$rememberTokens): ?>
<?php
$emptyState = [
'message' => t('No entries found'),
'message' => t('No login tokens'),
'hint' => t('This user is currently not signed in via remember-me.'),
'size' => 'compact',
];
require templatePath('partials/app-empty-state.phtml');
@@ -543,10 +545,13 @@ foreach ($tenants as $tenant) {
</table>
</div>
<?php endif; ?>
<?php if (empty($apiTokens) && !$canManageApiTokens): ?>
<?php if (empty($apiTokens)): ?>
<?php
$emptyState = [
'message' => t('No API tokens'),
'hint' => $canManageApiTokens
? t('Create a token to enable API access for this user.')
: t('No API token has been created for this user yet.'),
'size' => 'compact',
];
require templatePath('partials/app-empty-state.phtml');
@@ -563,35 +568,46 @@ foreach ($tenants as $tenant) {
<details name="assignments-tenants" data-details-key="assignments-tenants" open>
<summary><?php e(t('Tenants')); ?></summary>
<hr>
<?php multiSelectForm('user-tenants', 'tenant_ids', 'Assigned tenants', 'Select tenants', $tenants, $selectedTenantIds, $isReadOnly); ?>
<label>
<span>
<?php e(t('Primary tenant')); ?>
</span>
</label>
<?php if ($primaryTenantDisabled && $primaryTenantId > 0): ?>
<input type="hidden" name="primary_tenant_id" value="<?php e((string) $primaryTenantId); ?>">
<?php endif; ?>
<select id="user-primary-tenant" name="primary_tenant_id" <?php e($primaryTenantDisabledAttr); ?>
<?php e($disabledAttr); ?>>
<?php if (count($selectedTenantIds) !== 1): ?>
<option value="">
<?php e(t('Select primary tenant')); ?>
</option>
<?php if (!$tenants): ?>
<?php
$emptyState = [
'message' => t('No tenants available'),
'hint' => t('No tenant is available in your current scope.'),
'size' => 'compact',
];
require templatePath('partials/app-empty-state.phtml');
?>
<?php else: ?>
<?php multiSelectForm('user-tenants', 'tenant_ids', 'Assigned tenants', 'Select tenants', $tenants, $selectedTenantIds, $isReadOnly); ?>
<label>
<span>
<?php e(t('Primary tenant')); ?>
</span>
</label>
<?php if ($primaryTenantDisabled && $primaryTenantId > 0): ?>
<input type="hidden" name="primary_tenant_id" value="<?php e((string) $primaryTenantId); ?>">
<?php endif; ?>
<?php foreach ($tenants as $tenant): ?>
<?php
$tenantId = (int) ($tenant['id'] ?? 0);
if (!in_array($tenantId, $selectedTenantIds ?? [], true)) {
continue;
}
$selected = $tenantId === $primaryTenantId ? 'selected' : '';
?>
<option value="<?php e((string) $tenantId); ?>" <?php e($selected); ?>>
<?php e($tenant['description'] ?? ''); ?>
</option>
<?php endforeach; ?>
</select>
<select id="user-primary-tenant" name="primary_tenant_id" <?php e($primaryTenantDisabledAttr); ?>
<?php e($disabledAttr); ?>>
<?php if (count($selectedTenantIds) !== 1): ?>
<option value="">
<?php e(t('Select primary tenant')); ?>
</option>
<?php endif; ?>
<?php foreach ($tenants as $tenant): ?>
<?php
$tenantId = (int) ($tenant['id'] ?? 0);
if (!in_array($tenantId, $selectedTenantIds ?? [], true)) {
continue;
}
$selected = $tenantId === $primaryTenantId ? 'selected' : '';
?>
<option value="<?php e((string) $tenantId); ?>" <?php e($selected); ?>>
<?php e($tenant['description'] ?? ''); ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>
</details>
<hr>
<?php endif; ?>
@@ -655,7 +671,18 @@ foreach ($tenants as $tenant) {
<details name="assignments-roles" data-details-key="assignments-roles">
<summary><?php e(t('Roles')); ?></summary>
<hr>
<?php multiSelectForm('user-roles', 'role_ids', 'Assigned roles', 'Select roles', $roles, $selectedRoleIds, $isReadOnly); ?>
<?php if (!$roles): ?>
<?php
$emptyState = [
'message' => t('No roles available'),
'hint' => t('No active roles are configured yet.'),
'size' => 'compact',
];
require templatePath('partials/app-empty-state.phtml');
?>
<?php else: ?>
<?php multiSelectForm('user-roles', 'role_ids', 'Assigned roles', 'Select roles', $roles, $selectedRoleIds, $isReadOnly); ?>
<?php endif; ?>
</details>
<?php endif; ?>
<?php endif; ?>
@@ -667,7 +694,8 @@ foreach ($tenants as $tenant) {
<?php if (!$permissionRows): ?>
<?php
$emptyState = [
'message' => t('No entries found'),
'message' => t('No effective permissions'),
'hint' => t('Assign at least one role to show effective permissions.'),
'size' => 'compact',
];
require templatePath('partials/app-empty-state.phtml');

View File

@@ -175,7 +175,7 @@ if ($canViewSecurityArtifacts) {
$apiTokens = $apiTokenService->listForUser($userId);
}
$canManageApiTokens = $canManageApiTokens && $canViewSecurityArtifacts;
$showApiTokens = $canViewSecurityArtifacts && (!empty($apiTokens) || $canManageApiTokens);
$showApiTokens = $canViewSecurityArtifacts;
if ($request->isMethod('POST') && !Session::checkCsrfToken()) {
Flash::error(t('Form expired, please try again'), $editTarget, 'csrf_expired');