diff --git a/apps/builder/src/api/base.ts b/apps/builder/src/api/base.ts index 440bd1c2ce..8a9b8cef13 100644 --- a/apps/builder/src/api/base.ts +++ b/apps/builder/src/api/base.ts @@ -25,7 +25,7 @@ const axios = Axios.create({ }) axios.interceptors.request.use( - (config) => { + config => { addRequestPendingPool(config) const token = getLocalStorage("token") if (token) { @@ -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 @@ -80,7 +80,7 @@ export class Api { errorState?.(false) axios .request, RequestBody>(config) - .then((response) => { + .then(response => { loading?.(false) errorState?.(false) success?.(response) diff --git a/apps/builder/src/api/helpers/axiosPendingPool.tsx b/apps/builder/src/api/helpers/axiosPendingPool.tsx index 539be68d67..cc1893617c 100644 --- a/apps/builder/src/api/helpers/axiosPendingPool.tsx +++ b/apps/builder/src/api/helpers/axiosPendingPool.tsx @@ -12,7 +12,7 @@ export const generateUniqueKey = (config: AxiosRequestConfig) => ].join("/") export const clearRequestPendingPool = () => { - pendingPollMap.forEach((cancel) => { + pendingPollMap.forEach(cancel => { cancel?.() }) pendingPollMap.clear() diff --git a/apps/builder/src/api/ws/index.ts b/apps/builder/src/api/ws/index.ts index 44b096856a..261a060fd8 100644 --- a/apps/builder/src/api/ws/index.ts +++ b/apps/builder/src/api/ws/index.ts @@ -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) { diff --git a/apps/builder/src/auth/index.tsx b/apps/builder/src/auth/index.tsx index ed4912d011..71127ff05d 100644 --- a/apps/builder/src/auth/index.tsx +++ b/apps/builder/src/auth/index.tsx @@ -12,7 +12,7 @@ interface CheckIsLoginWrapperProps { children: ReactNode } -export const CheckIsLogin: FC = (props) => { +export const CheckIsLogin: FC = props => { const { children } = props const navigate = useNavigate() const token = getLocalStorage("token") @@ -31,7 +31,7 @@ export const CheckIsLogin: FC = (props) => { url: "/users", method: "GET", }, - (response) => { + response => { // TIPS: can check user role dispatch( currentUserActions.updateCurrentUserReducer({ diff --git a/apps/builder/src/components/CodeEditor/CodePreview.tsx b/apps/builder/src/components/CodeEditor/CodePreview.tsx index 35f3ec4a5e..0ee7b9bec3 100644 --- a/apps/builder/src/components/CodeEditor/CodePreview.tsx +++ b/apps/builder/src/components/CodeEditor/CodePreview.tsx @@ -24,7 +24,7 @@ function copyToClipboard(content: any) { Message.success("copied to clipboard") } -export const CodePreview: FC = (props) => { +export const CodePreview: FC = props => { const { className, preview, ...otherProps } = props return ( diff --git a/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx b/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx index 1b87eba2a6..c9182315d2 100644 --- a/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx +++ b/apps/builder/src/components/CodeEditor/TernSever/HintTooltip/index.tsx @@ -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 ( @@ -83,7 +83,7 @@ const handleTernCompletions = (data: TypeQueryResult): TransQuery => { return result } -export const HintTooltip: FC = (props) => { +export const HintTooltip: FC = props => { const { current: data } = useRef(handleTernCompletions(props.data)) const { globalData: executionResult = {} } = props diff --git a/apps/builder/src/components/CodeEditor/TernSever/index.tsx b/apps/builder/src/components/CodeEditor/TernSever/index.tsx index d630cce0d0..36cd2f9d28 100644 --- a/apps/builder/src/components/CodeEditor/TernSever/index.tsx +++ b/apps/builder/src/components/CodeEditor/TernSever/index.tsx @@ -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" @@ -159,7 +159,7 @@ export const TernServer = ( // @ts-ignore: type define error completionTip: (completion: TypeQueryResult) => { let div = document.createElement("div") - ReactDOM.render(, div) + render(, div) return div }, }) @@ -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(, div) + render(, div) return div }, }) diff --git a/apps/builder/src/components/CodeEditor/hinter.tsx b/apps/builder/src/components/CodeEditor/hinter.tsx index f87d90300c..2e305a4248 100644 --- a/apps/builder/src/components/CodeEditor/hinter.tsx +++ b/apps/builder/src/components/CodeEditor/hinter.tsx @@ -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" @@ -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) => { @@ -27,7 +28,7 @@ const transHinters = (inner: Hints) => { text: item, render: (elt: HTMLLIElement) => { let div = document.createElement("div") - ReactDOM.render(, div) + render(, div) elt?.appendChild(div) }, }) @@ -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: [], diff --git a/apps/builder/src/components/CodeEditor/index.tsx b/apps/builder/src/components/CodeEditor/index.tsx index 3019087670..b010c98ac6 100644 --- a/apps/builder/src/components/CodeEditor/index.tsx +++ b/apps/builder/src/components/CodeEditor/index.tsx @@ -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" @@ -36,7 +30,7 @@ import { import { clearMarks, lineMarker } from "@/components/CodeEditor/lintHelper" import { VALIDATION_TYPES } from "@/utils/validationFactory" -export const CodeEditor: FC = props => { +export const CodeEditor: FC = (props) => { const { className, mode = "TEXT_JS", @@ -83,7 +77,7 @@ export const CodeEditor: FC = props => { setFocus(true) } - const handleBlur = (instance: Editor, event: FocusEvent) => { + const handleBlur = () => { latestProps.current?.onBlur?.() setFocus(false) setPreviewVisible(false) @@ -127,10 +121,10 @@ export const CodeEditor: FC = 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) { @@ -154,7 +148,7 @@ export const CodeEditor: FC = props => { } }, [executionError, executionResult, path]) - const handleChange = (editor: Editor, change: CodeMirror.EditorChange) => { + const handleChange = (editor: Editor) => { const currentValue = editor?.getValue() clearMarks(editor) if (path) { @@ -298,7 +292,7 @@ export const CodeEditor: FC = props => { content={} showArrow={false} colorScheme="white" - onVisibleChange={visible => { + onVisibleChange={(visible) => { if (visible !== previewVisible && focus) { setPreviewVisible(true) } diff --git a/apps/builder/src/components/CodeEditor/interface.ts b/apps/builder/src/components/CodeEditor/interface.ts index 80294c2b2b..fffaa9b84e 100644 --- a/apps/builder/src/components/CodeEditor/interface.ts +++ b/apps/builder/src/components/CodeEditor/interface.ts @@ -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 diff --git a/apps/builder/src/components/CodeEditor/lintHelper.tsx b/apps/builder/src/components/CodeEditor/lintHelper.tsx index 5d828f3006..dab08c4cd2 100644 --- a/apps/builder/src/components/CodeEditor/lintHelper.tsx +++ b/apps/builder/src/components/CodeEditor/lintHelper.tsx @@ -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" @@ -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, ) diff --git a/apps/builder/src/components/CodeEditor/modes.ts b/apps/builder/src/components/CodeEditor/modes.ts index 36caf8f10b..e6102843e7 100644 --- a/apps/builder/src/components/CodeEditor/modes.ts +++ b/apps/builder/src/components/CodeEditor/modes.ts @@ -1,4 +1,4 @@ -import CodeMirror from "codemirror" +import { defineMode, getMode, multiplexingMode } from "codemirror" import "codemirror/addon/mode/multiplex" import "codemirror/mode/javascript/javascript" import "codemirror/mode/htmlmixed/htmlmixed" @@ -11,78 +11,79 @@ import "codemirror/addon/hint/javascript-hint" import { EditorModes } from "./interface" -CodeMirror.defineMode(EditorModes.TEXT_JS, function (config) { - return CodeMirror.multiplexingMode( - CodeMirror.getMode(config, EditorModes.TEXT), - { - open: "{{", - close: "}}", - mode: CodeMirror.getMode(config, { - name: "application/json", - }), - delimStyle: "illa-expression", - innerStyle: "illa-expression", - parseDelimiters: false, - }, - ) +defineMode(EditorModes.Postgre_SQL_JS, function (config) { + return multiplexingMode(getMode(config, { name: "text/x-pgsql" }), { + open: "{{", + close: "}}", + mode: getMode(config, { + name: "application/json", + }), + delimStyle: "illa-expression", + innerStyle: "illa-expression", + parseDelimiters: false, + }) }) -CodeMirror.defineMode(EditorModes.SQL_JS, function (config) { - return CodeMirror.multiplexingMode( - CodeMirror.getMode(config, { name: "text/x-mysql" }), - { - open: "{{", - close: "}}", - mode: CodeMirror.getMode(config, { - name: "application/json", - }), - delimStyle: "illa-expression", - innerStyle: "illa-expression", - parseDelimiters: false, - }, - ) +defineMode(EditorModes.TEXT_JS, function (config) { + return multiplexingMode(getMode(config, EditorModes.TEXT), { + open: "{{", + close: "}}", + mode: getMode(config, { + name: "application/json", + }), + delimStyle: "illa-expression", + innerStyle: "illa-expression", + parseDelimiters: false, + }) }) -CodeMirror.defineMode(EditorModes.XML_JS, function (config) { - return CodeMirror.multiplexingMode( - CodeMirror.getMode(config, { name: "application/xml" }), - { - open: "{{", - close: "}}", - mode: CodeMirror.getMode(config, { - name: "application/json", - }), - delimStyle: "illa-expression", - innerStyle: "illa-expression", - parseDelimiters: false, - }, - ) +defineMode(EditorModes.SQL_JS, function (config) { + return multiplexingMode(getMode(config, { name: "text/x-mysql" }), { + open: "{{", + close: "}}", + mode: getMode(config, { + name: "application/json", + }), + delimStyle: "illa-expression", + innerStyle: "illa-expression", + parseDelimiters: false, + }) }) -CodeMirror.defineMode(EditorModes.HTML_JS, function (config) { - return CodeMirror.multiplexingMode( - CodeMirror.getMode(config, { name: "text/html" }), - { - open: "{{", - close: "}}", - mode: CodeMirror.getMode(config, { - name: "application/json", - }), - delimStyle: "illa-expression", - innerStyle: "illa-expression", - parseDelimiters: false, - }, - ) +defineMode(EditorModes.XML_JS, function (config) { + return multiplexingMode(getMode(config, { name: "application/xml" }), { + open: "{{", + close: "}}", + mode: getMode(config, { + name: "application/json", + }), + delimStyle: "illa-expression", + innerStyle: "illa-expression", + parseDelimiters: false, + }) +}) + +defineMode(EditorModes.HTML_JS, function (config) { + return multiplexingMode(getMode(config, { name: "text/html" }), { + open: "{{", + close: "}}", + mode: getMode(config, { + name: "application/json", + }), + delimStyle: "illa-expression", + innerStyle: "illa-expression", + parseDelimiters: false, + }) }) -CodeMirror.defineMode(EditorModes.JAVASCRIPT, function (config) { - return CodeMirror.multiplexingMode( - CodeMirror.getMode(config, { +defineMode(EditorModes.JAVASCRIPT, function (config) { + return multiplexingMode( + getMode(config, { name: "application/javascript", }), { open: "{{", close: "}}", - mode: CodeMirror.getMode(config, { + mode: getMode(config, { name: "application/json", }), delimStyle: "illa-expression", @@ -92,9 +93,9 @@ CodeMirror.defineMode(EditorModes.JAVASCRIPT, function (config) { ) }) -CodeMirror.defineMode(EditorModes.JSON, function (config) { - return CodeMirror.multiplexingMode( - CodeMirror.getMode(config, { +defineMode(EditorModes.JSON, function (config) { + return multiplexingMode( + getMode(config, { name: "application/json", json: true, jsonld: true, @@ -102,7 +103,7 @@ CodeMirror.defineMode(EditorModes.JSON, function (config) { { open: "{{", close: "}}", - mode: CodeMirror.getMode(config, { + mode: getMode(config, { name: "application/json", }), delimStyle: "illa-expression", diff --git a/apps/builder/src/components/CodeEditor/style.ts b/apps/builder/src/components/CodeEditor/style.ts index a43c599182..7b77fbfc05 100644 --- a/apps/builder/src/components/CodeEditor/style.ts +++ b/apps/builder/src/components/CodeEditor/style.ts @@ -200,3 +200,7 @@ export const contentTextStyle = css` font-weight: 400; word-wrap: break-word; ` + +export const containerStyle = css` + overflow: scroll; +` \ No newline at end of file diff --git a/apps/builder/src/components/EditableText/index.tsx b/apps/builder/src/components/EditableText/index.tsx index 74562c16dc..4fa29900b1 100644 --- a/apps/builder/src/components/EditableText/index.tsx +++ b/apps/builder/src/components/EditableText/index.tsx @@ -8,7 +8,7 @@ import { EditableTextWrapperStyle, textStyle } from "./style" import { isValidDisplayName } from "@/utils/typeHelper" import { DisplayNameGenerator } from "@/utils/generators/generateDisplayName" -export const EditableText: FC = (props) => { +export const EditableText: FC = props => { const { displayName, updateDisplayNameByBlur } = props const [inputValue, setInputValue] = useState(displayName) const [isFocusInput, setIsFocusInput] = useState(false) diff --git a/apps/builder/src/components/JSONViewer/index.tsx b/apps/builder/src/components/JSONViewer/index.tsx index 46d9cace67..49e41b6bfd 100644 --- a/apps/builder/src/components/JSONViewer/index.tsx +++ b/apps/builder/src/components/JSONViewer/index.tsx @@ -3,7 +3,7 @@ import ReactJson from "react-json-view" import { JSONViewerProps } from "./interface" import { jsonViewContainer } from "./style" -export const JSONViewer: FC = (props) => { +export const JSONViewer: FC = props => { const { data = {}, collapsed } = props const reactJsonConfig = { diff --git a/apps/builder/src/constants/regExp.ts b/apps/builder/src/constants/regExp.ts index f8ad464220..1a737304f6 100644 --- a/apps/builder/src/constants/regExp.ts +++ b/apps/builder/src/constants/regExp.ts @@ -1,2 +1 @@ -export const EMAIL_FORMAT = - /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/ +export const EMAIL_FORMAT = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/ diff --git a/apps/builder/src/hooks/useInitApp.tsx b/apps/builder/src/hooks/useInitApp.tsx index c7a2feced0..54dc91248d 100644 --- a/apps/builder/src/hooks/useInitApp.tsx +++ b/apps/builder/src/hooks/useInitApp.tsx @@ -28,7 +28,7 @@ export const useInitBuilderApp = (model: IllaMode) => { method: "GET", signal: controller.signal, }, - (response) => { + response => { dispatch(configActions.updateIllaMode(model)) dispatch(appInfoActions.updateAppInfoReducer(response.data.appInfo)) dispatch( @@ -57,9 +57,9 @@ export const useInitBuilderApp = (model: IllaMode) => { dispatch(configActions.changeSelectedAction(response.data.actions[0])) } }, - (e) => {}, - (e) => {}, - (loading) => { + e => {}, + e => {}, + loading => { setLoadingState(loading) }, ) diff --git a/apps/builder/src/i18n/locale/en-US.json b/apps/builder/src/i18n/locale/en-US.json index d6465de58f..b54cf39d39 100644 --- a/apps/builder/src/i18n/locale/en-US.json +++ b/apps/builder/src/i18n/locale/en-US.json @@ -4,6 +4,7 @@ "exit_preview": "Exit Preview", "edit": "Edit", "edit_at": "Edited at", + "created_at": "Created at", "title": "Welcome to illa", "description": { "part1": "This is an example without namespaces." @@ -186,8 +187,9 @@ "valid_name": "Can only contain letters, numbers, '_' or '$', start with '_' or a letter", "load_action_list_fail": "Failed to get Action list: {{message}}", "load_resource_fail": "Failed to get resource list: {{message}}", - "success_created": "Successfully created!", - "success_saved": "Successfully saved!", + "success_created": "Successfully created", + "success_saved": "Successfully saved", + "success_deleted": "Successfully deleted", "failed": "Failed to connect to server" }, "action_generator": { @@ -263,8 +265,7 @@ "btn": { "back": "Back", "test_connection": "Test Connection", - "create_resource": "Create Resource", - "save_changes": "Save Changes" + "save_changes": "Save Resource" }, "validate": { "required": "{name} is required" @@ -279,14 +280,10 @@ "external_reference": "You can create external references to variables you've defined. For example, {{ transformer2.value }}. " } }, - "js_transformer": { - "name": "Transformer" - }, "label": { "coming_soon": "Coming Soon" }, "mysql": { - "name": "MySQL", "title": { "advanced_option": "Advanced Options" }, @@ -296,22 +293,46 @@ "database": "Database", "username_password": "Username/Password", "connect_type": "Connect Type", - "connect_over_ssh": "Connect over SSH", - "ssh_hostname_port": "SSH Hostname/Port", - "ssh_credentials": "SSH Credentials", "private_key": "Private Key", - "ssh_passphrase": "SSH passphrase", "ssl_options": "SSL options", - "server_root_certificate": "Server Root Certificate", + "ca_certificate": "CA Cert", + "client_key": "Client Key", + "client_certificate": "Client Cert" + }, + "tip": { + "username_password": "Credentials will be encrypted & stored securely on our servers.", + "connect_type": "Cloud: ILLA servers will securely connect to your database.", + "ssl_options": "SSL is used when available" + }, + "placeholder": { + "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", + "hostname": "Hostname", + "database": "acme_production", + "username": "Username", + "password": "Password", + "certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" + } + }, + "postgresql": { + "title": { + "advanced_option": "Advanced Options" + }, + "label": { + "name": "Name", + "hostname_port": "Hostname/Port", + "database": "Database", + "username_password": "Username/Password", + "connect_type": "Connect Type", + "private_key": "Private Key", + "ssl_options": "SSL options", + "ca_certificate": "CA Cert", "client_key": "Client Key", - "client_certificate": "Client Certificate" + "client_certificate": "Client Cert" }, "tip": { "username_password": "Credentials will be encrypted & stored securely on our servers.", "connect_type": "Cloud: ILLA servers will securely connect to your database.", - "connect_over_ssh": "Useful to connect to private network", - "ssl_options": "SSL is used when available", - "ssh_passphrase": "used if provided" + "ssl_options": "SSL is used when available" }, "placeholder": { "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", @@ -319,16 +340,13 @@ "database": "acme_production", "username": "Username", "password": "Password", - "ssh_hostname_port": "e.g.localhost", - "ssh_credentials": "e.g.ec2-user", - "private_key": "e.g.path/to/root.crt", - "server_root_certificate": "e.g.path/to/root.crt", - "client_key": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----", - "client_certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" + "certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" } }, "restapi": { - "name": "REST API", + "title": { + "advanced_option": "GENERAL" + }, "label": { "name": "Name", "action_type": "Action Type", @@ -370,8 +388,6 @@ "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", "api": "i.e.\"Internal Admin API\"", "database": "i.e.\"Users DB(readonly)\"", - "action_url_path_with_base_url": "api/v2/endpoint.json", - "action_url_path": "http://www.api.com/api/v2/endpoint.json", "base_url": "Use the absolute URL (e.g https://example.com)", "username": "username", "password": "password", @@ -394,14 +410,35 @@ "new": "New" } }, - "postgres": { - "name": "Postgres" - }, "redis": { - "name": "Redis" - }, - "mongodb": { - "name": "MongoDB" + "title": { + "advanced_option": "Advanced Options" + }, + "label": { + "name": "Name", + "hostname_port": "Hostname/Port", + "database": "Database", + "username_password": "Username/Password", + "connect_type": "Connect Type", + "private_key": "Private Key", + "ssl_options": "SSL options", + "ca_certificate": "CA Cert", + "client_key": "Client Key", + "client_certificate": "Client Cert" + }, + "tip": { + "username_password": "Credentials will be encrypted & stored securely on our servers.", + "connect_type": "Cloud: ILLA servers will securely connect to your database.", + "ssl_options": "SSL is used when available" + }, + "placeholder": { + "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", + "hostname": "Hostname", + "database": "acme_production", + "username": "Username", + "password": "Password", + "certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" + } } }, "result": { @@ -451,6 +488,11 @@ "style": "STYLE", "validation": "VALIDATION", "options": "OPTIONS", + "column": "COLUMNS", + "sort": "SORT", + "row_selection": "ROW SELECTION", + "pagination": "PAGINATION", + "toolbar": "TOOLBAR", "data": "DATA" }, "setter_label": { @@ -564,13 +606,25 @@ "remove": "Remove dataset", "aggregation_method": "Aggregation method" }, + "sort": "Sort", + "default_sort_key": "Column", + "default_sort_order": "Direction", + "column_title": "Column title", + "column_type": "Column type", + "enable_sorting": "Enable Sorting", + "decimal_places": "Decimal places", + "multi_row_selection": "Multi-Row Selection", + "overFlow": "OverFlow", + "download": "Download", + "filter": "Filter", "new_tab": "New tab", "description": "Description", "duration": "Duration", "data": "Data", + "empty_state": "Empty state", "chart_title": "Title", "x_axis_name": "X-axis name", - "Y_axis_name": "Y-axis name" + "y_axis_name": "Y-axis name" }, "setter_tooltip": { "default_value": "The initial value of the input box. You can dynamically change the initial value of the input field by typing JavaScript in {{}}.", @@ -592,7 +646,9 @@ "loading": "Whether the component should show a loading indicator.", "progress_percentage": "The percentage value is between 0 and 100", "timeline_direction": "Change the direction of the timeline.", - "only_run_when": "Conditions that must be met before the event executes" + "only_run_when": "Conditions that must be met before the event executes", + "download": "Show download button in toolbar", + "filter": "Show filter button in toolbar" }, "setter_default_value": { "fill": "Fill", @@ -610,6 +666,11 @@ } }, "setter_content": { + "column_setter": { + "label": "Columns ({{number}})", + "title": "Title", + "new": "New" + }, "option_list": { "action_menu": { "delete": "Delete", @@ -634,6 +695,9 @@ "prefabricated": "Prefabricated color" }, "widget_action_type_name": { + "sortingChange": "Sort change", + "paginationChange": "Page change", + "columnFiltersChange": "Filter change", "click": "Click", "change": "Change", "focus": "Focus", @@ -747,7 +811,11 @@ "name": "Chart" }, "table": { - "name": "Table" + "name": "Table", + "pagination": "Pagination", + "scroll": "Scroll", + "ascend": "Asc", + "descend": "Desc" } }, "Setting": "Setting", @@ -787,14 +855,15 @@ "delete_success": "Deleted successfully", "delete_fail": "Failed to delete", "create_resource": "Create New", - "create_success": "Create Success!", - "edit_success": "Edit Success" + "save_success": "Save successfully", + "save_fail": "Failed to save", + "test_success": "Test successfully", + "test_fail": "Failed to test" } }, "setting": { "account": { "email": "Email", - "uneditable": "uneditable", "title": "ACCOUNT", "username": "Username", "empty_username": "Please enter your username", diff --git a/apps/builder/src/i18n/locale/zh-CN.json b/apps/builder/src/i18n/locale/zh-CN.json index fd0e5e595c..425683c784 100644 --- a/apps/builder/src/i18n/locale/zh-CN.json +++ b/apps/builder/src/i18n/locale/zh-CN.json @@ -4,6 +4,7 @@ "exit_preview": "退出预览", "edit": "编辑", "edit_at": "上次编辑于", + "created_at": "创建于", "title": "欢迎来到艾拉云", "description": { "part1": "这是一个示例。" @@ -186,8 +187,9 @@ "valid_name": "仅能包含字母,数字,'_' 或 '$', 请以 '_' 或字母开头", "load_action_list_fail": "获取 Action 列表失败: {{message}}", "load_resource_fail": "获取资源列表失败: {{message}}", - "success_created": "创建成功!", - "success_saved": "保存成功!", + "success_created": "创建成功", + "success_saved": "保存成功", + "success_deleted": "删除成功", "failed": "服务器连接失败" }, "action_generator": { @@ -230,8 +232,9 @@ "run": "运行", "save": "保存", "save_and_run": "保存 & 运行", - "disable": "禁用", - "enable": "使用", + "save_fail": "保存失败", + "disable": "关闭", + "enable": "开启", "new": "新增" }, "menu": { @@ -262,8 +265,7 @@ "btn": { "back": "后退", "test_connection": "测试连接", - "create_resource": "创建资源", - "save_changes": "保存修改" + "save_changes": "保存资源" }, "validate": { "required": "请输入{name}" @@ -278,14 +280,10 @@ "external_reference": "您可以创建对已定义变量的外部引用。 例如 {{ transformer2.value }}" } }, - "js_transformer": { - "name": "Transformer" - }, "label": { "coming_soon": "即将更新" }, "mysql": { - "name": "MySQL", "title": { "advanced_option": "高级配置" }, @@ -295,22 +293,16 @@ "database": "数据库名称", "username_password": "用户名/密码", "connect_type": "连接类型", - "connect_over_ssh": "通过 SSH 连接", - "ssh_hostname_port": "SSH 主机名/端口", - "ssh_credentials": "SSH 凭证", "private_key": "私钥", - "ssh_passphrase": "SSH 密码", "ssl_options": "SSL 选项", - "server_root_certificate": "服务器根证书", + "ca_certificate": "服务端证书", "client_key": "客户端密钥", "client_certificate": "客户端证书" }, "tip": { "username_password": "凭证将被加密并安全存储在我们的服务器上", "connect_type": "云服务器: ILLA 服务器将安全地连接到您的数据库", - "connect_over_ssh": "用于连接到专用网络", - "ssl_options": "可用时使用 SSL", - "ssh_passphrase": "如果提供则使用" + "ssl_options": "可用时使用 SSL" }, "placeholder": { "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", @@ -318,16 +310,43 @@ "database": "acme_production", "username": "用户名", "password": "密码", - "ssh_hostname_port": "e.g.localhost", - "ssh_credentials": "e.g.ec2-user", - "private_key": "e.g.path/to/root.crt", - "server_root_certificate": "e.g.path/to/root.crt", - "client_key": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----", - "client_certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" + "certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" + } + }, + "postgresql": { + "title": { + "advanced_option": "高级配置" + }, + "label": { + "name": "名称", + "hostname_port": "主机/端口", + "database": "数据库名称", + "username_password": "用户名/密码", + "connect_type": "连接类型", + "private_key": "私钥", + "ssl_options": "SSL 选项", + "ca_certificate": "服务端证书", + "client_key": "客户端密钥", + "client_certificate": "客户端证书" + }, + "tip": { + "username_password": "凭证将被加密并安全存储在我们的服务器上", + "connect_type": "云服务器: ILLA 服务器将安全地连接到您的数据库", + "ssl_options": "可用时使用 SSL" + }, + "placeholder": { + "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", + "hostname": "主机名", + "database": "acme_production", + "username": "用户名", + "password": "密码", + "certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" } }, "restapi": { - "name": "REST API", + "title": { + "advanced_option": "通用" + }, "label": { "name": "名称", "action_type": "Action type", @@ -361,7 +380,7 @@ }, "tip": { "get_req_auto_run": "(GET 请求) 当参数改变时会自动执行", - "name": "在 ILLA 中创建 actions 时的资源名称", + "name": "在 ILLA 中创建 Action 时的资源名称", "extra_body_values": "Extra body values are not passed for GET or HEAD requests", "configure_oauth2": "OAuth 2.0 is a complex spec. ILLA currently supports the server-side OAuth 2.0 authentication flow as well as the Client Credentials flow. In both cases, you must use the OAUTH2_TOKEN placeholder in order to inform ILLA where to place the OAuth access token in the API request. A common location for this is as a header such as Authorization: Bearer OAUTH2_TOKEN." }, @@ -369,8 +388,6 @@ "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", "api": "i.e.\"Internal Admin API\"", "database": "i.e.\"Users DB(readonly)\"", - "action_url_path_with_base_url": "api/v2/endpoint.json", - "action_url_path": "http://www.api.com/api/v2/endpoint.json", "base_url": "请使用绝对 URL (e.g https://example.com)", "username": "用户名", "password": "密码", @@ -393,14 +410,35 @@ "new": "新增" } }, - "postgres": { - "name": "Postgres" - }, "redis": { - "name": "Redis" - }, - "mongodb": { - "name": "MongoDB" + "title": { + "advanced_option": "高级配置" + }, + "label": { + "name": "名称", + "hostname_port": "主机/端口", + "database": "数据库名称", + "username_password": "用户名/密码", + "connect_type": "连接类型", + "private_key": "私钥", + "ssl_options": "SSL 选项", + "ca_certificate": "服务端证书", + "client_key": "客户端密钥", + "client_certificate": "客户端证书" + }, + "tip": { + "username_password": "凭证将被加密并安全存储在我们的服务器上", + "connect_type": "云服务器: ILLA 服务器将安全地连接到您的数据库", + "ssl_options": "可用时使用 SSL" + }, + "placeholder": { + "name": "i.e.\"Users DB(readonly)\" or \"Internal Admin API\"", + "hostname": "主机名", + "database": "acme_production", + "username": "用户名", + "password": "密码", + "certificate": "-----BEGIN CERTIFICATE-----\nMIIEMDCCApigAwIBAgIDI2GWMA0GCSqGSIb3DQEBDAUAMDoxODA2BgNVBAMML2Fm\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\nDTE5MDQwODAzNDIyMloXDTI5MDQwNTAzNDIyMlowOjE4MDYGA1UEAwwvYWY1ZjU4\n...\n-----END CERTIFICATE-----" + } } }, "result": { @@ -450,6 +488,10 @@ "style": "风格", "validation": "验证", "options": "选项", + "column": "列", + "row_selection": "行选择", + "pagination": "翻页", + "toolbar": "工具栏", "data": "数据" }, "setter_label": { @@ -563,10 +605,21 @@ "remove": "移除数据集", "aggregation_method": "聚合方式" }, + "sort": "排序", + "default_sort_key": "排序列", + "default_sort_order": "顺序", + "column_title": "列标题", + "enable_sorting": "排序", + "decimal_places": "小数位数", + "multi_row_selection": "多行选择", + "overFlow": "翻页方式", + "download": "下载", + "filter": "筛选", "new_tab": "在新标签中打开", "description": "描述", "duration": "持续时间", "data": "数据", + "empty_state": "空状态", "chart_title": "标题", "x_axis_name": "横坐标名称", "y_axis_name": "纵坐标名称" @@ -591,7 +644,9 @@ "loading": "控制组件是否为加载状态。", "progress_percentage": "进度条的数值范围为 0-100", "timeline_direction": "切换时间轴的方向", - "only_run_when": "在此输入该事件执行前必须满足的条件" + "only_run_when": "在此输入该事件执行前必须满足的条件", + "download": "在工具栏显示下载按钮", + "filter": "在工具栏显示筛选按钮" }, "setter_default_value": { "fill": "填充", @@ -609,6 +664,11 @@ } }, "setter_content": { + "column_setter": { + "label": "列 ({{number}})", + "title": "标题", + "new": "新建" + }, "option_list": { "action_menu": { "delete": "删除", @@ -633,6 +693,9 @@ "prefabricated": "Prefabricated color" }, "widget_action_type_name": { + "sortingChange": "排序方式改变", + "paginationChange": "翻页配置改变", + "columnFiltersChange": "行筛选改变", "click": "单击", "change": "内容改变", "focus": "聚焦", @@ -694,8 +757,7 @@ "name": "日期选择器" }, "date_range": { - "name": "日期范围选择器", - "start_date": "Start date" + "name": "Date range" }, "image": { "name": "图片" @@ -712,6 +774,12 @@ "switch": { "name": "开关" }, + "circle_progress": { + "name": "圆形进度条" + }, + "bar_progress": { + "name": "条形进度条" + }, "rate": { "name": "评分" }, @@ -719,12 +787,6 @@ "name": "日期时间选择器", "placeholder": "请选择时间" }, - "circle_progress": { - "name": "环形进度条" - }, - "bar_progress": { - "name": "进度条" - }, "divider_progress": { "name": "分割线" }, @@ -747,7 +809,11 @@ "name": "图表" }, "table": { - "name": "表格" + "name": "表格", + "pagination": "翻页", + "scroll": "滚动", + "ascend": "升序", + "descend": "降序" } }, "Setting": "设置", @@ -787,8 +853,10 @@ "delete_success": "删除成功", "delete_fail": "删除失败", "create_resource": "创建资源", - "create_success": "创建成功!", - "edit_success": "修改成功" + "save_success": "保存成功", + "save_fail": "保存失败", + "test_success": "测试成功", + "test_fail": "测试失败" } }, "setting": { diff --git a/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/index.tsx b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/index.tsx new file mode 100644 index 0000000000..f5f6aa5614 --- /dev/null +++ b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/index.tsx @@ -0,0 +1,32 @@ +import { FC } from "react" +import { ActionTypeSelectorCardProps } from "./interface" +import { applyItemStyle, comingStyle, nameStyle } from "./style" +import { getIconFromActionType } from "@/page/App/components/Actions/getIcon" +import { useTranslation } from "react-i18next" +import { getActionNameFromActionType } from "@/utils/actionResourceTransformer" + +export const ActionCard: FC = (props) => { + const { actionType, onSelect, isDraft } = props + const { t } = useTranslation() + + return ( +
{ + if (!isDraft) { + onSelect?.(actionType) + } + }} + > + {getIconFromActionType(actionType, "24px")} + {getActionNameFromActionType(actionType)} + {isDraft && ( + + {t("editor.action.resource.label.coming_soon")} + + )} +
+ ) +} + +ActionCard.displayName = "ActionCard" diff --git a/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/interface.ts b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/interface.ts new file mode 100644 index 0000000000..4eb4525327 --- /dev/null +++ b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/interface.ts @@ -0,0 +1,6 @@ +import { ActionDataItem } from "@/page/App/components/Actions/ActionGenerator/config" +import { ActionType } from "@/redux/currentApp/action/actionState" + +export interface ActionTypeSelectorCardProps extends ActionDataItem { + onSelect?: (item: ActionType) => void +} diff --git a/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/style.ts b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/style.ts new file mode 100644 index 0000000000..980c0ded77 --- /dev/null +++ b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionCard/style.ts @@ -0,0 +1,56 @@ +import { css, SerializedStyles } from "@emotion/react" +import { getColor, globalColor, illaPrefix } from "@illa-design/theme" + +export function applyItemStyle(isDraft: boolean): SerializedStyles { + const draftStyle = isDraft + ? css` + pointer-events: auto; + cursor: not-allowed; + ` + : css`` + + const hoverStyle = isDraft + ? css`` + : css` + &:hover { + box-shadow: 0 4px 10px 0 + ${globalColor(`--${illaPrefix}-blackAlpha-07`)}; + background-color: ${globalColor(`--${illaPrefix}-techPurple-07`)}; + border-color: ${globalColor(`--${illaPrefix}-techPurple-01`)}; + } + ` + + return css` + flex-direction: column; + justify-content: center; + align-items: center; + padding: 24px 0; + border-radius: 8px; + border: solid 1px ${globalColor(`--${illaPrefix}-grayBlue-08`)}; + position: relative; + display: flex; + background-color: ${globalColor(`--${illaPrefix}-white-01`)}; + cursor: pointer; + transition: all 0.2s ease-in-out; + ${hoverStyle}; + ${draftStyle}; + ` +} + +export const nameStyle = css` + margin-top: 8px; + font-size: 14px; + font-weight: 500; + color: ${globalColor(`--${illaPrefix}-grayBlue-02`)}; +` + +export const comingStyle = css` + position: absolute; + border-radius: 0 0 4px 4px; + padding: 0 8px; + top: 0; + height: 16px; + background-color: ${getColor("techPurple", "07")}; + font-size: 10px; + color: ${getColor("techPurple", "02")}; +` diff --git a/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionResourceCreator/MySQLConfigure/index.tsx b/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionResourceCreator/MySQLConfigure/index.tsx deleted file mode 100644 index b8d474a37f..0000000000 --- a/apps/builder/src/page/App/components/Actions/ActionGenerator/ActionResourceCreator/MySQLConfigure/index.tsx +++ /dev/null @@ -1,329 +0,0 @@ -import { forwardRef, useImperativeHandle, useState } from "react" -import { css } from "@emotion/react" -import { Controller, SubmitHandler, useForm } from "react-hook-form" -import { Input, Password, TextArea } from "@illa-design/input" -import { Switch } from "@illa-design/switch" -import { InputNumber } from "@illa-design/input-number" -import { useSelector } from "react-redux" -import { - connectTextStyle, - descriptionStyle, - errorMessageStyle, - formStyle, - gridContainerStyle, - gridRowContainerStyle, - groupTitleStyle, - labelTextStyle, - requiredLabelTextStyle, - splitLineStyle, - formPaddingStyle, - hostnamePortStyle, - switchAreaStyle, - switchDescriptionStyle, - usernamePasswordStyle, - applyGridColIndex, -} from "./style" -import { MySQLConfigureProps, MySQLConfigureValues } from "./interface" -import i18n from "@/i18n/config" -import { getAllResources } from "@/redux/resource/resourceSelector" -import { MysqlResource } from "@/redux/resource/resourceState" - -export const MySQLConfigure = forwardRef( - (props, ref) => { - const { resourceId, connectionRef, onSubmit, onTestConnection } = props - const resourceConfig = useSelector(getAllResources).find( - (i) => i.resourceId === resourceId, - ) - const [enableSSL, setEnableSSL] = useState( - (resourceConfig?.content as MysqlResource)?.ssl?.ssl, - ) - const { - handleSubmit, - control, - formState: { errors }, - getValues, - trigger, - } = useForm({ - mode: "onChange", - defaultValues: { - resourceName: resourceConfig?.resourceName, - ...resourceConfig?.content, - } || { - port: 3306, - }, - }) - - const testConnection = () => { - const data = getValues() - const { resourceName, ...content } = data - - trigger().then((res)=>{ - if (res) { - onTestConnection?.({ - resourceName: resourceName, - resourceType: "mysql", - content: { - ...content, - port: content.port?.toString(), - }, - }) - } - }) - } - - useImperativeHandle(connectionRef, () => { - { - return { testConnection } - } - }) - - const submitForm: SubmitHandler = (data) => { - const { resourceName, ...content } = data - onSubmit?.({ - resourceName: resourceName, - resourceType: "mysql", - content: { - ...content, - port: content.port?.toString(), - ssh: { ssh: false }, - ssl: { ...content.ssl, ssl: enableSSL }, - }, - }) - } - return ( -
-
-
- - ( - - )} - rules={{ - required: i18n.t("editor.action.form.required") as string, - }} - control={control} - name="resourceName" - /> - {errors.resourceName && ( -
- {errors.resourceName.message} -
- )} -
-
- -
- ( - - )} - control={control} - name="host" - rules={{ - required: i18n.t("editor.action.form.required") as string, - }} - /> - ( - - )} - control={control} - name="port" - rules={{ - required: i18n.t("editor.action.form.required") as string, - }} - /> -
- {(errors.host || errors.port) && ( -
-
{errors.host?.message}
-
{errors.port?.message}
-
- )} -
-
- - ( - - )} - control={control} - name="databaseName" - rules={{ - required: i18n.t("editor.action.form.required") as string, - }} - /> - {errors.databaseName && ( -
- {errors.databaseName.message} -
- )} -
-
- -
- ( - - )} - control={control} - name="databaseUsername" - /> - ( - - )} - control={control} - name="databasePassword" - /> -
-
- {i18n.t("editor.action.resource.mysql.tip.username_password")} -
-
-
- -
- {i18n.t("editor.action.resource.mysql.tip.connect_type")} -
-
-
-

- {i18n.t("editor.action.resource.mysql.title.advanced_option")} -

-
- -
- { - setEnableSSL(val) - }} - /> -
-
- {i18n.t("editor.action.resource.mysql.tip.ssl_options")} -
-
-
-
- {enableSSL && ( - <> -
- - ( - - )} - control={control} - /> -
-
- - ( -