Skip to content

Commit

Permalink
Hotfix/close modal goes to activity (#699)
Browse files Browse the repository at this point in the history
* fix a bug where closing the Run Details modal would navigate back to /activity instead of the previous route in many cases (from Dashboard, from Branches tab)

* publish beta core-js; update deps

* tick core-js version after publishing 0.0.44; update deps
  • Loading branch information
cliffmeyers committed Jan 11, 2017
1 parent bd7928e commit 39e09e5
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 16 deletions.
2 changes: 1 addition & 1 deletion blueocean-core-js/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-core-js/package.json
@@ -1,6 +1,6 @@
{
"name": "@jenkins-cd/blueocean-core-js",
"version": "0.0.44-unpublished",
"version": "0.0.45-unpublished",
"description": "Shared JavaScript libraries for use with Jenkins Blue Ocean",
"main": "dist/js/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions blueocean-core-js/src/js/services/LocationService.js
@@ -1,15 +1,15 @@
import { observable, action } from 'mobx';

/**
* Stores the previous and current pathnames.
* Stores the previous and current location pathnames.
*/
export default class LocationService {
@observable current;
@observable previous;

@action setCurrent(newLocation) {
if (newLocation.action !== 'REPLACE') {
this.current = this.previous;
this.previous = this.current;
}

this.current = newLocation.pathname;
Expand Down
79 changes: 79 additions & 0 deletions blueocean-core-js/test/js/services/LocationService-spec.js
@@ -0,0 +1,79 @@
import { assert } from 'chai';

import LocationService from '../../../src/js/services/LocationService';

/**
* Utility for creating location object passed to history.listen
* @param {string} action
* @param {string} pathname
* @returns {Object}
*/
function createLocation(pathname, action = 'PUSH') {
return {
action,
pathname,
search: '',
hash: '',
state: null,
key: 'mdrv0s',
basename: '/jenkins/blue',
query: {},
$searchBase: {
search: '',
searchBase: '',
},
};
}

describe('LocationService', () => {
let locationService;

beforeEach(() => {
locationService = new LocationService();
});

it('sets current after a route added', () => {
const loc = '/pipelines';
locationService.setCurrent(
createLocation(loc)
);

assert.isNotOk(locationService.previous);
assert.equal(locationService.current, loc);
});

it('sets previous after two routes added', () => {
const loc = '/pipelines';
locationService.setCurrent(
createLocation(loc)
);

const loc2 = '/organizations/jenkins/pipelines';
locationService.setCurrent(
createLocation(loc2)
);

assert.equal(locationService.previous, loc);
assert.equal(locationService.current, loc2);
});

it('handles the REPLACE scenario', () => {
const loc = '/pipelines';
locationService.setCurrent(
createLocation(loc)
);

const loc2 = '/organizations/jankins/pipeline-1/activity';
locationService.setCurrent(
createLocation(loc2)
);

const loc3 = '/organizations/jenkins/pipelines';
locationService.setCurrent(
createLocation(loc3, 'REPLACE')
);

assert.equal(locationService.previous, loc);
assert.equal(locationService.current, loc3);
});
});
6 changes: 3 additions & 3 deletions blueocean-dashboard/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-dashboard/package.json
Expand Up @@ -39,7 +39,7 @@
"skin-deep": "0.16.0"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.43",
"@jenkins-cd/blueocean-core-js": "0.0.44",
"@jenkins-cd/design-language": "0.0.99",
"@jenkins-cd/js-extensions": "0.0.32",
"@jenkins-cd/js-modules": "0.0.8",
Expand Down
6 changes: 3 additions & 3 deletions blueocean-personalization/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-personalization/package.json
Expand Up @@ -35,7 +35,7 @@
"react-addons-test-utils": "15.3.2"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.43",
"@jenkins-cd/blueocean-core-js": "0.0.44",
"@jenkins-cd/design-language": "0.0.99",
"@jenkins-cd/js-extensions": "0.0.32",
"@jenkins-cd/js-modules": "0.0.8",
Expand Down
6 changes: 3 additions & 3 deletions blueocean-web/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueocean-web/package.json
Expand Up @@ -29,7 +29,7 @@
"zombie": "4.2.1"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.43",
"@jenkins-cd/blueocean-core-js": "0.0.44",
"@jenkins-cd/design-language": "0.0.99",
"@jenkins-cd/js-extensions": "0.0.32",
"@jenkins-cd/js-modules": "0.0.8",
Expand Down

0 comments on commit 39e09e5

Please sign in to comment.