Unverified Commit 19bf594b authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Revert "[devtool] merge segment explorer flag into panel ui flag (#81085)" (#81131)

Reverts #81085 to keep the flags separate so can test separately
parent 890c1199
...@@ -797,9 +797,8 @@ pub struct ExperimentalConfig { ...@@ -797,9 +797,8 @@ pub struct ExperimentalConfig {
global_not_found: Option<bool>, global_not_found: Option<bool>,
/// Defaults to false in development mode, true in production mode. /// Defaults to false in development mode, true in production mode.
turbopack_remove_unused_exports: Option<bool>, turbopack_remove_unused_exports: Option<bool>,
/// Devtool option for new panel UI. /// Devtool option for the segment explorer.
#[serde(rename = "devtoolNewPanelUI")] devtool_segment_explorer: Option<bool>,
devtool_new_panel_ui: Option<bool>,
} }
#[derive( #[derive(
......
...@@ -298,6 +298,9 @@ export function getDefineEnv({ ...@@ -298,6 +298,9 @@ export function getDefineEnv({
), ),
} }
: {}), : {}),
'process.env.__NEXT_DEVTOOL_SEGMENT_EXPLORER':
// Enable segment explorer in devtools
isDevToolPanelUIEnabled || !!config.experimental.devtoolSegmentExplorer,
'process.env.__NEXT_DEVTOOL_NEW_PANEL_UI': isDevToolPanelUIEnabled, 'process.env.__NEXT_DEVTOOL_NEW_PANEL_UI': isDevToolPanelUIEnabled,
// The devtools need to know whether or not to show an option to clear the // The devtools need to know whether or not to show an option to clear the
......
...@@ -484,7 +484,8 @@ export async function handler( ...@@ -484,7 +484,8 @@ export async function handler(
deploymentId: nextConfig.deploymentId, deploymentId: nextConfig.deploymentId,
enableTainting: nextConfig.experimental.taint, enableTainting: nextConfig.experimental.taint,
htmlLimitedBots: nextConfig.htmlLimitedBots, htmlLimitedBots: nextConfig.htmlLimitedBots,
devtoolNewPanelUI: nextConfig.experimental.devtoolNewPanelUI, devtoolSegmentExplorer:
nextConfig.experimental.devtoolSegmentExplorer,
reactMaxHeadersLength: nextConfig.reactMaxHeadersLength, reactMaxHeadersLength: nextConfig.reactMaxHeadersLength,
multiZoneDraftMode, multiZoneDraftMode,
......
...@@ -100,7 +100,7 @@ export function getRender({ ...@@ -100,7 +100,7 @@ export function getRender({
serverActionsManifest, serverActionsManifest,
serverActions, serverActions,
nextFontManifest, nextFontManifest,
devtoolNewPanelUI: config.experimental.devtoolNewPanelUI, devtoolSegmentExplorer: config.experimental.devtoolSegmentExplorer,
}, },
renderToHTML, renderToHTML,
incrementalCacheHandler, incrementalCacheHandler,
......
...@@ -56,7 +56,7 @@ export function DevToolsIndicator({ ...@@ -56,7 +56,7 @@ export function DevToolsIndicator({
[vertical]: `${INDICATOR_PADDING}px`, [vertical]: `${INDICATOR_PADDING}px`,
[horizontal]: `${INDICATOR_PADDING}px`, [horizontal]: `${INDICATOR_PADDING}px`,
visibility: visibility:
state.isDevToolsPanelOpen && !state.isErrorOverlayOpen state.isDevToolsPanelOpen || state.isErrorOverlayOpen
? 'hidden' ? 'hidden'
: 'visible', : 'visible',
} as CSSProperties } as CSSProperties
......
...@@ -161,8 +161,7 @@ export function DevToolsPanel({ ...@@ -161,8 +161,7 @@ export function DevToolsPanel({
> >
<div data-nextjs-devtools-panel-header-tab-group> <div data-nextjs-devtools-panel-header-tab-group>
<button <button
data-nextjs-devtools-panel-header-tab="issues" data-nextjs-devtools-panel-header-tab={
data-nextjs-devtools-panel-header-tab-active={
activeTab === 'issues' activeTab === 'issues'
} }
onClick={() => setActiveTab('issues')} onClick={() => setActiveTab('issues')}
...@@ -177,8 +176,7 @@ export function DevToolsPanel({ ...@@ -177,8 +176,7 @@ export function DevToolsPanel({
) : null} ) : null}
</button> </button>
<button <button
data-nextjs-devtools-panel-header-tab="route" data-nextjs-devtools-panel-header-tab={
data-nextjs-devtools-panel-header-tab-active={
activeTab === 'route' activeTab === 'route'
} }
onClick={() => setActiveTab('route')} onClick={() => setActiveTab('route')}
...@@ -186,8 +184,7 @@ export function DevToolsPanel({ ...@@ -186,8 +184,7 @@ export function DevToolsPanel({
Route Info Route Info
</button> </button>
<button <button
data-nextjs-devtools-panel-header-tab="settings" data-nextjs-devtools-panel-header-tab={
data-nextjs-devtools-panel-header-tab-active={
activeTab === 'settings' activeTab === 'settings'
} }
onClick={() => setActiveTab('settings')} onClick={() => setActiveTab('settings')}
...@@ -355,7 +352,7 @@ export const DEVTOOLS_PANEL_STYLES = css` ...@@ -355,7 +352,7 @@ export const DEVTOOLS_PANEL_STYLES = css`
} }
} }
[data-nextjs-devtools-panel-header-tab-active='true'] { [data-nextjs-devtools-panel-header-tab='true'] {
color: var(--color-gray-1000); color: var(--color-gray-1000);
background-color: var(--color-gray-100); background-color: var(--color-gray-100);
} }
......
...@@ -26,6 +26,7 @@ import { ...@@ -26,6 +26,7 @@ import {
type DevToolsScale, type DevToolsScale,
} from './dev-tools-info/preferences' } from './dev-tools-info/preferences'
import { Draggable } from './draggable' import { Draggable } from './draggable'
import { SegmentsExplorer } from './dev-tools-info/segments-explorer'
// TODO: add E2E tests to cover different scenarios // TODO: add E2E tests to cover different scenarios
...@@ -83,6 +84,7 @@ const OVERLAYS = { ...@@ -83,6 +84,7 @@ const OVERLAYS = {
Turbo: 'turbo', Turbo: 'turbo',
Route: 'route', Route: 'route',
Preferences: 'preferences', Preferences: 'preferences',
SegmentExplorer: 'segment-explorer',
} as const } as const
export type Overlays = (typeof OVERLAYS)[keyof typeof OVERLAYS] export type Overlays = (typeof OVERLAYS)[keyof typeof OVERLAYS]
...@@ -128,6 +130,7 @@ function DevToolsPopover({ ...@@ -128,6 +130,7 @@ function DevToolsPopover({
const isTurbopackInfoOpen = open === OVERLAYS.Turbo const isTurbopackInfoOpen = open === OVERLAYS.Turbo
const isRouteInfoOpen = open === OVERLAYS.Route const isRouteInfoOpen = open === OVERLAYS.Route
const isPreferencesOpen = open === OVERLAYS.Preferences const isPreferencesOpen = open === OVERLAYS.Preferences
const isSegmentExplorerOpen = open === OVERLAYS.SegmentExplorer
const { mounted: menuMounted, rendered: menuRendered } = useDelayedRender( const { mounted: menuMounted, rendered: menuRendered } = useDelayedRender(
isMenuOpen, isMenuOpen,
...@@ -217,9 +220,7 @@ function DevToolsPopover({ ...@@ -217,9 +220,7 @@ function DevToolsPopover({
} }
function toggleErrorOverlay() { function toggleErrorOverlay() {
if (!process.env.__NEXT_DEVTOOL_NEW_PANEL_UI) { dispatch({ type: ACTION_ERROR_OVERLAY_TOGGLE })
dispatch({ type: ACTION_ERROR_OVERLAY_TOGGLE })
}
} }
function closeToRootMenu() { function closeToRootMenu() {
...@@ -335,6 +336,19 @@ function DevToolsPopover({ ...@@ -335,6 +336,19 @@ function DevToolsPopover({
setScale={setScale} setScale={setScale}
/> />
{/* Page Route Info */}
{process.env.__NEXT_DEVTOOL_SEGMENT_EXPLORER ? (
<SegmentsExplorer
isOpen={isSegmentExplorerOpen}
close={closeToRootMenu}
triggerRef={triggerRef}
style={popover}
routerType={routerType}
// dummy page for legacy segment explorer, will be removed in the future
page={''}
/>
) : null}
{/* Dropdown Menu */} {/* Dropdown Menu */}
{menuMounted && ( {menuMounted && (
<div <div
...@@ -400,6 +414,15 @@ function DevToolsPopover({ ...@@ -400,6 +414,15 @@ function DevToolsPopover({
onClick={() => setOpen(OVERLAYS.Preferences)} onClick={() => setOpen(OVERLAYS.Preferences)}
index={isTurbopack ? 2 : 3} index={isTurbopack ? 2 : 3}
/> />
{process.env.__NEXT_DEVTOOL_SEGMENT_EXPLORER ? (
<MenuItem
data-segment-explorer
label="Route Info"
value={<ChevronRight />}
onClick={() => setOpen(OVERLAYS.SegmentExplorer)}
index={isTurbopack ? 3 : 4}
/>
) : null}
</div> </div>
</Context.Provider> </Context.Provider>
</div> </div>
......
import { PageSegmentTree } from '../../../overview/segment-explorer'
import { DevToolsInfo, type DevToolsInfoPropsCore } from './dev-tools-info'
export function SegmentsExplorer({
routerType,
page,
...props
}: DevToolsInfoPropsCore &
React.HTMLProps<HTMLDivElement> & {
routerType: 'app' | 'pages'
page: string
}) {
const isAppRouter = routerType === 'app'
return (
<DevToolsInfo title="Route Info" {...props}>
<div data-nextjs-segments-explorer>
<PageSegmentTree isAppRouter={isAppRouter} page={page} />
</div>
</DevToolsInfo>
)
}
export const SEGMENTS_EXPLORER_STYLES = `
[data-nextjs-segments-explorer] {
margin: -12px -8px;
}
`
...@@ -36,6 +36,7 @@ import { DEVTOOLS_PANEL_TAB_ISSUES_CONTENT_STYLES } from '../components/devtools ...@@ -36,6 +36,7 @@ import { DEVTOOLS_PANEL_TAB_ISSUES_CONTENT_STYLES } from '../components/devtools
import { ISSUE_FEEDBACK_BUTTON_STYLES } from '../components/errors/error-overlay-toolbar/issue-feedback-button' import { ISSUE_FEEDBACK_BUTTON_STYLES } from '../components/errors/error-overlay-toolbar/issue-feedback-button'
import { ERROR_CONTENT_SKELETON_STYLES } from '../container/runtime-error/error-content-skeleton' import { ERROR_CONTENT_SKELETON_STYLES } from '../container/runtime-error/error-content-skeleton'
import { SEGMENTS_EXPLORER_TAB_STYLES } from '../components/devtools-panel/devtools-panel-tab/segments-explorer-tab' import { SEGMENTS_EXPLORER_TAB_STYLES } from '../components/devtools-panel/devtools-panel-tab/segments-explorer-tab'
import { SEGMENTS_EXPLORER_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/segments-explorer'
import { DEVTOOLS_PANEL_TAB_ISSUES_CONTENT_LAYOUT_STYLES } from '../components/devtools-panel/devtools-panel-tab/issues-tab/issues-tab-content-layout' import { DEVTOOLS_PANEL_TAB_ISSUES_CONTENT_LAYOUT_STYLES } from '../components/devtools-panel/devtools-panel-tab/issues-tab/issues-tab-content-layout'
import { DEVTOOLS_PANEL_TAB_ISSUES_EMPTY_CONTENT_STYLES } from '../components/devtools-panel/devtools-panel-tab/issues-tab/issues-tab-empty-content' import { DEVTOOLS_PANEL_TAB_ISSUES_EMPTY_CONTENT_STYLES } from '../components/devtools-panel/devtools-panel-tab/issues-tab/issues-tab-empty-content'
...@@ -67,6 +68,7 @@ export function ComponentStyles() { ...@@ -67,6 +68,7 @@ export function ComponentStyles() {
${DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES} ${DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES}
${DEV_TOOLS_INFO_ROUTE_INFO_STYLES} ${DEV_TOOLS_INFO_ROUTE_INFO_STYLES}
${DEV_TOOLS_INFO_USER_PREFERENCES_STYLES} ${DEV_TOOLS_INFO_USER_PREFERENCES_STYLES}
${SEGMENTS_EXPLORER_STYLES}
${DEV_TOOLS_INFO_RENDER_FILES_STYLES} ${DEV_TOOLS_INFO_RENDER_FILES_STYLES}
${FADER_STYLES} ${FADER_STYLES}
${DEVTOOLS_PANEL_STYLES} ${DEVTOOLS_PANEL_STYLES}
......
...@@ -3977,7 +3977,7 @@ const getGlobalErrorStyles = async ( ...@@ -3977,7 +3977,7 @@ const getGlobalErrorStyles = async (
dir, dir,
globalErrorModule?.[1] globalErrorModule?.[1]
) )
if (ctx.renderOpts.devtoolNewPanelUI && globalErrorModulePath) { if (ctx.renderOpts.devtoolSegmentExplorer && globalErrorModulePath) {
const SegmentViewNode = ctx.componentMod.SegmentViewNode const SegmentViewNode = ctx.componentMod.SegmentViewNode
globalErrorStyles = ( globalErrorStyles = (
// This will be rendered next to GlobalError component under ErrorBoundary, // This will be rendered next to GlobalError component under ErrorBoundary,
......
...@@ -396,7 +396,8 @@ async function createComponentTreeInternal({ ...@@ -396,7 +396,8 @@ async function createComponentTreeInternal({
// Resolve the segment param // Resolve the segment param
const actualSegment = segmentParam ? segmentParam.treeSegment : segment const actualSegment = segmentParam ? segmentParam.treeSegment : segment
const isSegmentViewEnabled = const isSegmentViewEnabled =
process.env.NODE_ENV === 'development' && ctx.renderOpts.devtoolNewPanelUI process.env.NODE_ENV === 'development' &&
ctx.renderOpts.devtoolSegmentExplorer
const dir = const dir =
process.env.NEXT_RUNTIME === 'edge' process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR! ? process.env.__NEXT_EDGE_PROJECT_DIR!
...@@ -1083,7 +1084,8 @@ async function createBoundaryConventionElement({ ...@@ -1083,7 +1084,8 @@ async function createBoundaryConventionElement({
tree: LoaderTree tree: LoaderTree
}) { }) {
const isSegmentViewEnabled = const isSegmentViewEnabled =
process.env.NODE_ENV === 'development' && ctx.renderOpts.devtoolNewPanelUI process.env.NODE_ENV === 'development' &&
ctx.renderOpts.devtoolSegmentExplorer
const dir = const dir =
process.env.NEXT_RUNTIME === 'edge' process.env.NEXT_RUNTIME === 'edge'
? process.env.__NEXT_EDGE_PROJECT_DIR! ? process.env.__NEXT_EDGE_PROJECT_DIR!
......
...@@ -280,9 +280,9 @@ export interface RenderOptsPartial { ...@@ -280,9 +280,9 @@ export interface RenderOptsPartial {
allowEmptyStaticShell?: boolean allowEmptyStaticShell?: boolean
/** /**
* next config experimental.devtoolNewPanelUI * next config experimental.devtoolSegmentExplorer
*/ */
devtoolNewPanelUI?: boolean devtoolSegmentExplorer?: boolean
} }
export type RenderOpts = LoadComponentsReturnType<AppPageModule> & export type RenderOpts = LoadComponentsReturnType<AppPageModule> &
......
...@@ -612,7 +612,8 @@ export default abstract class Server< ...@@ -612,7 +612,8 @@ export default abstract class Server<
onInstrumentationRequestError: onInstrumentationRequestError:
this.instrumentationOnRequestError.bind(this), this.instrumentationOnRequestError.bind(this),
reactMaxHeadersLength: this.nextConfig.reactMaxHeadersLength, reactMaxHeadersLength: this.nextConfig.reactMaxHeadersLength,
devtoolNewPanelUI: this.nextConfig.experimental.devtoolNewPanelUI, devtoolSegmentExplorer:
this.nextConfig.experimental.devtoolSegmentExplorer,
} }
// Initialize next/config with the environment configuration // Initialize next/config with the environment configuration
......
...@@ -500,6 +500,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() => ...@@ -500,6 +500,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
}) })
.optional(), .optional(),
globalNotFound: z.boolean().optional(), globalNotFound: z.boolean().optional(),
devtoolSegmentExplorer: z.boolean().optional(),
devtoolNewPanelUI: z.boolean().optional(), devtoolNewPanelUI: z.boolean().optional(),
}) })
.optional(), .optional(),
......
...@@ -736,6 +736,11 @@ export interface ExperimentalConfig { ...@@ -736,6 +736,11 @@ export interface ExperimentalConfig {
*/ */
globalNotFound?: boolean globalNotFound?: boolean
/**
* Enable segment viewer for the app directory in Next.js DevTools.
*/
devtoolSegmentExplorer?: boolean
/** /**
* Enable new panel UI for the Next.js DevTools. * Enable new panel UI for the Next.js DevTools.
*/ */
...@@ -1451,6 +1456,7 @@ export const defaultConfig = { ...@@ -1451,6 +1456,7 @@ export const defaultConfig = {
useCache: undefined, useCache: undefined,
slowModuleDetection: undefined, slowModuleDetection: undefined,
globalNotFound: false, globalNotFound: false,
devtoolSegmentExplorer: false,
}, },
htmlLimitedBots: undefined, htmlLimitedBots: undefined,
bundlePagesRouterDependencies: false, bundlePagesRouterDependencies: false,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
const nextConfig = { const nextConfig = {
experimental: { experimental: {
devtoolNewPanelUI: true, devtoolSegmentExplorer: true,
authInterrupts: true, authInterrupts: true,
globalNotFound: true, globalNotFound: true,
}, },
......
...@@ -3,12 +3,11 @@ import { openDevToolsIndicatorPopover } from 'next-test-utils' ...@@ -3,12 +3,11 @@ import { openDevToolsIndicatorPopover } from 'next-test-utils'
import { Playwright } from 'next-webdriver' import { Playwright } from 'next-webdriver'
async function getSegmentExplorerContent(browser: Playwright) { async function getSegmentExplorerContent(browser: Playwright) {
// open the devtool button
await openDevToolsIndicatorPopover(browser) await openDevToolsIndicatorPopover(browser)
// open segment explorer tab // open the segment explorer
await browser await browser.elementByCss('[data-segment-explorer]').click()
.elementByCss('[data-nextjs-devtools-panel-header-tab="route"]')
.click()
// wait for the segment explorer to be visible // wait for the segment explorer to be visible
await browser.waitForElementByCss('[data-nextjs-devtool-segment-explorer]') await browser.waitForElementByCss('[data-nextjs-devtool-segment-explorer]')
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
const nextConfig = { const nextConfig = {
experimental: { experimental: {
devtoolNewPanelUI: true, devtoolSegmentExplorer: true,
authInterrupts: true, authInterrupts: true,
}, },
} }
......
...@@ -6,10 +6,8 @@ async function getSegmentExplorerContent(browser: Playwright) { ...@@ -6,10 +6,8 @@ async function getSegmentExplorerContent(browser: Playwright) {
// open the devtool button // open the devtool button
await openDevToolsIndicatorPopover(browser) await openDevToolsIndicatorPopover(browser)
// open segment explorer tab // open the segment explorer
await browser await browser.elementByCss('[data-segment-explorer]').click()
.elementByCss('[data-nextjs-devtools-panel-header-tab="route"]')
.click()
// wait for the segment explorer to be visible // wait for the segment explorer to be visible
await browser.waitForElementByCss('[data-nextjs-devtool-segment-explorer]') await browser.waitForElementByCss('[data-nextjs-devtool-segment-explorer]')
...@@ -88,7 +86,6 @@ describe('segment-explorer', () => { ...@@ -88,7 +86,6 @@ describe('segment-explorer', () => {
await browser.elementByCss('[href="/soft-navigation/b"]').click() await browser.elementByCss('[href="/soft-navigation/b"]').click()
await retry(async () => { await retry(async () => {
expect(await browser.elementByCss('body').text()).toContain('Page B') expect(await browser.elementByCss('body').text()).toContain('Page B')
expect(await browser.url()).toBe(`${next.url}/soft-navigation/b`)
}) })
expect(await getSegmentExplorerContent(browser)).toMatchInlineSnapshot(` expect(await getSegmentExplorerContent(browser)).toMatchInlineSnapshot(`
......
...@@ -951,11 +951,6 @@ export async function openRedbox(browser: Playwright): Promise<void> { ...@@ -951,11 +951,6 @@ export async function openRedbox(browser: Playwright): Promise<void> {
export async function openDevToolsIndicatorPopover( export async function openDevToolsIndicatorPopover(
browser: Playwright browser: Playwright
): Promise<void> { ): Promise<void> {
// If the devtools panel is already open, we don't assert the indicator,
// and no need to open it again.
if (await hasDevToolsPanel(browser)) {
return
}
const devToolsIndicator = await assertHasDevToolsIndicator(browser) const devToolsIndicator = await assertHasDevToolsIndicator(browser)
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment