Skip to content

Commit

Permalink
feat(web): cloud functions support multi-level url
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored and maslow committed Jun 1, 2023
1 parent f43a0a9 commit 5aec195
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
9 changes: 6 additions & 3 deletions web/src/pages/app/functions/mods/DeployButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ export default function DeployButton() {

const updateFunctionMutation = useUpdateFunctionMutation();

const functionDetailQuery = useFunctionDetailQuery(store.currentFunction.name, {
enabled: isOpen,
});
const functionDetailQuery = useFunctionDetailQuery(
encodeURIComponent(store.currentFunction.name),
{
enabled: isOpen,
},
);

const { displayName } = useHotKey(
DEFAULT_SHORTCUTS.deploy,
Expand Down
9 changes: 6 additions & 3 deletions web/src/pages/app/functions/mods/FetchButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export default function FetchButton() {
const { isOpen, onOpen, onClose } = useDisclosure();
const store = useFunctionStore((state) => state);
const { currentFunction, updateFunctionCode, setIsFetchButtonClicked } = store;
const functionDetailQuery = useFunctionDetailQuery(store.currentFunction.name, {
enabled: isOpen,
});
const functionDetailQuery = useFunctionDetailQuery(
encodeURIComponent(store.currentFunction.name),
{
enabled: isOpen,
},
);
const data = functionDetailQuery.data?.data?.source?.code;
const { showSuccess } = useGlobalStore((state) => state);

Expand Down
18 changes: 15 additions & 3 deletions web/src/pages/app/functions/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ export const useUpdateFunctionMutation = () => {
const queryClient = useQueryClient();
return useMutation(
(values: any) => {
return FunctionControllerUpdate(values);
const updatedValues = {
...values,
name: encodeURIComponent(values.name),
};
return FunctionControllerUpdate(updatedValues);
},
{
onSuccess(data) {
Expand All @@ -81,7 +85,11 @@ export const useDeleteFunctionMutation = () => {
const queryClient = useQueryClient();
return useMutation(
(values: any) => {
return FunctionControllerRemove(values);
const updatedValues = {
...values,
name: encodeURIComponent(values.name),
};
return FunctionControllerRemove(updatedValues);
},
{
onSuccess(data) {
Expand All @@ -100,7 +108,11 @@ export const useCompileMutation = () => {
return useMutation({
mutationKey: ["compileMutation"],
mutationFn: (values: { code: string; name: string }) => {
return FunctionControllerCompile(values);
const updatedValues = {
...values,
name: encodeURIComponent(values.name),
};
return FunctionControllerCompile(updatedValues);
},
onSuccess(data) {
if (!data.error) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const routes = [
auth: true,
children: [
{
path: "/app/:appid/:pageId/:id?",
path: "/app/:appid/:pageId/:id?/*",
element: () => import("@/pages/app/index"),
},
],
Expand Down

0 comments on commit 5aec195

Please sign in to comment.