Skip to content

Commit 105c7ad

Browse files
committed
Add usage of link from server and send python / ddk version to server
1 parent 308d737 commit 105c7ad

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

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

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,34 @@ function compareVersions(v1, v2) {
1919
return 0;
2020
}
2121

22-
async function requestDashVersionInfo(currentDashVersion, dashVersionUrl) {
22+
async function requestDashVersionInfo(config) {
23+
const {
24+
dash_version: currentDashVersion,
25+
dash_version_url: dashVersionUrl,
26+
python_version: pythonVersion,
27+
ddk_version: ddkVersion
28+
} = config;
2329
const cachedVersionInfo = localStorage.getItem('cachedNewDashVersion');
30+
const cachedNewDashVersionLink = localStorage.getItem(
31+
'cachedNewDashVersionLink'
32+
);
2433
const lastFetched = localStorage.getItem('lastFetched');
2534
if (
2635
lastFetched &&
2736
Date.now() - Number(lastFetched) < DAY_IN_MS &&
2837
cachedVersionInfo
2938
) {
30-
return JSON.parse(cachedVersionInfo);
39+
return {
40+
version: JSON.parse(cachedVersionInfo),
41+
link: cachedNewDashVersionLink
42+
};
3143
} else {
3244
return fetch(dashVersionUrl, {
3345
method: 'POST',
3446
body: JSON.stringify({
35-
dash_version: currentDashVersion
47+
dash_version: currentDashVersion,
48+
python_version: pythonVersion,
49+
ddk_version: ddkVersion
3650
}),
3751
headers: {
3852
'Content-Type': 'application/json'
@@ -44,8 +58,9 @@ async function requestDashVersionInfo(currentDashVersion, dashVersionUrl) {
4458
'cachedNewDashVersion',
4559
JSON.stringify(body.version)
4660
);
61+
localStorage.setItem('cachedNewDashVersionLink', body.link);
4762
localStorage.setItem('lastFetched', Date.now());
48-
return body.version;
63+
return body;
4964
});
5065
}
5166
}
@@ -81,6 +96,7 @@ function shouldShowUpgradeNotification(currentDashVersion, newDashVersion) {
8196

8297
export const VersionInfo = ({config}) => {
8398
const [newDashVersion, setNewDashVersion] = useState(undefined);
99+
const [newDashVersionLink, setNewDashVersionLink] = useState(undefined);
84100
const [upgradeTooltipOpened, setUpgradeTooltipOpened] = useState(false);
85101

86102
const setDontShowAgain = () => {
@@ -102,11 +118,9 @@ export const VersionInfo = ({config}) => {
102118
};
103119

104120
useEffect(() => {
105-
requestDashVersionInfo(
106-
config.dash_version,
107-
config.dash_version_url
108-
).then(version => {
109-
setNewDashVersion(version);
121+
requestDashVersionInfo(config).then(body => {
122+
setNewDashVersionLink(body.link);
123+
setNewDashVersion(body.version);
110124
});
111125
}, []);
112126

@@ -131,12 +145,11 @@ export const VersionInfo = ({config}) => {
131145
<div className='dash-debug-menu__version'>
132146
{upgradeTooltipOpened ? (
133147
<div className='dash-debug-menu__upgrade-tooltip'>
134-
<a
135-
target='_blank'
136-
href='https://dash.plotly.com/installation'
137-
>
138-
Read details
139-
</a>
148+
{newDashVersionLink ? (
149+
<a target='_blank' href={newDashVersionLink}>
150+
Read details
151+
</a>
152+
) : null}
140153
<button onClick={setSkipThisVersion}>
141154
Skip this version
142155
</button>

dash/dash.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
from ._jupyter import jupyter_dash, JupyterDisplayMode
7878
from .types import RendererHooks
7979

80+
dash_design_kit_version = None
81+
try:
82+
import dash_design_kit
83+
84+
dash_design_kit_version = dash_design_kit.__version__
85+
except ImportError:
86+
pass
87+
8088
# Add explicit mapping for map files
8189
mimetypes.add_type("application/json", ".map", True)
8290

@@ -769,7 +777,9 @@ def _config(self):
769777
"children_props": ComponentRegistry.children_props,
770778
"serve_locally": self.config.serve_locally,
771779
"dash_version": __version__,
780+
"python_version": sys.version,
772781
"dash_version_url": DASH_VERSION_URL,
782+
"design_kit_version": dash_design_kit_version,
773783
}
774784
if not self.config.serve_locally:
775785
config["plotlyjs_url"] = self._plotlyjs_url

0 commit comments

Comments
 (0)