Skip to content

Commit c1bd31c

Browse files
authored
Merge branch 'dev' into feature-add-reverse-slider
2 parents 1ef30bc + f6f80dd commit c1bd31c

File tree

16 files changed

+298
-20
lines changed

16 files changed

+298
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ This project adheres to [Semantic Versioning](https://semver.org/).
88
- [#3395](https://github.com/plotly/dash/pull/3396) Add position argument to hooks.devtool
99
- [#3403](https://github.com/plotly/dash/pull/3403) Add app_context to get_app, allowing to get the current app in routes.
1010
- [#3407](https://github.com/plotly/dash/pull/3407) Add `hidden` to callback arguments, hiding the callback from appearing in the devtool callback graph.
11+
- [#3397](https://github.com/plotly/dash/pull/3397) Add optional callbacks, suppressing callback warning for missing component ids for a single callback.
1112
- [#3424](https://github.com/plotly/dash/pull/3424) Adds support for `Patch` on clientside callbacks class `dash_clientside.Patch`, as well as supporting side updates, eg: (Running, SetProps).
1213
- [#3347](https://github.com/plotly/dash/pull/3347) Added 'api_endpoint' to `callback` to expose api endpoints at the provided path for use to be executed directly without dash.
1314
- [#3445](https://github.com/plotly/dash/pull/3445) Added API to reverse direction of slider component.
15+
- [#3465](https://github.com/plotly/dash/pull/3465) Plotly cloud integrations, add devtool API, placeholder plotly cloud CLI & publish button, `dash[cloud]` extra dependencies.
1416

1517
## Fixed
1618
- [#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)
17-
- [#3397](https://github.com/plotly/dash/pull/3397) Add optional callbacks, suppressing callback warning for missing component ids for a single callback.
1819
- [#3415](https://github.com/plotly/dash/pull/3415) Fix the error triggered when only a single no_update is returned for client-side callback functions with multiple Outputs. Fix [#3366](https://github.com/plotly/dash/issues/3366)
1920
- [#3416](https://github.com/plotly/dash/issues/3416) Fix DeprecationWarning in dash/_jupyter.py by migrating from deprecated ipykernel.comm.Comm to comm module
2021

dash/_plotly_cli.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
3+
4+
def cli():
5+
try:
6+
from plotly_cloud.cli import main # pylint: disable=import-outside-toplevel
7+
8+
main()
9+
except ImportError:
10+
print(
11+
"Plotly cloud is not installed,"
12+
" install it with `pip install dash[cloud]` to use the plotly command",
13+
file=sys.stderr,
14+
)
15+
sys.exit(-1)

dash/background_callback/managers/diskcache_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,14 @@ async def async_run():
287287
}
288288
},
289289
)
290+
290291
if asyncio.iscoroutine(user_callback_output):
291292
user_callback_output = await user_callback_output
292293
if not errored:
293-
cache.set(result_key, user_callback_output)
294+
try:
295+
cache.set(result_key, user_callback_output)
296+
except Exception as err: # pylint: disable=broad-except
297+
print(f"Diskcache manager couldn't save output: {err}")
294298

295299
if asyncio.iscoroutinefunction(fn):
296300
func = partial(ctx.run, async_run)
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 3 deletions
Loading
Lines changed: 1 addition & 3 deletions
Loading

dash/dash-renderer/src/components/error/menu/DebugMenu.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
}
113113

114114
.dash-debug-menu:hover {
115-
background-color: #108de4;
115+
background-color: #7f4bc4;
116116
}
117117

118118
.dash-debug-menu__outer {
@@ -208,13 +208,12 @@
208208
align-items: center;
209209
transition: background-color 0.2s;
210210
font-family: Verdana, sans-serif !important;
211-
font-weight: bold;
212-
color: black;
211+
color: #7f4bc4;
213212
}
214213

215214
.dash-debug-menu__button.dash-debug-menu__button--selected {
216215
color: #7f4bc4;
217-
box-shadow: 0 2px #0071c2;
216+
box-shadow: 0 2px #7f4bc4;
218217
}
219218
.dash-debug-menu__button.dash-debug-menu__button--selected:hover {
220219
color: #5806c4;
@@ -253,3 +252,9 @@
253252
font-size: 14px;
254253
margin-left: 3px;
255254
}
255+
.dash-debug-menu__icon {
256+
color: #9ca3af;
257+
}
258+
.dash-debug-menu__button:hover .dash-debug-menu__icon {
259+
color: #5806c4;
260+
}

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

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useEffect, useState} from 'react';
22
import PropTypes from 'prop-types';
33
import {concat} from 'ramda';
4+
import {useSelector} from 'react-redux';
45

56
import './DebugMenu.css';
67

@@ -14,7 +15,8 @@ import {VersionInfo} from './VersionInfo.react';
1415
import {CallbackGraphContainer} from '../CallbackGraph/CallbackGraphContainer.react';
1516
import {FrontEndErrorContainer} from '../FrontEnd/FrontEndErrorContainer.react';
1617
import ExternalWrapper from '../../../wrapper/ExternalWrapper';
17-
import {useSelector} from 'react-redux';
18+
import PlotlyCloud from './PlotlyCloud';
19+
import {DevtoolProvider, useDevtool} from './DevtoolContext';
1820

1921
const classes = (base, variant, variant2) =>
2022
`${base} ${base}--${variant}` + (variant2 ? ` ${base}--${variant2}` : '');
@@ -75,6 +77,7 @@ const MenuContent = ({
7577
return (
7678
<div className='dash-debug-menu__content'>
7779
{custom && <>{custom.left}</>}
80+
{!config.plotly_cloud_installed ? <PlotlyCloud /> : null}
7881
<button
7982
onClick={toggleErrors}
8083
className={
@@ -84,7 +87,12 @@ const MenuContent = ({
8487
}
8588
id='dash-debug-menu__errors-button'
8689
>
87-
<ErrorIcon className='dash-debug-menu__icon' />
90+
<ErrorIcon
91+
className='dash-debug-menu__icon'
92+
width={16}
93+
height={16}
94+
fill='currentColor'
95+
/>
8896
Errors
8997
{errCount > 0 ? (
9098
<span className='test-devtools-error-count dash-debug-menu__error-count'>
@@ -101,7 +109,12 @@ const MenuContent = ({
101109
}
102110
id='dash-debug-menu__callback-graph-button'
103111
>
104-
<GraphIcon className='dash-debug-menu__icon' />
112+
<GraphIcon
113+
className='dash-debug-menu__icon'
114+
width={16}
115+
height={16}
116+
fill='currentColor'
117+
/>
105118
Callbacks
106119
</button>
107120
<div className='dash-debug-menu__divider' />
@@ -122,8 +135,8 @@ const MenuContent = ({
122135
);
123136
};
124137

125-
const DebugMenu = ({error, hotReload, config, children}) => {
126-
const [popup, setPopup] = useState('errors');
138+
const Debug = ({error, hotReload, config, children}) => {
139+
const {popup, setPopup} = useDevtool();
127140
const [collapsed, setCollapsed] = useState(isCollapsed);
128141

129142
const errCount = error.frontEnd.length + error.backEnd.length;
@@ -154,6 +167,12 @@ const DebugMenu = ({error, hotReload, config, children}) => {
154167

155168
const errors = concat(error.frontEnd, error.backEnd);
156169

170+
useEffect(() => {
171+
if (errors.length && popup !== 'errors') {
172+
setPopup('errors');
173+
}
174+
}, [error]);
175+
157176
const popupContent = (
158177
<div className='dash-debug-menu__popup'>
159178
{popup == 'callbackGraph' ? <CallbackGraphContainer /> : undefined}
@@ -207,6 +226,14 @@ const DebugMenu = ({error, hotReload, config, children}) => {
207226
);
208227
};
209228

229+
const DebugMenu = ({children, ...props}) => {
230+
return (
231+
<DevtoolProvider>
232+
<Debug {...props}>{children}</Debug>
233+
</DevtoolProvider>
234+
);
235+
};
236+
210237
DebugMenu.propTypes = {
211238
children: PropTypes.object,
212239
error: PropTypes.object,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React, {useContext, useMemo, useState} from 'react';
2+
3+
export const DevtoolContext = React.createContext({});
4+
5+
export const DevtoolProvider = ({children}) => {
6+
const [popup, setPopup] = useState('');
7+
8+
return (
9+
<DevtoolContext.Provider
10+
value={{
11+
popup,
12+
setPopup
13+
}}
14+
>
15+
{children}
16+
</DevtoolContext.Provider>
17+
);
18+
};
19+
20+
export const useDevtool = () => {
21+
return useContext(DevtoolContext);
22+
};
23+
24+
export const useDevtoolMenuButtonClassName = popupName => {
25+
const {popup} = useDevtool();
26+
27+
const className = useMemo(() => {
28+
const base = 'dash-debug-menu__button';
29+
if (popup === popupName) {
30+
return base + ' dash-debug-menu__button--selected';
31+
}
32+
return base;
33+
}, [popup]);
34+
35+
return className;
36+
};
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
Same as in plotly-cloud but without the publish
3+
in the name to avoid future conflicts if changed
4+
upstream.
5+
*/
6+
.plotly-cloud-modal-overlay {
7+
position: absolute;
8+
bottom: 100%;
9+
left: -1px;
10+
z-index: 10000;
11+
}
12+
13+
.plotly-cloud-modal-content {
14+
border-radius: 8px;
15+
width: 522px;
16+
background: white;
17+
border: 1px solid #d1d5db;
18+
border-radius: 4px 4px 0 0;
19+
box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.08);
20+
overflow: hidden;
21+
}
22+
23+
.plotly-cloud-modal-header {
24+
display: flex;
25+
justify-content: space-between;
26+
align-items: center;
27+
padding: 16px 20px;
28+
border-bottom: 1px solid #e5e5e5;
29+
background: #f9fafb;
30+
}
31+
32+
.plotly-cloud-modal-header h3 {
33+
margin: 0;
34+
color: #333;
35+
}
36+
37+
.plotly-cloud-modal-close {
38+
background: none;
39+
border: none;
40+
font-size: 24px;
41+
cursor: pointer;
42+
color: #666;
43+
padding: 0;
44+
width: 30px;
45+
height: 30px;
46+
display: flex;
47+
align-items: center;
48+
justify-content: center;
49+
}
50+
51+
.plotly-cloud-modal-close:hover {
52+
color: #333;
53+
}
54+
55+
.plotly-cloud-modal-body {
56+
padding: 20px;
57+
color: black !important;
58+
font-weight: 100;
59+
}
60+
button.plotly-cloud-modal-button {
61+
display: inline-flex;
62+
align-items: center;
63+
gap: 6px;
64+
padding: 6px 10px !important;
65+
border-radius: 4px !important;
66+
font-size: 12px !important;
67+
font-weight: 600 !important;
68+
cursor: pointer;
69+
border: 1px solid transparent;
70+
background: #8b5cf6;
71+
color: white;
72+
border-color: #7c3aed;
73+
}
74+
75+
.plotly-cloud-modal-button:disabled {
76+
cursor: not-allowed;
77+
}
78+
.plotly-cloud-copy-install {
79+
display: flex;
80+
align-items: center;
81+
justify-content: space-between;
82+
gap: 10px;
83+
padding: 8px 10px;
84+
background: #f9fafb;
85+
border: 1px solid #e5e7eb;
86+
border-radius: 6px;
87+
margin-top: 8px;
88+
}

0 commit comments

Comments
 (0)