Skip to content

Commit

Permalink
fix(remove_submit_context): removed context for the submit button and…
Browse files Browse the repository at this point in the history
… made the onNotify optional
  • Loading branch information
asalem1 committed Jun 15, 2020
1 parent 813b750 commit 597c50f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
3 changes: 0 additions & 3 deletions ui/src/notebooks/components/header/Submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {SubmitQueryButton} from 'src/timeMachine/components/SubmitQueryButton'
import QueryProvider, {
QueryContext,
BothResults,
SubmitQueryButtonContext,
} from 'src/notebooks/context/query'
import {NotebookContext, PipeMeta} from 'src/notebooks/context/notebook'
import {TimeContext} from 'src/notebooks/context/time'
Expand All @@ -18,7 +17,6 @@ const COMMENT_REMOVER = /(\/\*([\s\S]*?)\*\/)|(\/\/(.*)$)/gm

export const Submit: FC = () => {
const {query} = useContext(QueryContext)
const {onNotify} = useContext(SubmitQueryButtonContext)
const {id, pipes, updateResult, updateMeta} = useContext(NotebookContext)
const {timeContext} = useContext(TimeContext)
const [isLoading, setLoading] = useState(RemoteDataState.NotStarted)
Expand Down Expand Up @@ -99,7 +97,6 @@ export const Submit: FC = () => {
return (
<SubmitQueryButton
text="Run Flow"
onNotify={onNotify}
icon={IconFont.Play}
submitButtonDisabled={!hasQueries}
queryStatus={isLoading}
Expand Down
14 changes: 0 additions & 14 deletions ui/src/notebooks/context/query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ export const QueryContext = React.createContext<QueryContextType>(
DEFAULT_CONTEXT
)

export interface SubmitQueryButtonContextType {
onNotify: () => void
setQueryToLoading: () => void
}

const defaultSubmitBtnContext: SubmitQueryButtonContextType = {
onNotify: () => {},
setQueryToLoading: () => {},
}

export const SubmitQueryButtonContext = React.createContext<
SubmitQueryButtonContextType
>(defaultSubmitBtnContext)

type Props = StateProps
export const QueryProvider: FC<Props> = ({children, variables, org}) => {
const {id} = useContext(NotebookContext)
Expand Down
6 changes: 4 additions & 2 deletions ui/src/timeMachine/components/SubmitQueryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface StateProps {

interface DispatchProps {
onSubmit: typeof saveAndExecuteQueries | (() => void)
onNotify: typeof notify | (() => void)
onNotify?: typeof notify
}

interface OwnProps {
Expand Down Expand Up @@ -104,7 +104,9 @@ class SubmitQueryButton extends PureComponent<Props> {
}

private handleCancelClick = (): void => {
this.props.onNotify(queryCancelRequest())
if (this.props.onNotify) {
this.props.onNotify(queryCancelRequest())
}
if (this.abortController) {
this.abortController.abort()
this.abortController = null
Expand Down

0 comments on commit 597c50f

Please sign in to comment.