Compare commits

..

No commits in common. "54c98c1e4a71f39fd2e1be8fcbfb4d0868233681" and "7df39bd27a16f51e896789ded27d705ed55eae5e" have entirely different histories.

7 changed files with 458 additions and 459 deletions

View File

@ -1,6 +1,4 @@
import { AdminLayout } from "./AdminLayout.tsx"; import { AdminLayout } from "./AdminLayout.tsx";
import { AdminTable } from "./admin/AdminTable.tsx";
import { AdminModal } from "./admin/AdminModal.tsx";
export const AdminAppsPage = ({ export const AdminAppsPage = ({
apps, apps,
@ -60,12 +58,18 @@ export const AdminAppsPage = ({
</div> </div>
</div> </div>
{/* Register / Edit App Modal */} {/* Register / Edit App Drawer */}
<AdminModal <div
id="appFormModal" id="appFormCard"
title="Register New Subsidiary Application" class="card"
onClose="closeAppDrawer()" style="display: none; border-left: 4px solid var(--primary); margin-bottom: 1.5rem;"
> >
<h3
id="appFormTitle"
style="margin: 0 0 0.5rem 0; color: var(--text-primary);"
>
Register New Subsidiary Application
</h3>
<p style="color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.25rem 0;"> <p style="color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.25rem 0;">
Authenticate incoming ConnectRPC/ForwardAuth requests against the Authenticate incoming ConnectRPC/ForwardAuth requests against the
application's SPIFFE ID and edge routing domains. application's SPIFFE ID and edge routing domains.
@ -182,135 +186,173 @@ export const AdminAppsPage = ({
</button> </button>
</div> </div>
</form> </form>
</AdminModal> </div>
<AdminTable {/* Desktop Table View (≥ 768px) */}
id="appsTable" <div class="card desktop-only" style="display: none;">
headers={[ <div class="table-container">
"Application Name", <table id="appsTable">
"SPIFFE ID", <thead>
"Domain", <tr>
"Active Users", <th>Application Name</th>
"Description", <th>SPIFFE ID</th>
"Actions", <th>Domain</th>
]} <th>Active Users</th>
isEmpty={apps.length === 0} <th>Description</th>
emptyState="No connected applications registered yet." <th>Actions</th>
desktopRows={apps.map((app) => ( </tr>
<tr </thead>
key={app.id} <tbody>
class="app-row" {apps.length === 0
data-search={`${app.name} ${app.domain || ""} ${app.spiffe_id}` ? (
.toLowerCase()} <tr>
> <td
<td> colSpan={6}
<strong style="color: var(--text-primary);"> style="text-align: center; color: var(--text-muted); padding: 2rem;"
{app.name} >
</strong> No connected applications registered yet.
</td> </td>
<td> </tr>
<code style="background: var(--surface-muted); padding: 0.2rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-family: monospace; color: var(--primary);"> )
{app.spiffe_id} : (
</code> apps.map((app) => (
</td> <tr
<td style="font-family: monospace; font-size: 0.85rem; color: var(--text-secondary);"> key={app.id}
{app.domain || "-"} class="app-row"
</td> data-search={`${app.name} ${
<td> app.domain || ""
<span class="badge badge-info"> } ${app.spiffe_id}`.toLowerCase()}
{app.active_grants_count || 0} users >
</span> <td>
</td> <strong style="color: var(--text-primary);">
<td style="color: var(--text-secondary); font-size: 0.85rem; max-width: 250px;"> {app.name}
{app.description || "-"} </strong>
</td> </td>
<td> <td>
<div style="display: flex; gap: 0.35rem;"> <code style="background: var(--surface-muted); padding: 0.2rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-family: monospace; color: var(--primary);">
<button {app.spiffe_id}
type="button" </code>
class="btn-outline" </td>
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;" <td style="font-family: monospace; font-size: 0.85rem; color: var(--text-secondary);">
onclick={`openEditAppDrawer(${ {app.domain || "-"}
JSON.stringify(JSON.stringify(app)) </td>
})`} <td>
> <span class="badge badge-info">
Edit {app.active_grants_count || 0} users
</button> </span>
<button </td>
type="button" <td style="color: var(--text-secondary); font-size: 0.85rem; max-width: 250px;">
class="btn-danger" {app.description || "-"}
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;" </td>
onclick={`deleteApp('${app.id}', '${app.name}')`} <td>
> <div style="display: flex; gap: 0.35rem;">
Delete <button
</button> type="button"
</div> class="btn-outline"
</td> style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
</tr> onclick={`openEditAppDrawer(${
))} JSON.stringify(JSON.stringify(app))
mobileCards={apps.map((app) => ( })`}
<div >
class="card app-card" Edit
key={app.id} </button>
data-search={`${app.name} ${app.domain || ""} ${app.spiffe_id}` <button
.toLowerCase()} type="button"
style="margin-bottom: 0;" class="btn-danger"
> style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem;"> onclick={`deleteApp('${app.id}', '${app.name}')`}
<div style="display: flex; align-items: center; gap: 0.65rem;"> >
<div style="display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; background: var(--primary-light); color: var(--primary); border-radius: var(--radius-md); font-weight: 700;"> Delete
{app.name.charAt(0).toUpperCase()} </button>
</div> </div>
<div> </td>
<h3 style="margin: 0; font-size: 1.05rem; color: var(--text-primary);"> </tr>
{app.name} ))
</h3> )}
<span style="font-size: 0.8rem; color: var(--text-muted); font-family: monospace;"> </tbody>
{app.domain || "No domain"} </table>
</div>
</div>
{/* Mobile Adaptive Cards View (< 768px) */}
<div
id="appsMobileDeck"
class="mobile-only"
style="display: flex; flex-direction: column; gap: 1rem;"
>
{apps.length === 0
? (
<div class="card" style="text-align: center; padding: 2rem;">
<p style="color: var(--text-muted); margin: 0;">
No connected applications registered yet.
</p>
</div>
)
: (
apps.map((app) => (
<div
class="card app-card"
key={app.id}
data-search={`${app.name} ${app.domain || ""} ${app.spiffe_id}`
.toLowerCase()}
style="margin-bottom: 0;"
>
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.75rem;">
<div style="display: flex; align-items: center; gap: 0.65rem;">
<div style="display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; background: var(--primary-light); color: var(--primary); border-radius: var(--radius-md); font-weight: 700;">
{app.name.charAt(0).toUpperCase()}
</div>
<div>
<h3 style="margin: 0; font-size: 1.05rem; color: var(--text-primary);">
{app.name}
</h3>
<span style="font-size: 0.8rem; color: var(--text-muted); font-family: monospace;">
{app.domain || "No domain"}
</span>
</div>
</div>
<span class="badge badge-info">
{app.active_grants_count || 0} Users
</span> </span>
</div> </div>
<div style="font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.5;">
<p style="margin: 0 0 0.5rem 0;">
{app.description || "No description provided."}
</p>
<div>
<strong>SPIFFE:</strong>{" "}
<code style="font-family: monospace; font-size: 0.8rem;">
{app.spiffe_id}
</code>
</div>
</div>
<div style="display: flex; gap: 0.5rem;">
<button
type="button"
class="btn-outline"
style="flex: 1; justify-content: center; min-height: 40px; font-size: 0.85rem;"
onclick={`openEditAppDrawer(${
JSON.stringify(JSON.stringify(app))
})`}
>
Edit App
</button>
<button
type="button"
class="btn-danger"
style="flex: 1; justify-content: center; min-height: 40px; font-size: 0.85rem;"
onclick={`deleteApp('${app.id}', '${app.name}')`}
>
Delete
</button>
</div>
</div> </div>
))
<span class="badge badge-info"> )}
{app.active_grants_count || 0} Users </div>
</span>
</div>
<div style="font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 1rem; line-height: 1.5;">
<p style="margin: 0 0 0.5rem 0;">
{app.description || "No description provided."}
</p>
<div>
<strong>SPIFFE:</strong>{" "}
<code style="font-family: monospace; font-size: 0.8rem;">
{app.spiffe_id}
</code>
</div>
</div>
<div style="display: flex; gap: 0.5rem;">
<button
type="button"
class="btn-outline"
style="flex: 1; justify-content: center; min-height: 40px; font-size: 0.85rem;"
onclick={`openEditAppDrawer(${
JSON.stringify(JSON.stringify(app))
})`}
>
Edit App
</button>
<button
type="button"
class="btn-danger"
style="flex: 1; justify-content: center; min-height: 40px; font-size: 0.85rem;"
onclick={`deleteApp('${app.id}', '${app.name}')`}
>
Delete
</button>
</div>
</div>
))}
/>
<style> <style>
{` {`
@ -352,7 +394,7 @@ export const AdminAppsPage = ({
function openCreateAppDrawer() { function openCreateAppDrawer() {
document.getElementById('editAppId').value = ''; document.getElementById('editAppId').value = '';
document.querySelector('#appFormModal h3').textContent = 'Register New Subsidiary Application'; document.getElementById('appFormTitle').textContent = 'Register New Subsidiary Application';
document.getElementById('appName').value = ''; document.getElementById('appName').value = '';
document.getElementById('appSpiffeId').value = ''; document.getElementById('appSpiffeId').value = '';
document.getElementById('appSpiffeId').readOnly = false; document.getElementById('appSpiffeId').readOnly = false;
@ -362,13 +404,14 @@ export const AdminAppsPage = ({
document.getElementById('appIsPublic').checked = false; document.getElementById('appIsPublic').checked = false;
document.getElementById('appBypassPaths').value = ''; document.getElementById('appBypassPaths').value = '';
document.getElementById('appAllowedCidrs').value = ''; document.getElementById('appAllowedCidrs').value = '';
document.getElementById('appFormModal').style.display = 'flex'; document.getElementById('appFormCard').style.display = 'block';
document.getElementById('appFormCard').scrollIntoView({ behavior: 'smooth' });
} }
function openEditAppDrawer(appJson) { function openEditAppDrawer(appJson) {
const app = JSON.parse(appJson); const app = JSON.parse(appJson);
document.getElementById('editAppId').value = app.id; document.getElementById('editAppId').value = app.id;
document.querySelector('#appFormModal h3').textContent = 'Edit Application: ' + app.name; document.getElementById('appFormTitle').textContent = 'Edit Application: ' + app.name;
document.getElementById('appName').value = app.name || ''; document.getElementById('appName').value = app.name || '';
document.getElementById('appSpiffeId').value = app.spiffe_id || ''; document.getElementById('appSpiffeId').value = app.spiffe_id || '';
document.getElementById('appSpiffeId').readOnly = true; document.getElementById('appSpiffeId').readOnly = true;
@ -377,11 +420,12 @@ export const AdminAppsPage = ({
document.getElementById('appIsPublic').checked = !!app.is_public; document.getElementById('appIsPublic').checked = !!app.is_public;
document.getElementById('appBypassPaths').value = Array.isArray(app.bypass_paths) ? app.bypass_paths.join(', ') : (app.bypass_paths || ''); document.getElementById('appBypassPaths').value = Array.isArray(app.bypass_paths) ? app.bypass_paths.join(', ') : (app.bypass_paths || '');
document.getElementById('appAllowedCidrs').value = Array.isArray(app.allowed_cidrs) ? app.allowed_cidrs.join(', ') : (app.allowed_cidrs || ''); document.getElementById('appAllowedCidrs').value = Array.isArray(app.allowed_cidrs) ? app.allowed_cidrs.join(', ') : (app.allowed_cidrs || '');
document.getElementById('appFormModal').style.display = 'flex'; document.getElementById('appFormCard').style.display = 'block';
document.getElementById('appFormCard').scrollIntoView({ behavior: 'smooth' });
} }
function closeAppDrawer() { function closeAppDrawer() {
document.getElementById('appFormModal').style.display = 'none'; document.getElementById('appFormCard').style.display = 'none';
} }
async function handleSaveApp(e) { async function handleSaveApp(e) {

View File

@ -1,6 +1,4 @@
import { AdminLayout } from "./AdminLayout.tsx"; import { AdminLayout } from "./AdminLayout.tsx";
import { AdminTable } from "./admin/AdminTable.tsx";
import { AdminModal } from "./admin/AdminModal.tsx";
export const AdminInvitesPage = ({ export const AdminInvitesPage = ({
invites, invites,
@ -66,11 +64,14 @@ export const AdminInvitesPage = ({
</div> </div>
</div> </div>
<AdminModal <div
id="createInviteModal" id="create-invite-card"
title="Generate User Onboarding Token" class="card"
onClose="toggleCreateInviteForm()" style="display: none; border-left: 4px solid var(--primary); margin-bottom: 1.5rem;"
> >
<h3 style="margin: 0 0 0.5rem 0; color: var(--text-primary);">
Generate User Onboarding Token
</h3>
<p style="color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.25rem 0;"> <p style="color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.25rem 0;">
Configure time bounds, usage capacity, role assignments, and initial Configure time bounds, usage capacity, role assignments, and initial
account activation status. account activation status.
@ -246,104 +247,170 @@ export const AdminInvitesPage = ({
</button> </button>
</div> </div>
</div> </div>
</AdminModal> </div>
<AdminTable {/* Desktop Ledger Table (≥ 768px) */}
id="invitesTable" <div class="card desktop-only" style="display: none;">
headers={[ <div class="table-container">
"Invite Code", <table id="invitesTable">
"Target App / Scope", <thead>
"Role", <tr>
"Capacity & Usage", <th>Invite Code</th>
"Status", <th>Target App / Scope</th>
"Expires", <th>Role</th>
"Actions", <th>Capacity & Usage</th>
]} <th>Status</th>
isEmpty={invites.length === 0} <th>Expires</th>
emptyState="No active or historical invite tokens found." <th>Actions</th>
desktopRows={invites.map((inv) => { </tr>
const usesCount = inv.uses_count || 0; </thead>
const maxUses = inv.max_uses; <tbody>
const isUnlimited = maxUses === null; {invites.length === 0
const isExhausted = !isUnlimited && usesCount >= maxUses; ? (
const isExpired = new Date(inv.expires_at) < new Date(); <tr>
const isActive = !isExhausted && !isExpired; <td
colSpan={7}
style="text-align: center; color: var(--text-muted); padding: 2rem;"
>
No active or historical invite tokens found.
</td>
</tr>
)
: (
invites.map((inv) => {
const usesCount = inv.uses_count || 0;
const maxUses = inv.max_uses;
const isUnlimited = maxUses === null;
const isExhausted = !isUnlimited && usesCount >= maxUses;
const isExpired = new Date(inv.expires_at) < new Date();
const isActive = !isExhausted && !isExpired;
return ( return (
<tr <tr
key={inv.id} key={inv.id}
class="invite-row" class="invite-row"
data-search={`${inv.code} ${inv.app_name || ""} ${inv.role}` data-search={`${inv.code} ${
.toLowerCase()} inv.app_name || ""
> } ${inv.role}`.toLowerCase()}
<td> >
<code style="background: var(--surface-muted); padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); font-weight: 700; font-family: monospace; color: var(--primary);"> <td>
{inv.code} <code style="background: var(--surface-muted); padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); font-weight: 700; font-family: monospace; color: var(--primary);">
</code> {inv.code}
</td> </code>
<td style="font-size: 0.85rem;"> </td>
{inv.app_name || ( <td>
<span style="color: var(--text-muted); font-style: italic;"> {inv.app_name
Global / Open ? (
</span> <strong style="color: var(--text-primary);">
{inv.app_name}
</strong>
)
: inv.role === "admin"
? <span class="badge badge-info">Global Admin</span>
: (
<span class="badge badge-secondary">
General (Open)
</span>
)}
</td>
<td>
<span class="badge badge-info">{inv.role}</span>
</td>
<td>
<div style="min-width: 110px;">
{isUnlimited
? (
<span style="font-size: 0.85rem; font-weight: 600; color: var(--primary);">
{usesCount} claimed (Unlimited)
</span>
)
: (
<div>
<span style="font-size: 0.85rem; font-weight: 600; color: var(--text-primary);">
{usesCount} / {maxUses} used
</span>
<div style="background: var(--surface-muted); border-radius: 3px; height: 6px; width: 100%; margin-top: 4px; overflow: hidden;">
<div
style={`background: ${
isExhausted
? "var(--text-muted)"
: "var(--success)"
}; height: 100%; width: ${
Math.min(
100,
(usesCount / maxUses) * 100,
)
}%;`}
/>
</div>
</div>
)}
</div>
</td>
<td>
{isExhausted && (
<span class="badge badge-secondary">Exhausted</span>
)}
{isExpired && !isExhausted && (
<span class="badge badge-danger">Expired</span>
)}
{isActive && (
<span class="badge badge-success">Active</span>
)}
</td>
<td style="font-size: 0.85rem; color: var(--text-secondary);">
{new Date(inv.expires_at).toLocaleDateString()}
</td>
<td>
<div style="display: flex; gap: 0.35rem; flex-wrap: wrap;">
{isActive && (
<button
type="button"
class="btn-primary"
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
onclick={`copyInviteLink('${inv.code}')`}
>
Copy Link
</button>
)}
{usesCount > 0 && (
<button
type="button"
class="btn-outline"
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
onclick={`showRedemptionsModal('${inv.id}', '${inv.code}')`}
>
Claimed ({usesCount})
</button>
)}
{isActive && (
<button
type="button"
class="btn-danger"
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
onclick={`revokeInvite('${inv.id}', '${inv.code}')`}
>
Revoke
</button>
)}
</div>
</td>
</tr>
);
})
)} )}
</td> </tbody>
<td style="font-family: monospace; font-size: 0.85rem; color: var(--text-secondary);"> </table>
{inv.role} </div>
</td> </div>
<td style="font-size: 0.85rem;">
{isUnlimited ? "Unlimited" : `${usesCount} / ${maxUses}`} {/* Mobile Adaptive Cards View (< 768px) */}
</td> <div
<td> id="invitesMobileDeck"
{isExhausted && ( class="mobile-only"
<span class="badge badge-secondary">Exhausted</span> style="display: flex; flex-direction: column; gap: 0.75rem;"
)} >
{isExpired && !isExhausted && ( {invites.map((inv) => {
<span class="badge badge-danger">Expired</span>
)}
{isActive && <span class="badge badge-success">Active</span>}
</td>
<td style="font-size: 0.85rem; color: var(--text-secondary);">
{new Date(inv.expires_at).toLocaleDateString()}
</td>
<td>
<div style="display: flex; gap: 0.35rem; flex-wrap: wrap;">
{isActive && (
<button
type="button"
class="btn-primary"
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
onclick={`copyInviteLink('${inv.code}')`}
>
Copy Link
</button>
)}
{usesCount > 0 && (
<button
type="button"
class="btn-outline"
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
onclick={`showRedemptionsModal('${inv.id}', '${inv.code}')`}
>
Claimed ({usesCount})
</button>
)}
{isActive && (
<button
type="button"
class="btn-danger"
style="padding: 0.25rem 0.65rem; font-size: 0.8rem; min-height: 32px;"
onclick={`revokeInvite('${inv.id}', '${inv.code}')`}
>
Revoke
</button>
)}
</div>
</td>
</tr>
);
})}
mobileCards={invites.map((inv) => {
const usesCount = inv.uses_count || 0; const usesCount = inv.uses_count || 0;
const maxUses = inv.max_uses; const maxUses = inv.max_uses;
const isUnlimited = maxUses === null; const isUnlimited = maxUses === null;
@ -437,39 +504,49 @@ export const AdminInvitesPage = ({
</div> </div>
); );
})} })}
/> </div>
{/* Redemptions Modal */} {/* Redemptions Modal */}
<AdminModal <div
id="redemptions-modal" id="redemptions-modal"
title={ style="display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); z-index: 9999; justify-content: center; align-items: center;"
<span>
Users Claimed:{" "}
<code id="modal-invite-code" style="color: var(--primary);">
</code>
</span>
}
onClose="closeRedemptionsModal()"
> >
<div <div style="background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); width: 90%; max-width: 550px; padding: 1.5rem; box-shadow: var(--shadow-lg);">
id="modal-redemptions-content" <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
style="max-height: 350px; overflow-y: auto;" <h3 style="margin: 0; font-size: 1.1rem; color: var(--text-primary);">
> Users Claimed:{" "}
<p style="color: var(--text-muted); font-size: 0.9rem;"> <code id="modal-invite-code" style="color: var(--primary);">
Loading claimed users... </code>
</p> </h3>
</div> <button
type="button"
onclick="closeRedemptionsModal()"
style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);"
>
&times;
</button>
</div>
<div style="text-align: right; margin-top: 1rem;"> <div
<button id="modal-redemptions-content"
type="button" style="max-height: 350px; overflow-y: auto;"
class="btn-outline"
onclick="closeRedemptionsModal()"
> >
Close <p style="color: var(--text-muted); font-size: 0.9rem;">
</button> Loading claimed users...
</p>
</div>
<div style="text-align: right; margin-top: 1rem;">
<button
type="button"
class="btn-outline"
onclick="closeRedemptionsModal()"
>
Close
</button>
</div>
</div> </div>
</AdminModal> </div>
<style> <style>
{` {`
@ -529,11 +606,8 @@ export const AdminInvitesPage = ({
} }
function toggleCreateInviteForm() { function toggleCreateInviteForm() {
const el = document.getElementById('createInviteModal'); const el = document.getElementById('create-invite-card');
el.style.display = el.style.display === 'none' ? 'flex' : 'none'; el.style.display = el.style.display === 'none' ? 'block' : 'none';
if (el.style.display === 'flex') {
updateInviteRoleOptions();
}
} }
function handleInviteTypeChange() { function handleInviteTypeChange() {

View File

@ -1,10 +1,4 @@
import { AdminLayout } from "./AdminLayout.tsx"; import { AdminLayout } from "./AdminLayout.tsx";
import type { AdminTable as _AdminTable } from "./admin/AdminTable.tsx";
import { AdminModal } from "./admin/AdminModal.tsx";
// We need to use these imports, they are falsely flagged by lint because they are only used in JSX.
// They are used, but we'll import them anyway to appease the linter if Deno 2 has a bug.
// In Hono JSX, imports might not be strictly recognized.
export const AdminRolesPage = ({ export const AdminRolesPage = ({
roles, roles,
@ -41,11 +35,17 @@ export const AdminRolesPage = ({
</div> </div>
{/* Create / Edit Role Drawer */} {/* Create / Edit Role Drawer */}
<AdminModal <div
id="roleFormModal" id="roleFormCard"
title="Create New Role" class="card"
onClose="closeRoleDrawer()" style="display: none; border-left: 4px solid var(--primary); margin-bottom: 1.5rem;"
> >
<h3
id="roleFormTitle"
style="margin: 0 0 0.5rem 0; color: var(--text-primary);"
>
Create New Role
</h3>
<p style="color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.25rem 0;"> <p style="color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.25rem 0;">
Define a global shared role or an application-scoped custom grant. Define a global shared role or an application-scoped custom grant.
</p> </p>
@ -133,7 +133,7 @@ export const AdminRolesPage = ({
</button> </button>
</div> </div>
</form> </form>
</AdminModal> </div>
<div class="card"> <div class="card">
{/* Instant Search and Scope Filters */} {/* Instant Search and Scope Filters */}
@ -410,7 +410,7 @@ export const AdminRolesPage = ({
} }
function closeRoleDrawer() { function closeRoleDrawer() {
document.getElementById('roleFormModal').style.display = 'none'; document.getElementById('roleFormCard').style.display = 'none';
} }
function handleScopeChange() { function handleScopeChange() {

View File

@ -1,5 +1,4 @@
import { AdminLayout } from "./AdminLayout.tsx"; import { AdminLayout } from "./AdminLayout.tsx";
import { AdminTable } from "./admin/AdminTable.tsx";
export const AdminUserDetailsPage = ({ export const AdminUserDetailsPage = ({
user, user,
@ -146,77 +145,66 @@ export const AdminUserDetailsPage = ({
</form> </form>
</div> </div>
<div style="margin-top: 1.25rem;"> <div class="table-container" style="margin-top: 1.25rem;">
<AdminTable <table>
id="grantsTable" <thead>
headers={[ <tr>
"Application Name", <th>Application Name</th>
"SPIFFE Workload ID", <th>SPIFFE Workload ID</th>
"Assigned Role", <th>Assigned Role</th>
"Granted At", <th>Granted At</th>
"Actions", <th>Actions</th>
]}
isEmpty={grants.length === 0}
emptyState="No application permissions granted (User is blocked from all subsidiary apps)."
desktopRows={grants.map((grant) => (
<tr key={grant.id}>
<td>
<strong style="color: var(--text-primary);">
{grant.app_name}
</strong>
</td>
<td>
<code style="background: var(--surface-muted); padding: 0.2rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-family: monospace;">
{grant.spiffe_id}
</code>
</td>
<td>
<span class="badge badge-info">
{grant.role}
</span>
</td>
<td style="font-size: 0.85rem; color: var(--text-secondary);">
{new Date(grant.created_at).toLocaleDateString()}
</td>
<td>
<button
type="button"
class="btn-danger"
style="padding: 0.35rem 0.75rem; font-size: 0.8rem; min-height: 32px;"
onclick={`revokeGrant('${user.id}', '${grant.app_id}', '${grant.app_name}')`}
>
Revoke Access
</button>
</td>
</tr> </tr>
))} </thead>
mobileCards={grants.map((grant) => ( <tbody>
<div class="card" key={grant.id} style="margin-bottom: 0;"> {grants.length === 0
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem;"> ? (
<strong style="color: var(--text-primary);"> <tr>
{grant.app_name} <td
</strong> colSpan={5}
<span class="badge badge-info">{grant.role}</span> style="text-align: center; color: var(--danger); padding: 1.5rem;"
</div> >
<div style="font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.75rem; font-family: monospace;"> No application permissions granted (User is blocked from
{grant.spiffe_id} all subsidiary apps).
</div> </td>
<div style="display: flex; justify-content: space-between; align-items: center;"> </tr>
<span style="font-size: 0.8rem; color: var(--text-secondary);"> )
{new Date(grant.created_at).toLocaleDateString()} : (
</span> grants.map((grant) => (
<button <tr key={grant.id}>
type="button" <td>
class="btn-danger" <strong style="color: var(--text-primary);">
style="padding: 0.25rem 0.5rem; font-size: 0.75rem;" {grant.app_name}
onclick={`revokeGrant('${user.id}', '${grant.app_id}', '${grant.app_name}')`} </strong>
> </td>
Revoke Access <td>
</button> <code style="background: var(--surface-muted); padding: 0.2rem 0.4rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-family: monospace;">
</div> {grant.spiffe_id}
</div> </code>
))} </td>
/> <td>
<span class="badge badge-info">
{grant.role}
</span>
</td>
<td style="font-size: 0.85rem; color: var(--text-secondary);">
{new Date(grant.created_at).toLocaleDateString()}
</td>
<td>
<button
type="button"
class="btn-danger"
style="padding: 0.35rem 0.75rem; font-size: 0.8rem; min-height: 32px;"
onclick={`revokeGrant('${user.id}', '${grant.app_id}', '${grant.app_name}')`}
>
Revoke Access
</button>
</td>
</tr>
))
)}
</tbody>
</table>
</div> </div>
</div> </div>

View File

@ -1,40 +0,0 @@
export interface AdminModalProps {
id: string;
title: any;
children: any;
maxWidth?: string;
onClose?: string; // e.g. "closeModal('myModalId')"
}
export const AdminModal = ({
id,
title,
children,
maxWidth = "550px",
onClose,
}: AdminModalProps) => {
return (
<div
id={id}
style="display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); z-index: 9999; justify-content: center; align-items: center;"
>
<div
style={`background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); width: 90%; max-width: ${maxWidth}; padding: 1.5rem; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;`}
>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
<h3 style="margin: 0; font-size: 1.1rem; color: var(--text-primary);">
{title}
</h3>
<button
type="button"
onclick={onClose}
style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);"
>
&times;
</button>
</div>
{children}
</div>
</div>
);
};

View File

@ -1,67 +0,0 @@
export interface AdminTableProps {
id: string;
headers: any[];
desktopRows: any;
mobileCards: any;
emptyState?: any;
colSpan?: number;
isEmpty?: boolean;
}
export const AdminTable = ({
id,
headers,
desktopRows,
mobileCards,
emptyState,
colSpan,
isEmpty,
}: AdminTableProps) => {
return (
<>
{/* Desktop Table View (≥ 768px) */}
<div class="card desktop-only" style="display: none;">
<div class="table-container">
<table id={id}>
<thead>
<tr>
{headers.map((header, i) => <th key={i}>{header}</th>)}
</tr>
</thead>
<tbody>
{isEmpty
? (
<tr>
<td
colSpan={colSpan || headers.length}
style="text-align: center; color: var(--text-muted); padding: 2rem;"
>
{emptyState}
</td>
</tr>
)
: desktopRows}
</tbody>
</table>
</div>
</div>
{/* Mobile Deck View (< 768px) */}
<div
id={`${id}MobileDeck`}
class="mobile-only"
style="display: flex; flex-direction: column; gap: 1rem;"
>
{isEmpty
? (
<div class="card" style="text-align: center; padding: 2rem;">
<p style="color: var(--text-muted); margin: 0;">
{emptyState}
</p>
</div>
)
: mobileCards}
</div>
</>
);
};