From 3e6bac22624a441fd940006224a1834ffee29a99 Mon Sep 17 00:00:00 2001 From: Dzmitry Tamashevich Date: Tue, 31 Aug 2021 11:05:36 +0300 Subject: [PATCH] [Graph] apply suggestions --- x-pack/plugins/graph/public/apps/listing_route.tsx | 4 ++-- .../public/components/control_panel/control_panel.tsx | 2 +- .../graph_visualization/graph_visualization.test.tsx | 3 +++ .../graph/public/components/settings/settings.test.tsx | 10 +++++----- .../graph/public/helpers/saved_workspace_utils.ts | 4 ++-- x-pack/plugins/graph/public/plugin.ts | 1 - x-pack/plugins/graph/public/types/workspace_state.ts | 3 ++- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/graph/public/apps/listing_route.tsx b/x-pack/plugins/graph/public/apps/listing_route.tsx index d459982c78c60..e7457f18005e6 100644 --- a/x-pack/plugins/graph/public/apps/listing_route.tsx +++ b/x-pack/plugins/graph/public/apps/listing_route.tsx @@ -62,8 +62,8 @@ export function ListingRoute({ ); const deleteItems = useCallback( - (savedWorkspaces: GraphWorkspaceSavedObject[]) => { - return deleteSavedWorkspace( + async (savedWorkspaces: GraphWorkspaceSavedObject[]) => { + await deleteSavedWorkspace( savedObjectsClient, savedWorkspaces.map((cur) => cur.id!) ); diff --git a/x-pack/plugins/graph/public/components/control_panel/control_panel.tsx b/x-pack/plugins/graph/public/components/control_panel/control_panel.tsx index e4fa361675fff..2946bc8ad56f5 100644 --- a/x-pack/plugins/graph/public/components/control_panel/control_panel.tsx +++ b/x-pack/plugins/graph/public/components/control_panel/control_panel.tsx @@ -103,7 +103,7 @@ const ControlPanelComponent = ({ {workspace.selectedNodes.map((node) => ( { const nodes: WorkspaceNode[] = [ { + id: '1', color: 'black', data: { field: 'A', @@ -34,6 +35,7 @@ describe('graph_visualization', () => { y: 5, }, { + id: '2', color: 'red', data: { field: 'B', @@ -55,6 +57,7 @@ describe('graph_visualization', () => { y: 9, }, { + id: '3', color: 'yellow', data: { field: 'C', diff --git a/x-pack/plugins/graph/public/components/settings/settings.test.tsx b/x-pack/plugins/graph/public/components/settings/settings.test.tsx index b6405fa211679..060b1e93fbdc0 100644 --- a/x-pack/plugins/graph/public/components/settings/settings.test.tsx +++ b/x-pack/plugins/graph/public/components/settings/settings.test.tsx @@ -46,7 +46,7 @@ describe('settings', () => { isDefault: false, }; - const angularProps: jest.Mocked = { + const workspaceProps: jest.Mocked = { blocklistedNodes: [ { x: 0, @@ -138,7 +138,7 @@ describe('settings', () => { ); dispatchSpy = jest.fn(store.dispatch); store.dispatch = dispatchSpy; - subject = new Rx.BehaviorSubject(angularProps); + subject = new Rx.BehaviorSubject(workspaceProps); instance = mountWithIntl( @@ -218,7 +218,7 @@ describe('settings', () => { it('should update on new data', () => { act(() => { subject.next({ - ...angularProps, + ...workspaceProps, blocklistedNodes: [ { x: 0, @@ -251,13 +251,13 @@ describe('settings', () => { it('should delete node', () => { instance.find(EuiListGroupItem).at(0).prop('extraAction')!.onClick!({} as any); - expect(angularProps.unblockNode).toHaveBeenCalledWith(angularProps.blocklistedNodes![0]); + expect(workspaceProps.unblockNode).toHaveBeenCalledWith(workspaceProps.blocklistedNodes![0]); }); it('should delete all nodes', () => { instance.find('[data-test-subj="graphUnblocklistAll"]').find(EuiButton).simulate('click'); - expect(angularProps.unblockAll).toHaveBeenCalled(); + expect(workspaceProps.unblockAll).toHaveBeenCalled(); }); }); diff --git a/x-pack/plugins/graph/public/helpers/saved_workspace_utils.ts b/x-pack/plugins/graph/public/helpers/saved_workspace_utils.ts index 1c1ada2856ab2..336708173d321 100644 --- a/x-pack/plugins/graph/public/helpers/saved_workspace_utils.ts +++ b/x-pack/plugins/graph/public/helpers/saved_workspace_utils.ts @@ -123,11 +123,11 @@ export async function getSavedWorkspace( return savedObject as GraphWorkspaceSavedObject; } -export async function deleteSavedWorkspace( +export function deleteSavedWorkspace( savedObjectsClient: SavedObjectsClientContract, ids: string[] ) { - await Promise.all(ids.map((id: string) => savedObjectsClient.delete(savedWorkspaceType, id))); + return Promise.all(ids.map((id: string) => savedObjectsClient.delete(savedWorkspaceType, id))); } export async function saveSavedWorkspace( diff --git a/x-pack/plugins/graph/public/plugin.ts b/x-pack/plugins/graph/public/plugin.ts index d8c1af9cd94a9..1ff9afe505a3b 100644 --- a/x-pack/plugins/graph/public/plugin.ts +++ b/x-pack/plugins/graph/public/plugin.ts @@ -84,7 +84,6 @@ export class GraphPlugin updater$: this.appUpdater$, mount: async (params: AppMountParameters) => { const [coreStart, pluginsStart] = await core.getStartServices(); - await pluginsStart.kibanaLegacy.loadAngularBootstrap(); coreStart.chrome.docTitle.change( i18n.translate('xpack.graph.pageTitle', { defaultMessage: 'Graph' }) ); diff --git a/x-pack/plugins/graph/public/types/workspace_state.ts b/x-pack/plugins/graph/public/types/workspace_state.ts index 734b7b146160a..bca94a7cfad6d 100644 --- a/x-pack/plugins/graph/public/types/workspace_state.ts +++ b/x-pack/plugins/graph/public/types/workspace_state.ts @@ -12,6 +12,7 @@ import { FontawesomeIcon } from '../helpers/style_choices'; import { WorkspaceField, AdvancedSettings } from './app_state'; export interface WorkspaceNode { + id: string; x: number; y: number; label: string; @@ -29,7 +30,7 @@ export interface WorkspaceNode { ky: number; } -export type BlockListedNode = Omit; +export type BlockListedNode = Omit; export interface WorkspaceEdge { weight: number;