-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(superuser): improve banner ux #115168
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
Changes from 3 commits
2a5b0f6
cbba820
c95b106
56200f4
11b9b8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import {Fragment, useEffect} from 'react'; | ||
| import {Fragment, useEffect, useLayoutEffect, useRef, useState} from 'react'; | ||
| import {keyframes} from '@emotion/react'; | ||
| import {useTheme} from '@emotion/react'; | ||
| import styled from '@emotion/styled'; | ||
|
|
@@ -19,7 +19,7 @@ import {useHasPageFrameFeature} from 'sentry/views/navigation/useHasPageFrameFea | |
| const POLICY_URL = | ||
| 'https://www.notion.so/sentry/Sentry-Rules-for-Handling-Customer-Data-9612532c37e14eeb943a6a584abbac99'; | ||
|
|
||
| const SUPERUSER_MESSAGE = 'You are in superuser mode'; | ||
| const SUPERUSER_MESSAGE = 'You are in superuser mode / Hover for more information'; | ||
| const SUPERUSER_SEPARATOR = ' ///// '; | ||
| const WARNING_MESSAGE = ( | ||
| <Fragment> | ||
|
|
@@ -73,6 +73,34 @@ export function SuperuserWarning({organization, className}: Props) { | |
| const hasPageFrame = useHasPageFrameFeature(); | ||
| const isExcludedOrg = shouldExcludeOrg(organization); | ||
|
|
||
| const stripRef = useRef<HTMLDivElement>(null); | ||
| const textRef = useRef<HTMLSpanElement>(null); | ||
| const [marqueeCount, setMarqueeCount] = useState(8); | ||
|
|
||
| useLayoutEffect(() => { | ||
| const strip = stripRef.current; | ||
| const text = textRef.current; | ||
| if (!strip || !text) { | ||
| return; | ||
| } | ||
|
|
||
| const update = () => { | ||
| const stripWidth = strip.clientWidth; | ||
| if (!stripWidth || !text.offsetWidth) { | ||
| return; | ||
| } | ||
| setMarqueeCount(currentCount => { | ||
| const repWidth = text.offsetWidth / currentCount; | ||
|
sentry[bot] marked this conversation as resolved.
|
||
| return repWidth ? Math.ceil(stripWidth / repWidth) + 2 : currentCount; | ||
| }); | ||
|
Comment on lines
+93
to
+96
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Reading Suggested FixCapture the Prompt for AI Agent |
||
| }; | ||
|
|
||
| update(); | ||
| const observer = new ResizeObserver(update); | ||
| observer.observe(strip); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's refactor to use the lib? import {useResizeObserver} from '@react-aria/utils';
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yes sure! thanks for the reminder 🙏 |
||
| return () => observer.disconnect(); | ||
| }, [hasPageFrame, isExcludedOrg]); | ||
|
|
||
| useEffect(() => { | ||
| if (!isExcludedOrg) { | ||
| AlertStore.addAlert({ | ||
|
|
@@ -109,16 +137,18 @@ export function SuperuserWarning({organization, className}: Props) { | |
| > | ||
| <Tooltip | ||
| isHoverable | ||
| position="top-start" | ||
| position="bottom-start" | ||
| containerDisplayMode="block" | ||
| title={ | ||
| <TooltipContent> | ||
| <Content>{WARNING_MESSAGE}</Content> | ||
| <ExitSuperuserButton /> | ||
| </TooltipContent> | ||
| } | ||
| > | ||
| <MarqueeStrip align="baseline" overflow="hidden"> | ||
| <MarqueeStrip ref={stripRef} align="baseline" overflow="hidden"> | ||
| <MarqueeText | ||
| ref={textRef} | ||
| wrap="nowrap" | ||
| monospace | ||
| bold | ||
|
|
@@ -129,9 +159,7 @@ export function SuperuserWarning({organization, className}: Props) { | |
| } as React.CSSProperties | ||
| } | ||
| > | ||
| {Array.from({length: 8}, () => SUPERUSER_MESSAGE).join( | ||
| SUPERUSER_SEPARATOR | ||
| )} | ||
| {`${SUPERUSER_MESSAGE}${SUPERUSER_SEPARATOR}`.repeat(marqueeCount)} | ||
| </MarqueeText> | ||
| </MarqueeStrip> | ||
| </Tooltip> | ||
|
|
@@ -187,6 +215,8 @@ const Frame = styled(Container)` | |
| /* Ensures it stays on top of all content */ | ||
| z-index: 9999; | ||
| border-width: ${p => p.theme.border.xl}; | ||
| /* Keep the marquee strip pinned to the top so the tooltip anchors there too */ | ||
| align-items: flex-start; | ||
| `; | ||
|
|
||
| const MarqueeStrip = styled(Flex)` | ||
|
|
@@ -197,6 +227,7 @@ const MarqueeStrip = styled(Flex)` | |
| flex-shrink: 0; | ||
| /* Re-enable pointer events so the tooltip is hoverable */ | ||
| pointer-events: auto; | ||
| cursor: help; | ||
| `; | ||
|
|
||
| const MarqueeText = styled(Text)` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hover instruction leaks into non-marquee alert context
Medium Severity
The updated
SUPERUSER_MESSAGE("…Hover for more information") is shared across two contexts. On line 110, whenhasPageFrameis false, this message is injected into theAlertStorealert — which already displaysWARNING_MESSAGEinline right next to it. In that path there's no hoverable marquee strip, so telling users to "hover for more information" is misleading — the information is already visible in the alert itself. The old message ("You are in superuser mode") worked correctly in both contexts.Additional Locations (1)
static/gsApp/components/superuser/superuserWarning.tsx#L109-L110Reviewed by Cursor Bugbot for commit c95b106. Configure here.