Skip to content

Commit

Permalink
[wip] Typescripify, jestify, simplify state_hashing and state_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Nov 27, 2019
1 parent 04b91e7 commit db03365
Show file tree
Hide file tree
Showing 25 changed files with 673 additions and 658 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ export class DashboardAppController {
new FilterStateManager(globalState, getAppState, filterManager);
const queryFilter = filterManager;

function getUnhashableStates(): State[] {
return [getAppState(), globalState].filter(Boolean);
}

let lastReloadRequestTime = 0;

const dash = ($scope.dash = $route.current.locals.dash);
Expand Down Expand Up @@ -753,7 +749,7 @@ export class DashboardAppController {
anchorElement,
allowEmbed: true,
allowShortUrl: !dashboardConfig.getHideWriteControls(),
shareableUrl: unhashUrl(window.location.href, getUnhashableStates()),
shareableUrl: unhashUrl(window.location.href),
objectId: dash.id,
objectType: 'dashboard',
sharingData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import {
getRequestInspectorStats,
getResponseInspectorStats,
getServices,
getUnhashableStatesProvider,
hasSearchStategyForIndexPattern,
intervalOptions,
isDefaultTypeIndexPattern,
Expand Down Expand Up @@ -192,7 +191,6 @@ function discoverController(
uiCapabilities
) {
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
const getUnhashableStates = Private(getUnhashableStatesProvider);

const queryFilter = Private(FilterBarQueryFilterProvider);

Expand Down Expand Up @@ -329,7 +327,7 @@ function discoverController(
anchorElement,
allowEmbed: false,
allowShortUrl: uiCapabilities.discover.createShortUrl,
shareableUrl: unhashUrl(window.location.href, getUnhashableStates()),
shareableUrl: unhashUrl(window.location.href),
objectId: savedSearch.id,
objectType: 'search',
sharingData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
getServices,
angular,
absoluteToParsedUrl,
getUnhashableStatesProvider,
KibanaParsedUrl,
migrateLegacyQuery,
SavedObjectSaveModal,
Expand Down Expand Up @@ -165,7 +164,6 @@ function VisEditor(
localStorage,
) {
const queryFilter = Private(FilterBarQueryFilterProvider);
const getUnhashableStates = Private(getUnhashableStatesProvider);

// Retrieve the resolved SavedVis instance.
const savedVis = $route.current.locals.savedVis;
Expand Down Expand Up @@ -249,7 +247,7 @@ function VisEditor(
anchorElement,
allowEmbed: true,
allowShortUrl: capabilities.visualize.createShortUrl,
shareableUrl: unhashUrl(window.location.href, getUnhashableStates()),
shareableUrl: unhashUrl(window.location.href),
objectId: savedVis.id,
objectType: 'visualization',
sharingData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@
import chrome from 'ui/chrome';
import { hashUrl } from 'ui/state_management/state_hashing';
import uiRoutes from 'ui/routes';
import { fatalError } from 'ui/notify';

uiRoutes.enable();
uiRoutes
.when('/', {
resolve: {
url: function (AppState, globalState, $window) {
const redirectUrl = chrome.getInjected('redirectUrl');
try {
const hashedUrl = hashUrl(redirectUrl);
const url = chrome.addBasePath(hashedUrl);

const hashedUrl = hashUrl([new AppState(), globalState], redirectUrl);
const url = chrome.addBasePath(hashedUrl);

$window.location = url;
$window.location = url;
} catch (e) {
fatalError(e);
}
}
}
});
4 changes: 1 addition & 3 deletions src/legacy/ui/public/chrome/api/sub_url_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@
import url from 'url';

import {
getUnhashableStatesProvider,
unhashUrl,
} from '../../state_management/state_hashing';

export function registerSubUrlHooks(angularModule, internals) {
angularModule.run(($rootScope, Private, $location) => {
const getUnhashableStates = Private(getUnhashableStatesProvider);
const subUrlRouteFilter = Private(SubUrlRouteFilterProvider);

function updateSubUrls() {
const urlWithHashes = window.location.href;
const urlWithStates = unhashUrl(urlWithHashes, getUnhashableStates());
const urlWithStates = unhashUrl(urlWithHashes);
internals.trackPossibleSubUrl(urlWithStates);
}

Expand Down
6 changes: 4 additions & 2 deletions src/legacy/ui/public/state_management/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ import { createLegacyClass } from '../utils/legacy_class';
import { callEach } from '../utils/function';

import {
createStateHash,
HashedItemStoreSingleton,
isStateHash,
} from './state_storage';
import {
createStateHash,
isStateHash
} from './state_hashing';

export function StateProvider(Private, $rootScope, $location, stateManagementConfig, config, kbnUrl, $injector) {
const Events = Private(EventsProvider);
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit db03365

Please sign in to comment.