mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 00:03:07 +00:00
fix: hide AI Gen btn when language not supported (#2016)
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
|
||||
// state
|
||||
let genLoading: boolean = false
|
||||
let openaiAvailable: boolean | undefined = undefined
|
||||
let generatedCode = ''
|
||||
let explanation = ''
|
||||
|
||||
@@ -65,13 +64,6 @@
|
||||
explanation = ''
|
||||
}
|
||||
|
||||
function checkIfOpenaiAvailable(
|
||||
lang: SupportedLanguage | 'frontend',
|
||||
existsOpenaiResourcePath: boolean
|
||||
) {
|
||||
openaiAvailable = existsOpenaiResourcePath && SUPPORTED_LANGUAGES.has(lang)
|
||||
}
|
||||
|
||||
function showDiff() {
|
||||
diffEditor?.setDiff(editor?.getCode() || '', generatedCode, scriptLangToEditorLang(lang))
|
||||
diffEditor?.show()
|
||||
@@ -83,8 +75,6 @@
|
||||
diffEditor?.hide()
|
||||
}
|
||||
|
||||
$: checkIfOpenaiAvailable(lang, $existsOpenaiResourcePath)
|
||||
|
||||
$: lang && (generatedCode = '')
|
||||
|
||||
$: generatedCode && showDiff()
|
||||
@@ -92,7 +82,7 @@
|
||||
</script>
|
||||
|
||||
{#if error}
|
||||
{#if openaiAvailable}
|
||||
{#if existsOpenaiResourcePath && SUPPORTED_LANGUAGES.has(lang)}
|
||||
<div class="mt-2">
|
||||
{#if generatedCode}
|
||||
<div class="flex gap-1">
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
// state
|
||||
let funcDesc: string = ''
|
||||
let genLoading: boolean = false
|
||||
let openaiAvailable: boolean | undefined = undefined
|
||||
let button: HTMLButtonElement | undefined
|
||||
let input: HTMLInputElement | undefined
|
||||
let generatedCode = ''
|
||||
@@ -79,13 +78,6 @@
|
||||
generatedCode = ''
|
||||
}
|
||||
|
||||
function checkIfOpenaiAvailable(
|
||||
lang: SupportedLanguage | 'frontend',
|
||||
existsOpenaiResourcePath: boolean
|
||||
) {
|
||||
openaiAvailable = existsOpenaiResourcePath && SUPPORTED_LANGUAGES.has(lang)
|
||||
}
|
||||
|
||||
function showDiff() {
|
||||
diffEditor?.setDiff(
|
||||
editor?.getCode() || '',
|
||||
@@ -107,8 +99,6 @@
|
||||
})
|
||||
}
|
||||
|
||||
$: checkIfOpenaiAvailable(lang, $existsOpenaiResourcePath)
|
||||
|
||||
$: input?.focus()
|
||||
|
||||
$: lang && (generatedCode = '')
|
||||
@@ -168,7 +158,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if !generatedCode}
|
||||
{#if !generatedCode && SUPPORTED_LANGUAGES.has(lang)}
|
||||
<Popup floatingConfig={{ placement: 'bottom-end', strategy: 'absolute' }} let:close>
|
||||
<svelte:fragment slot="button">
|
||||
{#if inlineScript}
|
||||
@@ -200,7 +190,7 @@
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<label class="block text-primary">
|
||||
{#if openaiAvailable}
|
||||
{#if $existsOpenaiResourcePath}
|
||||
<div class="flex w-96">
|
||||
<input
|
||||
type="text"
|
||||
|
||||
Reference in New Issue
Block a user