Skip to content

Commit

Permalink
Mock shareCallback to test UI on AIConfigEditor
Browse files Browse the repository at this point in the history
TSIA, just adding code so we can mock the UI
  • Loading branch information
Rossdan Craig [email protected] committed Jan 26, 2024
1 parent 1170ed1 commit 87b7110
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions python/src/aiconfig/editor/client/src/LocalEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const useStyles = createStyles(() => ({
},
}));


const MODE = "local";

export default function LocalEditor() {
Expand Down Expand Up @@ -75,7 +74,7 @@ export default function LocalEditor() {
sessionSampleRate: 100,
});

datadogLogs.setGlobalContextProperty('mode', MODE);
datadogLogs.setGlobalContextProperty("mode", MODE);
}
}, []);

Expand Down Expand Up @@ -239,6 +238,16 @@ export default function LocalEditor() {
[]
);

const mockShare = useCallback(() => {
return new Promise<{ share_url: string }>((resolve, _reject) => {
setTimeout(() => {
resolve({ share_url: "test" });
// uncomment & comment out resolve to test error handling
// reject("message");
}, 2000);
});
}, []);

const callbacks: AIConfigCallbacks = useMemo(
() => ({
addPrompt,
Expand All @@ -253,6 +262,7 @@ export default function LocalEditor() {
setConfigDescription,
setConfigName,
setParameters,
share: mockShare,
updateModel,
updatePrompt,
}),
Expand All @@ -269,6 +279,7 @@ export default function LocalEditor() {
setConfigDescription,
setConfigName,
setParameters,
mockShare,
updateModel,
updatePrompt,
]
Expand All @@ -289,11 +300,7 @@ export default function LocalEditor() {
<Loader size="xl" />
</Flex>
) : (
<AIConfigEditor
aiconfig={aiconfig}
callbacks={callbacks}
mode={MODE}
/>
<AIConfigEditor aiconfig={aiconfig} callbacks={callbacks} mode={MODE} />
)}
</div>
);
Expand Down

0 comments on commit 87b7110

Please sign in to comment.