From e5481eca7e66fd194c3b897fa3b8911cfe420958 Mon Sep 17 00:00:00 2001 From: epoger Date: Wed, 2 Jul 2014 13:51:47 -0700 Subject: rebaseline_server: add urlSchemaVersion parameter In https://codereview.chromium.org/369473005 ('rebaseline_server: handle category filtering more generically'), I am changing the meaning of some URL parameters. If a user pastes an old URL into an updated rebaseline_server instance, they may get unexpected results. Adding a urlSchemaVersion parameter allows us to automatically convert the URL, or at least warn the user. BUG=skia:2230 NOTRY=True R=jcgregorio@google.com Author: epoger@google.com Review URL: https://codereview.chromium.org/368933002 --- gm/rebaseline_server/static/constants.js | 5 +++++ gm/rebaseline_server/static/loader.js | 11 +++++++++++ gm/rebaseline_server/static/view.html | 8 ++++++++ 3 files changed, 24 insertions(+) (limited to 'gm/rebaseline_server/static') diff --git a/gm/rebaseline_server/static/constants.js b/gm/rebaseline_server/static/constants.js index 7db245daf0..55751d1e21 100644 --- a/gm/rebaseline_server/static/constants.js +++ b/gm/rebaseline_server/static/constants.js @@ -73,6 +73,11 @@ module.constant('constants', (function() { KEY__EDITS__MODIFICATIONS: 'modifications', KEY__EDITS__OLD_RESULTS_HASH: 'oldResultsHash', KEY__EDITS__OLD_RESULTS_TYPE: 'oldResultsType', + URL_KEY__SCHEMA_VERSION: 'urlSchemaVersion', + URL_VALUE__SCHEMA_VERSION__CURRENT: 0, + // always interpret as then-current schema version; + // used for toplevel links on index page + URL_VALUE__SCHEMA_VERSION__ALWAYS_CURRENT: 'current', // These are just used on the client side, no need to sync with server code. KEY__IMAGEPAIRS__ROWSPAN: 'rowspan', diff --git a/gm/rebaseline_server/static/loader.js b/gm/rebaseline_server/static/loader.js index 296689bde2..dbded05f25 100644 --- a/gm/rebaseline_server/static/loader.js +++ b/gm/rebaseline_server/static/loader.js @@ -426,6 +426,16 @@ Loader.controller( // any which are not found within the URL will keep their current value. $scope.queryParameters.load = function() { var nameValuePairs = $location.search(); + + var urlSchemaVersion = nameValuePairs[constants.URL_KEY__SCHEMA_VERSION]; + if (!urlSchemaVersion) { + $scope.urlSchemaVersionLoaded = 0; + } else if (urlSchemaVersion == constants.URL_VALUE__SCHEMA_VERSION__ALWAYS_CURRENT) { + $scope.urlSchemaVersionLoaded = constants.URL_VALUE__SCHEMA_VERSION__CURRENT; + } else { + $scope.urlSchemaVersionLoaded = urlSchemaVersion; + } + angular.forEach($scope.queryParameters.map, function(copier, paramName) { copier.load(nameValuePairs, paramName); @@ -436,6 +446,7 @@ Loader.controller( // Saves all parameters from $scope into the URL query string. $scope.queryParameters.save = function() { var nameValuePairs = {}; + nameValuePairs[constants.URL_KEY__SCHEMA_VERSION] = constants.URL_VALUE__SCHEMA_VERSION__CURRENT; angular.forEach($scope.queryParameters.map, function(copier, paramName) { copier.save(nameValuePairs, paramName); diff --git a/gm/rebaseline_server/static/view.html b/gm/rebaseline_server/static/view.html index fda767c5b4..94dc9ba63e 100644 --- a/gm/rebaseline_server/static/view.html +++ b/gm/rebaseline_server/static/view.html @@ -25,6 +25,14 @@
+
+ WARNING! The URL you loaded used schema version {{urlSchemaVersionLoaded}}, rather than + the most recent version {{constants.URL_VALUE__SCHEMA_VERSION__CURRENT}}. It has been + converted to the most recent version on a best-effort basis; you may wish to double-check + which records are displayed. +
+
WARNING! These results are editable and exported, so any user -- cgit v1.2.3