-
Notifications
You must be signed in to change notification settings - Fork 4.9k
chore: move attachment link back to tree item, make it flash yellow #34353
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 11 commits
2162ade
2b74e52
269b0bb
b191773
879ba72
13d89e4
299a52e
5dcff8f
b75cf1f
05ca43b
34df343
ef9f0ff
b4d900f
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 |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ export const Workbench: React.FunctionComponent<{ | |
| }> = ({ model, showSourcesFirst, rootDir, fallbackLocation, isLive, hideTimeline, status, annotations, inert, onOpenExternally, revealSource }) => { | ||
| const [selectedCallId, setSelectedCallId] = React.useState<string | undefined>(undefined); | ||
| const [revealedError, setRevealedError] = React.useState<ErrorDescription | undefined>(undefined); | ||
| const [revealedAttachment, setRevealedAttachment] = React.useState<AfterActionTraceEventAttachment | undefined>(undefined); | ||
| const [revealedAttachment, setRevealedAttachment] = React.useState<[attachment: AfterActionTraceEventAttachment, renderCounter: number] | undefined>(undefined); | ||
| const [highlightedCallId, setHighlightedCallId] = React.useState<string | undefined>(); | ||
| const [highlightedEntry, setHighlightedEntry] = React.useState<Entry | undefined>(); | ||
| const [highlightedConsoleMessage, setHighlightedConsoleMessage] = React.useState<ConsoleEntry | undefined>(); | ||
|
|
@@ -148,7 +148,12 @@ export const Workbench: React.FunctionComponent<{ | |
|
|
||
| const revealAttachment = React.useCallback((attachment: AfterActionTraceEventAttachment) => { | ||
| selectPropertiesTab('attachments'); | ||
| setRevealedAttachment(attachment); | ||
| setRevealedAttachment(currentValue => { | ||
|
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. It looks to me this can be reverted.
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. Nope, this is required that to re-trigger the animation. We're discussing the specific form in #34353 (comment). We don't need it in the HTML reporter because we have the |
||
| if (!currentValue) | ||
| return [attachment, 0]; | ||
| const revealCounter = currentValue[1]; | ||
| return [attachment, revealCounter + 1]; | ||
| }); | ||
| }, [selectPropertiesTab]); | ||
|
|
||
| React.useEffect(() => { | ||
|
|
@@ -238,7 +243,7 @@ export const Workbench: React.FunctionComponent<{ | |
| id: 'attachments', | ||
| title: 'Attachments', | ||
| count: attachments.length, | ||
| render: () => <AttachmentsTab model={model} selectedAction={selectedAction} revealedAttachment={revealedAttachment} /> | ||
| render: () => <AttachmentsTab model={model} revealedAttachment={revealedAttachment} /> | ||
| }; | ||
|
|
||
| const tabs: TabbedPaneTabModel[] = [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| limitations under the License. | ||
| */ | ||
|
|
||
| import type { EffectCallback } from 'react'; | ||
| import React from 'react'; | ||
|
|
||
| // Recalculates the value when dependencies change. | ||
|
|
@@ -224,3 +225,22 @@ export function scrollIntoViewIfNeeded(element: Element | undefined) { | |
|
|
||
| const kControlCodesRe = '\\u0000-\\u0020\\u007f-\\u009f'; | ||
| export const kWebLinkRe = new RegExp('(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\\/\\/|www\\.)[^\\s' + kControlCodesRe + '"]{2,}[^\\s' + kControlCodesRe + '"\')}\\],:;.!?]', 'ug'); | ||
|
|
||
| export function useFlash(): [boolean, EffectCallback] { | ||
|
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. IIUC, this is only needed to re-trigger the animation mid-flight? Otherwise, we'd just set the css class when needed, and the animation will play by itself? If so, please add a comment explaining this. I am not 100% sure it's worth the complexity, but I leave that up to you.
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. The important bit is that the css class is removed after a second, so the animation can be played multiple times. I've added a comment to explain that. |
||
| const [flash, setFlash] = React.useState(false); | ||
| const trigger = React.useCallback<React.EffectCallback>(() => { | ||
| let timeout: number | undefined; | ||
| setFlash(currentlyFlashing => { | ||
| if (!currentlyFlashing) { | ||
| timeout = setTimeout(() => setFlash(false), 1000) as any; | ||
| return true; | ||
| } | ||
|
|
||
| // It's already flashing, so we remove the class and re-add it after 50ms to trigger the animation again. | ||
| timeout = setTimeout(() => setFlash(true), 50) as any; | ||
| return false; | ||
| }); | ||
| return () => clearTimeout(timeout); | ||
| }, [setFlash]); | ||
| return [flash, trigger]; | ||
| } | ||
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.
It seems like you can revert this back to be a boolean? I don't see why it should be different now with the yellow flash compared to scrolling into view.
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.
Just like with scrolling into view, we need this to be an ID object so we can retrigger the animation. I think there was a bug with scroll into view before, where it didn't retrigger when clicking the same button twice. But it wasn't as noticeable because you'd have to scroll around between clicking the button.