feat: coordinator tabs (Shifts, Contacts, Settings)
- pages.tsx: Layout shows a Coordinator tab row on every signed-in /admin page. Shifts covers the dashboard, events, shifts and templates; Contacts covers /admin/contacts; Settings covers /admin/settings and /admin/admins. - admin-pages.tsx: remove the dashboard link cluster and the redundant Contacts/Settings breadcrumbs. Administrators moves under Settings, with a "Manage administrators" card. Routes are unchanged. - app.css: .desk-tabs styles (white pill, gold underline on the current tab, 48px tap targets, full width on phones, hidden in print); drop .desk-links. - tests: admins.test.ts checks the tabs and the new Settings link.
This commit is contained in:
1 parent
1230030e39
commit
c4fe911969
4 files changed
+117
-14
No files matched your search
+61
-5
@@ -2259,6 +2259,11 @@ article.shift-card {
|
|||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-more {
|
||||||
|
max-width: 46rem;
|
||||||
|
margin-top: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 42em) {
|
@media (max-width: 42em) {
|
||||||
.settings-fields {
|
.settings-fields {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
@@ -3279,18 +3284,68 @@ button.btn-quiet::before {
|
|||||||
margin: 0.15rem 0 0;
|
margin: 0.15rem 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.desk-links {
|
/* Coordinator tabs. Same family as the session bar: a white pill, plain links, a gold line under the current one. */
|
||||||
|
.desk-tabs {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: flex-end;
|
align-items: center;
|
||||||
gap: 0.35rem 0.9rem;
|
gap: 0 1.75rem;
|
||||||
font-size: 0.95rem;
|
width: fit-content;
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 0 0 1.25rem;
|
||||||
|
padding: 0 1.5rem;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #e6eef3;
|
||||||
|
border-radius: 999px;
|
||||||
|
box-shadow: var(--hope-shadow-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
.desk-links a {
|
.desk-tabs a {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 48px;
|
||||||
|
color: var(--hope-ink);
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desk-tabs a:hover {
|
||||||
|
color: var(--hope-ink-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.desk-tabs a[aria-current] {
|
||||||
font-weight: 650;
|
font-weight: 650;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.desk-tabs a[aria-current]::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 10px;
|
||||||
|
height: 2px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--hope-gold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.desk-tabs a:focus-visible {
|
||||||
|
outline: 2px solid var(--hope-ink);
|
||||||
|
outline-offset: 3px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 42em) {
|
||||||
|
.desk-tabs {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0 1rem;
|
||||||
|
padding: 0 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.coordinator-board {
|
.coordinator-board {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
@@ -5846,6 +5901,7 @@ main > .crumb,
|
|||||||
.header,
|
.header,
|
||||||
.footer,
|
.footer,
|
||||||
.session-bar,
|
.session-bar,
|
||||||
|
.desk-tabs,
|
||||||
.crumb,
|
.crumb,
|
||||||
.desk-actions,
|
.desk-actions,
|
||||||
.desk-inline,
|
.desk-inline,
|
||||||
|
|||||||
+18
-8
@@ -274,11 +274,6 @@ export function AdminHome(props: {
|
|||||||
<p class={props.backupSavedToday ? 'desk-note is-saved' : 'desk-note'}>
|
<p class={props.backupSavedToday ? 'desk-note is-saved' : 'desk-note'}>
|
||||||
{props.backupSavedToday ? <BackupSavedToday /> : <BackupNote text={props.backupNote} />}
|
{props.backupSavedToday ? <BackupSavedToday /> : <BackupNote text={props.backupNote} />}
|
||||||
</p>
|
</p>
|
||||||
<nav class="desk-links" aria-label="Coordinator">
|
|
||||||
<a href={appPath(props.config, '/admin/contacts')}>Contacts</a>
|
|
||||||
<a href={appPath(props.config, '/admin/settings')}>Settings</a>
|
|
||||||
<a href={appPath(props.config, '/admin/admins')}>Administrators</a>
|
|
||||||
</nav>
|
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<Notice notice={props.notice} />
|
<Notice notice={props.notice} />
|
||||||
@@ -375,7 +370,6 @@ export function SettingsPage(props: {
|
|||||||
const keepNote = retentionPreview(props.values.retentionMonths);
|
const keepNote = retentionPreview(props.values.retentionMonths);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Crumb items={[{ href: appPath(props.config, '/admin'), label: 'Coordinator' }, { label: 'Settings' }]} />
|
|
||||||
<header class="settings-intro">
|
<header class="settings-intro">
|
||||||
<h1>Settings</h1>
|
<h1>Settings</h1>
|
||||||
<p>Choose when volunteers get a reminder, where their replies go, and how long signup details stay here. This applies to email that has not gone out yet.</p>
|
<p>Choose when volunteers get a reminder, where their replies go, and how long signup details stay here. This applies to email that has not gone out yet.</p>
|
||||||
@@ -437,6 +431,17 @@ export function SettingsPage(props: {
|
|||||||
<button type="submit">Save these choices</button>
|
<button type="submit">Save these choices</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<section class="settings-card settings-more" aria-labelledby="admins-heading">
|
||||||
|
<div class="settings-card-copy">
|
||||||
|
<h2 id="admins-heading">Administrators</h2>
|
||||||
|
<p>Choose who can sign in to this coordinator area.</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a class="btn" href={appPath(props.config, '/admin/admins')}>
|
||||||
|
Manage administrators
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
<script src={assetHref(props.config, '/js/settings.js')} defer />
|
<script src={assetHref(props.config, '/js/settings.js')} defer />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -527,7 +532,13 @@ export function AdminsPage(props: {
|
|||||||
const only = props.admins.length === 1;
|
const only = props.admins.length === 1;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Crumb items={[{ href: appPath(props.config, '/admin'), label: 'Coordinator' }, { label: 'Administrators' }]} />
|
<Crumb
|
||||||
|
items={[
|
||||||
|
{ href: appPath(props.config, '/admin'), label: 'Coordinator' },
|
||||||
|
{ href: appPath(props.config, '/admin/settings'), label: 'Settings' },
|
||||||
|
{ label: 'Administrators' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
<h1>Administrators</h1>
|
<h1>Administrators</h1>
|
||||||
<Notice notice={props.notice} />
|
<Notice notice={props.notice} />
|
||||||
<p>
|
<p>
|
||||||
@@ -634,7 +645,6 @@ export function ContactsPage(props: {
|
|||||||
const importOpen = Boolean(props.importError);
|
const importOpen = Boolean(props.importError);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Crumb items={[{ href: appPath(props.config, '/admin'), label: 'Coordinator' }, { label: 'Contacts' }]} />
|
|
||||||
<h1>Contacts</h1>
|
<h1>Contacts</h1>
|
||||||
{props.summary ? <Notice text={contactImportSentence(props.summary)} /> : <Notice notice={props.notice} />}
|
{props.summary ? <Notice text={contactImportSentence(props.summary)} /> : <Notice notice={props.notice} />}
|
||||||
{props.summary && props.summary.skips.length > 0 ? (
|
{props.summary && props.summary.skips.length > 0 ? (
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ export function Layout(props: {
|
|||||||
</form>
|
</form>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
{props.account && pathIs(props.path, appPath(props.config, '/admin')) ? <CoordinatorTabs config={props.config} path={props.path} /> : null}
|
||||||
{props.children}
|
{props.children}
|
||||||
</main>
|
</main>
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
@@ -223,6 +224,32 @@ export function Layout(props: {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coordinator sections, on every signed-in coordinator page.
|
||||||
|
* Shifts covers the dashboard, events, shifts, and templates. Administrators sits under Settings.
|
||||||
|
*/
|
||||||
|
function CoordinatorTabs(props: { config: AppConfig; path?: string }) {
|
||||||
|
const shifts = appPath(props.config, '/admin');
|
||||||
|
const contacts = appPath(props.config, '/admin/contacts');
|
||||||
|
const settings = appPath(props.config, '/admin/settings');
|
||||||
|
const admins = appPath(props.config, '/admin/admins');
|
||||||
|
const section = pathIs(props.path, contacts) ? 'contacts' : pathIs(props.path, settings) || pathIs(props.path, admins) ? 'settings' : 'shifts';
|
||||||
|
const tabs = [
|
||||||
|
{ key: 'shifts', href: shifts, label: 'Shifts' },
|
||||||
|
{ key: 'contacts', href: contacts, label: 'Contacts' },
|
||||||
|
{ key: 'settings', href: settings, label: 'Settings' },
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<nav class="desk-tabs" aria-label="Coordinator">
|
||||||
|
{tabs.map((tab) => (
|
||||||
|
<a key={tab.key} href={tab.href} aria-current={tab.key === section ? (props.path === tab.href ? 'page' : 'true') : undefined}>
|
||||||
|
{tab.label}
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function EmptySchedulePage() {
|
export function EmptySchedulePage() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
+11
-1
@@ -37,12 +37,22 @@ describe('administrators', () => {
|
|||||||
const { app, db } = await buildApp();
|
const { app, db } = await buildApp();
|
||||||
const cookie = await signIn(app, db, 'coordinator@example.invalid');
|
const cookie = await signIn(app, db, 'coordinator@example.invalid');
|
||||||
const home = await app.request('/admin', { headers: { cookie } });
|
const home = await app.request('/admin', { headers: { cookie } });
|
||||||
expect(await home.text()).toContain('href="/admin/admins"');
|
const homeHtml = await home.text();
|
||||||
|
expect(homeHtml).toContain('<nav class="desk-tabs" aria-label="Coordinator">');
|
||||||
|
expect(homeHtml).toContain('<a href="/admin" aria-current="page">Shifts</a>');
|
||||||
|
expect(homeHtml).toContain('<a href="/admin/contacts">Contacts</a>');
|
||||||
|
expect(homeHtml).not.toContain('href="/admin/admins"');
|
||||||
|
const settings = await (await app.request('/admin/settings', { headers: { cookie } })).text();
|
||||||
|
expect(settings).toContain('<a href="/admin/settings" aria-current="page">Settings</a>');
|
||||||
|
expect(settings).toContain('href="/admin/admins"');
|
||||||
|
expect(settings).toContain('Manage administrators');
|
||||||
|
|
||||||
const first = await app.request('/admin/admins', { headers: { cookie } });
|
const first = await app.request('/admin/admins', { headers: { cookie } });
|
||||||
const firstHtml = await first.text();
|
const firstHtml = await first.text();
|
||||||
expect(first.status).toBe(200);
|
expect(first.status).toBe(200);
|
||||||
expect(firstHtml).toContain('Administrator');
|
expect(firstHtml).toContain('Administrator');
|
||||||
|
expect(firstHtml).toContain('<a href="/admin/settings" aria-current="true">Settings</a>');
|
||||||
|
expect(firstHtml).toContain('<a href="/admin/settings">Settings</a>');
|
||||||
expect(firstHtml).toContain('coordinator@example.invalid');
|
expect(firstHtml).toContain('coordinator@example.invalid');
|
||||||
expect(firstHtml).toContain('>You</span>');
|
expect(firstHtml).toContain('>You</span>');
|
||||||
expect(firstHtml).toContain('This is the only administrator.');
|
expect(firstHtml).toContain('This is the only administrator.');
|
||||||
|
|||||||
Reference in new issue
Block a user