Skip to content

Commit

Permalink
Merge pull request #273 from sasjs/issue-270
Browse files Browse the repository at this point in the history
feat: add option for program launch in context menu
  • Loading branch information
allanbowe authored Sep 2, 2022
2 parents d0a24aa + 730c7c5 commit 769a840
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions web/src/components/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ const TreeViewNode = ({
mouseY: number
} | null>(null)

const launchProgram = () => {
const baseUrl = window.location.origin
window.open(`${baseUrl}/SASjsApi/stp/execute?_program=${node.relativePath}`)
}

const launchProgramWithDebug = () => {
const baseUrl = window.location.origin
window.open(
`${baseUrl}/SASjsApi/stp/execute?_program=${node.relativePath}&_debug=131`
)
}

const handleContextMenu = (event: React.MouseEvent) => {
event.preventDefault()
event.stopPropagation()
Expand Down Expand Up @@ -224,23 +236,30 @@ const TreeViewNode = ({
: undefined
}
>
{node.isFolder && (
<div>
{node.isFolder ? (
<>
<MenuItem onClick={handleNewFolderItemClick}>Add Folder</MenuItem>
<MenuItem
disabled={!node.relativePath}
onClick={handleNewFileItemClick}
>
Add File
</MenuItem>
</div>
</>
) : (
<>
<MenuItem onClick={launchProgram}>Launch</MenuItem>
<MenuItem onClick={launchProgramWithDebug}>
Launch and Debug
</MenuItem>
</>
)}
{!!node.relativePath && (
<>
<MenuItem onClick={handleRenameItemClick}>Rename</MenuItem>
<MenuItem onClick={handleDeleteItemClick}>Delete</MenuItem>
</>
)}
<MenuItem disabled={!node.relativePath} onClick={handleRenameItemClick}>
Rename
</MenuItem>
<MenuItem disabled={!node.relativePath} onClick={handleDeleteItemClick}>
Delete
</MenuItem>
</Menu>
</div>
)
Expand Down

0 comments on commit 769a840

Please sign in to comment.