mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 17:26:34 +00:00
feat(GUI): add webview api version parameter (#1558)
We add the API version sent to the banner via a GET search parameter, allowing for more intricate control over what data needs or can be sent.
This commit is contained in:
parent
f1ddf07a45
commit
b18fa1f13f
@ -29,14 +29,6 @@ const robot = require('../../shared/robot');
|
|||||||
const MODULE_NAME = 'Etcher.Components.SafeWebview';
|
const MODULE_NAME = 'Etcher.Components.SafeWebview';
|
||||||
const angularSafeWebview = angular.module(MODULE_NAME, []);
|
const angularSafeWebview = angular.module(MODULE_NAME, []);
|
||||||
|
|
||||||
/**
|
|
||||||
* @summary GET parameter sent to the initial webview source URL
|
|
||||||
* @constant
|
|
||||||
* @private
|
|
||||||
* @type {String}
|
|
||||||
*/
|
|
||||||
const VERSION_PARAM = 'etcher-version';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Electron session identifier
|
* @summary Electron session identifier
|
||||||
* @constant
|
* @constant
|
||||||
@ -45,6 +37,36 @@ const VERSION_PARAM = 'etcher-version';
|
|||||||
*/
|
*/
|
||||||
const ELECTRON_SESSION = 'persist:success-banner';
|
const ELECTRON_SESSION = 'persist:success-banner';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Etcher version search-parameter key
|
||||||
|
* @constant
|
||||||
|
* @private
|
||||||
|
* @type {String}
|
||||||
|
*/
|
||||||
|
const ETCHER_VERSION_PARAM = 'etcher-version';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary API version search-parameter key
|
||||||
|
* @constant
|
||||||
|
* @private
|
||||||
|
* @type {String}
|
||||||
|
*/
|
||||||
|
const API_VERSION_PARAM = 'api-version';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Webview API version
|
||||||
|
* @constant
|
||||||
|
* @private
|
||||||
|
* @type {String}
|
||||||
|
*
|
||||||
|
* @description
|
||||||
|
* Changing this number represents a departure from an older API and as such
|
||||||
|
* should only be changed when truly necessary as it introduces breaking changes.
|
||||||
|
* This version number is exposed to the banner such that it can determine what
|
||||||
|
* features are safe to utilize.
|
||||||
|
*/
|
||||||
|
const API_VERSION = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Webviews that hide/show depending on the HTTP status returned
|
* @summary Webviews that hide/show depending on the HTTP status returned
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
@ -67,8 +89,9 @@ class SafeWebview extends react.PureComponent {
|
|||||||
|
|
||||||
const url = new URL(props.src);
|
const url = new URL(props.src);
|
||||||
|
|
||||||
// We set the version GET parameter here.
|
// We set the version GET parameters here.
|
||||||
url.searchParams.set(VERSION_PARAM, packageJSON.version);
|
url.searchParams.set(ETCHER_VERSION_PARAM, packageJSON.version);
|
||||||
|
url.searchParams.set(API_VERSION_PARAM, API_VERSION);
|
||||||
|
|
||||||
this.entryHref = url.href;
|
this.entryHref = url.href;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user