6654 serverless functions add a deploy button disable deploy when autosave (#6715)
- improvements on serverless function behavior (autosave performances, deploy on execution only) - add versioning to serverless functions - add a publish endpoint to create a new version of a serverless function - add deploy and reset to lastVersion button in the settings section: <img width="736" alt="image" src="https://github.com/user-attachments/assets/2001f8d2-07a4-4f79-84dd-ec74b6f301d3">
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { H2Title, IconPlayerPlay } from 'twenty-ui';
|
||||
import { H2Title, IconPlayerPlay, IconGitCommit, IconRestore } from 'twenty-ui';
|
||||
import { CodeEditor } from '@/ui/input/code-editor/components/CodeEditor';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
import { ServerlessFunctionFormValues } from '@/settings/serverless-functions/hooks/useServerlessFunctionUpdateFormState';
|
||||
@ -14,13 +14,23 @@ const StyledTabList = styled(TabList)`
|
||||
export const SettingsServerlessFunctionCodeEditorTab = ({
|
||||
formValues,
|
||||
handleExecute,
|
||||
handlePublish,
|
||||
handleReset,
|
||||
resetDisabled,
|
||||
publishDisabled,
|
||||
onChange,
|
||||
setIsCodeValid,
|
||||
}: {
|
||||
formValues: ServerlessFunctionFormValues;
|
||||
handleExecute: () => void;
|
||||
handlePublish: () => void;
|
||||
handleReset: () => void;
|
||||
resetDisabled: boolean;
|
||||
publishDisabled: boolean;
|
||||
onChange: (key: string) => (value: string) => void;
|
||||
setIsCodeValid: (isCodeValid: boolean) => void;
|
||||
}) => {
|
||||
const HeaderButton = (
|
||||
const TestButton = (
|
||||
<Button
|
||||
title="Test"
|
||||
variant="primary"
|
||||
@ -30,6 +40,26 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
|
||||
onClick={handleExecute}
|
||||
/>
|
||||
);
|
||||
const PublishButton = (
|
||||
<Button
|
||||
title="Publish"
|
||||
variant="secondary"
|
||||
size="small"
|
||||
Icon={IconGitCommit}
|
||||
onClick={handlePublish}
|
||||
disabled={publishDisabled}
|
||||
/>
|
||||
);
|
||||
const ResetButton = (
|
||||
<Button
|
||||
title="Reset"
|
||||
variant="secondary"
|
||||
size="small"
|
||||
Icon={IconRestore}
|
||||
onClick={handleReset}
|
||||
disabled={resetDisabled}
|
||||
/>
|
||||
);
|
||||
|
||||
const TAB_LIST_COMPONENT_ID = 'serverless-function-editor';
|
||||
|
||||
@ -41,7 +71,10 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
|
||||
);
|
||||
|
||||
const Header = (
|
||||
<CoreEditorHeader leftNodes={[HeaderTabList]} rightNodes={[HeaderButton]} />
|
||||
<CoreEditorHeader
|
||||
leftNodes={[HeaderTabList]}
|
||||
rightNodes={[ResetButton, PublishButton, TestButton]}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
@ -53,6 +86,7 @@ export const SettingsServerlessFunctionCodeEditorTab = ({
|
||||
<CodeEditor
|
||||
value={formValues.code}
|
||||
onChange={onChange('code')}
|
||||
setIsCodeValid={setIsCodeValid}
|
||||
header={Header}
|
||||
/>
|
||||
</Section>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import {
|
||||
DEFAULT_OUTPUT_VALUE,
|
||||
@ -13,11 +13,16 @@ export const SettingsServerlessFunctionTestTabEffect = () => {
|
||||
const setSettingsServerlessFunctionCodeEditorOutputParams = useSetRecoilState(
|
||||
settingsServerlessFunctionCodeEditorOutputParamsState,
|
||||
);
|
||||
if (settingsServerlessFunctionOutput.data !== DEFAULT_OUTPUT_VALUE) {
|
||||
setSettingsServerlessFunctionCodeEditorOutputParams({
|
||||
language: 'json',
|
||||
height: 300,
|
||||
});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (settingsServerlessFunctionOutput.data !== DEFAULT_OUTPUT_VALUE) {
|
||||
setSettingsServerlessFunctionCodeEditorOutputParams({
|
||||
language: 'json',
|
||||
height: 300,
|
||||
});
|
||||
}
|
||||
}, [
|
||||
settingsServerlessFunctionOutput.data,
|
||||
setSettingsServerlessFunctionCodeEditorOutputParams,
|
||||
]);
|
||||
return <></>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user