Skip to content

Commit

Permalink
Fix test tab redirect in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
martmull committed Dec 11, 2024
1 parent e427018 commit f12418a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
import { Key } from 'ts-key-enum';
import { RightDrawerHotkeyScope } from '@/ui/layout/right-drawer/types/RightDrawerHotkeyScope';

export const RightDrawerActionRunButton = ({
export const CmdEnterActionButton = ({
title,
onClick,
}: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ServerlessFunctionExecutionResult } from '@/serverless-functions/compon
import { INDEX_FILE_PATH } from '@/serverless-functions/constants/IndexFilePath';
import { InputLabel } from '@/ui/input/components/InputLabel';
import { RightDrawerFooter } from '@/ui/layout/right-drawer/components/RightDrawerFooter';
import { RightDrawerActionRunButton } from '@/action-menu/components/RightDrawerActionRunButton';
import { CmdEnterActionButton } from '@/action-menu/components/CmdEnterActionButton';
import { useTestServerlessFunction } from '@/serverless-functions/hooks/useTestServerlessFunction';
import { getFunctionOutputSchema } from '@/serverless-functions/utils/getFunctionOutputSchema';
import { getFunctionInputFromSourceCode } from '@/serverless-functions/utils/getFunctionInputFromSourceCode';
Expand Down Expand Up @@ -330,10 +330,7 @@ export const WorkflowEditActionFormServerlessFunction = ({
</WorkflowStepBody>
<RightDrawerFooter
actions={[
<RightDrawerActionRunButton
title="Test"
onClick={handleRunFunction}
/>,
<CmdEnterActionButton title="Test" onClick={handleRunFunction} />,
]}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const TAB_LIST_COMPONENT_ID = 'serverless-function-detail';
export const SettingsServerlessFunctionDetail = () => {
const { serverlessFunctionId = '' } = useParams();
const { enqueueSnackBar } = useSnackBar();
const { activeTabId } = useTabList(TAB_LIST_COMPONENT_ID);
const { activeTabId, setActiveTabId } = useTabList(TAB_LIST_COMPONENT_ID);
const [isCodeValid, setIsCodeValid] = useState(true);
const { updateOneServerlessFunction } = useUpdateOneServerlessFunction();
const { publishOneServerlessFunction } = usePublishOneServerlessFunction();
Expand Down Expand Up @@ -126,6 +126,11 @@ export const SettingsServerlessFunctionDetail = () => {
}
};

const handleTestFunction = async () => {
setActiveTabId('test');
await testServerlessFunction();
};

const isAnalyticsEnabled = useRecoilValue(isAnalyticsEnabledState);

const isAnalyticsV2Enabled = useIsFeatureEnabled('IS_ANALYTICS_V2_ENABLED');
Expand Down Expand Up @@ -157,7 +162,7 @@ export const SettingsServerlessFunctionDetail = () => {
return (
<SettingsServerlessFunctionCodeEditorTab
files={files}
handleExecute={testServerlessFunction}
handleExecute={handleTestFunction}
handlePublish={handlePublish}
handleReset={handleReset}
resetDisabled={resetDisabled}
Expand All @@ -170,7 +175,7 @@ export const SettingsServerlessFunctionDetail = () => {
return (
<SettingsServerlessFunctionTestTab
serverlessFunctionId={serverlessFunctionId}
handleExecute={testServerlessFunction}
handleExecute={handleTestFunction}
/>
);
case 'settings':
Expand Down Expand Up @@ -210,7 +215,11 @@ export const SettingsServerlessFunctionDetail = () => {
]}
>
<SettingsPageContainer>
<TabList tabListInstanceId={TAB_LIST_COMPONENT_ID} tabs={tabs} />
<TabList
tabListInstanceId={TAB_LIST_COMPONENT_ID}
tabs={tabs}
behaveAsLinks={false}
/>
{renderActiveTabContent()}
</SettingsPageContainer>
</SubMenuTopBarContainer>
Expand Down

0 comments on commit f12418a

Please sign in to comment.