Skip to content

Commit

Permalink
[state] add configurable warning level based on url length
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Apr 4, 2016
1 parent 83764a7 commit 55db90d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/ui/public/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ export default function configDefaultsProvider() {
value: 5000,
description: 'The time in milliseconds which an information notification ' +
'will be displayed on-screen for. Setting to Infinity will disable.'
}
},
'warn:urlLength': {
value: 1900,
description: `
When the application url reaches this length we will start warning about
potential issues. Internet Explorer supports urls up to
<a href="https://support.microsoft.com/en-us/kb/208427">2,083 characters</a> long.
If IE compatibility is not important this can probably be disabled (set to 0).
`,
},
};
};
12 changes: 10 additions & 2 deletions src/ui/public/state_management/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import EventsProvider from 'ui/events';
import Notifier from 'ui/notify/notifier';


export default function StateProvider(Private, $rootScope, $location) {
export default function StateProvider(Private, $rootScope, $location, config) {
var notify = new Notifier();
var Events = Private(EventsProvider);

_.class(State).inherits(Events);
Expand Down Expand Up @@ -44,7 +45,6 @@ export default function StateProvider(Private, $rootScope, $location) {
try {
return search[this._urlParam] ? rison.decode(search[this._urlParam]) : null;
} catch (e) {
var notify = new Notifier();
notify.error('Unable to parse URL');
search[this._urlParam] = rison.encode(this._defaults);
$location.search(search).replace();
Expand Down Expand Up @@ -107,6 +107,14 @@ export default function StateProvider(Private, $rootScope, $location) {
} else {
$location.search(search);
}

const warnLength = config.get('warn:urlLength');
if (warnLength && $location.absUrl().length > warnLength) {
notify.warning(`
The URL has gotten big and may cause Kibana
to stop working. Please simplify the data on screen.
`);
}
};

/**
Expand Down

0 comments on commit 55db90d

Please sign in to comment.