Skip to content

Commit

Permalink
update: add func
Browse files Browse the repository at this point in the history
  • Loading branch information
LeezQ committed Jan 12, 2023
1 parent 5a8b45e commit 255f5d7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
10 changes: 5 additions & 5 deletions web/src/pages/app/functions/mods/DebugPannel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import useHotKey, { DEFAULT_SHORTCUTS } from "@/hooks/useHotKey";
import useGlobalStore from "@/pages/globalStore";

export default function DebugPanel() {
const { getFunctionDebugUrl, currentFunction, setCurrentRequestId } = useFunctionStore(
const { getFunctionUrl, currentFunction, setCurrentRequestId } = useFunctionStore(
(state) => state,
);

Expand Down Expand Up @@ -71,12 +71,12 @@ export default function DebugPanel() {
const func_data = JSON.stringify(compileRes.data);
const body_params = JSON.parse(params);
const res = await axios({
url: getFunctionDebugUrl(),
url: getFunctionUrl(),
method: runningMethod,
data: body_params,
headers: {
"x-laf-debug-token": `${globalStore.currentApp?.function_debug_token}`,
"x-laf-func-data": func_data,
"x-laf-func-data": encodeURIComponent(func_data),
},
});

Expand Down Expand Up @@ -112,7 +112,7 @@ export default function DebugPanel() {
width="150px"
size="sm"
value={runningMethod}
disabled={getFunctionDebugUrl() === ""}
disabled={getFunctionUrl() === ""}
onChange={(e) => {
setRunningMethod(e.target.value);
}}
Expand All @@ -126,7 +126,7 @@ export default function DebugPanel() {
})}
</Select>
<Button
disabled={getFunctionDebugUrl() === ""}
disabled={getFunctionUrl() === ""}
className="ml-2"
onClick={() => runningCode()}
bg="#E0F6F4"
Expand Down
6 changes: 3 additions & 3 deletions web/src/pages/app/functions/mods/EditorPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useFunctionCache from "@/hooks/useFuncitonCache";

function EditorPanel() {
const store = useFunctionStore((store) => store);
const { currentFunction, updateFunctionCode, getFunctionDebugUrl } = store;
const { currentFunction, updateFunctionCode, getFunctionUrl } = store;

const functionCache = useFunctionCache();

Expand All @@ -39,14 +39,14 @@ function EditorPanel() {
</div>

<HStack>
<CopyText className="ml-2" text={getFunctionDebugUrl()}>
<CopyText className="ml-2" text={getFunctionUrl()}>
<Input
size="sm"
bg="#F1F4F6"
border="none"
readOnly
rounded={4}
value={getFunctionDebugUrl()}
value={getFunctionUrl()}
/>
</CopyText>

Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/app/functions/mods/FunctionPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export default function FunctionList() {

const { currentApp } = useGlobalStore();

const { id: functionId } = useParams();
const { id: functionName } = useParams();
const navigate = useNavigate();

useFunctionListQuery({
onSuccess: (data) => {
setAllFunctionList(data.data);
if (!currentFunction?.id && data.data.length > 0) {
const currentFunction =
data.data.find((item: TFunction) => item.id === functionId) || data.data[0];
data.data.find((item: TFunction) => item.name === functionName) || data.data[0];
setCurrentFunction(currentFunction);
navigate(`/app/${currentApp?.appid}/${Pages.function}/${currentFunction?.name}`, {
replace: true,
Expand Down
10 changes: 0 additions & 10 deletions web/src/pages/app/functions/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type State = {
currentRequestId: string | undefined;
functionCodes: { [key: string]: string };
getFunctionUrl: () => string;
getFunctionDebugUrl: () => string;

setCurrentRequestId: (requestId: string | undefined) => void;
setAllFunctionList: (funcionList: TFunction[]) => void;
Expand All @@ -36,15 +35,6 @@ const useFunctionStore = create<State>()(
: "";
},

getFunctionDebugUrl: () => {
const currentApp = useGlobalStore.getState().currentApp;
const currentFunction = get().currentFunction;

return currentFunction?.name
? `http://${currentApp?.gateway.status.appRoute.domain}/${currentFunction?.name}`
: "";
},

setCurrentRequestId: (requestId) => {
set((state) => {
state.currentRequestId = requestId;
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/customSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const useCustomSettingStore = create<State>()(

RightPanel: {
style: {
width: 500,
width: "350px",
},
},

Expand Down

0 comments on commit 255f5d7

Please sign in to comment.