Skip to content

Commit

Permalink
Moves Drag and Drop to create visualization menu
Browse files Browse the repository at this point in the history
Signed-off-by: Ashwin Pc <[email protected]>
  • Loading branch information
ashwin-pc committed Mar 29, 2022
1 parent b7907a6 commit 9477522
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 80 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class TypeSelection extends React.Component<TypeSelectionProps, TypeSelectionSta
>
<VisTypeIcon
icon={visType.type.icon === 'visTimeline' ? 'visTimelion' : visType.type.icon}
image={'image' in visType.type ? visType.type.image : 'visTimelion'}
image={'image' in visType.type ? visType.type.image : undefined}
/>
</EuiKeyPadMenuItem>
);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/wizard/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"opensearchDashboardsReact",
"savedObjects",
"embeddable",
"dashboard"
"dashboard",
"visualizations"
],
"optionalPlugins": []
}
5 changes: 3 additions & 2 deletions src/plugins/wizard/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { PluginInitializerContext } from '../../../core/public';
import { WizardPlugin } from './plugin';

// This exports static code and TypeScript types,
// as well as, OpenSearch Dashboards Platform `plugin()` initializer.
export function plugin() {
return new WizardPlugin();
export function plugin(initializerContext: PluginInitializerContext) {
return new WizardPlugin(initializerContext);
}
export { WizardServices, WizardPluginStartDependencies } from './types';
49 changes: 37 additions & 12 deletions src/plugins/wizard/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,53 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import {
AppMountParameters,
AppNavLinkStatus,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
Plugin,
PluginInitializerContext,
} from '../../../core/public';
import { WizardPluginStartDependencies, WizardServices } from './types';
import {
WizardPluginSetupDependencies,
WizardPluginStartDependencies,
WizardServices,
} from './types';
import { PLUGIN_NAME } from '../common';

export class WizardPlugin implements Plugin<void, void, object, WizardPluginStartDependencies> {
public setup(core: CoreSetup<WizardPluginStartDependencies>) {
// Register an application into the side navigation menu
export class WizardPlugin
implements Plugin<void, void, WizardPluginSetupDependencies, WizardPluginStartDependencies> {
constructor(public initializerContext: PluginInitializerContext) {}

public setup(
core: CoreSetup<WizardPluginStartDependencies>,
{ visualizations }: WizardPluginSetupDependencies
) {
// Register the plugin to core
core.application.register({
id: 'wizard',
title: PLUGIN_NAME,
euiIconType: 'inputOutput',
defaultPath: '#/',
category: DEFAULT_APP_CATEGORIES.opensearchDashboards,
navLinkStatus: AppNavLinkStatus.hidden,
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in opensearch_dashboards.json
const [coreStart, pluginsStart] = await core.getStartServices();
const { data, savedObjects, navigation } = pluginsStart;

const services: WizardServices = {
...coreStart,
toastNotifications: coreStart.notifications.toasts,
data: pluginsStart.data,
savedObjectsPublic: pluginsStart.savedObjects,
navigation: pluginsStart.navigation,
data,
savedObjectsPublic: savedObjects,
navigation,
setHeaderActionMenu: params.setHeaderActionMenu,
};

// make sure the index pattern list is up to date
pluginsStart.data.indexPatterns.clearCache();
data.indexPatterns.clearCache();
// make sure a default index pattern exists
// if not, the page will be redirected to management and visualize won't be rendered
await pluginsStart.data.indexPatterns.ensureDefaultIndexPattern();
Expand All @@ -47,6 +58,20 @@ export class WizardPlugin implements Plugin<void, void, object, WizardPluginStar
return renderApp(params, services);
},
});

// Register the plugin as an alias to create visualization
visualizations.registerAlias({
name: 'wizard',
title: 'Wizard',
description: i18n.translate('wizard.vizPicker.description', {
defaultMessage: 'TODO...',
}),
// TODO: Replace with actual icon once available
icon: 'vector',
stage: 'beta',
aliasApp: 'wizard',
aliasPath: '#/',
});
}

public start(core: CoreStart) {}
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/wizard/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { SavedObjectsStart } from 'src/plugins/saved_objects/public';
import { AppMountParameters, CoreStart, ToastsStart } from 'opensearch-dashboards/public';
import { EmbeddableSetup } from 'src/plugins/embeddable/public';
import { DashboardStart } from 'src/plugins/dashboard/public';
import { VisualizationsSetup } from 'src/plugins/visualizations/public';
import { NavigationPublicPluginStart } from '../../navigation/public';
import { DataPublicPluginStart } from '../../data/public';

export interface WizardPluginSetupDependencies {
embeddable: EmbeddableSetup;
visualizations: VisualizationsSetup;
}
export interface WizardPluginStartDependencies {
navigation: NavigationPublicPluginStart;
Expand Down

0 comments on commit 9477522

Please sign in to comment.