Skip to content

Commit

Permalink
Merge pull request #2404 from aliraza556/repository-node-actions
Browse files Browse the repository at this point in the history
Add Specific Actions to `Repository Node Type`
  • Loading branch information
Rassl authored Nov 1, 2024
2 parents 960d6a3 + b96b9bf commit d939c2b
Showing 1 changed file with 83 additions and 18 deletions.
101 changes: 83 additions & 18 deletions src/components/Universe/Graph/UI/NodeControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import styled from 'styled-components'
import { Group, Vector3 } from 'three'
import { useGraphData } from '~/components/DataRetriever'
import AddCircleIcon from '~/components/Icons/AddCircleIcon'
import ConstructionIcon from '~/components/Icons/ConstructionIcon'
import DocumentIcon from '~/components/Icons/DocumentIcon'
import EditIcon from '~/components/Icons/EditIcon'
import MergeIcon from '~/components/Icons/MergeIcon'
import NodesIcon from '~/components/Icons/NodesIcon'
import PlusIcon from '~/components/Icons/PlusIcon'
import RobotIcon from '~/components/Icons/RobotIcon'
import { Flex } from '~/components/common/Flex'
import { fetchNodeEdges } from '~/network/fetchGraphData'
import { useAppStore } from '~/stores/useAppStore'
Expand Down Expand Up @@ -164,6 +167,8 @@ export const NodeControls = memo(() => {

const id = open ? 'simple-popover' : undefined

const isRepository = selectedNode?.node_type?.toLowerCase() === 'repository'

const isShowCreateTestButton = !!(selectedNode && selectedNode?.node_type?.toLowerCase() === 'function')

return (
Expand Down Expand Up @@ -216,24 +221,70 @@ export const NodeControls = memo(() => {
open={open}
transformOrigin={{ vertical: 'top', horizontal: 'right' }}
>
<PopoverOption
data-testid="merge"
onClick={() => {
mergeTopicModal()
handleClose()
}}
>
<MergeIcon data-testid="MergeIcon" /> Merge
</PopoverOption>
<PopoverOption
data-testid="add_edge"
onClick={() => {
addEdgeToNodeModal()
handleClose()
}}
>
<AddCircleIcon data-testid="AddCircleIcon" /> Add edge
</PopoverOption>
{!isRepository ? (
<>
<PopoverOption
data-testid="merge"
onClick={() => {
mergeTopicModal()
handleClose()
}}
>
<MergeIcon data-testid="MergeIcon" /> Merge
</PopoverOption>
<PopoverOption
data-testid="add_edge"
onClick={() => {
addEdgeToNodeModal()
handleClose()
}}
>
<AddCircleIcon data-testid="AddCircleIcon" />
Add edge
</PopoverOption>
</>
) : (
<>
<PopoverOption
data-testid="generate_tests"
onClick={() => {
handleClose()
}}
>
<IconWrapper>
<AddCircleIcon data-testid="AddCircleIcon" />
</IconWrapper>
Generate Tests
</PopoverOption>
<PopoverOption
data-testid="add_comments"
onClick={() => {
handleClose()
}}
>
<IconWrapper>
<DocumentIcon data-testid="DocumentIcon" />{' '}
</IconWrapper>
Add Comments
</PopoverOption>
<PopoverOption
data-testid="review_bugs"
onClick={() => {
handleClose()
}}
>
<ConstructionIcon data-testid="ConstructionIcon" /> Review Bugs
</PopoverOption>
<PopoverOption
data-testid="find_vulnerabilities"
onClick={() => {
handleClose()
}}
>
<RobotIcon data-testid="RobotIcon" /> Find Vulnerabilities
</PopoverOption>
</>
)}
</PopoverWrapper>
</Html>
</group>
Expand Down Expand Up @@ -301,6 +352,20 @@ const PopoverWrapper = styled(Popover)`
font-family: Barlow;
font-size: 14px;
font-weight: 500;
background-color: transparent !important;
margin: 2px;
}
`

const IconWrapper = styled.div`
display: flex;
align-items: center;
justify-content: start;
svg {
margin-top: 1px;
width: 12px;
height: 12px;
}
`

Expand Down

0 comments on commit d939c2b

Please sign in to comment.