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

[Dashboard][Lens] Add "convert to lens" action to dashboard #146363

Merged
merged 24 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7df2590
Add "convert to lens" action to dashboard
VladLasitsa Nov 28, 2022
1b00b5e
Fix CI
VladLasitsa Nov 28, 2022
0fca07e
Fix more tests
VladLasitsa Nov 28, 2022
f78d79b
Fix test
VladLasitsa Nov 29, 2022
8676538
Some improvments
VladLasitsa Nov 29, 2022
fe7c5cd
Add functional tests
VladLasitsa Dec 1, 2022
efe7d80
Merge branch 'main' into convert_to_lens_for_dashboard
kibanamachine Dec 2, 2022
a2397db
Merge branch 'main' into convert_to_lens_for_dashboard
stratoula Dec 5, 2022
15d3380
Fix notification
VladLasitsa Dec 5, 2022
2e22b1e
Fix some comments
VladLasitsa Dec 5, 2022
c7fdc8e
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Dec 5, 2022
b6f99e8
Fix some more nits
VladLasitsa Dec 6, 2022
8a74239
Merge remote-tracking branch 'origin/convert_to_lens_for_dashboard' i…
VladLasitsa Dec 6, 2022
0a6c890
Fix some tests
VladLasitsa Dec 6, 2022
cf4ac72
Merge branch 'main' into convert_to_lens_for_dashboard
kibanamachine Dec 7, 2022
91020f0
Fix some new comments
VladLasitsa Dec 7, 2022
54161f8
Some fixes
VladLasitsa Dec 8, 2022
a5447b4
Fix mocks
VladLasitsa Dec 8, 2022
135b36d
Merge branch 'main' into convert_to_lens_for_dashboard
kibanamachine Dec 8, 2022
1489189
Merge branch 'main' into convert_to_lens_for_dashboard
kibanamachine Dec 12, 2022
9b35aa5
Fix small nits
VladLasitsa Dec 13, 2022
ed576bd
Merge remote-tracking branch 'upstream/main' into convert_to_lens_for…
VladLasitsa Dec 13, 2022
1d260b1
fix test
VladLasitsa Dec 13, 2022
705101f
Get correct title for replace action
VladLasitsa Dec 13, 2022
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
3 changes: 2 additions & 1 deletion src/plugins/visualizations/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"presentationUtil",
"dataViews",
"dataViewEditor",
"unifiedSearch"
"unifiedSearch",
"usageCollection"
],
"optionalPlugins": ["home", "share", "spaces", "savedObjectsTaggingOss"],
"requiredBundles": ["kibanaUtils", "savedSearch", "kibanaReact", "charts"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { take } from 'rxjs/operators';
import { EuiFlexGroup, EuiFlexItem, EuiBadge } from '@elastic/eui';
import { METRIC_TYPE } from '@kbn/analytics';
import { reactToUiComponent } from '@kbn/kibana-react-plugin/public';
import { ActionExecutionContext } from '@kbn/ui-actions-plugin/public';
import { TimefilterContract } from '@kbn/data-plugin/public';
Expand All @@ -17,7 +18,7 @@ import { IEmbeddable, ViewMode } from '@kbn/embeddable-plugin/public';
import { Action } from '@kbn/ui-actions-plugin/public';
import { VisualizeEmbeddable } from '../embeddable';
import { DASHBOARD_VISUALIZATION_PANEL_TRIGGER } from '../triggers';
import { getUiActions, getApplication, getEmbeddable } from '../services';
import { getUiActions, getApplication, getEmbeddable, getUsageCollection } from '../services';

export const ACTION_EDIT_IN_LENS = 'ACTION_EDIT_IN_LENS';

Expand Down Expand Up @@ -53,7 +54,7 @@ const isVisualizeEmbeddable = (embeddable: IEmbeddable): embeddable is Visualize
export class EditInLensAction implements Action<EditInLensContext> {
public id = ACTION_EDIT_IN_LENS;
public readonly type = ACTION_EDIT_IN_LENS;
public order = 100;
public order = 49;
public showNotification = true;
public currentAppId: string | undefined;

Expand Down Expand Up @@ -94,6 +95,13 @@ export class EditInLensAction implements Action<EditInLensContext> {
isEmbeddable: true,
};
if (navigateToLensConfig) {
if (this.currentAppId) {
getUsageCollection().reportUiCounter(
this.currentAppId,
METRIC_TYPE.CLICK,
ACTION_EDIT_IN_LENS
);
}
getEmbeddable().getStateTransfer().isTransferInProgress = true;
getUiActions().getTrigger(DASHBOARD_VISUALIZATION_PANEL_TRIGGER).exec(updatedWithMeta);
}
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/visualizations/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import type {
Setup as InspectorSetup,
Start as InspectorStart,
} from '@kbn/inspector-plugin/public';
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { ExpressionsSetup, ExpressionsStart } from '@kbn/expressions-plugin/public';
Expand Down Expand Up @@ -95,6 +96,7 @@ import {
setExecutionContext,
setFieldFormats,
setSavedObjectTagging,
setUsageCollection,
} from './services';
import { VisualizeConstants } from '../common/constants';
import { EditInLensAction } from './actions/edit_in_lens_action';
Expand Down Expand Up @@ -143,6 +145,7 @@ export interface VisualizationsStartDeps {
screenshotMode: ScreenshotModePluginStart;
fieldFormats: FieldFormatsStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
usageCollection: UsageCollectionStart;
}

/**
Expand Down Expand Up @@ -368,6 +371,7 @@ export class VisualizationsPlugin
spaces,
savedObjectsTaggingOss,
fieldFormats,
usageCollection,
}: VisualizationsStartDeps
): VisualizationsStart {
const types = this.types.start();
Expand All @@ -387,6 +391,7 @@ export class VisualizationsPlugin
setExecutionContext(core.executionContext);
setChrome(core.chrome);
setFieldFormats(fieldFormats);
setUsageCollection(usageCollection);

if (spaces) {
setSpaces(spaces);
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/visualizations/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import type { EmbeddableStart } from '@kbn/embeddable-plugin/public';
import type { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import type { SavedObjectTaggingOssPluginStart } from '@kbn/saved-objects-tagging-oss-plugin/public';
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
import type { TypesStart } from './vis_types';

export const [getUISettings, setUISettings] = createGetterSetter<IUiSettingsClient>('UISettings');
Expand Down Expand Up @@ -72,3 +73,6 @@ export const [getSpaces, setSpaces] = createGetterSetter<SpacesPluginStart>('Spa

export const [getSavedObjectTagging, setSavedObjectTagging] =
createGetterSetter<SavedObjectTaggingOssPluginStart>('SavedObjectTagging', false);

export const [getUsageCollection, setUsageCollection] =
createGetterSetter<UsageCollectionStart>('UsageCollection');
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,20 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => {
originalAst.chain[functionIndex].arguments.config[0] as string
);

const originalType = originalAst.chain[functionIndex].arguments.type[0];

// clear out resolved arg for old embeddable
const argumentPath = [embeddableId, 'expressionRenderable'];
dispatch(clearValue({ path: argumentPath }));

const updatedInput = { ...originalInput, ...incomingInput };
let updatedInput;

// if type was changed, we should not provide originalInput
if (originalType !== type) {
updatedInput = incomingInput;
} else {
updatedInput = { ...originalInput, ...incomingInput };
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding this fix! Now we can close this issue when this PR merges.

#147032

}

const expression = `embeddable config="${encode(updatedInput)}"
type="${type}"
Expand Down