Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] visualizations plugin #159

Merged
merged 3 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "visualizations",
"version": "kibana",
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "inspector", "dashboard"],
"optionalPlugins": ["usageCollection"],
"requiredBundles": ["kibanaUtils", "discover", "savedObjects"]
"requiredBundles": ["opensearchDashboardsUtils", "discover", "savedObjects"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as Rx from 'rxjs';
import { debounceTime, filter, share, switchMap } from 'rxjs/operators';
import { PersistedState } from '../../../../plugins/visualizations/public';
import { VisualizationController } from '../types';
import { ResizeChecker } from '../../../../plugins/kibana_utils/public';
import { ResizeChecker } from '../../../../plugins/opensearch_dashboards_utils/public';
import { ExprVis } from '../expressions/vis';

interface VisualizationChartProps {
Expand Down Expand Up @@ -76,7 +76,7 @@ class VisualizationChart extends React.Component<VisualizationChartProps> {

public render() {
return (
<div className="visChart__container kbn-resetFocusState" tabIndex={0} ref={this.containerDiv}>
<div className="visChart__container osd-resetFocusState" tabIndex={0} ref={this.containerDiv}>
<div className="visChart" ref={this.chartDiv} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { EuiIcon, EuiSpacer, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import React from 'react';

interface VisualizationNoResultsProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
import React from 'react';

export function DisabledLabVisualization({ title }: { title: string }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import _, { get } from 'lodash';
import { Subscription } from 'rxjs';
import * as Rx from 'rxjs';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
IIndexPattern,
TimeRange,
Query,
esFilters,
opensearchFilters,
Filter,
TimefilterContract,
} from '../../../../plugins/data/public';
Expand Down Expand Up @@ -232,7 +232,7 @@ export class VisualizeEmbeddable
}

// Check if filters has changed
if (!esFilters.onlyDisabledFiltersChanged(this.input.filters, this.filters)) {
if (!opensearchFilters.onlyDisabledFiltersChanged(this.input.filters, this.filters)) {
this.filters = this.input.filters;
dirty = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { SavedObjectMetaData, OnSaveProps } from 'src/plugins/saved_objects/public';
import { first } from 'rxjs/operators';
import { SavedObjectAttributes } from '../../../../core/public';
Expand Down Expand Up @@ -47,7 +47,7 @@ import {
import { showNewVisModal } from '../wizard';
import { convertToSerializedVis } from '../saved_visualizations/_saved_vis';
import { createVisEmbeddableFromObject } from './create_vis_embeddable_from_object';
import { StartServicesGetter } from '../../../kibana_utils/public';
import { StartServicesGetter } from '../../../opensearch_dashboards_utils/public';
import { VisualizationsStartDeps } from '../plugin';
import { VISUALIZE_ENABLE_LABS_SETTING } from '../../common/constants';
import { AttributeService } from '../../../dashboard/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { ExpressionFunctionDefinition, KibanaDatatable, Range } from '../../../expressions/public';
import { i18n } from '@osd/i18n';
import { ExpressionFunctionDefinition, OpensearchDashboardsDatatable, Range } from '../../../expressions/public';

interface Arguments {
from: number;
Expand All @@ -27,7 +27,7 @@ interface Arguments {

export const range = (): ExpressionFunctionDefinition<
'range',
KibanaDatatable | null,
OpensearchDashboardsDatatable | null,
Arguments,
Range
> => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import {
ExpressionFunctionDefinition,
ExpressionValueBoxed,
KibanaDatatable,
KibanaDatatableColumn,
OpensearchDashboardsDatatable,
OpensearchDashboardsDatatableColumn,
} from '../../../expressions/public';

interface Arguments {
Expand All @@ -34,7 +34,7 @@ interface Arguments {
type ExpressionValueVisDimension = ExpressionValueBoxed<
'vis_dimension',
{
accessor: number | KibanaDatatableColumn;
accessor: number | OpensearchDashboardsDatatableColumn;
format: {
id?: string;
params: unknown;
Expand All @@ -44,7 +44,7 @@ type ExpressionValueVisDimension = ExpressionValueBoxed<

export const visDimension = (): ExpressionFunctionDefinition<
'visdimension',
KibanaDatatable,
OpensearchDashboardsDatatable,
Arguments,
ExpressionValueVisDimension
> => ({
Expand All @@ -53,7 +53,7 @@ export const visDimension = (): ExpressionFunctionDefinition<
defaultMessage: 'Generates visConfig dimension object',
}),
type: 'vis_dimension',
inputTypes: ['kibana_datatable'],
inputTypes: ['opensearch_dashboards_datatable'],
args: {
accessor: {
types: ['string', 'number'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { get } from 'lodash';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { VisResponseValue, PersistedState } from '../../../../plugins/visualizations/public';
import { ExpressionFunctionDefinition, Render } from '../../../../plugins/expressions/public';
import { getTypes, getIndexPatterns, getFilterManager, getSearch } from '../services';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { PublicContract } from '@kbn/utility-types';
import { PublicContract } from '@osd/utility-types';
import { PluginInitializerContext } from 'src/core/public';
import { VisualizationsPlugin, VisualizationsSetup, VisualizationsStart } from './plugin';
import { VisualizeEmbeddableFactory, VisualizeEmbeddable } from './embeddable';
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = {
...params,
...buildVisConfig.table(schemas, params),
};
return `kibana_table ${prepareJson('visConfig', visConfig)}`;
return `opensearch_dashboards_table ${prepareJson('visConfig', visConfig)}`;
},
region_map: (params, schemas) => {
const visConfig = {
Expand All @@ -293,7 +293,7 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = {
...params,
...buildVisConfig.pie(schemas),
};
return `kibana_pie ${prepareJson('visConfig', visConfig)}`;
return `opensearch_dashboards_pie ${prepareJson('visConfig', visConfig)}`;
},
};

Expand Down Expand Up @@ -393,7 +393,7 @@ export const buildPipeline = async (vis: Vis, params: BuildPipelineParams) => {
const { uiState, title } = vis;

// context
let pipeline = `kibana | kibana_context `;
let pipeline = `opensearch_dashboards | opensearch_dashboards_context `;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this in expression context ? if so @boktorbb-amzn has replaced with opensearchDashboards

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it. we should sync up about that or w/e gets merged in.

if (query) {
pipeline += prepareJson('query', query);
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/visualizations/public/legacy/vis_update_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function convertHeatmapLabelColor(visState) {
/**
* Update old terms aggregation format to new terms aggregation format. This will
* update the following things:
* - Rewrite orderBy: _term to orderBy: _key (new API in Elasticsearch)
* - Rewrite orderBy: _term to orderBy: _key (new API in OpenSearch)
*/
function convertTermAggregation(visState) {
if (visState.aggs) {
Expand Down Expand Up @@ -149,9 +149,9 @@ function convertSeriesParams(visState) {

/**
* This function is responsible for updating old visStates - the actual saved object
* object - into the format, that will be required by the current Kibana version.
* object - into the format, that will be required by the current OpenSearch Dashboards version.
* This method will be executed for each saved vis object, that will be loaded.
* It will return the updated version as Kibana would expect it. It does not modify
* It will return the updated version as OpenSearch Dashboards would expect it. It does not modify
* the passed state.
*/
export const updateOldState = (visState) => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
Start as InspectorStart,
} from '../../../plugins/inspector/public';
import { UsageCollectionSetup } from '../../usage_collection/public';
import { createStartServicesGetter, StartServicesGetter } from '../../kibana_utils/public';
import { createStartServicesGetter, StartServicesGetter } from '../../opensearch_dashboards_utils/public';
import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visualizations';
import { SerializedVis, Vis } from './vis';
import { showNewVisModal } from './wizard';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import {
createSavedObjectClass,
SavedObject,
SavedObjectKibanaServices,
SavedObjectOpenSearchDashboardsServices,
} from '../../../../plugins/saved_objects/public';
// @ts-ignore
import { updateOldState } from '../legacy/vis_update_state';
Expand Down Expand Up @@ -73,7 +73,7 @@ export const convertFromSerializedVis = (vis: SerializedVis): ISavedVis => {
};
};

export function createSavedVisClass(services: SavedObjectKibanaServices) {
export function createSavedVisClass(services: SavedObjectOpenSearchDashboardsServices) {
const SavedObjectClass = createSavedObjectClass(services);
const savedSearch = createSavedSearchesLoader(services);

Expand Down Expand Up @@ -111,7 +111,7 @@ export function createSavedVisClass(services: SavedObjectKibanaServices) {
savedSearchId: opts.savedSearchId,
version: 1,
},
afterESResp: async (savedObject: SavedObject) => {
afterOpenSearchResp: async (savedObject: SavedObject) => {
const savedVis = (savedObject as any) as ISavedVis;
savedVis.visState = await updateOldState(savedVis.visState);
if (savedVis.searchSourceFields?.index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
*/
import {
SavedObjectLoader,
SavedObjectKibanaServices,
SavedObjectOpenSearchDashboardsServices,
} from '../../../../plugins/saved_objects/public';
import { findListItems } from './find_list_items';
import { createSavedVisClass } from './_saved_vis';
import { TypesStart } from '../vis_types';

export interface SavedObjectKibanaServicesWithVisualizations extends SavedObjectKibanaServices {
export interface SavedObjectOpenSearchDashboardsServicesWithVisualizations extends SavedObjectOpenSearchDashboardsServices {
visualizationTypes: TypesStart;
}
export type SavedVisualizationsLoader = ReturnType<typeof createSavedVisLoader>;
export function createSavedVisLoader(services: SavedObjectKibanaServicesWithVisualizations) {
export function createSavedVisLoader(services: SavedObjectOpenSearchDashboardsServicesWithVisualizations) {
const { savedObjectsClient, visualizationTypes } = services;

class SavedObjectLoaderVisualize extends SavedObjectLoader {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
SavedObjectsStart,
} from '../../../core/public';
import { TypesStart } from './vis_types';
import { createGetterSetter } from '../../../plugins/kibana_utils/public';
import { createGetterSetter } from '../../../plugins/opensearch_dashboards_utils/public';
import {
DataPublicPluginStart,
FilterManager,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/visualizations/public/vis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*/

import { isFunction, defaults, cloneDeep } from 'lodash';
import { Assign } from '@kbn/utility-types';
import { i18n } from '@kbn/i18n';
import { Assign } from '@osd/utility-types';
import { i18n } from '@osd/i18n';
import { PersistedState } from './persisted_state';
import { getTypes, getAggs, getSearch, getSavedSearchLoader } from './services';
import { VisType } from './vis_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class TypesService {
},
/**
* registers a visualization alias
* alias is a visualization type without implementation, it just redirects somewhere in kibana
* alias is a visualization type without implementation, it just redirects somewhere in OpenSearch Dashboards
* @param {VisTypeAlias} config - visualization alias definition
*/
registerAlias: visTypeAliasRegistry.add,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/visualizations/public/wizard/new_vis_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import React from 'react';

import { EuiModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';

import { METRIC_TYPE, UiStatsMetricType } from '@kbn/analytics';
import { METRIC_TYPE, UiStatsMetricType } from '@osd/analytics';
import { ApplicationStart, IUiSettingsClient, SavedObjectsStart } from '../../../../core/public';
import { SearchSelection } from './search_selection';
import { TypeSelection } from './type_selection';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import { EuiModalBody, EuiModalHeader, EuiModalHeaderTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import React from 'react';
import { IUiSettingsClient, SavedObjectsStart } from '../../../../../core/public';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/public/wizard/show_new_vis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import ReactDOM from 'react-dom';

import { I18nProvider } from '@kbn/i18n/react';
import { I18nProvider } from '@osd/i18n/react';
import { NewVisModal } from './new_vis_modal';
import {
getHttp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
import React, { Fragment } from 'react';
import { EuiText, EuiButton } from '@elastic/eui';
import { VisTypeAlias } from '../../vis_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import { orderBy } from 'lodash';
import React, { ChangeEvent } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/visualizations/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { VisualizationsPlugin } from './plugin';
export { VISUALIZE_ENABLE_LABS_SETTING } from '../common/constants';

// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
// as well as, OpenSearch Dashboards Platform `plugin()` initializer.

export function plugin(initializerContext: PluginInitializerContext) {
return new VisualizationsPlugin(initializerContext);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/visualizations/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { i18n } from '@osd/i18n';
import { schema } from '@osd/config-schema';
import { Observable } from 'rxjs';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import {
Expand All @@ -39,7 +39,7 @@ import { registerVisualizationsCollector } from './usage_collector';
export class VisualizationsPlugin
implements Plugin<VisualizationsPluginSetup, VisualizationsPluginStart> {
private readonly logger: Logger;
private readonly config: Observable<{ kibana: { index: string } }>;
private readonly config: Observable<{ opensearchDashboards: { index: string } }>;

constructor(initializerContext: PluginInitializerContext) {
this.logger = initializerContext.logger.get();
Expand Down
Loading