Skip to content

Commit

Permalink
Merge pull request #365 from illa-family/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
owenlongbo authored Sep 30, 2022
2 parents b88fe54 + 9f13c21 commit e6e01b0
Show file tree
Hide file tree
Showing 290 changed files with 6,749 additions and 2,920 deletions.
8 changes: 4 additions & 4 deletions apps/builder/src/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const axios = Axios.create({
})

axios.interceptors.request.use(
(config) => {
config => {
addRequestPendingPool(config)
const token = getLocalStorage("token")
if (token) {
Expand All @@ -36,13 +36,13 @@ axios.interceptors.request.use(
}
return config
},
(err) => {
err => {
return Promise.reject(err)
},
)

axios.interceptors.response.use(
(response) => {
response => {
const { config } = response
removeRequestPendingPool(config)
return response
Expand Down Expand Up @@ -80,7 +80,7 @@ export class Api {
errorState?.(false)
axios
.request<RespData, AxiosResponse<RespData>, RequestBody>(config)
.then((response) => {
.then(response => {
loading?.(false)
errorState?.(false)
success?.(response)
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/api/helpers/axiosPendingPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const generateUniqueKey = (config: AxiosRequestConfig) =>
].join("/")

export const clearRequestPendingPool = () => {
pendingPollMap.forEach((cancel) => {
pendingPollMap.forEach(cancel => {
cancel?.()
})
pendingPollMap.clear()
Expand Down
16 changes: 8 additions & 8 deletions apps/builder/src/api/ws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ function resetHeartbeat(ws: ILLAWebSocket) {

function reconnect(ws: ILLAWebSocket) {
clearWSTimeout(ws)
const callNow = !ws.debounceTimeout
ws.debounceTimeout = setTimeout(() => {
ws.debounceTimeout = null
reconnect(ws)
}, RECONNECT_TIMEOUT)
if (callNow) {
generateWs(ws.url)
}
// const callNow = !ws.debounceTimeout
// ws.debounceTimeout = setTimeout(() => {
// ws.debounceTimeout = null
// reconnect(ws)
// }, RECONNECT_TIMEOUT)
// if (callNow) {
// generateWs(ws.url)
// }
}

function initWsConfig(ws: ILLAWebSocket) {
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/auth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface CheckIsLoginWrapperProps {
children: ReactNode
}

export const CheckIsLogin: FC<CheckIsLoginWrapperProps> = (props) => {
export const CheckIsLogin: FC<CheckIsLoginWrapperProps> = props => {
const { children } = props
const navigate = useNavigate()
const token = getLocalStorage("token")
Expand All @@ -31,7 +31,7 @@ export const CheckIsLogin: FC<CheckIsLoginWrapperProps> = (props) => {
url: "/users",
method: "GET",
},
(response) => {
response => {
// TIPS: can check user role
dispatch(
currentUserActions.updateCurrentUserReducer({
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/components/CodeEditor/CodePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function copyToClipboard(content: any) {
Message.success("copied to clipboard")
}

export const CodePreview: FC<CodePreviewProps> = (props) => {
export const CodePreview: FC<CodePreviewProps> = props => {
const { className, preview, ...otherProps } = props

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const formatEvaluate = (data: any) => {
return format
}

const Evaluate: FC<{ type: string; data?: any }> = (props) => {
const Evaluate: FC<{ type: string; data?: any }> = props => {
const { type, data } = props

return (
Expand Down Expand Up @@ -83,7 +83,7 @@ const handleTernCompletions = (data: TypeQueryResult): TransQuery => {
return result
}

export const HintTooltip: FC<HintTooltipProps> = (props) => {
export const HintTooltip: FC<HintTooltipProps> = props => {
const { current: data } = useRef(handleTernCompletions(props.data))
const { globalData: executionResult = {} } = props

Expand Down
6 changes: 3 additions & 3 deletions apps/builder/src/components/CodeEditor/TernSever/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "codemirror/addon/tern/tern"
import "./tern/tern"
import ecmascript from "tern/defs/ecmascript.json"
import CodeMirror from "codemirror"
import ReactDOM from "react-dom"
import { render } from "react-dom"
import { TypeQueryResult } from "tern/lib/tern"
import { isObject } from "@illa-design/system"
import { getValueType } from "@/components/CodeEditor/utils"
Expand Down Expand Up @@ -159,7 +159,7 @@ export const TernServer = (
// @ts-ignore: type define error
completionTip: (completion: TypeQueryResult) => {
let div = document.createElement("div")
ReactDOM.render(<HintTooltip data={completion} />, div)
render(<HintTooltip data={completion} />, div)
return div
},
})
Expand All @@ -171,7 +171,7 @@ export const BaseTern = new CodeMirror.TernServer({
// @ts-ignore: type define error
completionTip: (completion: TypeQueryResult) => {
let div = document.createElement("div")
ReactDOM.render(<HintTooltip data={completion} />, div)
render(<HintTooltip data={completion} />, div)
return div
},
})
19 changes: 10 additions & 9 deletions apps/builder/src/components/CodeEditor/hinter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReactDOM from "react-dom"
import { render } from "react-dom"
import CodeMirror, { Hint, Hints } from "codemirror"
import "codemirror/addon/hint/sql-hint"
import "codemirror/addon/hint/javascript-hint"
Expand All @@ -9,12 +9,13 @@ import { AutoCompleteItem } from "./AutoComplete"

let origJsHint = CodeMirror.hint.javascript
CodeMirror.hint.javascript = async function (cm, option) {
let inner = (await origJsHint(cm, option)) || {
from: cm.getCursor(),
to: cm.getCursor(),
list: [],
}
return inner
return (
(await origJsHint(cm, option)) || {
from: cm.getCursor(),
to: cm.getCursor(),
list: [],
}
)
}

const transHinters = (inner: Hints) => {
Expand All @@ -27,7 +28,7 @@ const transHinters = (inner: Hints) => {
text: item,
render: (elt: HTMLLIElement) => {
let div = document.createElement("div")
ReactDOM.render(<AutoCompleteItem content={item as string} />, div)
render(<AutoCompleteItem content={item as string} />, div)
elt?.appendChild(div)
},
})
Expand Down Expand Up @@ -63,7 +64,7 @@ CodeMirror.hint.xml = async function (cm, option) {

let origHtmlHint = CodeMirror.hint.html
CodeMirror.hint.html = async function (cm, option) {
let inner = (await origXmlHint(cm, option)) || {
let inner = (await origHtmlHint(cm, option)) || {
from: cm.getCursor(),
to: cm.getCursor(),
list: [],
Expand Down
24 changes: 9 additions & 15 deletions apps/builder/src/components/CodeEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React, {
FC,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from "react"
import { css, Global } from "@emotion/react"
/* eslint-disable */
import { FC, useContext, useEffect, useRef, useState } from "react"
import { Global } from "@emotion/react"
import { debounce, get } from "lodash"
import CodeMirror, { Editor } from "codemirror"
import "codemirror/lib/codemirror.css"
Expand Down Expand Up @@ -36,7 +30,7 @@ import {
import { clearMarks, lineMarker } from "@/components/CodeEditor/lintHelper"
import { VALIDATION_TYPES } from "@/utils/validationFactory"

export const CodeEditor: FC<CodeEditorProps> = props => {
export const CodeEditor: FC<CodeEditorProps> = (props) => {
const {
className,
mode = "TEXT_JS",
Expand Down Expand Up @@ -83,7 +77,7 @@ export const CodeEditor: FC<CodeEditorProps> = props => {
setFocus(true)
}

const handleBlur = (instance: Editor, event: FocusEvent) => {
const handleBlur = () => {
latestProps.current?.onBlur?.()
setFocus(false)
setPreviewVisible(false)
Expand Down Expand Up @@ -127,10 +121,10 @@ export const CodeEditor: FC<CodeEditorProps> = props => {
const error = get(executionError, path)
const result = get(executionResult, path)
if (error) {
const evalError = error?.find(item => {
const evalError = error?.find((item) => {
return item.errorType !== "LINT"
})
const lintError = error?.find(item => {
const lintError = error?.find((item) => {
return item.errorType === "LINT"
})
if (evalError) {
Expand All @@ -154,7 +148,7 @@ export const CodeEditor: FC<CodeEditorProps> = props => {
}
}, [executionError, executionResult, path])

const handleChange = (editor: Editor, change: CodeMirror.EditorChange) => {
const handleChange = (editor: Editor) => {
const currentValue = editor?.getValue()
clearMarks(editor)
if (path) {
Expand Down Expand Up @@ -298,7 +292,7 @@ export const CodeEditor: FC<CodeEditorProps> = props => {
content={<CodePreview preview={preview} />}
showArrow={false}
colorScheme="white"
onVisibleChange={visible => {
onVisibleChange={(visible) => {
if (visible !== previewVisible && focus) {
setPreviewVisible(true)
}
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/components/CodeEditor/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum EditorModes {
SQL_JS = "sql-js",
XML_JS = "xml-js",
HTML_JS = "html-js",
Postgre_SQL_JS = "postgre_sql_js",
}

export type EditorMode = keyof typeof EditorModes
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/components/CodeEditor/lintHelper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReactDOM from "react-dom"
import { render } from "react-dom"
import { JSHINT } from "jshint"
import { Editor } from "codemirror"
import "codemirror/addon/lint/lint"
Expand All @@ -15,7 +15,7 @@ const GUTTER_ID = "CodeMirror-lint-markers"
export const lineMarker = (cm: Editor, line: number) => {
cm.clearGutter(GUTTER_ID)
const div = document.createElement("div")
ReactDOM.render(
render(
<div className={"CodeMirror-lint-marker CodeMirror-lint-marker-error"} />,
div,
)
Expand Down
Loading

0 comments on commit e6e01b0

Please sign in to comment.