Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Added callback to Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed May 17, 2021
1 parent ae55cbc commit c84ff39
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100
"printWidth": 90
}
7 changes: 6 additions & 1 deletion src/components/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export function Report(props: IReportProps) {

{/* Tasks */}
{tasks.map((task, index) => (
<ReportTask key={index} task={task} taskNumber={index + 1} tasksCount={tasks.length} />
<ReportTask
key={index}
task={task}
taskNumber={index + 1}
tasksCount={tasks.length}
/>
))}
</div>
)
Expand Down
9 changes: 7 additions & 2 deletions src/components/ReportError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export function ReportError(props: IReportErrorProps) {
<div className="error-details">
{reportError.description && (
<div className="error-description">
<div dangerouslySetInnerHTML={{ __html: marked(reportError.description) }} />
<div
dangerouslySetInnerHTML={{ __html: marked(reportError.description) }}
/>
</div>
)}
<div className="error-list">
Expand Down Expand Up @@ -69,7 +71,10 @@ export function ReportError(props: IReportErrorProps) {

{/* Show more */}
{visibleRowsCount < rowPositions.length && (
<a className="show-more" onClick={() => setVisibleRowsCount(visibleRowsCount + 10)}>
<a
className="show-more"
onClick={() => setVisibleRowsCount(visibleRowsCount + 10)}
>
Show more <span className="icon-keyboard_arrow_down" />
</a>
)}
Expand Down
18 changes: 16 additions & 2 deletions src/components/Workflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,25 @@ export interface IWorkflowProps {
* A GitHub run id
*/
run?: string
/**
* A callback on submit
*/
callback?: (
error: Error | undefined,
props: {
user: string
repo: string
workflow: string
run?: string
}
) => void
}

/**
* Visual component for Frictionless Repository workflow
*/
export function Workflow(props: IWorkflowProps) {
const { token, run } = props
const { token, run, callback } = props
const [user, setUser] = useState(props.user || '')
const [repo, setRepo] = useState(props.repo || '')
const [workflow, setWorkflow] = useState(props.workflow || '')
Expand All @@ -44,6 +56,7 @@ export function Workflow(props: IWorkflowProps) {
if (!user || !repo || !workflow) return
const report = await loadReport({ token, user, repo, workflow, run, setProgress })
if (!isMounted()) return
if (callback) callback(undefined, { user, repo, workflow, run })
setReport(report)
}, [])

Expand All @@ -52,6 +65,7 @@ export function Workflow(props: IWorkflowProps) {
ev.preventDefault()
if (!user || !repo || !workflow) return
const report = await loadReport({ token, user, repo, workflow, run, setProgress })
if (callback) callback(undefined, { user, repo, workflow, run })
setReport(report)
}

Expand Down Expand Up @@ -122,7 +136,7 @@ async function loadReport(props: {
run?: string
setProgress: (progress: number) => void
}) {
const { user, repo, workflow, token, run, setProgress } = props
const { token, user, repo, workflow, run, setProgress } = props

// Request
async function makeRequest(path: string) {
Expand Down

0 comments on commit c84ff39

Please sign in to comment.