Skip to content

Commit

Permalink
Tag/untag nodes from context menu (#259)
Browse files Browse the repository at this point in the history
* add rightCLickNode stub

* weird

* handle right click event

* change verbiage

* remove local state management from nodesearch

* pass actual node data into context menu

* working but eh

* exploreSearch tab switching happens in ducks

* graphview empties canvas when chartprops is empty obj

* combobox manages its state internally

* highlight works on element zero

* put pathfinding tests in pathfindingSearch.test.tsx, move out of exploresearch.test

* add some test coverage for tab switching to exploreSearch.test

* add ending node to context menu

* breakout edgeFilter.tsx from pathfindingSearch.tsx

* breakout contextMenu

* contextmenu.test.tsx

* cypher reducer cleaned up

* context menu properly opens the combobox

* rename SECONDARY -> PATHFINDING

* setActiveTab action renamed to tabChanged

* breakout PathfindingSwapButton

* sourceNodeSuggested action updates all of the related reducer state

* destinationNodeSuggested reducer handles everything

* change action to -> cypherSearch

* change action to -> cypherQueryEdited

* remove dead code for `SEARCH_SET_PATHFINDING`

* cleanup references to dead code for setSearchValue

* remove startSearchAction, replace w sourceNodeEdited, destNodeEdited

* remove setSearchValue

* remove startSearchSelected

* suggesting a node automatically runs the search

* clear out primary/secondary value when input changes

* remove controlled menu open

* props for combobox

* rip out suggested types

* Context menu works on hover

* Context menu works with tooltip

* contextMenu tests fixes

* anchor prop type

* cleanup actions

* add shadow to submenu

* remove console.log

* add logic to primarySearchWorker

* styled component instead of withStyles

* useSelector returns a smaller piece of data

* asset group menu item started

* blah

* js-client updates from wes

* wip

* conditional rendering of add/remove functionality

* optimistically update the rgraph when adding node to tier 0

* assetGroupMenuItem unit tests

* tests added for context menu

* cleanup

* boop

* add ip notice

* change wording
  • Loading branch information
brandonshearin authored Dec 15, 2023
1 parent 038f9c1 commit 9d42508
Show file tree
Hide file tree
Showing 15 changed files with 723 additions and 112 deletions.
10 changes: 3 additions & 7 deletions cmd/ui/src/components/SigmaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { Box } from '@mui/material';
import { GraphNodes } from 'js-client-library';
import { GraphButtonProps, SearchCurrentNodes } from 'bh-shared-ui';
import { SigmaNodeEventPayload } from 'sigma/sigma';
import ContextMenu from 'src/views/Explore/ContextMenu/ContextMenu';

interface SigmaChartProps {
rankDirection: RankDirection;
Expand All @@ -51,8 +50,7 @@ interface SigmaChartProps {
onClickEdge: (id: string, relatedFindingType?: string | null) => void;
onClickStage: () => void;
edgeReducer: (edge: string, data: Attributes, graph: AbstractGraph) => Attributes;
anchorPosition: { x: number; y: number };
onRightClickNode: (event: SigmaNodeEventPayload) => void;
handleContextMenu: (event: SigmaNodeEventPayload) => void;
}

const SigmaChart: FC<Partial<SigmaChartProps>> = ({
Expand All @@ -68,8 +66,7 @@ const SigmaChart: FC<Partial<SigmaChartProps>> = ({
onClickEdge,
onClickStage,
edgeReducer,
anchorPosition,
onRightClickNode,
handleContextMenu,
}) => {
return (
<div
Expand Down Expand Up @@ -109,7 +106,7 @@ const SigmaChart: FC<Partial<SigmaChartProps>> = ({
onClickEdge={onClickEdge}
onClickStage={onClickStage}
edgeReducer={edgeReducer}
onRightClickNode={onRightClickNode}
onRightClickNode={handleContextMenu}
/>
<Box position={'absolute'} bottom={16}>
{isCurrentSearchOpen && (
Expand All @@ -125,7 +122,6 @@ const SigmaChart: FC<Partial<SigmaChartProps>> = ({
)}
<GraphButtons rankDirection={rankDirection} options={options} nonLayoutButtons={nonLayoutButtons} />
</Box>
<ContextMenu anchorPosition={anchorPosition} />
</SigmaContainer>
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions cmd/ui/src/ducks/assetgroups/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { produce } from 'immer';
import * as actions from './actions';
import * as types from './types';
import { AppState } from 'src/store';

const INITIAL_STATE: types.AssetGroupsState = {
assetGroups: [],
Expand Down Expand Up @@ -63,4 +64,12 @@ const asssetGroupReducer = (state: types.AssetGroupsState = INITIAL_STATE, actio
});
};

export const selectTierZeroAssetGroupId = (state: AppState) => {
return state.assetgroups.assetGroups.find((assetGroup) => assetGroup.tag === 'admin_tier_0')?.id;
};

export const selectOwnedAssetGroupId = (state: AppState) => {
return state.assetgroups.assetGroups.find((assetGroup) => assetGroup.tag === 'owned')?.id;
};

export default asssetGroupReducer;
7 changes: 7 additions & 0 deletions cmd/ui/src/ducks/explore/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,10 @@ export const saveResponseForExport = (payload: Items): types.GraphActionTypes =>
payload,
};
};

export const toggleTierZeroNode = (nodeId: string): types.GraphActionTypes => {
return {
type: types.TOGGLE_TIER_ZERO_NODE,
nodeId,
};
};
8 changes: 8 additions & 0 deletions cmd/ui/src/ducks/explore/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const graphDataReducer = (state = initialGraphDataState, action: types.GraphActi
draft.init = action.payload;
} else if (action.type === types.SAVE_RESPONSE_FOR_EXPORT) {
draft.export = action.payload;
} else if (action.type === types.TOGGLE_TIER_ZERO_NODE) {
const systemTags = state.chartProps.items[action.nodeId].data.system_tags;
// remove the tier zero tag from the node
if (systemTags === 'admin_tier_0') {
draft.chartProps.items[action.nodeId].data.system_tags = '';
} else {
draft.chartProps.items[action.nodeId].data.system_tags = 'admin_tier_0';
}
}
return draft;
});
Expand Down
11 changes: 10 additions & 1 deletion cmd/ui/src/ducks/explore/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const REMOVE_NODES = 'app/explore/REMOVENODE';

const SAVE_RESPONSE_FOR_EXPORT = 'app/explore/SAVE_RESPONSE_FOR_EXPORT';

const TOGGLE_TIER_ZERO_NODE = 'app/explore/TOGGLE_TIER_ZERO_NODE';

export {
SET_GRAPH_LOADING,
GRAPH_START,
Expand All @@ -38,6 +40,7 @@ export {
REMOVE_NODES,
GRAPH_INIT,
SAVE_RESPONSE_FOR_EXPORT,
TOGGLE_TIER_ZERO_NODE,
};

export enum GraphEndpoints {}
Expand Down Expand Up @@ -97,6 +100,11 @@ interface SaveResponseForExportAction {
payload: Items;
}

interface ToggleTierZeroNodeAction {
type: typeof TOGGLE_TIER_ZERO_NODE;
nodeId: string;
}

export type GraphActionTypes =
| SetGraphLoadingAction
| GraphStartAction
Expand All @@ -106,7 +114,8 @@ export type GraphActionTypes =
| AddNodeAction
| RemoveNodeAction
| GraphInitAction
| SaveResponseForExportAction;
| SaveResponseForExportAction
| ToggleTierZeroNodeAction;

export interface NodeInfoRequest {
type: typeof GRAPH_START;
Expand Down
Loading

0 comments on commit 9d42508

Please sign in to comment.