Skip to content

Commit fca6388

Browse files
authored
Merge pull request #3396 from plotly/hooks/devtool-position
Add position argument to hooks.devtool
2 parents b63c8ff + 389b894 commit fca6388

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
44

55
## [UNRELEASED]
66

7+
## Added
8+
- [#3395](https://github.com/plotly/dash/pull/3396) Add position argument to hooks.devtool
9+
710
## Fixed
811
- [#3395](https://github.com/plotly/dash/pull/3395) Fix Components added through set_props() cannot trigger related callback functions. Fix [#3316](https://github.com/plotly/dash/issues/3316)
912
- [#3397](https://github.com/plotly/dash/pull/3397) Add optional callbacks, suppressing callback warning for missing component ids for a single callback.

dash/_hooks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323

2424
HookDataType = _tx.TypeVar("HookDataType")
25+
DevtoolPosition = _tx.Literal["right", "left"]
2526

2627

2728
# pylint: disable=too-few-public-methods
@@ -217,7 +218,13 @@ def wrap(func: _t.Callable[[_t.Dict], _t.Any]):
217218

218219
return wrap
219220

220-
def devtool(self, namespace: str, component_type: str, props=None):
221+
def devtool(
222+
self,
223+
namespace: str,
224+
component_type: str,
225+
props=None,
226+
position: DevtoolPosition = "right",
227+
):
221228
"""
222229
Add a component to be rendered inside the dev tools.
223230
@@ -232,6 +239,7 @@ def devtool(self, namespace: str, component_type: str, props=None):
232239
"namespace": namespace,
233240
"type": component_type,
234241
"props": props or {},
242+
"position": position,
235243
}
236244
)
237245

dash/dash-renderer/src/components/error/menu/DebugMenu.react.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,29 @@ const MenuContent = ({
5252

5353
let custom = null;
5454
if (config.dev_tools?.length && ready) {
55-
custom = (
56-
<>
57-
{config.dev_tools.map((devtool, i) => (
55+
custom = config.dev_tools.reduce(
56+
(acc, devtool, i) => {
57+
const comp = (
5858
<ExternalWrapper
5959
component={devtool}
6060
componentPath={['__dash_devtools', i]}
6161
key={devtool?.props?.id ? devtool.props.id : i}
6262
/>
63-
))}
64-
<div
65-
className='dash-debug-menu__divider'
66-
style={{marginRight: 0}}
67-
/>
68-
</>
63+
);
64+
if (devtool.position === 'left') {
65+
acc.left.push(comp);
66+
} else {
67+
acc.right.push(comp);
68+
}
69+
return acc;
70+
},
71+
{left: [], right: []}
6972
);
7073
}
7174

7275
return (
7376
<div className='dash-debug-menu__content'>
77+
{custom && <>{custom.left}</>}
7478
<button
7579
onClick={toggleErrors}
7680
className={
@@ -109,11 +113,11 @@ const MenuContent = ({
109113
Server
110114
<_StatusIcon className='dash-debug-menu__icon' />
111115
</div>
116+
{custom && <>{custom.right}</>}
112117
<div
113118
className='dash-debug-menu__divider'
114119
style={{marginRight: 0}}
115120
/>
116-
{custom}
117121
</div>
118122
);
119123
};

0 commit comments

Comments
 (0)