mirror of
https://github.com/urbit/shrub.git
synced 2024-12-30 15:44:03 +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
|
||||
desk={desk}
|
||||
active={active}
|
||||
chad={chad}
|
||||
menuColor={active ? menuColor : suspendMenuColor}
|
||||
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"
|
||||
|
@ -3,6 +3,7 @@ import type * as Polymorphic from '@radix-ui/react-polymorphic';
|
||||
import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
|
||||
import classNames from 'classnames';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Chad, chadIsRunning } from '@urbit/api';
|
||||
import useDocketState from '../state/docket';
|
||||
import { disableDefault, handleDropdownLink } from '../state/util';
|
||||
|
||||
@ -10,7 +11,7 @@ export interface TileMenuProps {
|
||||
desk: string;
|
||||
lightText: boolean;
|
||||
menuColor: string;
|
||||
active: boolean;
|
||||
chad: Chad;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
@ -37,11 +38,13 @@ const Item = React.forwardRef(({ children, ...props }, ref) => (
|
||||
</DropdownMenu.Item>
|
||||
)) 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 toggleDocket = useDocketState((s) => s.toggleDocket);
|
||||
const menuBg = { backgroundColor: menuColor };
|
||||
const linkOnSelect = useCallback(handleDropdownLink(setOpen), []);
|
||||
const active = chadIsRunning(chad);
|
||||
const suspended = 'suspend' in chad;
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root open={open} onOpenChange={(isOpen) => setOpen(isOpen)}>
|
||||
@ -80,7 +83,7 @@ export const TileMenu = ({ desk, active, menuColor, lightText, className }: Tile
|
||||
Suspend App
|
||||
</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}>
|
||||
Remove App
|
||||
</Item>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Poke, Scry } from '../lib';
|
||||
import { Vats } from './types';
|
||||
import { Vats, Vat } from './types';
|
||||
import _ from 'lodash';
|
||||
|
||||
export const getVats: Scry = {
|
||||
@ -108,3 +108,11 @@ export function getBlockers(vats: Vats): string[] {
|
||||
|
||||
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