mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
80c04df4fc
Packing items, tasks and expenses swipe sideways to their actions, as in Mail or Reminders: done or open one way, delete and edit the other, the first one run by a full swipe. They are second ways to what each row already offers; an expense still asks before it goes. A long press on a trip card lifts it and opens its menu with the card's own actions. Plain confirmations in MConfirmSheet now also ask through the system where the app can. Lists, the atlas and a journey show grey placeholders in their shape while loading instead of a spinner in an empty screen (MSkeleton); buttons keep theirs. A picture still loading fades in once it is there; one from the cache shows at once. In the iOS app the page bounces at its ends again, except on screens with pull-to-refresh, whose pull it would race; Android keeps its stretch off. On iOS a long press on the app icon offers "New trip" and the trip coming up by its name, set by the UI in its language (TrekShell.setQuickActions, feature quickActions), and a tap opens it, also from a cold start. The app's own CSS moves out of index.css into native/nativeApp.css, which had outgrown its size budget.
89 lines
4.0 KiB
TypeScript
89 lines
4.0 KiB
TypeScript
import React from 'react'
|
|
import { useTranslation } from '../../../i18n'
|
|
import { PermissionLevel } from '../../../store/permissionsStore'
|
|
import { CATEGORIES, LEVEL_LABELS, usePermissionsAdmin } from '../../../components/Admin/usePermissionsAdmin'
|
|
import { Save, RotateCcw } from 'lucide-react'
|
|
import { MAdminButton, MAdminCard } from './MAdminUi'
|
|
import MSkeleton from '../../components/MSkeleton'
|
|
|
|
export default function MAdminPermissionsPanel(): React.ReactElement {
|
|
const { t } = useTranslation()
|
|
const { entryMap, values, loading, saving, dirty, handleChange, handleSave, handleReset } = usePermissionsAdmin()
|
|
|
|
if (loading) {
|
|
return (
|
|
<MAdminCard>
|
|
<MSkeleton variant="rows" count={5} framed={false} />
|
|
</MAdminCard>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<MAdminCard>
|
|
{/* The title gets the full width and the actions a row of their own: beside a
|
|
long title they ran into its second line. */}
|
|
<div className="mb-1">
|
|
<div className="text-[length:calc(14px*var(--fs-scale-body,1))] font-extrabold text-m-ink">{t('perm.title')}</div>
|
|
<div className="mt-[2px] font-geist text-[length:calc(10px*var(--fs-scale-caption,1))] leading-relaxed text-m-muted">{t('perm.subtitle')}</div>
|
|
<div className="mt-2.5 flex items-center justify-end gap-2">
|
|
<MAdminButton variant="ghost" disabled={saving} onClick={handleReset}>
|
|
<RotateCcw size={12} strokeWidth={2.2} />
|
|
{t('perm.resetDefaults')}
|
|
</MAdminButton>
|
|
<MAdminButton busy={saving} disabled={saving || !dirty} onClick={handleSave}>
|
|
{!saving && <Save size={12} strokeWidth={2.2} />}
|
|
{t('common.save')}
|
|
</MAdminButton>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
{CATEGORIES.map(cat => (
|
|
<div key={cat.id} className="border-t border-[color:var(--m-rowbr)] pt-3 mt-3">
|
|
<div className="mb-2 font-geist text-[0.5625rem] font-extrabold uppercase tracking-wider text-m-faint">
|
|
{t(`perm.cat.${cat.id}`)}
|
|
</div>
|
|
<div className="space-y-3">
|
|
{cat.keys.map(key => {
|
|
const entry = entryMap.get(key)
|
|
if (!entry) return null
|
|
const currentLevel = values[key] || entry.defaultLevel
|
|
const isDefault = currentLevel === entry.defaultLevel
|
|
return (
|
|
<div key={key}>
|
|
<div className="mb-[6px] flex items-start gap-2">
|
|
<div className="min-w-0 flex-1">
|
|
<div className="text-[0.8125rem] font-bold text-m-ink">{t(`perm.action.${key}`)}</div>
|
|
<div className="mt-[1px] font-geist text-[0.625rem] leading-relaxed text-m-muted">
|
|
{t(`perm.actionHint.${key}`)}
|
|
</div>
|
|
</div>
|
|
{!isDefault && (
|
|
<span className="mt-[1px] flex-none rounded-full bg-[color:color-mix(in_srgb,var(--m-st-pending)_14%,transparent)] px-[7px] py-[2px] font-geist text-[0.5625rem] font-bold text-[color:var(--m-st-pending)]">
|
|
{t('perm.customized')}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<select
|
|
value={currentLevel}
|
|
onChange={(e) => handleChange(key, e.target.value as PermissionLevel)}
|
|
aria-label={t(`perm.action.${key}`)}
|
|
className="h-[42px] w-full rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] px-3 text-[0.84375rem] text-m-ink outline-none"
|
|
>
|
|
{entry.allowedLevels.map(l => (
|
|
<option key={l} value={l}>
|
|
{t(LEVEL_LABELS[l] || l)}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</MAdminCard>
|
|
)
|
|
}
|