forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when using qgrid > 1.1.1 (#11280)
For #11245 * Warn when using qgrid version > 1.1.1 * For now hardcoded to check only qgrid version 1.1.1. * Should be easy enough to add others, didn't want to make it too generic.
- Loading branch information
1 parent
dbc444c
commit 88e141a
Showing
15 changed files
with
215 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Warn when using a version of the widget `qgrid` greater than `1.1.1` with the recommendation to downgrade to `1.1.1`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/datascience-ui/ipywidgets/incompatibleWidgetHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import * as semver from 'semver'; | ||
import { WidgetScriptSource } from '../../client/datascience/ipywidgets/types'; | ||
const supportedVersionOfQgrid = '1.1.1'; | ||
const qgridModuleName = 'qgrid'; | ||
|
||
/** | ||
* For now only warns about qgrid. | ||
* Warn user about qgrid versions > 1.1.1 (we know CDN isn't available for newer versions and local widget source will not work). | ||
* Recommend to downgrade to 1.1.1. | ||
* Returns `true` if a warning has been displayed. | ||
*/ | ||
export function warnAboutWidgetVersionsThatAreNotSupported( | ||
widgetSource: WidgetScriptSource, | ||
moduleVersion: string, | ||
cdnSupported: boolean, | ||
errorDispatcher: (info: { moduleName: typeof qgridModuleName; moduleVersion: string }) => void | ||
) { | ||
// if widget exists on CDN or CDN is disabled, get out. | ||
if (widgetSource.source === 'cdn' || !cdnSupported) { | ||
return false; | ||
} | ||
// Warn about qrid. | ||
if (widgetSource.moduleName !== qgridModuleName) { | ||
return false; | ||
} | ||
// We're only interested in versions > 1.1.1. | ||
try { | ||
// If we have an exact version, & if that is <= 1.1.1, then no warning needs to be displayed. | ||
if (!moduleVersion.startsWith('^') && semver.compare(moduleVersion, supportedVersionOfQgrid) <= 0) { | ||
return false; | ||
} | ||
// If we have a version range, then check the range. | ||
// Basically if our minimum version 1.1.1 is met, then nothing to do. | ||
// Eg. requesting script source for version `^1.3.0`. | ||
if (moduleVersion.startsWith('^') && semver.satisfies(supportedVersionOfQgrid, moduleVersion)) { | ||
return false; | ||
} | ||
} catch { | ||
return false; | ||
} | ||
errorDispatcher({ moduleName: widgetSource.moduleName, moduleVersion }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.