mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-12 09:30:45 +03:00
Auto expand frames group when no CodeBlock shown
This commit is contained in:
parent
7f2979bbe4
commit
983aeb71ab
|
@ -44,22 +44,26 @@ type State = {|
|
||||||
|
|
||||||
class Collapsible extends Component<Props, State> {
|
class Collapsible extends Component<Props, State> {
|
||||||
state = {
|
state = {
|
||||||
collapsed: true,
|
collapsed: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
toggleCollaped = () => {
|
toggleCollapsed = () => {
|
||||||
this.setState(state => ({
|
this.setState(state => ({
|
||||||
collapsed: !state.collapsed,
|
collapsed: !this.isCollapsed(state),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
isCollapsed = (state) => (
|
||||||
|
state.collapsed === undefined ? this.props.collapsedByDefault : state.collapsed
|
||||||
|
);
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const count = this.props.children.length;
|
const count = this.props.children.length;
|
||||||
const collapsed = this.state.collapsed;
|
const collapsed = this.isCollapsed(this.state);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
onClick={this.toggleCollaped}
|
onClick={this.toggleCollapsed}
|
||||||
style={
|
style={
|
||||||
collapsed ? collapsibleCollapsedStyle : collapsibleExpandedStyle
|
collapsed ? collapsibleCollapsedStyle : collapsibleExpandedStyle
|
||||||
}
|
}
|
||||||
|
@ -71,7 +75,7 @@ class Collapsible extends Component<Props, State> {
|
||||||
<div style={{ display: collapsed ? 'none' : 'block' }}>
|
<div style={{ display: collapsed ? 'none' : 'block' }}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
<button
|
<button
|
||||||
onClick={this.toggleCollaped}
|
onClick={this.toggleCollapsed}
|
||||||
style={collapsibleExpandedStyle}
|
style={collapsibleExpandedStyle}
|
||||||
>
|
>
|
||||||
{`▲ ${count} stack frames were expanded.`}
|
{`▲ ${count} stack frames were expanded.`}
|
||||||
|
|
|
@ -35,7 +35,8 @@ class StackTrace extends Component<Props> {
|
||||||
const renderedFrames = [];
|
const renderedFrames = [];
|
||||||
let hasReachedAppCode = false,
|
let hasReachedAppCode = false,
|
||||||
currentBundle = [],
|
currentBundle = [],
|
||||||
bundleCount = 0;
|
bundleCount = 0,
|
||||||
|
anyNodeExpanded = false;
|
||||||
|
|
||||||
stackFrames.forEach((frame, index) => {
|
stackFrames.forEach((frame, index) => {
|
||||||
const { fileName, _originalFileName: sourceFileName } = frame;
|
const { fileName, _originalFileName: sourceFileName } = frame;
|
||||||
|
@ -44,6 +45,10 @@ class StackTrace extends Component<Props> {
|
||||||
const shouldCollapse =
|
const shouldCollapse =
|
||||||
isInternalUrl && (isThrownIntentionally || hasReachedAppCode);
|
isInternalUrl && (isThrownIntentionally || hasReachedAppCode);
|
||||||
|
|
||||||
|
if (!shouldCollapse) {
|
||||||
|
anyNodeExpanded = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isInternalUrl) {
|
if (!isInternalUrl) {
|
||||||
hasReachedAppCode = true;
|
hasReachedAppCode = true;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +75,7 @@ class StackTrace extends Component<Props> {
|
||||||
} else if (currentBundle.length > 1) {
|
} else if (currentBundle.length > 1) {
|
||||||
bundleCount++;
|
bundleCount++;
|
||||||
renderedFrames.push(
|
renderedFrames.push(
|
||||||
<Collapsible key={'bundle-' + bundleCount}>
|
<Collapsible collapsedByDefault={anyNodeExpanded} key={'bundle-' + bundleCount}>
|
||||||
{currentBundle}
|
{currentBundle}
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
);
|
);
|
||||||
|
|
|
@ -175,6 +175,7 @@ exports[`StackTraceTab component should render with trace stack 1`] = `
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Collapsible
|
<Collapsible
|
||||||
|
collapsedByDefault={false}
|
||||||
key="bundle-1"
|
key="bundle-1"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
|
@ -189,19 +190,19 @@ exports[`StackTraceTab component should render with trace stack 1`] = `
|
||||||
"display": "block",
|
"display": "block",
|
||||||
"fontSize": "1em",
|
"fontSize": "1em",
|
||||||
"lineHeight": "1.5",
|
"lineHeight": "1.5",
|
||||||
"marginBottom": "1.5em",
|
"marginBottom": "0.6em",
|
||||||
"padding": "0px 5px",
|
"padding": "0px 5px",
|
||||||
"textAlign": "left",
|
"textAlign": "left",
|
||||||
"width": "100%",
|
"width": "100%",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
▶ 2 stack frames were collapsed.
|
▼ 2 stack frames were expanded.
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
"display": "none",
|
"display": "block",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user