* Add close dismiss button to Infinite duration non-loading toasts * Add text-to-cad icon candidates * Add a way to silently create files * Add text-to-cad command with mock backend * add the actual endpoint Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix the response Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * Add `credentials: include` * add headers Signed-off-by: Jess Frazelle <github@jessfraz.com> * Mostly working? Just getting CORS on desktop * Merge goof * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * create cross platform fetch; Signed-off-by: Jess Frazelle <github@jessfraz.com> * send the token; Signed-off-by: Jess Frazelle <github@jessfraz.com> * send the token; Signed-off-by: Jess Frazelle <github@jessfraz.com> * better names for files Signed-off-by: Jess Frazelle <github@jessfraz.com> * Commit broken THREEjs success toast * base64 decode Signed-off-by: Jess Frazelle <github@jessfraz.com> * send telemetry on reject / accept Signed-off-by: Jess Frazelle <github@jessfraz.com> * start of tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * more tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * basic tests; Signed-off-by: Jess Frazelle <github@jessfraz.com> * lego Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * Get model stylized based on settings * Don't need automatic dismiss button for Infinity-duration toasts anymore * Stylize loaded model, add OrbitControls, polish button behavior * Allow user to retry prompt if one fails * Add an auto-grow textarea input type to the command bar, set text-to-cad to use it * Delete the created file in desktop if user rejects it * Submit with meta+Enter * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * add more tests and various fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * Set `prompt` arg defaultValue to failed prompt value on retry * Add missing `awaits` to playwright tests to get them passing * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * empty --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
109 lines
2.5 KiB
TypeScript
109 lines
2.5 KiB
TypeScript
import CommandArgOptionInput from './CommandArgOptionInput'
|
|
import CommandBarBasicInput from './CommandBarBasicInput'
|
|
import CommandBarSelectionInput from './CommandBarSelectionInput'
|
|
import { CommandArgument } from 'lib/commandTypes'
|
|
import { useCommandsContext } from 'hooks/useCommandsContext'
|
|
import CommandBarHeader from './CommandBarHeader'
|
|
import CommandBarKclInput from './CommandBarKclInput'
|
|
import CommandBarTextareaInput from './CommandBarTextareaInput'
|
|
|
|
function CommandBarArgument({ stepBack }: { stepBack: () => void }) {
|
|
const { commandBarState, commandBarSend } = useCommandsContext()
|
|
const {
|
|
context: { currentArgument },
|
|
} = commandBarState
|
|
|
|
function onSubmit(data: unknown) {
|
|
if (!currentArgument) return
|
|
|
|
commandBarSend({
|
|
type: 'Submit argument',
|
|
data: {
|
|
[currentArgument.name]: data,
|
|
},
|
|
})
|
|
}
|
|
|
|
return (
|
|
currentArgument && (
|
|
<CommandBarHeader>
|
|
<ArgumentInput
|
|
arg={currentArgument}
|
|
stepBack={stepBack}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
</CommandBarHeader>
|
|
)
|
|
)
|
|
}
|
|
|
|
export default CommandBarArgument
|
|
|
|
function ArgumentInput({
|
|
arg,
|
|
stepBack,
|
|
onSubmit,
|
|
}: {
|
|
arg: CommandArgument<unknown> & { name: string }
|
|
stepBack: () => void
|
|
onSubmit: (event: any) => void
|
|
}) {
|
|
switch (arg.inputType) {
|
|
case 'options':
|
|
return (
|
|
<CommandArgOptionInput
|
|
arg={arg}
|
|
argName={arg.name}
|
|
stepBack={stepBack}
|
|
onSubmit={onSubmit}
|
|
placeholder="Select an option"
|
|
/>
|
|
)
|
|
case 'boolean':
|
|
return (
|
|
<CommandArgOptionInput
|
|
arg={{
|
|
...arg,
|
|
inputType: 'options',
|
|
options: [
|
|
{ name: 'On', value: true },
|
|
{ name: 'Off', value: false },
|
|
],
|
|
}}
|
|
argName={arg.name}
|
|
stepBack={stepBack}
|
|
onSubmit={onSubmit}
|
|
placeholder="Select an option"
|
|
/>
|
|
)
|
|
case 'selection':
|
|
return (
|
|
<CommandBarSelectionInput
|
|
arg={arg}
|
|
stepBack={stepBack}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
)
|
|
case 'kcl':
|
|
return (
|
|
<CommandBarKclInput arg={arg} stepBack={stepBack} onSubmit={onSubmit} />
|
|
)
|
|
case 'text':
|
|
return (
|
|
<CommandBarTextareaInput
|
|
arg={arg}
|
|
stepBack={stepBack}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
)
|
|
default:
|
|
return (
|
|
<CommandBarBasicInput
|
|
arg={arg}
|
|
stepBack={stepBack}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
)
|
|
}
|
|
}
|