forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 22
Create FB-only react_devtools_placeholder panel #36
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # Copyright 2020 The Chromium Authors. All rights reserved. | ||
| # Use of this source code is governed by a BSD-style license that can be | ||
| # found in the LICENSE file. | ||
|
|
||
| import("../../../scripts/build/ninja/devtools_entrypoint.gni") | ||
| import("../../../scripts/build/ninja/devtools_module.gni") | ||
| import("../../../scripts/build/ninja/generate_css.gni") | ||
| import("../visibility.gni") | ||
|
|
||
| generate_css("css_files") { | ||
| sources = [ "reactDevToolsPlaceholder.css" ] | ||
| } | ||
|
|
||
| devtools_module("react_devtools_placeholder") { | ||
| sources = [ "ReactDevToolsPlaceholder.ts" ] | ||
|
|
||
| deps = [ | ||
| "../../core/host:bundle", | ||
| "../../core/i18n:bundle", | ||
| "../../core/protocol_client:bundle", | ||
| "../../core/sdk:bundle", | ||
| "../../models/text_utils:bundle", | ||
| "../../ui/components/data_grid:bundle", | ||
| "../../ui/components/icon_button:bundle", | ||
| "../../ui/legacy:bundle", | ||
| "../../ui/lit-html:bundle", | ||
| ] | ||
| } | ||
|
|
||
| devtools_entrypoint("bundle") { | ||
| entrypoint = "react_devtools_placeholder.ts" | ||
|
|
||
| deps = [ | ||
| ":css_files", | ||
| ":react_devtools_placeholder", | ||
| ] | ||
|
|
||
| visibility = [ | ||
| ":*", | ||
| "../../../test/unittests/front_end/entrypoints/missing_entrypoints/*", | ||
| # "../../../test/unittests/front_end/panels/react_devtools_placeholder/*", | ||
| "../../entrypoints/*", | ||
| ] | ||
|
|
||
| visibility += devtools_panels_visibility | ||
| } | ||
|
|
||
| devtools_entrypoint("meta") { | ||
| entrypoint = "react_devtools_placeholder-meta.ts" | ||
|
|
||
| deps = [ ":bundle" ] | ||
|
|
||
| visibility = [ "../../entrypoints/*" ] | ||
| } |
78 changes: 78 additions & 0 deletions
78
front_end/panels/react_devtools_placeholder/ReactDevToolsPlaceholder.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| // Copyright 2018 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import * as i18n from '../../core/i18n/i18n.js'; | ||
| import * as UI from '../../ui/legacy/legacy.js'; | ||
| import * as LitHtml from '../../ui/lit-html/lit-html.js'; | ||
|
|
||
| import ReactDevToolsPlaceholderStyles from './reactDevToolsPlaceholder.css.js'; | ||
|
|
||
| const UIStrings = { | ||
| /** @description Placeholder message */ | ||
| placeholderMessage: '[FB-only] React DevTools is coming soon! ⚡', | ||
| }; | ||
| const {render, html} = LitHtml; | ||
|
|
||
| const str_ = i18n.i18n.registerUIStrings('panels/react_devtools_placeholder/ReactDevToolsPlaceholder.ts', UIStrings); | ||
| const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); | ||
|
|
||
| let instance: ReactDevToolsPlaceholderImpl; | ||
|
|
||
| export class ReactDevToolsPlaceholderImpl extends UI.Widget.VBox { | ||
| static instance(opts: {forceNew: null|boolean} = {forceNew: null}): ReactDevToolsPlaceholderImpl { | ||
| const {forceNew} = opts; | ||
| if (!instance || forceNew) { | ||
| instance = new ReactDevToolsPlaceholderImpl(); | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
| private constructor() { | ||
| super(true, true); | ||
| } | ||
|
|
||
| override wasShown(): void { | ||
| super.wasShown(); | ||
| this.registerCSSFiles([ReactDevToolsPlaceholderStyles]); | ||
| this.render(); | ||
| UI.InspectorView.InspectorView.instance().setDrawerMinimized(true); | ||
| } | ||
|
|
||
| override willHide(): void { | ||
| UI.InspectorView.InspectorView.instance().setDrawerMinimized(false); | ||
| } | ||
|
|
||
| render(): void { | ||
| render( | ||
| html` | ||
| <div class="rn-devtools-placeholder-panel"> | ||
| <div class="rn-devtoools-placeholder-main"> | ||
| <div class="rn-devtoools-placeholder-title"> | ||
| ${i18nString(UIStrings.placeholderMessage)} | ||
| </div> | ||
| <div class="rn-devtools-placeholder-detail"> | ||
| Soon, you will be able to use React DevTools within this panel and | ||
| inspect multiple apps at once. In the meantime, you can connect to | ||
| your app using the standalone React DevTools. | ||
| </div> | ||
| <div class="rn-devtools-placeholder-detail"> | ||
| <code class="rn-devtools-placeholder-code">js1 devtools</code> | ||
| or | ||
| <code class="rn-devtools-placeholder-code" | ||
| >npx react-devtools</code | ||
| > | ||
| </div> | ||
| <a | ||
| class="devtools-link rn-devtools-placeholder-link" | ||
| href="https://fburl.com/workplace/og7mt427" | ||
| target="_blank" | ||
| >https://fburl.com/workplace/og7mt427</a | ||
| > | ||
| </div> | ||
| </div> | ||
| `, | ||
| this.contentElement, {host: this}); | ||
| } | ||
| } | ||
53 changes: 53 additions & 0 deletions
53
front_end/panels/react_devtools_placeholder/reactDevToolsPlaceholder.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * Copyright 2021 The Chromium Authors. All rights reserved. | ||
| * Use of this source code is governed by a BSD-style license that can be | ||
| * found in the LICENSE file. | ||
| */ | ||
|
|
||
| .rn-devtools-placeholder-panel { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| height: 100%; | ||
| padding: 16px; | ||
| text-align: center; | ||
| background-color: var(--color-background); | ||
| } | ||
|
|
||
| .rn-devtoools-placeholder-main { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| margin-bottom: 16px; | ||
| padding: 24px; | ||
| max-width: 560px; | ||
| border-radius: 4px; | ||
| background-color: var(--color-background-elevation-1); | ||
| } | ||
|
|
||
| .rn-devtoools-placeholder-title { | ||
| font-size: 1rem; | ||
| color: var(--color-text-primary); | ||
| } | ||
|
|
||
| .rn-devtools-placeholder-detail { | ||
| margin-top: 16px; | ||
| font-size: 14px; | ||
| line-height: 1.5; | ||
| color: var(--color-text-secondary); | ||
| } | ||
|
|
||
| .rn-devtools-placeholder-code { | ||
| padding: 2px 8px; | ||
| border-radius: 4px; | ||
| background-color: var(--color-background); | ||
| pointer-events: all; | ||
| cursor: auto; | ||
| user-select: all; | ||
| } | ||
|
|
||
| .rn-devtools-placeholder-link { | ||
| margin-top: 12px; | ||
| } |
46 changes: 46 additions & 0 deletions
46
front_end/panels/react_devtools_placeholder/react_devtools_placeholder-meta.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| // Copyright 2020 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import * as i18n from '../../core/i18n/i18n.js'; | ||
| import * as Root from '../../core/root/root.js'; | ||
| import * as UI from '../../ui/legacy/legacy.js'; | ||
|
|
||
| import type * as ReactDevToolsPlaceholder from './react_devtools_placeholder.js'; | ||
|
|
||
| const UIStrings = { | ||
| /** | ||
| * @description Title of the React DevTools placeholder panel, plus an emoji symbolizing React Native | ||
| */ | ||
| reactDevToolsWelcome: '⚛️ React DevTools', | ||
|
|
||
| /** | ||
| * @description Command for showing the React DevTools placeholder panel | ||
| */ | ||
| showReactDevTools: 'Show React DevTools panel', | ||
| }; | ||
| const str_ = i18n.i18n.registerUIStrings('panels/react_devtools_placeholder/react_devtools_placeholder-meta.ts', UIStrings); | ||
| const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_); | ||
|
|
||
| let loadedReactDevToolsPlaceholderModule: (typeof ReactDevToolsPlaceholder|undefined); | ||
|
|
||
| async function loadReactDevToolsPlaceholderModule(): Promise<typeof ReactDevToolsPlaceholder> { | ||
| if (!loadedReactDevToolsPlaceholderModule) { | ||
| loadedReactDevToolsPlaceholderModule = await import('./react_devtools_placeholder.js'); | ||
| } | ||
| return loadedReactDevToolsPlaceholderModule; | ||
| } | ||
|
|
||
| UI.ViewManager.registerViewExtension({ | ||
| location: UI.ViewManager.ViewLocationValues.PANEL, | ||
| id: 'react-devtools-placeholder', | ||
| title: i18nLazyString(UIStrings.reactDevToolsWelcome), | ||
| commandPrompt: i18nLazyString(UIStrings.showReactDevTools), | ||
| order: 110, | ||
| persistence: UI.ViewManager.ViewPersistence.PERMANENT, | ||
| async loadView() { | ||
| const ReactDevToolsPlaceholder = await loadReactDevToolsPlaceholderModule(); | ||
| return ReactDevToolsPlaceholder.ReactDevToolsPlaceholder.ReactDevToolsPlaceholderImpl.instance(); | ||
| }, | ||
| }); |
12 changes: 12 additions & 0 deletions
12
front_end/panels/react_devtools_placeholder/react_devtools_placeholder.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| // Copyright 2019 The Chromium Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import './ReactDevToolsPlaceholder.js'; | ||
|
|
||
| import * as ReactDevToolsPlaceholder from './ReactDevToolsPlaceholder.js'; | ||
|
|
||
| export { | ||
| ReactDevToolsPlaceholder, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think this fburl quite makes sense considering that we launch CDT in a Chrome guest profile.
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.
@huntie, #31 and the internal diff could be a useful pattern here