Skip to content

fix(web): create same function cause page error #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,16 @@
"Cancel": "Cancel",
"Edit": "Edit",
"Delete": "Delete",
"CreateTime": "CreateTime"
}
"CreateTime": "CreateTime",
"Common": {
"Dialog": {
"ConfirmDeploy": "Confirm Deploy"
}
},
"FunctionPanel": {
"Deploy": "Deploy"
},
"Message": {
"DeploySuccess": "Published successfully"
}
}
55 changes: 28 additions & 27 deletions web/src/pages/app/functions/mods/DeployButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import {
Button,
Modal,
Expand Down Expand Up @@ -73,33 +72,35 @@ export default function DeployButton() {
{t("FunctionPanel.Deploy")} ({hotKeyP})
</Button>

<Modal isOpen={isOpen} onClose={onClose} size="6xl" isCentered>
<ModalOverlay />
<ModalContent maxW={"80%"}>
<ModalHeader>Code Diff</ModalHeader>
<ModalCloseButton />
<ModalBody borderBottom={"1px"} borderBottomColor="gray.200">
<CommonDiffEditor
original={store.currentFunction.source?.code}
modified={functionCache.getCache(store.currentFunction.id)}
/>
</ModalBody>
{isOpen ? (
<Modal isOpen={isOpen} onClose={onClose} size="6xl" isCentered>
<ModalOverlay />
<ModalContent maxW={"80%"}>
<ModalHeader>Code Diff</ModalHeader>
<ModalCloseButton />
<ModalBody borderBottom={"1px"} borderBottomColor="gray.200">
<CommonDiffEditor
original={store.currentFunction?.source?.code}
modified={functionCache.getCache(store.currentFunction?.id)}
/>
</ModalBody>

<ModalFooter>
<Button mr={3} onClick={onClose}>
{t("Cancel")}
</Button>
<Button
colorScheme={"blue"}
onClick={() => {
deploy();
}}
>
{t("Common.Dialog.ConfirmDeploy")}
</Button>
</ModalFooter>
</ModalContent>
</Modal>
<ModalFooter>
<Button mr={3} onClick={onClose}>
{t("Cancel")}
</Button>
<Button
colorScheme={"blue"}
onClick={() => {
deploy();
}}
>
{t("Common.Dialog.ConfirmDeploy")}
</Button>
</ModalFooter>
</ModalContent>
</Modal>
) : null}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ const CreateModal = (props: { functionItem?: any }) => {
let res: any = {};
if (isEdit) {
res = await updateFunctionMutation.mutateAsync(data);
store.setCurrentFunction(res.data);
} else {
res = await createFuncitonMutation.mutateAsync(data);
store.setCurrentFunction(res.data);
}

if (!res.error) {
showSuccess(isEdit ? "update success" : "create success");
onClose();
store.setCurrentFunction(res.data);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only setCurrentFunction when request is success

reset(defaultValues);
}
};
Expand Down Expand Up @@ -126,7 +125,12 @@ const CreateModal = (props: { functionItem?: any }) => {

<FormControl>
<FormLabel htmlFor="description">函数描述</FormLabel>
<Input id="description" placeholder="函数描述" variant="filled" />
<Input
{...register("description")}
id="description"
placeholder="函数描述"
variant="filled"
/>
</FormControl>

<FormControl isInvalid={!!errors?.websocket}>
Expand Down
7 changes: 1 addition & 6 deletions web/src/pages/app/storages/mods/FileList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect } from "react";
import { DeleteIcon, ViewIcon } from "@chakra-ui/icons";
import { HStack, Table, TableContainer, Tbody, Td, Th, Thead, Tr } from "@chakra-ui/react";
import { useQuery } from "@tanstack/react-query";
Expand All @@ -24,17 +23,13 @@ export default function FileList() {
// const bucketType = currentStorage?.spec.policy;

const query = useQuery(
["fileList", bucketName],
["fileList", bucketName, prefix],
() => getList(bucketName, { marker: "", prefix }),
{
enabled: !!bucketName,
},
);

useEffect(() => {
query.refetch();
}, [bucketName, prefix, query]);

const viewAppFile = (file: TFile) => {
if (file.Prefix) {
changeDirectory(file);
Expand Down