GeezerVison is showing github.com — Add "Welcome to the new DevTools" notification · react/react@4f8b786
File treeExpand file treeCollapse file tree Open diff view settings packages/react-devtools-core/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-devtools-core/src/standalone.js +12Lines changed: 12 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,11 @@ let nodeWaitingToConnectHTML: string = ''; | 29 | 29 | let projectRoots: Array<string> = []; | 30 | 30 | let statusListener: StatusListener = (message: string) => {}; | 31 | 31 |
| | 32 | +// Unlike browser extension users, people using the standalone have actively installed version 4, | | 33 | +// So we probably don't need to show them a changelog notice. | | 34 | +// We should give embedded users (e.g. Nuclide, Sonar) a way of showing this dialog though. | | 35 | +let showWelcomeToTheNewDevToolsDialog: boolean = false; | | 36 | + | 32 | 37 | function setContentDOMNode(value: HTMLElement) { | 33 | 38 | node = value; | 34 | 39 |
| @@ -47,6 +52,11 @@ function setStatusListener(value: StatusListener) { | 47 | 52 | return DevtoolsUI; | 48 | 53 | } | 49 | 54 |
| | 55 | +function setShowWelcomeToTheNewDevToolsDialog(value: boolean) { | | 56 | + showWelcomeToTheNewDevToolsDialog = value; | | 57 | + return DevtoolsUI; | | 58 | +} | | 59 | + | 50 | 60 | let bridge: FrontendBridge | null = null; | 51 | 61 | let store: Store | null = null; | 52 | 62 | let root = null; | @@ -87,6 +97,7 @@ function reload() { | 87 | 97 | bridge: ((bridge: any): FrontendBridge), | 88 | 98 | canViewElementSourceFunction, | 89 | 99 | showTabBar: true, | | 100 | + showWelcomeToTheNewDevToolsDialog, | 90 | 101 | store: ((store: any): Store), | 91 | 102 | warnIfLegacyBackendDetected: true, | 92 | 103 | viewElementSourceFunction, | @@ -300,6 +311,7 @@ const DevtoolsUI = { | 300 | 311 | connectToSocket, | 301 | 312 | setContentDOMNode, | 302 | 313 | setProjectRoots, | | 314 | + setShowWelcomeToTheNewDevToolsDialog, | 303 | 315 | setStatusListener, | 304 | 316 | startServer, | 305 | 317 | }; | |
Collapse file Copy file name to clipboardExpand all lines: shells/browser/shared/src/main.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -155,6 +155,7 @@ function createPanelIfReactLoaded() { | 155 | 155 | profilerPortalContainer, | 156 | 156 | settingsPortalContainer, | 157 | 157 | showTabBar: false, | | 158 | + showWelcomeToTheNewDevToolsDialog: true, | 158 | 159 | store, | 159 | 160 | viewElementSourceFunction, | 160 | 161 | }) | |
Collapse file Copy file name to clipboardExpand all lines: shells/dev/src/devtools.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -76,6 +76,7 @@ inject('dist/app.js', () => { | 76 | 76 | bridge, | 77 | 77 | browserTheme: 'light', | 78 | 78 | showTabBar: true, | | 79 | + showWelcomeToTheNewDevToolsDialog: true, | 79 | 80 | store, | 80 | 81 | warnIfLegacyBackendDetected: true, | 81 | 82 | }) | |
Collapse file Copy file name to clipboardExpand all lines: src/constants.js +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,3 +24,6 @@ export const LOCAL_STORAGE_SHOULD_PATCH_CONSOLE_KEY = | 24 | 24 | 'React::DevTools::appendComponentStack'; | 25 | 25 |
| 26 | 26 | export const PROFILER_EXPORT_VERSION = 4; | | 27 | + | | 28 | +export const CHANGE_LOG_URL = | | 29 | + 'https://github.com/bvaughn/react-devtools-experimental/blob/master/CHANGELOG.md'; |
Collapse file Copy file name to clipboardExpand all lines: src/devtools/views/DevTools.js +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,6 +18,7 @@ import { ProfilerContextController } from './Profiler/ProfilerContext'; | 18 | 18 | import { ModalDialogContextController } from './ModalDialog'; | 19 | 19 | import ReactLogo from './ReactLogo'; | 20 | 20 | import WarnIfLegacyBackendDetected from './WarnIfLegacyBackendDetected'; | | 21 | +import ShowWelcomeToTheNewDevToolsDialog from './ShowWelcomeToTheNewDevToolsDialog'; | 21 | 22 |
| 22 | 23 | import styles from './DevTools.css'; | 23 | 24 |
| @@ -42,6 +43,7 @@ export type Props = {| | 42 | 43 | canViewElementSourceFunction?: ?CanViewElementSource, | 43 | 44 | defaultTab?: TabID, | 44 | 45 | showTabBar?: boolean, | | 46 | + showWelcomeToTheNewDevToolsDialog?: boolean, | 45 | 47 | store: Store, | 46 | 48 | warnIfLegacyBackendDetected?: boolean, | 47 | 49 | viewElementSourceFunction?: ?ViewElementSource, | @@ -85,6 +87,7 @@ export default function DevTools({ | 85 | 87 | profilerPortalContainer, | 86 | 88 | settingsPortalContainer, | 87 | 89 | showTabBar = false, | | 90 | + showWelcomeToTheNewDevToolsDialog = false, | 88 | 91 | store, | 89 | 92 | warnIfLegacyBackendDetected = false, | 90 | 93 | viewElementSourceFunction = null, | @@ -150,6 +153,9 @@ export default function DevTools({ | 150 | 153 | </ViewElementSourceContext.Provider> | 151 | 154 | </SettingsContextController> | 152 | 155 | {warnIfLegacyBackendDetected && <WarnIfLegacyBackendDetected />} | | 156 | + {showWelcomeToTheNewDevToolsDialog && ( | | 157 | + <ShowWelcomeToTheNewDevToolsDialog /> | | 158 | + )} | 153 | 159 | </ModalDialogContextController> | 154 | 160 | </StoreContext.Provider> | 155 | 161 | </BridgeContext.Provider> | |
Collapse file Copy file name to clipboardExpand all lines: src/devtools/views/ModalDialog.css +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 34 | 34 | text-align: right; | 35 | 35 | margin-top: 0.5rem; | 36 | 36 | } | | 37 | + | | 38 | +.Button { | | 39 | + font-size: var(--font-size-sans-large); | | 40 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/devtools/views/ModalDialog.js +22-5Lines changed: 22 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,18 +109,35 @@ function ModalDialogImpl(_: {||}) { | 109 | 109 | dispatch({ type: 'HIDE' }); | 110 | 110 | } | 111 | 111 | }, [canBeDismissed, dispatch]); | 112 | | - const modalRef = useRef<HTMLDivElement | null>(null); | | 112 | + const dialogRef = useRef<HTMLDivElement | null>(null); | 113 | 113 |
| 114 | | - useModalDismissSignal(modalRef, dismissModal); | | 114 | + // It's important to trap click events within the dialog, | | 115 | + // so the dismiss hook will use it for click hit detection. | | 116 | + // Because multiple tabs may be showing this ModalDialog, | | 117 | + // the normal `dialog.contains(target)` check would fail on a background tab. | | 118 | + useModalDismissSignal(dialogRef, dismissModal, false); | | 119 | + | | 120 | + // Clicks on the dialog should not bubble. | | 121 | + // This way we can dismiss by listening to clicks on the background. | | 122 | + const handleDialogClick = (event: any) => { | | 123 | + event.stopPropagation(); | | 124 | + | | 125 | + // It is important that we don't also prevent default, | | 126 | + // or clicks within the dialog (e.g. on links) won't work. | | 127 | + }; | 115 | 128 |
| 116 | 129 | return ( | 117 | | - <div className={styles.Background}> | 118 | | - <div className={styles.Dialog} ref={modalRef}> | | 130 | + <div className={styles.Background} onClick={dismissModal}> | | 131 | + <div | | 132 | + ref={dialogRef} | | 133 | + className={styles.Dialog} | | 134 | + onClick={handleDialogClick} | | 135 | + > | 119 | 136 | {title !== null && <div className={styles.Title}>{title}</div>} | 120 | 137 | {content} | 121 | 138 | {canBeDismissed && ( | 122 | 139 | <div className={styles.Buttons}> | 123 | | - <Button autoFocus onClick={dismissModal}> | | 140 | + <Button autoFocus className={styles.Button} onClick={dismissModal}> | 124 | 141 | Okay | 125 | 142 | </Button> | 126 | 143 | </div> | |
Collapse file Copy file name to clipboardExpand all lines: src/devtools/views/ReactLogo.js +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,11 +4,15 @@ import React from 'react'; | 4 | 4 |
| 5 | 5 | import styles from './ReactLogo.css'; | 6 | 6 |
| 7 | | -export default function ReactLogo() { | | 7 | +type Props = {| | | 8 | + className?: string, | | 9 | +|}; | | 10 | + | | 11 | +export default function ReactLogo({ className }: Props) { | 8 | 12 | return ( | 9 | 13 | <svg | 10 | 14 | xmlns="http://www.w3.org/2000/svg" | 11 | | - className={styles.ReactLogo} | | 15 | + className={`${styles.ReactLogo} ${className || ''}`} | 12 | 16 | viewBox="-11.5 -10.23174 23 20.46348" | 13 | 17 | > | 14 | 18 | <circle cx="0" cy="0" r="2.05" fill="currentColor" /> | |
Collapse file Copy file name to clipboardExpand all lines: src/devtools/views/Settings/GeneralSettings.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | import React, { useContext } from 'react'; | 4 | 4 | import { SettingsContext } from './SettingsContext'; | | 5 | +import { CHANGE_LOG_URL } from 'src/constants'; | 5 | 6 |
| 6 | 7 | import styles from './SettingsShared.css'; | 7 | 8 |
| @@ -54,6 +55,18 @@ export default function GeneralSettings(_: {||}) { | 54 | 55 | Append component stacks to console warnings and errors. | 55 | 56 | </label> | 56 | 57 | </div> | | 58 | + | | 59 | + <div className={styles.ReleaseNotes}> | | 60 | + <a | | 61 | + className={styles.ReleaseNotesLink} | | 62 | + target="_blank" | | 63 | + rel="noopener noreferrer" | | 64 | + href={CHANGE_LOG_URL} | | 65 | + > | | 66 | + View release notes | | 67 | + </a>{' '} | | 68 | + for DevTools version {process.env.DEVTOOLS_VERSION} | | 69 | + </div> | 57 | 70 | </div> | 58 | 71 | ); | 59 | 72 | } |
Collapse file Copy file name to clipboardExpand all lines: src/devtools/views/Settings/SettingsShared.css +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 134 | 134 | height: 0.375rem; | 135 | 135 | background-color: var(--color-toggle-text); | 136 | 136 | } | | 137 | + | | 138 | +.ReleaseNotes { | | 139 | + width: 100%; | | 140 | + background-color: var(--color-background-hover); | | 141 | + padding: 0.25rem 0.5rem; | | 142 | + border-radius: 0.25rem; | | 143 | +} | | 144 | + | | 145 | +.ReleaseNotesLink { | | 146 | + color: var(--color-button-active); | | 147 | +} |
|