grid: fix settings rendering if no upstream

This commit is contained in:
Liam Fitzgerald 2021-09-28 13:58:28 +10:00
parent ba353fbd36
commit 2592ef673b
2 changed files with 25 additions and 17 deletions

View File

@ -9,8 +9,9 @@ export const AppPrefs = ({ match }: RouteComponentProps<{ desk: string }>) => {
const { desk } = match.params; const { desk } = match.params;
const charge = useCharge(desk); const charge = useCharge(desk);
const vat = useVat(desk); const vat = useVat(desk);
const otasEnabled = !vat?.arak.rail?.paused; const tracking = !!vat?.arak.rail;
const otaSource = vat?.arak.rail!.ship; const otasEnabled = vat?.arak.rail?.paused;
const otaSource = vat?.arak.rail?.ship;
const toggleOTAs = useKilnState((s) => s.toggleOTAs); const toggleOTAs = useKilnState((s) => s.toggleOTAs);
const toggleUpdates = useCallback((on: boolean) => toggleOTAs(desk, on), [desk, toggleOTAs]); const toggleUpdates = useCallback((on: boolean) => toggleOTAs(desk, on), [desk, toggleOTAs]);
@ -19,14 +20,18 @@ export const AppPrefs = ({ match }: RouteComponentProps<{ desk: string }>) => {
<> <>
<h2 className="h3 mb-7">{charge?.title} Settings</h2> <h2 className="h3 mb-7">{charge?.title} Settings</h2>
<div className="space-y-3"> <div className="space-y-3">
<Setting on={!!otasEnabled} toggle={toggleUpdates} name="Automatic Updates"> {tracking ? (
<p>Automatically download and apply updates to keep {charge?.title} up to date.</p> <Setting on={!!otasEnabled} toggle={toggleUpdates} name="Automatic Updates">
{otaSource && ( <p>Automatically download and apply updates to keep {charge?.title} up to date.</p>
<p> {otaSource && (
OTA Source: <ShipName name={otaSource} className="font-semibold font-mono" /> <p>
</p> OTA Source: <ShipName name={otaSource} className="font-semibold font-mono" />
)} </p>
</Setting> )}
</Setting>
) : (
<h4 className="text-gray-500">No settings</h4>
)}
</div> </div>
</> </>
); );

View File

@ -342,13 +342,16 @@ export const mockVat = (desk: string, blockers?: boolean): Vat => ({
sub: [], sub: [],
add: [] add: []
}, },
rail: { rail:
aeon: 3, desk === 'uniswap'
desk, ? null
next: blockers ? [{ aeon: 3, weft: { name: 'zuse', kelvin: 419 } }] : [], : {
ship: '~zod', aeon: 3,
paused: desk === 'groups' desk,
} next: blockers ? [{ aeon: 3, weft: { name: 'zuse', kelvin: 419 } }] : [],
ship: '~zod',
paused: desk === 'groups'
}
}, },
hash: '0vh.lhfn6.julg1.fs52d.g2lqj.q5kp0.2o7j3.2bljl.jdm34.hd46v.9uv5v' hash: '0vh.lhfn6.julg1.fs52d.g2lqj.q5kp0.2o7j3.2bljl.jdm34.hd46v.9uv5v'
}); });