Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant committed Feb 21, 2020
1 parent 13c9fb1 commit a04e2a2
Show file tree
Hide file tree
Showing 30 changed files with 80 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { VisSavedObject } from './visualize_embeddable';
import { VisSavedObject } from '../types';
import { indexPatterns, IIndexPattern } from '../../../../../../../plugins/data/public';
import { getUISettings, getSavedObjects } from '../services';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/
export { DisabledLabEmbeddable } from './disabled_lab_embeddable';
export { VisualizeEmbeddable, VisualizeInput, VisSavedObject } from './visualize_embeddable';
export { VisualizeEmbeddable, VisualizeInput } from './visualize_embeddable';
export { VisualizeEmbeddableFactory } from './visualize_embeddable_factory';
export { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
Query,
esFilters,
Filter,
ISearchSource,
TimefilterContract,
} from '../../../../../../../plugins/data/public';
import {
Expand All @@ -48,25 +47,10 @@ import { buildPipeline } from '../legacy/build_pipeline';
import { Vis } from '../vis';
import { getExpressions, getUiActions } from '../services';
import { PersistedState } from '../../../legacy_imports';
import { SavedObject } from '../../../../../../../plugins/saved_objects/public';
// TODO: can't re-export this type from legacy_imports. Build fails. probably because it is in types.d.ts
import { SavedSearch } from '../../../../../kibana/public/discover/np_ready/types';
import { VisSavedObject } from '../types';

const getKeys = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;

export interface VisSavedObject extends SavedObject {
vis: Vis;
description?: string;
searchSource: ISearchSource;
title: string;
uiStateJSON?: string;
destroy: () => void;
savedSearchRefName?: string;
savedSearchId?: string;
savedSearch?: SavedSearch;
visState: any;
}

export interface VisualizeEmbeddableConfiguration {
savedVisualization: VisSavedObject;
indexPatterns?: IIndexPattern[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ import {
} from '../../../../../../../plugins/embeddable/public';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';
import { getIndexPattern } from './get_index_pattern';
import {
VisSavedObject,
VisualizeEmbeddable,
VisualizeInput,
VisualizeOutput,
} from './visualize_embeddable';
import { VisualizeEmbeddable, VisualizeInput, VisualizeOutput } from './visualize_embeddable';
import { VisSavedObject } from '../types';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
getCapabilities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import { VisualizationsPlugin, VisualizationsSetup, VisualizationsStart } from '
export { VisualizationsSetup, VisualizationsStart };

/** @public types */
export { VisTypeAlias, VisType } from './types';
export { VisSavedObject } from './embeddable';
export { VisTypeAlias, VisType } from './vis_types';
export { VisSavedObject } from './types';
export { Vis, VisParams, VisState } from './vis';
import { VisualizeEmbeddableFactory, VisualizeEmbeddable } from './embeddable';
export type VisualizeEmbeddableFactoryContract = PublicContract<VisualizeEmbeddableFactory>;
Expand All @@ -49,7 +49,7 @@ export function plugin(initializerContext: PluginInitializerContext) {
}

/** @public static code */
export { TypesService } from './types/types_service';
export { TypesService } from './vis_types/types_service';
export { VISUALIZE_EMBEDDABLE_TYPE, VisualizeInput } from './embeddable';

export { Status } from './legacy/update_status';
Expand All @@ -58,4 +58,4 @@ export { buildPipeline, buildVislibDimensions, SchemaConfig } from './legacy/bui
// @ts-ignore
export { updateOldState } from './legacy/vis_update_state';
export { calculateObjectHash } from './legacy/calculate_object_hash';
export { createSavedVisLoader } from '../../saved_visualizations/saved_visualizations';
export { createSavedVisLoader } from './saved_visualizations/saved_visualizations';
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import { BaseVisType } from '../../../types/base_vis_type';
import { BaseVisType } from '../../../vis_types/base_vis_type';

describe('Base Vis Type', function() {
beforeEach(ngMock.module('kibana'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import { ReactVisType } from '../../../types/react_vis_type';
import { ReactVisType } from '../../../vis_types/react_vis_type';

describe('React Vis Type', function() {
const visConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import moment from 'moment';
import { SerializedFieldFormat } from '../../../../../../../plugins/expressions/public';
import { fieldFormats, ISearchSource } from '../../../../../../../plugins/data/public';
import { IAggConfig, setBounds, isDateHistogramBucketAggConfig } from '../../../legacy_imports';
import { Vis, VisParams } from '..';
import { Vis, VisParams } from '../types';

interface SchemaConfigParams {
precision?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { TypesService, TypesSetup, TypesStart } from './types';
import { TypesService, TypesSetup, TypesStart } from './vis_types';
import {
setUISettings,
setTypes,
Expand All @@ -44,7 +44,7 @@ import {
DataPublicPluginStart,
} from '../../../../../../plugins/data/public';
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
import { createSavedVisLoader, SavedVisualizationsLoader } from '../../saved_visualizations';
import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visualizations';
import { VisImpl, VisImplConstructor } from './vis_impl';
import { showNewVisModal } from './wizard';
import { UiActionsStart } from '../../../../../../plugins/ui_actions/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import {
createSavedObjectClass,
SavedObject,
SavedObjectKibanaServices,
} from '../../../../../plugins/saved_objects/public';
import { updateOldState } from '../index';
} from '../../../../../../../plugins/saved_objects/public';
import { updateOldState } from '../../../index';
import { extractReferences, injectReferences } from './saved_visualization_references';
import { IIndexPattern } from '../../../../../plugins/data/public';
import { VisSavedObject } from '../np_ready/public/embeddable';
import { VisImpl } from '../np_ready/public/vis_impl';
import { createSavedSearchesLoader } from '../legacy_imports';
import { IIndexPattern } from '../../../../../../../plugins/data/public';
import { VisSavedObject } from '../types';
import { VisImpl } from '../vis_impl';
import { createSavedSearchesLoader } from '../../../legacy_imports';

async function _afterEsResp(savedVis: VisSavedObject, services: any) {
await _getLinkedSavedSearch(savedVis, services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

import { findListItems } from './find_list_items';
import { coreMock } from '../../../../../core/public/mocks';
import { coreMock } from '../../../../../../../core/public/mocks';
import { SavedObjectsClientContract } from 'kibana/public';
import { VisTypeAlias } from '../np_ready/public/types';
import { VisTypeAlias } from '../vis_types';

describe('saved_visualizations', () => {
function testProps() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import _ from 'lodash';
import { SavedObjectsClientContract } from 'kibana/public';
import { SavedObjectLoader } from '../../../../../plugins/saved_objects/public';
import { VisTypeAlias } from '../np_ready/public/types';
import { VisualizationsAppExtension } from '../np_ready/public/types/vis_type_alias_registry';
import { SavedObjectLoader } from '../../../../../../../plugins/saved_objects/public';
import { VisTypeAlias } from '../vis_types';
import { VisualizationsAppExtension } from '../vis_types/vis_type_alias_registry';

/**
* Search for visualizations and convert them into a list display-friendly format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { extractReferences, injectReferences } from './saved_visualization_references';
import { VisSavedObject } from '../np_ready/public';
import { VisSavedObject, VisState } from '../types';

describe('extractReferences', () => {
test('extracts nothing if savedSearchId is empty', () => {
Expand Down Expand Up @@ -128,7 +128,7 @@ Object {
id: '1',
title: 'test',
savedSearchRefName: 'search_0',
visState: {
visState: ({
params: {
controls: [
{
Expand All @@ -140,7 +140,7 @@ Object {
},
],
},
},
} as unknown) as VisState,
} as VisSavedObject;
const references = [
{
Expand Down Expand Up @@ -192,7 +192,7 @@ Object {
const context = {
id: '1',
title: 'test',
visState: {
visState: ({
params: {
controls: [
{
Expand All @@ -201,7 +201,7 @@ Object {
},
],
},
},
} as unknown) as VisState,
} as VisSavedObject;
expect(() => injectReferences(context, [])).toThrowErrorMatchingInlineSnapshot(
`"Could not find index pattern reference \\"control_0_index_pattern\\""`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { SavedObjectAttributes, SavedObjectReference } from 'kibana/public';
import { VisSavedObject } from '../np_ready/public';
import { VisSavedObject } from '../types';

export function extractReferences({
attributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import {
SavedObjectLoader,
SavedObjectKibanaServices,
} from '../../../../../plugins/saved_objects/public';
} from '../../../../../../../plugins/saved_objects/public';
import { findListItems } from './find_list_items';
import { createSavedVisClass } from './_saved_vis';
import { TypesStart } from '../np_ready/public/types';
import { TypesStart } from '../vis_types';

export interface SavedObjectKibanaServicesWithVisualizations extends SavedObjectKibanaServices {
visualizationTypes: TypesStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
IUiSettingsClient,
SavedObjectsStart,
} from 'src/core/public';
import { TypesStart } from './types';
import { TypesStart } from './vis_types';
import { createGetterSetter } from '../../../../../../plugins/kibana_utils/public';
import {
FilterManager,
Expand All @@ -34,7 +34,7 @@ import {
import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
import { ExpressionsStart } from '../../../../../../plugins/expressions/public';
import { UiActionsStart } from '../../../../../../plugins/ui_actions/public';
import { SavedVisualizationsLoader } from '../../saved_visualizations';
import { SavedVisualizationsLoader } from './saved_visualizations';

export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { SavedObject } from '../../../../../../plugins/saved_objects/public';
import { Vis, VisState, VisParams, VisualizationController } from './vis';
import { ISearchSource } from '../../../../../../plugins/data/public/';
import { SavedSearch } from '../../../../kibana/public/discover/np_ready/types';

export { Vis, VisState, VisParams, VisualizationController };

export interface VisSavedObject extends SavedObject {
vis: Vis;
description?: string;
searchSource: ISearchSource;
title: string;
uiStateJSON?: string;
destroy: () => void;
savedSearchRefName?: string;
savedSearchId?: string;
savedSearch?: SavedSearch;
visState: VisState;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { VisType } from './types';
import { VisType } from './vis_types';
import { IAggConfigs } from '../../legacy_imports';
import { Status } from './legacy/update_status';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { Vis, VisState, VisParams } from './vis';
import { VisType } from './types';
import { VisType } from './vis_types';
import { IIndexPattern } from '../../../../../../plugins/data/common';

type InitVisStateType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { TypesStart, VisType } from '../types';
import { TypesStart, VisType } from '../vis_types';
import { NewVisModal } from './new_vis_modal';
import { SavedObjectsStart } from 'kibana/public';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { METRIC_TYPE, UiStatsMetricType } from '@kbn/analytics';
import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public';
import { SearchSelection } from './search_selection';
import { TypeSelection } from './type_selection';
import { TypesStart, VisType, VisTypeAlias } from '../types';
import { TypesStart, VisType, VisTypeAlias } from '../vis_types';
import { UsageCollectionSetup } from '../../../../../../../plugins/usage_collection/public';

interface TypeSelectionProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import React from 'react';
import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public';

import { SavedObjectFinderUi } from '../../../../../../../../plugins/saved_objects/public';
import { VisType } from '../../types';
import { VisType } from '../../vis_types';

interface SearchSelectionProps {
onSearchSelected: (searchId: string, searchType: string) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { Fragment } from 'react';
import { EuiText, EuiButton } from '@elastic/eui';
import { VisTypeAliasListEntry } from './type_selection';
import { VisTypeAlias } from '../../types';
import { VisTypeAlias } from '../../vis_types';

interface Props {
promotedTypes: VisTypeAliasListEntry[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { VisTypeAlias } from '../../../../../../visualizations/public';
import { NewVisHelp } from './new_vis_help';
import { VisHelpText } from './vis_help_text';
import { VisTypeIcon } from './vis_type_icon';
import { VisType, TypesStart } from '../../types';
import { VisType, TypesStart } from '../../vis_types';

export interface VisTypeListEntry extends VisType {
highlighted: boolean;
Expand Down

0 comments on commit a04e2a2

Please sign in to comment.