Remove serverless functions on version archivation (#9535)

Fixes https://github.com/twentyhq/core-team-issues/issues/52
- contrary to title, we do not remove serverless functions on workflow
version archivation because serverless fucntion might be used in another
workflow version
- we fix the serverless funciton version displayed in the code step
- we allow test function version in step display right drawer
- we delete serverless function only when serverless function has no
published version
This commit is contained in:
martmull
2025-01-13 14:09:57 +01:00
committed by GitHub
parent 8643eaa28f
commit 5783d68d62
10 changed files with 64 additions and 33 deletions

View File

@ -36,7 +36,7 @@ describe('useServerlessFunctionUpdateFormState', () => {
},
);
const { result } = renderHook(
() => useServerlessFunctionUpdateFormState(serverlessFunctionId),
() => useServerlessFunctionUpdateFormState({ serverlessFunctionId }),
{
wrapper: RecoilRoot,
},

View File

@ -20,9 +20,13 @@ type SetServerlessFunctionFormValues = Dispatch<
SetStateAction<ServerlessFunctionFormValues>
>;
export const useServerlessFunctionUpdateFormState = (
serverlessFunctionId: string,
): {
export const useServerlessFunctionUpdateFormState = ({
serverlessFunctionId,
serverlessFunctionVersion = 'draft',
}: {
serverlessFunctionId: string;
serverlessFunctionVersion?: string;
}): {
formValues: ServerlessFunctionFormValues;
setFormValues: SetServerlessFunctionFormValues;
loading: boolean;
@ -43,7 +47,7 @@ export const useServerlessFunctionUpdateFormState = (
const { loading } = useGetOneServerlessFunctionSourceCode({
id: serverlessFunctionId,
version: 'draft',
version: serverlessFunctionVersion,
onCompleted: (data: FindOneServerlessFunctionSourceCodeQuery) => {
const newState = {
code: data?.getServerlessFunctionSourceCode || undefined,