Skip to content

Commit caa2a5d

Browse files
authored
fix(web): create same function cause page error (#603)
1 parent c8d997d commit caa2a5d

File tree

4 files changed

+49
-38
lines changed

4 files changed

+49
-38
lines changed

web/public/locales/en/translation.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,16 @@
99
"Cancel": "Cancel",
1010
"Edit": "Edit",
1111
"Delete": "Delete",
12-
"CreateTime": "CreateTime"
13-
}
12+
"CreateTime": "CreateTime",
13+
"Common": {
14+
"Dialog": {
15+
"ConfirmDeploy": "Confirm Deploy"
16+
}
17+
},
18+
"FunctionPanel": {
19+
"Deploy": "Deploy"
20+
},
21+
"Message": {
22+
"DeploySuccess": "Published successfully"
23+
}
24+
}

web/src/pages/app/functions/mods/DeployButton/index.tsx

+28-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from "react";
21
import {
32
Button,
43
Modal,
@@ -73,33 +72,35 @@ export default function DeployButton() {
7372
{t("FunctionPanel.Deploy")} ({hotKeyP})
7473
</Button>
7574

76-
<Modal isOpen={isOpen} onClose={onClose} size="6xl" isCentered>
77-
<ModalOverlay />
78-
<ModalContent maxW={"80%"}>
79-
<ModalHeader>Code Diff</ModalHeader>
80-
<ModalCloseButton />
81-
<ModalBody borderBottom={"1px"} borderBottomColor="gray.200">
82-
<CommonDiffEditor
83-
original={store.currentFunction.source?.code}
84-
modified={functionCache.getCache(store.currentFunction.id)}
85-
/>
86-
</ModalBody>
75+
{isOpen ? (
76+
<Modal isOpen={isOpen} onClose={onClose} size="6xl" isCentered>
77+
<ModalOverlay />
78+
<ModalContent maxW={"80%"}>
79+
<ModalHeader>Code Diff</ModalHeader>
80+
<ModalCloseButton />
81+
<ModalBody borderBottom={"1px"} borderBottomColor="gray.200">
82+
<CommonDiffEditor
83+
original={store.currentFunction?.source?.code}
84+
modified={functionCache.getCache(store.currentFunction?.id)}
85+
/>
86+
</ModalBody>
8787

88-
<ModalFooter>
89-
<Button mr={3} onClick={onClose}>
90-
{t("Cancel")}
91-
</Button>
92-
<Button
93-
colorScheme={"blue"}
94-
onClick={() => {
95-
deploy();
96-
}}
97-
>
98-
{t("Common.Dialog.ConfirmDeploy")}
99-
</Button>
100-
</ModalFooter>
101-
</ModalContent>
102-
</Modal>
88+
<ModalFooter>
89+
<Button mr={3} onClick={onClose}>
90+
{t("Cancel")}
91+
</Button>
92+
<Button
93+
colorScheme={"blue"}
94+
onClick={() => {
95+
deploy();
96+
}}
97+
>
98+
{t("Common.Dialog.ConfirmDeploy")}
99+
</Button>
100+
</ModalFooter>
101+
</ModalContent>
102+
</Modal>
103+
) : null}
103104
</>
104105
);
105106
}

web/src/pages/app/functions/mods/FunctionPanel/CreateModal/index.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ const CreateModal = (props: { functionItem?: any }) => {
7373
let res: any = {};
7474
if (isEdit) {
7575
res = await updateFunctionMutation.mutateAsync(data);
76-
store.setCurrentFunction(res.data);
7776
} else {
7877
res = await createFuncitonMutation.mutateAsync(data);
79-
store.setCurrentFunction(res.data);
8078
}
8179

8280
if (!res.error) {
8381
showSuccess(isEdit ? "update success" : "create success");
8482
onClose();
83+
store.setCurrentFunction(res.data);
8584
reset(defaultValues);
8685
}
8786
};
@@ -126,7 +125,12 @@ const CreateModal = (props: { functionItem?: any }) => {
126125

127126
<FormControl>
128127
<FormLabel htmlFor="description">函数描述</FormLabel>
129-
<Input id="description" placeholder="函数描述" variant="filled" />
128+
<Input
129+
{...register("description")}
130+
id="description"
131+
placeholder="函数描述"
132+
variant="filled"
133+
/>
130134
</FormControl>
131135

132136
<FormControl isInvalid={!!errors?.websocket}>

web/src/pages/app/storages/mods/FileList/index.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useEffect } from "react";
21
import { DeleteIcon, ViewIcon } from "@chakra-ui/icons";
32
import { HStack, Table, TableContainer, Tbody, Td, Th, Thead, Tr } from "@chakra-ui/react";
43
import { useQuery } from "@tanstack/react-query";
@@ -24,17 +23,13 @@ export default function FileList() {
2423
// const bucketType = currentStorage?.spec.policy;
2524

2625
const query = useQuery(
27-
["fileList", bucketName],
26+
["fileList", bucketName, prefix],
2827
() => getList(bucketName, { marker: "", prefix }),
2928
{
3029
enabled: !!bucketName,
3130
},
3231
);
3332

34-
useEffect(() => {
35-
query.refetch();
36-
}, [bucketName, prefix, query]);
37-
3833
const viewAppFile = (file: TFile) => {
3934
if (file.Prefix) {
4035
changeDirectory(file);

0 commit comments

Comments
 (0)