Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 6 additions & 19 deletions packages/ui/src/components/create-pr-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
import { DropdownMenuItem } from "../ui/dropdown-menu";
import { IconExternal, IconPullRequest } from "../icons";
import { IconPullRequest } from "../icons";

type CreatePrMenuProps = {
onCreateDraftPr?: () => void;
onManualCreatePr?: () => void;
};

function CreatePrMenu({ onCreateDraftPr, onManualCreatePr }: CreatePrMenuProps) {
function CreatePrMenu({ onCreateDraftPr }: { onCreateDraftPr?: () => void }) {
return (
<>
<DropdownMenuItem disabled={!onCreateDraftPr} onClick={onCreateDraftPr}>
<IconPullRequest className="size-4 text-muted-foreground" aria-hidden />
<span>Create draft PR</span>
</DropdownMenuItem>
{onManualCreatePr && (
<DropdownMenuItem onClick={onManualCreatePr}>
<IconExternal className="size-4.5 text-muted-foreground" aria-hidden />
<span>Manually create PR</span>
</DropdownMenuItem>
)}
</>
<DropdownMenuItem disabled={!onCreateDraftPr} onClick={onCreateDraftPr}>
<IconPullRequest className="size-4 text-muted-foreground" aria-hidden />
<span>Create draft PR</span>
</DropdownMenuItem>
);
}

Expand Down
3 changes: 0 additions & 3 deletions packages/ui/src/components/diff/diff-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ function PrAction({
onOpenPr,
onCreatePr,
onCreateDraftPr,
onManualCreatePr,
}: {
pr?: DiffViewPr;
creatingPr?: boolean;
preparingPr?: boolean;
onOpenPr?: () => void;
onCreatePr?: () => void;
onCreateDraftPr?: () => void;
onManualCreatePr?: () => void;
}) {
if (pr) {
let content = (
Expand Down Expand Up @@ -108,7 +106,6 @@ function PrAction({
menu={
<CreatePrMenu
onCreateDraftPr={onCreateDraftPr}
onManualCreatePr={onManualCreatePr}
/>
}
menuLabel="Create PR options"
Expand Down
4 changes: 0 additions & 4 deletions packages/ui/src/components/diff/diff-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ function useDiffView({
onOpenPr,
onCreatePr,
onCreateDraftPr,
onManualCreatePr,
actions,
onFileOpen,
className,
Expand Down Expand Up @@ -562,7 +561,6 @@ function useDiffView({
onOpenPr,
onCreatePr,
onCreateDraftPr,
onManualCreatePr,
actions,
className,
summary,
Expand Down Expand Up @@ -595,7 +593,6 @@ function DiffViewContent(props: DiffViewProps & { kept: Kept }) {
onOpenPr,
onCreatePr,
onCreateDraftPr,
onManualCreatePr,
actions,
className,
summary,
Expand Down Expand Up @@ -680,7 +677,6 @@ function DiffViewContent(props: DiffViewProps & { kept: Kept }) {
onOpenPr={onOpenPr}
onCreatePr={onCreatePr}
onCreateDraftPr={onCreateDraftPr}
onManualCreatePr={onManualCreatePr}
/>
<ToolButton
label={view === "unified" ? "Switch to split diff" : "Switch to unified diff"}
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/components/diff/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type DiffViewProps = {
onOpenPr?: () => void;
onCreatePr?: () => void;
onCreateDraftPr?: () => void;
onManualCreatePr?: () => void;
/** Git and pull request actions for the branch, each offered only while it can be taken. */
actions?: GitAction[];
onFileOpen?: (file: DiffViewFile) => void;
Expand Down
56 changes: 27 additions & 29 deletions packages/ui/src/components/message-toolbar/message-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ function MessageToolbar(
let [menu, setMenu] = useState(false);
let [popup, setPopup] = useState(false);
let button = useRef<HTMLButtonElement | null>(null);
let edit = mine && canEdit;
// A deleted message, or one in an archived channel, can't be deleted, so More drops Delete.
let remove = mine && actions?.delete !== false;

function handleOpenChange(o: boolean) {
setOpen(o);
Expand Down Expand Up @@ -148,7 +151,7 @@ function MessageToolbar(
ref={button}
active={menu}
aria-label="More"
className={!mine ? "notouch:hidden" : undefined}
className={!edit && !remove ? "notouch:hidden" : undefined}
icon={<IconDots className="size-3.5" />}
/>
}
Expand Down Expand Up @@ -188,34 +191,29 @@ function MessageToolbar(
<IconLinkMicro className="size-3.5" />
Copy link
</DropdownMenuItem>
{mine && canEdit && <DropdownMenuSeparator className="notouch:hidden" />}
{mine && (
<>
{canEdit && (
<>
<DropdownMenuItem
onClick={() => {
onAction({ type: "edit" });
}}
disabled={actions?.edit === false}
>
<IconPencil className="size-3.5" />
Edit
</DropdownMenuItem>
<DropdownMenuSeparator />
</>
)}
<DropdownMenuItem
variant="destructive"
disabled={actions?.delete === false}
onClick={() => {
onAction({ type: "delete" });
}}
>
<IconTrash className="size-3.5" />
Delete
</DropdownMenuItem>
</>
{(edit || remove) && <DropdownMenuSeparator className="notouch:hidden" />}
{edit && (
<DropdownMenuItem
onClick={() => {
onAction({ type: "edit" });
}}
disabled={actions?.edit === false}
>
<IconPencil className="size-3.5" />
Edit
</DropdownMenuItem>
)}
{edit && remove && <DropdownMenuSeparator />}
{remove && (
<DropdownMenuItem
variant="destructive"
onClick={() => {
onAction({ type: "delete" });
}}
>
<IconTrash className="size-3.5" />
Delete
</DropdownMenuItem>
)}
</DropdownMenuGroup>
</DropdownMenuContent>
Expand Down
14 changes: 7 additions & 7 deletions packages/ui/src/components/session-item/session-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,18 @@ function actions(data: SidebarRow, props: RowActions): RowActions {
if (data.kind === "lobby") return { onRebuild: props.onRebuild };
let pins = { onPin: props.onPin, onUnpin: props.onUnpin };
// Archived channels leave every group but Archived, so a pin would never show.
if (data.lifecycle === "archived") {
return {
onArchive: data.capabilities?.archive === false ? undefined : props.onArchive,
onDelete: data.capabilities?.delete === false ? undefined : props.onDelete,
};
}
let remove = {
onArchive: data.capabilities?.archive === false ? undefined : props.onArchive,
// A live channel's menu shows Delete disabled, with Archive first, so the path is findable.
onDelete: data.capabilities?.delete === false ? undefined : props.onDelete,
};
if (data.lifecycle === "archived") return remove;
return {
...pins,
...remove,
onFork: data.capabilities?.fork === false ? undefined : props.onFork,
onInfo: props.onInfo,
onLeave: props.onLeave,
onArchive: data.capabilities?.archive === false ? undefined : props.onArchive,
onRename: data.capabilities?.rename === false ? undefined : props.onRename,
...(data.capabilities?.move
? { onMoveTargets: props.onMoveTargets, onMove: props.onMove }
Expand Down