-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #294 from lucafaggianelli/improve-in-app-help
Improve in app help
- Loading branch information
Showing
13 changed files
with
612 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { | ||
Button, | ||
Tab, | ||
TabGroup, | ||
TabList, | ||
TabPanel, | ||
TabPanels, | ||
} from '@tremor/react' | ||
import { QuestionMarkCircleIcon } from '@heroicons/react/24/outline' | ||
import { useState } from 'react' | ||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' | ||
import { | ||
okaidia, | ||
oneLight, | ||
} from 'react-syntax-highlighter/dist/esm/styles/prism' | ||
|
||
import CopyButton from '@/components/CopyButton' | ||
import Dialog from '@/components/Dialog' | ||
import { getPipelineRunUrl } from '@/repository' | ||
|
||
interface Props { | ||
pipelineId: string | ||
triggerId?: string | ||
} | ||
|
||
const PipelineHttpRun: React.FC<Props> = ({ pipelineId, triggerId }) => { | ||
const [open, setOpen] = useState(false) | ||
const isDark = document.documentElement.classList.contains('dark') | ||
|
||
const SNIPPETS = [ | ||
{ | ||
language: 'python', | ||
name: 'Python', | ||
code: `import httpx | ||
httpx.post('${getPipelineRunUrl(pipelineId)}', json={ | ||
"pipeline_id": "${pipelineId}",${triggerId ? `\n "trigger_id": "${triggerId}",` : ''} | ||
"params": { | ||
"name": "value", | ||
} | ||
})`, | ||
}, | ||
{ | ||
language: 'js', | ||
name: 'JavaScript', | ||
code: `fetch('${getPipelineRunUrl(pipelineId)}', { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
pipeline_id: '${pipelineId}',${triggerId ? `\n trigger_id: '${triggerId}',` : ''} | ||
params: {}, | ||
}), | ||
})`, | ||
}, | ||
] | ||
|
||
return ( | ||
<> | ||
<Button | ||
color="indigo" | ||
variant="secondary" | ||
size="xs" | ||
icon={QuestionMarkCircleIcon} | ||
onClick={() => setOpen(true)} | ||
></Button> | ||
|
||
<Dialog | ||
isOpen={open} | ||
title="Run via HTTP request" | ||
subtitle="You can run pipelines and triggers via HTTP requests" | ||
onClose={() => setOpen(false)} | ||
> | ||
<TabGroup> | ||
<TabList className="mt-8"> | ||
{SNIPPETS.map((snippet) => ( | ||
<Tab key={snippet.name}>{snippet.name}</Tab> | ||
))} | ||
</TabList> | ||
<TabPanels> | ||
{SNIPPETS.map((snippet) => ( | ||
<TabPanel key={snippet.name}> | ||
<div className="mt-6 relative group"> | ||
<SyntaxHighlighter | ||
language={snippet.language} | ||
style={isDark ? okaidia : oneLight} | ||
customStyle={{ borderRadius: 8 }} | ||
> | ||
{snippet.code} | ||
</SyntaxHighlighter> | ||
|
||
<CopyButton | ||
content={snippet.code} | ||
className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity bg-slate-200/80 dark:bg-slate-800/80 rounded p-2" | ||
/> | ||
</div> | ||
</TabPanel> | ||
))} | ||
</TabPanels> | ||
</TabGroup> | ||
</Dialog> | ||
</> | ||
) | ||
} | ||
|
||
export default PipelineHttpRun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.