Skip to content

Commit

Permalink
fix(web): function name regex (#1092)
Browse files Browse the repository at this point in the history
* fix(web): update function name regex

* refactor(web): function panel margin
  • Loading branch information
LeezQ authored and maslow committed Apr 27, 2023
1 parent 0e72123 commit 0b933c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions web/src/components/Editor/FunctionEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef } from "react";
import { CSSProperties, useEffect, useRef } from "react";
import { debounce } from "lodash";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";

Expand Down Expand Up @@ -93,6 +93,7 @@ const updateModel = (path: string, value: string, editorRef: any) => {
function FunctionEditor(props: {
value: string;
className?: string;
style?: CSSProperties;
onChange?: (value: string | undefined) => void;
path: string;
height?: string;
Expand All @@ -105,6 +106,7 @@ function FunctionEditor(props: {
path,
height = "100%",
className,
style = {},
colorMode = COLOR_MODE.light,
readOnly = false,
} = props;
Expand Down Expand Up @@ -182,7 +184,7 @@ function FunctionEditor(props: {
}
}, [onChange]);

return <div style={{ height: height }} className={className} ref={monacoEl}></div>;
return <div style={{ height: height, ...style }} className={className} ref={monacoEl}></div>;
}

export default FunctionEditor;
6 changes: 5 additions & 1 deletion web/src/pages/app/functions/mods/EditorPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function EditorPanel() {
<Panel className="flex-1 flex-grow px-0">
{currentFunction?.name ? (
<Panel.Header
className={clsx("!mb-3 h-[50px] px-2", {
className={clsx("!mb-0 h-[50px] px-2", {
"border-b-2": !darkMode,
"border-lafWhite-400": !darkMode,
})}
Expand Down Expand Up @@ -89,6 +89,10 @@ function EditorPanel() {
<FunctionEditor
colorMode={colorMode}
className="flex-grow overflow-hidden"
style={{
marginLeft: -14,
marginRight: -14,
}}
path={currentFunction?.id || ""}
value={functionCache.getCache(currentFunction!.id, currentFunction!.source?.code)}
onChange={(value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const CreateModal = (props: { functionItem?: any; children?: React.ReactElement
<Input
{...register("name", {
pattern: {
value: /^[_A-Za-z][A-Za-z0-9-_]+$/,
value: /^[a-zA-Z0-9_.-]{1,128}$/,
message: t("FunctionPanel.FunctionNameRule"),
},
})}
Expand Down

0 comments on commit 0b933c9

Please sign in to comment.