mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-08 01:14:52 +00:00
* feat(app): refine workspace pane actions Prioritize Changes when available, keep Files useful before a selection, and reserve desktop diff clicks for selection so comments require the explicit affordance. Move the Changes shortcut to Shift+G to avoid consuming a likely copy variant. * feat(app): improve access to workspace changes
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { memo, useCallback, useMemo, useState, type ReactElement } from "react";
|
|
import { Pressable } from "react-native";
|
|
import { useTranslation } from "react-i18next";
|
|
import { DiffStat } from "@/components/diff-stat";
|
|
import { composerPillStyles } from "@/composer/pill-styles";
|
|
import { useVisibleWorkspaceDiffStat } from "@/composer/workspace-diff-stat";
|
|
|
|
interface ComposerDiffStatPillProps {
|
|
additions: number;
|
|
deletions: number;
|
|
onPress: () => void;
|
|
}
|
|
|
|
export function ComposerDiffStatPill({ additions, deletions, onPress }: ComposerDiffStatPillProps) {
|
|
const { t } = useTranslation();
|
|
const [isHovered, setIsHovered] = useState(false);
|
|
const handleHoverIn = useCallback(() => setIsHovered(true), []);
|
|
const handleHoverOut = useCallback(() => setIsHovered(false), []);
|
|
const bodyStyle = useMemo(
|
|
() => [composerPillStyles.body, isHovered && composerPillStyles.bodyActive],
|
|
[isHovered],
|
|
);
|
|
|
|
return (
|
|
<Pressable
|
|
testID="composer-diff-stat-pill"
|
|
accessibilityRole="button"
|
|
accessibilityLabel={t("workspace.git.diff.openChangesTab")}
|
|
onPress={onPress}
|
|
onHoverIn={handleHoverIn}
|
|
onHoverOut={handleHoverOut}
|
|
style={bodyStyle}
|
|
>
|
|
<DiffStat additions={additions} deletions={deletions} />
|
|
</Pressable>
|
|
);
|
|
}
|
|
|
|
export const WorkspaceDiffStatPill = memo(function WorkspaceDiffStatPill({
|
|
serverId,
|
|
workspaceId,
|
|
onPress,
|
|
}: {
|
|
serverId: string;
|
|
workspaceId: string;
|
|
onPress: () => void;
|
|
}): ReactElement | null {
|
|
const diffStat = useVisibleWorkspaceDiffStat(serverId, workspaceId);
|
|
if (!diffStat) {
|
|
return null;
|
|
}
|
|
return (
|
|
<ComposerDiffStatPill
|
|
additions={diffStat.additions}
|
|
deletions={diffStat.deletions}
|
|
onPress={onPress}
|
|
/>
|
|
);
|
|
});
|