Hotfix/close modal goes to activity (#699)
* 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
This commit is contained in:
parent
bd7928e114
commit
39e09e5be8
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@jenkins-cd/blueocean-core-js",
|
||||
"version": "0.0.44-unpublished",
|
||||
"version": "0.0.45-unpublished",
|
||||
"dependencies": {
|
||||
"@jenkins-cd/diag": {
|
||||
"version": "0.0.2",
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { observable, action } from 'mobx';
|
||||
|
||||
/**
|
||||
* Stores the previous and current pathnames.
|
||||
* Stores the previous and current location pathnames.
|
||||
*/
|
||||
export default class LocationService {
|
||||
@observable current;
|
||||
|
@ -9,7 +9,7 @@ export default class LocationService {
|
|||
|
||||
@action setCurrent(newLocation) {
|
||||
if (newLocation.action !== 'REPLACE') {
|
||||
this.current = this.previous;
|
||||
this.previous = this.current;
|
||||
}
|
||||
|
||||
this.current = newLocation.pathname;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -3,9 +3,9 @@
|
|||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@jenkins-cd/blueocean-core-js": {
|
||||
"version": "0.0.43",
|
||||
"from": "@jenkins-cd/blueocean-core-js@0.0.43",
|
||||
"resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.43.tgz",
|
||||
"version": "0.0.44",
|
||||
"from": "@jenkins-cd/blueocean-core-js@0.0.44",
|
||||
"resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.44.tgz",
|
||||
"dependencies": {
|
||||
"@jenkins-cd/sse-gateway": {
|
||||
"version": "0.0.10",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
"version": "0.0.2-unpublished",
|
||||
"dependencies": {
|
||||
"@jenkins-cd/blueocean-core-js": {
|
||||
"version": "0.0.43",
|
||||
"from": "@jenkins-cd/blueocean-core-js@0.0.43",
|
||||
"resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.43.tgz",
|
||||
"version": "0.0.44",
|
||||
"from": "@jenkins-cd/blueocean-core-js@0.0.44",
|
||||
"resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.44.tgz",
|
||||
"dependencies": {
|
||||
"react-router": {
|
||||
"version": "3.0.0",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@jenkins-cd/blueocean-core-js": {
|
||||
"version": "0.0.43",
|
||||
"from": "@jenkins-cd/blueocean-core-js@0.0.43",
|
||||
"resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.43.tgz",
|
||||
"version": "0.0.44",
|
||||
"from": "@jenkins-cd/blueocean-core-js@0.0.44",
|
||||
"resolved": "https://registry.npmjs.org/@jenkins-cd/blueocean-core-js/-/blueocean-core-js-0.0.44.tgz",
|
||||
"dependencies": {
|
||||
"history": {
|
||||
"version": "3.2.1",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue