Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Graph] apply suggestions
Browse files Browse the repository at this point in the history
dimaanj committed Aug 31, 2021
1 parent 7ed9068 commit 3e6bac2
Showing 7 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/graph/public/apps/listing_route.tsx
Original file line number Diff line number Diff line change
@@ -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!)
);
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ const ControlPanelComponent = ({

{workspace.selectedNodes.map((node) => (
<SelectedNodeItem
key={`${node.label}-${node.x}-${node.y}`}
key={node.id}
node={node}
isHighlighted={selectedNode === node}
onSelectedFieldClick={onSelectedFieldClick}
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import { Workspace, WorkspaceEdge, WorkspaceNode } from '../../types';
describe('graph_visualization', () => {
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',
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ describe('settings', () => {
isDefault: false,
};

const angularProps: jest.Mocked<SettingsWorkspaceProps> = {
const workspaceProps: jest.Mocked<SettingsWorkspaceProps> = {
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(
<Provider store={store}>
<Settings observable={subject.asObservable()} />
@@ -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();
});
});

4 changes: 2 additions & 2 deletions x-pack/plugins/graph/public/helpers/saved_workspace_utils.ts
Original file line number Diff line number Diff line change
@@ -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(
1 change: 0 additions & 1 deletion x-pack/plugins/graph/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -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' })
);
3 changes: 2 additions & 1 deletion x-pack/plugins/graph/public/types/workspace_state.ts
Original file line number Diff line number Diff line change
@@ -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<WorkspaceNode, 'numChildren' | 'kx' | 'ky'>;
export type BlockListedNode = Omit<WorkspaceNode, 'numChildren' | 'kx' | 'ky' | 'id'>;

export interface WorkspaceEdge {
weight: number;

0 comments on commit 3e6bac2

Please sign in to comment.