mirror of
https://github.com/urbit/shrub.git
synced 2024-12-22 02:11:38 +03:00
grid: hide suspend menu option
This commit is contained in:
parent
7601d686df
commit
4ac0f57720
@ -59,7 +59,7 @@ export const Tile: FunctionComponent<TileProps> = ({ charge, desk }) => {
|
|||||||
)}
|
)}
|
||||||
<TileMenu
|
<TileMenu
|
||||||
desk={desk}
|
desk={desk}
|
||||||
active={active}
|
chad={chad}
|
||||||
menuColor={active ? menuColor : suspendMenuColor}
|
menuColor={active ? menuColor : suspendMenuColor}
|
||||||
lightText={lightText}
|
lightText={lightText}
|
||||||
className="absolute z-10 top-3 right-3 sm:top-5 sm:right-5 opacity-0 pointer-coarse:opacity-100 hover-none:opacity-100 focus:opacity-100 group-hover:opacity-100"
|
className="absolute z-10 top-3 right-3 sm:top-5 sm:right-5 opacity-0 pointer-coarse:opacity-100 hover-none:opacity-100 focus:opacity-100 group-hover:opacity-100"
|
||||||
|
@ -3,6 +3,7 @@ import type * as Polymorphic from '@radix-ui/react-polymorphic';
|
|||||||
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import { Chad, chadIsRunning } from '@urbit/api';
|
||||||
import useDocketState from '../state/docket';
|
import useDocketState from '../state/docket';
|
||||||
import { disableDefault, handleDropdownLink } from '../state/util';
|
import { disableDefault, handleDropdownLink } from '../state/util';
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ export interface TileMenuProps {
|
|||||||
desk: string;
|
desk: string;
|
||||||
lightText: boolean;
|
lightText: boolean;
|
||||||
menuColor: string;
|
menuColor: string;
|
||||||
active: boolean;
|
chad: Chad;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +38,13 @@ const Item = React.forwardRef(({ children, ...props }, ref) => (
|
|||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
)) as ItemComponent;
|
)) as ItemComponent;
|
||||||
|
|
||||||
export const TileMenu = ({ desk, active, menuColor, lightText, className }: TileMenuProps) => {
|
export const TileMenu = ({ desk, chad, menuColor, lightText, className }: TileMenuProps) => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const toggleDocket = useDocketState((s) => s.toggleDocket);
|
const toggleDocket = useDocketState((s) => s.toggleDocket);
|
||||||
const menuBg = { backgroundColor: menuColor };
|
const menuBg = { backgroundColor: menuColor };
|
||||||
const linkOnSelect = useCallback(handleDropdownLink(setOpen), []);
|
const linkOnSelect = useCallback(handleDropdownLink(setOpen), []);
|
||||||
|
const active = chadIsRunning(chad);
|
||||||
|
const suspended = 'suspend' in chad;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu.Root open={open} onOpenChange={(isOpen) => setOpen(isOpen)}>
|
<DropdownMenu.Root open={open} onOpenChange={(isOpen) => setOpen(isOpen)}>
|
||||||
@ -80,7 +83,7 @@ export const TileMenu = ({ desk, active, menuColor, lightText, className }: Tile
|
|||||||
Suspend App
|
Suspend App
|
||||||
</Item>
|
</Item>
|
||||||
)}
|
)}
|
||||||
{!active && <Item onSelect={() => toggleDocket(desk)}>Resume App</Item>}
|
{suspended && <Item onSelect={() => toggleDocket(desk)}>Resume App</Item>}
|
||||||
<Item as={Link} to={`/app/${desk}/remove`} onSelect={linkOnSelect}>
|
<Item as={Link} to={`/app/${desk}/remove`} onSelect={linkOnSelect}>
|
||||||
Remove App
|
Remove App
|
||||||
</Item>
|
</Item>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Poke, Scry } from '../lib';
|
import { Poke, Scry } from '../lib';
|
||||||
import { Vats } from './types';
|
import { Vats, Vat } from './types';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
export const getVats: Scry = {
|
export const getVats: Scry = {
|
||||||
@ -108,3 +108,11 @@ export function getBlockers(vats: Vats): string[] {
|
|||||||
|
|
||||||
return blockers;
|
return blockers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getVatPublisher(vat: Vat): string | undefined {
|
||||||
|
if ('rail' in vat.arak) {
|
||||||
|
const { rail } = vat.arak;
|
||||||
|
return (rail.publisher || rail.ship);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user