From 9af5568ca8915f1c08388ed242750fb5b0d17f82 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Sat, 10 Mar 2018 18:18:10 -0800 Subject: [PATCH 1/8] add support roles required for a path [SCT-663] --- src/client/modules/app/services/route.js | 41 +++++++++++++------ src/client/modules/app/services/session.js | 10 +++-- src/plugins/mainwindow/modules/bodyWidget.js | 1 + .../mainwindow/modules/widgets/error.js | 5 ++- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/client/modules/app/services/route.js b/src/client/modules/app/services/route.js index 76c83c016..d08263cb8 100644 --- a/src/client/modules/app/services/route.js +++ b/src/client/modules/app/services/route.js @@ -29,21 +29,10 @@ define([ authorization: false, widget: 'notFound' } - } - // runtime.send('app', 'route-not-found', ex); - // return; + }; } else { throw ex; } - - - - // throw new NotFoundException({ - // original: req.original, - // path: req.path, - // params: params - // }); - } runtime.send('route', 'routing', handler); if (handler.route.authorization) { @@ -63,6 +52,34 @@ define([ return; } } + if (handler.route.rolesRequired) { + var roles = runtime.service('session').getRoles(); + if (!roles.some(function (role) { + return handler.route.rolesRequired.some(function (requiredRole) { + return requiredRole === role.id; + }); + })) { + handler = { + params: { + title: 'Access Error', + error: 'One or more required roles not available in your account: ' + handler.route.rolesRequired.join(', ') + }, + route: { + authorization: false, + widget: 'error' + } + }; + // throw new Error('One or more required roles not available in your account: ' + handler.route.requiredRoles.join(', ')); + // throw new lang.UIError({ + // type: 'ConfiguratonError', + // name: 'RouterConfigurationError', + // source: 'installRoute', + // message: 'invalid route', + // suggestion: 'Fix the plugin which specified this route.', + // data: route + // }); + } + } var route = { routeHandler: handler }; diff --git a/src/client/modules/app/services/session.js b/src/client/modules/app/services/session.js index 0fed59dc6..e2604cd02 100644 --- a/src/client/modules/app/services/session.js +++ b/src/client/modules/app/services/session.js @@ -16,9 +16,6 @@ define([ function factory(config) { var runtime = config.runtime; - var cookieName = config.cookie.name; - var cookieMaxAge = config.cookie.maxAge; - var extraCookies = []; if (config.cookie.backup.enabled) { extraCookies.push({ @@ -54,6 +51,10 @@ define([ return auth2Session.getRealname(); } + function getRoles() { + return auth2Session.getRoles(); + } + function getTokenInfo() { return auth2Session.getTokenInfo(); } @@ -187,7 +188,7 @@ define([ function stop() { auth2Session.stop() .then(function () { - session = null; + // session = null; }); } @@ -211,6 +212,7 @@ define([ getEmail: getEmail, getUsername: getUsername, getRealname: getRealname, + getRoles: getRoles, isLoggedIn: isLoggedIn, isAuthorized: isAuthorized, getKbaseSession: getKbaseSession, diff --git a/src/plugins/mainwindow/modules/bodyWidget.js b/src/plugins/mainwindow/modules/bodyWidget.js index cfca5f6f2..206d513b5 100644 --- a/src/plugins/mainwindow/modules/bodyWidget.js +++ b/src/plugins/mainwindow/modules/bodyWidget.js @@ -44,6 +44,7 @@ define([ console.error('ERROR mounting widget', err, data); widgetMount.unmount() .then(function () { + // Note that 'error' is a globally defined widget dependency. return widgetMount.mountWidget('error', { title: 'ERROR', error: err diff --git a/src/plugins/mainwindow/modules/widgets/error.js b/src/plugins/mainwindow/modules/widgets/error.js index 546a49780..3a9f69c19 100644 --- a/src/plugins/mainwindow/modules/widgets/error.js +++ b/src/plugins/mainwindow/modules/widgets/error.js @@ -158,7 +158,10 @@ define([ error.extended = html.makeObjTable([error.extra], { rotated: true }); } - return div({ class: 'container-fluid', dataWidget: 'error' }, html.makePanel({ + return div({ + class: 'container-fluid', + dataWidget: 'error' + }, html.makePanel({ title: params.title, class: 'danger', content: html.makeObjTable([error], { rotated: true }) From 0ed20ff88a750470d7ccf7d2c50d653a68fdab87 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Sat, 10 Mar 2018 18:19:01 -0800 Subject: [PATCH 2/8] add runtime to root context --- src/client/modules/lib/knockout-plus.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/modules/lib/knockout-plus.js b/src/client/modules/lib/knockout-plus.js index 18646cb07..fad6b18df 100644 --- a/src/client/modules/lib/knockout-plus.js +++ b/src/client/modules/lib/knockout-plus.js @@ -453,7 +453,9 @@ define([ '' ]); var node = temp.firstChild; - ko.applyBindings(vm, node); + ko.applyBindings(vm, node, function (context) { + context.runtime = runtime; + }); function start() { vm.running(true); From 09209f6fa4acc7c588ca330ca33a8a57677ad614 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Sat, 10 Mar 2018 18:19:59 -0800 Subject: [PATCH 3/8] add updated auth2 support for geting roles, improved jgi-search [SCT-663] --- bower.json | 2 +- config/app/dev/plugins.yml | 2 +- config/app/prod/plugins.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 00da5e0fc..ccab21c6c 100644 --- a/bower.json +++ b/bower.json @@ -34,7 +34,7 @@ "jquery": "2.2.4", "jquery-ui": "1.12.1", "js-yaml": "3.10.0", - "kbase-common-ts": "0.17.0", + "kbase-common-ts": "0.18.0", "kbase-common-js": "2.15.1", "kbase-sdk-clients-js": "0.5.1", "kbase-service-clients-js": "3.3.5", diff --git a/config/app/dev/plugins.yml b/config/app/dev/plugins.yml index 39490915b..166da9792 100644 --- a/config/app/dev/plugins.yml +++ b/config/app/dev/plugins.yml @@ -160,7 +160,7 @@ plugins: - name: jgi-search globalName: kbase-ui-plugin-jgi-search - version: 0.31.8 + version: 0.32.0 cwd: src/plugin source: bower: {} diff --git a/config/app/prod/plugins.yml b/config/app/prod/plugins.yml index 10818872c..52e4759f0 100644 --- a/config/app/prod/plugins.yml +++ b/config/app/prod/plugins.yml @@ -160,7 +160,7 @@ plugins: - name: jgi-search globalName: kbase-ui-plugin-jgi-search - version: 0.31.8 + version: 0.32.0 cwd: src/plugin source: bower: {} From 05be27656860a4e44818f1beca592bac59c56583 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Mon, 12 Mar 2018 07:27:45 -0700 Subject: [PATCH 4/8] integration test runner: disabling tests, testing text value --- src/test/integration-tests/specs/runner.js | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/test/integration-tests/specs/runner.js b/src/test/integration-tests/specs/runner.js index 6a509734c..c8734bb88 100644 --- a/src/test/integration-tests/specs/runner.js +++ b/src/test/integration-tests/specs/runner.js @@ -1,4 +1,4 @@ -/*global describe, it, browser, exports */ +/*global describe, it, browser, expect, exports */ var fs = require('fs'); @@ -33,24 +33,41 @@ function extend(path, elements) { function runTest(test) { describe(test.description, function () { + if (test.disabled) { + return; + } + var defaultUrl = test.defaultUrl || '/'; test.specs.forEach(function (spec) { + if (spec.disabled) { + return; + } it(spec.description, function () { - browser.url('/'); + var url = spec.url || defaultUrl; + browser.url(url); spec.tasks.forEach(function (task) { if (task.selector) { var selector = buildSelector(extend(spec.baseSelector, task.selector)); + var result; if (task.wait) { - browser.waitForExist(selector, task.wait); + result = browser.waitForExist(selector, task.wait); } else if (task.exists) { - browser.isExisting(selector); + result = browser.isExisting(selector); } - if (task.action) { - switch (task.action) { - case 'click': - browser.click(selector); - break; - default: - throw new Error('Unknown task action ' + task.action); + + // only proceed with a further action if succeeded so far. + if (result) { + if (task.text) { + var text = browser.getText(selector); + expect(text).toMatch(new RegExp(task.text)); + } + if (task.action) { + switch (task.action) { + case 'click': + browser.click(selector); + break; + default: + throw new Error('Unknown task action ' + task.action); + } } } } else if (task.navigate) { From 45964414719aa071003b734d7c876c2d2968cf5a Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Mon, 12 Mar 2018 07:28:02 -0700 Subject: [PATCH 5/8] common-js minor update --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index ccab21c6c..9f1304da9 100644 --- a/bower.json +++ b/bower.json @@ -35,7 +35,7 @@ "jquery-ui": "1.12.1", "js-yaml": "3.10.0", "kbase-common-ts": "0.18.0", - "kbase-common-js": "2.15.1", + "kbase-common-js": "2.15.2", "kbase-sdk-clients-js": "0.5.1", "kbase-service-clients-js": "3.3.5", "kbase-ui-widget": "1.2.1", From 6dd83086a62977d37d5fbb329c62dae01ef6d538 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Mon, 12 Mar 2018 07:28:18 -0700 Subject: [PATCH 6/8] add argument check function --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile b/Makefile index 912adb1f8..4ec0999cb 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,16 @@ CI_DOCKER_CONTEXT = $(TOPDIR)/deployment/ci/docker/context PROD_DOCKER_CONTEXT = $(TOPDIR)/deployment/prod/docker/context PROXIER_DOCKER_CONTEXT = $(TOPDIR)/tools/proxier/docker/context +# functions +# thanks https://stackoverflow.com/questions/10858261/abort-makefile-if-variable-not-set +check_defined = \ + $(strip $(foreach 1,$1, \ + $(call __check_defined,$1,$(strip $(value 2))))) +__check_defined = \ + $(if $(value $1),, \ + $(error Undefined $1$(if $2, ($2))$(if $(value @), \ + required by target `$@'))) + # Standard 'all' target = just do the standard build all: @echo Use "make init && make config=TARGET build" @@ -159,6 +169,7 @@ unit-tests: $(KARMA) start test/unit-tests/karma.conf.js integration-tests: + @:$(call check_defined, host, first component of hostname) $(GRUNT) integration-tests --host=$(host) travis-tests: From c25a91a69c2d7faac41cd1512030d1ff39e44521 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Mon, 12 Mar 2018 07:28:55 -0700 Subject: [PATCH 7/8] improve testability of user-profile and auth2-client --- config/app/dev/plugins.yml | 4 ++-- config/app/prod/plugins.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/app/dev/plugins.yml b/config/app/dev/plugins.yml index 166da9792..4668d8793 100644 --- a/config/app/dev/plugins.yml +++ b/config/app/dev/plugins.yml @@ -118,14 +118,14 @@ plugins: - name: auth2-client globalName: kbase-ui-plugin-auth2-client - version: 1.2.17 + version: 1.2.18 cwd: src/plugin source: bower: {} - name: user-profile globalName: kbase-ui-plugin-user-profile - version: 1.4.1 + version: 1.4.2 cwd: src/plugin source: bower: {} diff --git a/config/app/prod/plugins.yml b/config/app/prod/plugins.yml index 52e4759f0..389ed63aa 100644 --- a/config/app/prod/plugins.yml +++ b/config/app/prod/plugins.yml @@ -118,14 +118,14 @@ plugins: - name: auth2-client globalName: kbase-ui-plugin-auth2-client - version: 1.2.17 + version: 1.2.18 cwd: src/plugin source: bower: {} - name: user-profile globalName: kbase-ui-plugin-user-profile - version: 1.4.1 + version: 1.4.2 cwd: src/plugin source: bower: {} From 71da9c11c2fbc7f823e4d3239dfa186c4ccc0fc4 Mon Sep 17 00:00:00 2001 From: Erik Pearson Date: Mon, 12 Mar 2018 08:55:43 -0700 Subject: [PATCH 8/8] prep release v1.6.7 --- config/release.yml | 2 +- release-notes/RELEASE_NOTES_1.6.7.md | 36 ++++++++++++++++++++++++++++ release-notes/index.md | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 release-notes/RELEASE_NOTES_1.6.7.md diff --git a/config/release.yml b/config/release.yml index f07662fdc..fbfc43482 100644 --- a/config/release.yml +++ b/config/release.yml @@ -6,4 +6,4 @@ --- # Note that this file is merged into the master config in the release namespace. release: - version: 1.6.6 \ No newline at end of file + version: 1.6.7 \ No newline at end of file diff --git a/release-notes/RELEASE_NOTES_1.6.7.md b/release-notes/RELEASE_NOTES_1.6.7.md new file mode 100644 index 000000000..a8b3f9e5b --- /dev/null +++ b/release-notes/RELEASE_NOTES_1.6.7.md @@ -0,0 +1,36 @@ +# KBase kbase-ui 1.6.7 Release Notes + +The purpose of this release is to improve search history for jgi-search. An additional nicety is that the fuzzy profile gravatar is finally fixed. + + +## CHANGES + +### NEW + +n/a + +### REMOVED + +n/a + +### UNRELEASED + +n/a + +### IMPROVEMENTS + +- jgi-search: feedback button sends user information to pre-fill feedback form + - https://github.com/kbase/kbase-ui-plugin-jgi-search/commit/d2814e49498272ed50ddd36b99e84857b718b6c4 +- integration testing: disable tests, test for text by regex + - https://github.com/kbase/kbase-ui/commit/05be27656860a4e44818f1beca592bac59c56583 +- user-profile: fixed gravatar fuzziness + - https://github.com/kbase/kbase-ui/commit/c25a91a69c2d7faac41cd1512030d1ff39e44521 + +### FIXES + +- jgi-search: search history behaves better (as expected) + - https://github.com/kbase/kbase-ui-plugin-jgi-search/commit/83269c919f5bfd9a49f193892e71023f47efb737 + +## Dependency Changes + +n/a diff --git a/release-notes/index.md b/release-notes/index.md index b9dd5e046..3bbddfdbd 100644 --- a/release-notes/index.md +++ b/release-notes/index.md @@ -6,6 +6,7 @@ | Version | Date | Notes | |-----------------------------------|------------|---------------------| +| [1.6.7](RELEASE_NOTES_1.6.7.md) | 2018-03-12 | | | [1.6.6](RELEASE_NOTES_1.6.6.md) | 2018-03-09 | | | [1.6.5](RELEASE_NOTES_1.6.5.md) | 2018-03-09 | | | [1.6.4](RELEASE_NOTES_1.6.4.md) | 2018-02-27 | |