Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined log point panel icons #10602

Merged
merged 2 commits into from
Jul 8, 2024
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
1 change: 1 addition & 0 deletions packages/e2e-tests/helpers/source-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export async function editLogPoint(
.locator('[data-test-name="PointPanel-ContentWrapper"] [data-lexical-editor="true"]')
.isVisible();
if (!isEditing) {
await line.locator('[data-test-name="PointPanel-IconAndAvatar"]').hover();
await line.locator('[data-test-name="PointPanel-EditButton"]').click();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
justify-content: center;
line-height: 1.5rem;
height: 1rem;
width: 1rem;
min-width: 1rem;
cursor: pointer;
color: var(--point-panel-input-edit-button-color);
}
Expand All @@ -172,6 +172,11 @@
.ButtonWithIcon[data-invalid]:hover {
color: var(--point-panel-input-disabled-cancel-button-color-hover);
}
.ButtonWithIcon:disabled,
.ButtonWithIcon:disabled:hover {
cursor: default;
color: var(--point-panel-input-edit-button-color);
}

.ContentInput,
.ContentInputWithNag {
Expand Down Expand Up @@ -211,7 +216,7 @@
flex: 0 0 1.5rem;
}

.DisabledIconAndAvatar {
.IconAndAvatar {
flex-shrink: 0;
display: flex;
align-items: center;
Expand All @@ -231,3 +236,13 @@
word-break: break-word;
padding: 0.25rem 0;
}

.ButtonIcon {
height: 1rem;
width: 1rem;
}

.DisabledIcon {
height: 1rem;
width: 1.25rem;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TimeStampedPoint, TimeStampedPointRange } from "@replayio/protocol";
import {
MouseEvent,
Suspense,
unstable_useCacheRefresh as useCacheRefresh,
useContext,
Expand Down Expand Up @@ -193,6 +194,7 @@ export function PointPanelWithHitPoints({
const invalidateCache = useCacheRefresh();

const [isEditing, setIsEditing] = useState(!readOnlyMode && showEditBreakpointNag);
const [isHovering, setIsHovering] = useState(false);
const [editReason, setEditReason] = useState<EditReason | null>(null);

const [isPending, startTransition] = useTransition();
Expand Down Expand Up @@ -415,7 +417,7 @@ export function PointPanelWithHitPoints({
</div>

<RemoveConditionalButton
disabled={isPending}
disabled={isPending || !editable}
invalid={!isConditionValid}
onClick={toggleCondition}
/>
Expand All @@ -432,7 +434,7 @@ export function PointPanelWithHitPoints({
</div>

<RemoveConditionalButton
disabled={isPending}
disabled={isPending || !editable}
invalid={!isConditionValid}
onClick={toggleCondition}
/>
Expand Down Expand Up @@ -494,12 +496,30 @@ export function PointPanelWithHitPoints({
data-state-logging-enabled={shouldLog}
data-test-name="PointPanel-ContentWrapper"
onClick={() => startEditing("content")}
onMouseEnter={() => setIsHovering(true)}
onMouseLeave={() => setIsHovering(false)}
>
<BadgePicker
disabled={!editable}
invalid={!isContentValid}
point={pointWithPendingEdits}
/>
{shouldLog ? (
<BadgePicker
disabled={!editable}
invalid={!isContentValid}
point={pointWithPendingEdits}
/>
) : (
<button
className={styles.ButtonWithIcon}
data-test-name="PointPanel-DisabledButton"
disabled={isPending}
onClick={event => {
event.preventDefault();
event.stopPropagation();

toggleShouldLog();
}}
>
<Icon className={styles.DisabledIcon} data-disabled type="toggle-off" />
</button>
)}

<div className={styles.Content}>
{isEditing ? (
Expand Down Expand Up @@ -532,23 +552,24 @@ export function PointPanelWithHitPoints({
fileExtension=".js"
/>
)}
<div className={styles.DisabledIconAndAvatar}>
<div className={styles.IconAndAvatar} data-test-name="PointPanel-IconAndAvatar">
{isEditing ? (
saveButton
) : editable ? (
) : editable && isHovering ? (
<button
className={styles.ButtonWithIcon}
data-test-name="PointPanel-EditButton"
disabled={isPending}
>
<Icon className={styles.ButtonIcon} type={shouldLog ? "edit" : "toggle-off"} />
<Icon className={styles.ButtonIcon} type="edit" />
</button>
) : null}
<AvatarImage
className={styles.CreatedByAvatar}
src={user?.picture || undefined}
title={user?.name || undefined}
/>
) : (
<AvatarImage
className={styles.CreatedByAvatar}
src={user?.picture || undefined}
title={user?.name || undefined}
/>
)}
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/replay-next/src/hooks/useTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default function useTooltip({

const onMouseEnter = (event: MouseEvent) => {
setClientX(event.clientX);
setClientX(event.clientY);
setClientY(event.clientY);
setMouseTarget(event.currentTarget as HTMLElement);

if (delay === 0) {
Expand All @@ -173,7 +173,7 @@ export default function useTooltip({

const onMouseLeave = (event: MouseEvent) => {
setClientX(null);
setClientX(null);
setClientY(null);
setMouseTarget(null);
setShowTooltip(false);
setShowTooltipDebounced.cancel();
Expand All @@ -185,7 +185,7 @@ export default function useTooltip({
}

setClientX(event.clientX);
setClientX(event.clientY);
setClientY(event.clientY);
};

return { onMouseEnter, onMouseLeave, onMouseMove, tooltip: renderedTooltip };
Expand Down
Loading