Skip to content

Commit

Permalink
Remove grouping of imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Dec 6, 2019
1 parent 000dee1 commit 22d4135
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
KbnUrl,
SaveOptions,
SavedObjectFinder,
StateManagement,
unhashUrl,
} from './legacy_imports';
import { FilterStateManager, IndexPattern } from '../../../data/public';
import { Query, SavedQuery, IndexPatterns } from '../../../../../plugins/data/public';
Expand Down Expand Up @@ -747,7 +747,7 @@ export class DashboardAppController {
anchorElement,
allowEmbed: true,
allowShortUrl: !dashboardConfig.getHideWriteControls(),
shareableUrl: StateManagement.Url.unhashUrl(window.location.href),
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 @@ -63,6 +63,6 @@ export { confirmModalFactory } from 'ui/modals/confirm_modal';
export { configureAppAngularModule } from 'ui/legacy_compat';
export { stateMonitorFactory, StateMonitor } from 'ui/state_management/state_monitor_factory';
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { StateManagement } from '../../../../../plugins/kibana_utils/public';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';
export { IInjector } from 'ui/chrome';
export { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
migrateLegacyQuery,
RequestAdapter,
showSaveModal,
StateManagement,
unhashUrl,
stateMonitorFactory,
subscribeWithScope,
tabifyAggResponse,
Expand Down Expand Up @@ -330,7 +330,7 @@ function discoverController(
anchorElement,
allowEmbed: false,
allowShortUrl: uiCapabilities.discover.createShortUrl,
shareableUrl: StateManagement.Url.unhashUrl(window.location.href),
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 @@ -78,7 +78,7 @@ export { tabifyAggResponse } from 'ui/agg_response/tabify';
// @ts-ignore
export { vislibSeriesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { StateManagement } from '../../../../../plugins/kibana_utils/public';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';

// EXPORT types
export { Vis } from 'ui/vis';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
showSaveModal,
stateMonitorFactory,
subscribeWithScope,
StateManagement
unhashUrl
} from '../kibana_services';

const {
Expand Down Expand Up @@ -248,7 +248,7 @@ function VisEditor(
anchorElement,
allowEmbed: true,
allowShortUrl: capabilities.visualize.createShortUrl,
shareableUrl: StateManagement.Url.unhashUrl(window.location.href),
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 @@ -103,7 +103,7 @@ export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { StateManagement } from '../../../../../plugins/kibana_utils/public';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';
export {
Container,
Embeddable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import chrome from 'ui/chrome';
import { StateManagement } from '../../../../plugins/kibana_utils/public';
import { hashUrl } from '../../../../plugins/kibana_utils/public';
import uiRoutes from 'ui/routes';
import { fatalError } from 'ui/notify';

Expand All @@ -29,7 +29,7 @@ uiRoutes
url: function (AppState, globalState, $window) {
const redirectUrl = chrome.getInjected('redirectUrl');
try {
const hashedUrl = StateManagement.Url.hashUrl(redirectUrl);
const hashedUrl = hashUrl(redirectUrl);
const url = chrome.addBasePath(hashedUrl);

$window.location = url;
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/ui/public/chrome/api/sub_url_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import url from 'url';

import { StateManagement } from '../../../../../plugins/kibana_utils/public';
import { unhashUrl } from '../../../../../plugins/kibana_utils/public';
import { toastNotifications } from '../../notify/toasts';

export function registerSubUrlHooks(angularModule, internals) {
Expand All @@ -30,7 +30,7 @@ export function registerSubUrlHooks(angularModule, internals) {
const urlWithHashes = window.location.href;
let urlWithStates;
try {
urlWithStates = StateManagement.Url.unhashUrl(urlWithHashes);
urlWithStates = unhashUrl(urlWithHashes);
} catch (e) {
toastNotifications.addDanger(e.message);
}
Expand Down
16 changes: 9 additions & 7 deletions src/legacy/ui/public/state_management/__tests__/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import { toastNotifications } from '../../notify';
import * as FatalErrorNS from '../../notify/fatal_error';
import { StateProvider } from '../state';
import {
StateManagement,
unhashQuery,
createStateHash,
isStateHash,
HashedItemStore
} from '../../../../../plugins/kibana_utils/public';
import { StubBrowserStorage } from 'test_utils/stub_browser_storage';
Expand Down Expand Up @@ -56,7 +58,7 @@ describe('State Management', () => {
const hashedItemStore = new HashedItemStore(store);
const state = new State(param, initial, hashedItemStore);

const getUnhashedSearch = () => StateManagement.Url.unhashQuery($location.search());
const getUnhashedSearch = () => unhashQuery($location.search());

return { store, hashedItemStore, state, getUnhashedSearch };
};
Expand Down Expand Up @@ -246,7 +248,7 @@ describe('State Management', () => {
state.save();
const urlVal = $location.search()[state.getQueryParamName()];

expect(StateManagement.StateHash.isStateHash(urlVal)).to.be(true);
expect(isStateHash(urlVal)).to.be(true);
expect(hashedItemStore.getItem(urlVal)).to.eql(JSON.stringify({ foo: 'bar' }));
});

Expand All @@ -260,7 +262,7 @@ describe('State Management', () => {

const urlVal = $location.search()._s;
expect(urlVal).to.not.be(rison);
expect(StateManagement.StateHash.isStateHash(urlVal)).to.be(true);
expect(isStateHash(urlVal)).to.be(true);
expect(hashedItemStore.getItem(urlVal)).to.eql(JSON.stringify(obj));
});

Expand All @@ -276,7 +278,7 @@ describe('State Management', () => {

const { state } = setup({ storeInHash: true });
const search = $location.search();
const badHash = StateManagement.StateHash.createStateHash('{"a": "b"}', () => null);
const badHash = createStateHash('{"a": "b"}', () => null);

search[state.getQueryParamName()] = badHash;
$location.search(search);
Expand Down Expand Up @@ -313,10 +315,10 @@ describe('State Management', () => {
expect(state.translateHashToRison('(a:b)')).to.be('(a:b)');
expect(state.translateHashToRison('')).to.be('');

const existingHash = StateManagement.StateHash.createStateHash('{"a": "b"}', () => null);
const existingHash = createStateHash('{"a": "b"}', () => null);
hashedItemStore.setItem(existingHash, '{"a": "b"}');

const nonExistingHash = StateManagement.StateHash.createStateHash('{"b": "c"}', () => null);
const nonExistingHash = createStateHash('{"b": "c"}', () => null);

expect(state.translateHashToRison(existingHash)).to.be('(a:b)');
expect(state.translateHashToRison(nonExistingHash)).to.be('!n');
Expand Down
8 changes: 4 additions & 4 deletions src/legacy/ui/public/state_management/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { fatalError, toastNotifications } from '../notify';
import './config_provider';
import { createLegacyClass } from '../utils/legacy_class';
import { callEach } from '../utils/function';
import { hashedItemStore, StateManagement } from '../../../../plugins/kibana_utils/public';
import { hashedItemStore, isStateHash, createStateHash } from '../../../../plugins/kibana_utils/public';

export function StateProvider(Private, $rootScope, $location, stateManagementConfig, config, kbnUrl, $injector) {
const Events = Private(EventsProvider);
Expand Down Expand Up @@ -91,7 +91,7 @@ export function StateProvider(Private, $rootScope, $location, stateManagementCon
return null;
}

if (StateManagement.StateHash.isStateHash(urlVal)) {
if (isStateHash(urlVal)) {
return this._parseStateHash(urlVal);
}

Expand Down Expand Up @@ -265,7 +265,7 @@ export function StateProvider(Private, $rootScope, $location, stateManagementCon
* @return {string} rison
*/
State.prototype.translateHashToRison = function (stateHashOrRison) {
if (StateManagement.StateHash.isStateHash(stateHashOrRison)) {
if (isStateHash(stateHashOrRison)) {
return rison.encode(this._parseStateHash(stateHashOrRison));
}

Expand All @@ -288,7 +288,7 @@ export function StateProvider(Private, $rootScope, $location, stateManagementCon

// We need to strip out Angular-specific properties.
const json = angular.toJson(state);
const hash = StateManagement.StateHash.createStateHash(json);
const hash = createStateHash(json);
const isItemSet = this._hashedItemStore.setItem(hash, json);

if (isItemSet) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/kibana_utils/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export * from './errors';
export * from './field_mapping';
export * from './storage';
export * from './storage/hashed_item_store';
import * as StateManagement from './state_management';
export { StateManagement };
export * from './state_management/state_hash';
export * from './state_management/url';
23 changes: 0 additions & 23 deletions src/plugins/kibana_utils/public/state_management/index.ts

This file was deleted.

0 comments on commit 22d4135

Please sign in to comment.