mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 16:03:27 +00:00
* hack fix dnd with tick * DBExplorer table left table selector * kinda works * correct table metadata * separated columnDefs creation logic * Removed dependency on AppDbExplorer * (tweak) loadTableMetaData much faster * nit for darkmode * DBExplorerDrawerButton * footer * count footer * reload * update * fix height * db explorer btn in resources table * delete row * InsertRowDrawerButton * insert * refresh on insert and delete * moved db logic to ts file * better update ux * moved all IO upwards * fix: Remaining svelte 5 bugs (#5563) * hack fix dnd with tick * fix: infinite loading in CodeDisplay after update to svelte 5 * regen package-lock * fix tutorial (#5562) * fix tutorial first part * fix tutorial --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev> * feat: Implement sending diff to ai (#5510) * allow mentioning specific files in instructions * remove not working highlight implementation * make highlighted text work * fix tooltip position * clean code * cleaning * use lib for tooltip positioning * fix logic * draft for db in context * use tools for db in context * fixes * cleaning and bug fixes * fix * cleaning * fix when script is db type * simplify logic * put schema in context if already here * fix imports * fix tooltip position and make it scrollable * remove console logs * check if selected is in available * fix tooltip list * add back lost logic * last fix * fix type errors * use loaded schema from dbSchemas * fix typing, content and lang are always there * remove from context if not available anymore * add not loaded yet mention if schema not loaded * add missing callback logic * fix prompt * fix usage of updateselectedContext function * fix styling for white theme * handle tab and arrows * fix schemas not being refreshed on contexts * also refresh displayMessages when dbschemas change * fix duplicate available contexts * fix logic for new scripts * fix new lines inside text area * implement sending diff in context * add button in deploy options to ask ai about diff * also visualize change when asking for diff * better prompt * add limit to diff size * put diff mode toggle in editor bar * add button to see history from editor * adjustements * put see diff button in dropdown * fixes * better styling * highlight if diff mode * format files * change buttons based on diffmode * remove diff after sending message * fix type error * smaller buttons * draft * use existing editor in diff editor * fix number of db resources fetches * fix apply and add buttons on diff mode * cleaning * undo ai gen button show * better buttons * styling asjustements + show diff in badge * styling * fix deployed code check * cleaning and styling * better quick actions * dont send code when analyzing * remove apply in chat if only code and no diff * fix bad code refactor --------- Co-authored-by: HugoCasa <hugo@casademont.ch> Co-authored-by: Ruben Fiszel <ruben@windmill.dev> * fix: prevent invalid returned ai completion object errors (#5564) * fix(frontend): app builder - force json configuration in rich result (#5565) * feat: make azure a standalone AI provider (#5558) * feat: make azure a standalone AI provider * oups * nit * fix: openai/azure oauth * nit * nits * feat(frontend) add flow step result viewer (#5398) * fix(cli): properly handle enabled/disabled updates of schedules * fix benchmarks * feat: handle sending selected lines to ai context (#5527) * allow mentioning specific files in instructions * remove not working highlight implementation * make highlighted text work * fix tooltip position * clean code * cleaning * use lib for tooltip positioning * fix logic * draft for db in context * use tools for db in context * fixes * cleaning and bug fixes * fix * cleaning * fix when script is db type * simplify logic * put schema in context if already here * fix imports * fix tooltip position and make it scrollable * remove console logs * check if selected is in available * fix tooltip list * add back lost logic * last fix * fix type errors * use loaded schema from dbSchemas * fix typing, content and lang are always there * remove from context if not available anymore * add not loaded yet mention if schema not loaded * add missing callback logic * fix prompt * fix usage of updateselectedContext function * fix styling for white theme * handle tab and arrows * fix schemas not being refreshed on contexts * also refresh displayMessages when dbschemas change * fix duplicate available contexts * fix logic for new scripts * fix new lines inside text area * implement sending diff in context * add button in deploy options to ask ai about diff * also visualize change when asking for diff * better prompt * add limit to diff size * put diff mode toggle in editor bar * add button to see history from editor * adjustements * put see diff button in dropdown * fixes * better styling * handle adding code piece to context * add code piece in context * draft start end markers * adapt code * draft * apply code pieces before sending request * cleaning * highlight if diff mode * format files * change buttons based on diffmode * remove diff after sending message * fix type error * smaller buttons * draft * use existing editor in diff editor * fix number of db resources fetches * fix apply and add buttons on diff mode * cleaning * undo ai gen button show * better buttons * better prompt * remove console log * fix merge * avoid duplicates * fix merge * fix * fix apply logic * remove useless if * focus text area + close chat if no selected lines --------- Co-authored-by: HugoCasa <hugo@casademont.ch> * fix: flow editor svelte 5 issues (#5567) * feat: add diff toggle to flow inline scripts (#5550) * draft flow diff * add missing import * cleaning * code cleaning * fix for recursive renderings * fix typo * cleaning --------- Co-authored-by: HugoCasa <hugo@casademont.ch> * fix(frontend): proper each block binding + better app settings reactivity (#5568) * fix: properly bind to array elements in Svelte each loops This commit fixes an issue where binding directly to loop variables in Svelte's #each loops doesn't properly update the original array. Instead of binding directly to the loop variable, we now bind to the array elements using index variables. The pattern used is: - Change: {#each arr as el} -> {#each arr as _, index} - Change: bind:value={el} -> bind:value={arr[index]} Modified files: - frontend/src/lib/components/ArrayTypeNarrowing.svelte - frontend/src/lib/components/apps/editor/AppInputs.svelte - frontend/src/lib/components/flows/content/FlowModuleWrapper.svelte * better app settings panel reactivity --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev> Co-authored-by: HugoCasa <hugo@casademont.ch> * fix: app editor svelte 5 fixes (#5570) * fix: properly bind to array elements in Svelte each loops This commit fixes an issue where binding directly to loop variables in Svelte's #each loops doesn't properly update the original array. Instead of binding directly to the loop variable, we now bind to the array elements using index variables. The pattern used is: - Change: {#each arr as el} -> {#each arr as _, index} - Change: bind:value={el} -> bind:value={arr[index]} Modified files: - frontend/src/lib/components/ArrayTypeNarrowing.svelte - frontend/src/lib/components/apps/editor/AppInputs.svelte - frontend/src/lib/components/flows/content/FlowModuleWrapper.svelte * better app settings panel reactivity * fix: app editor table svelte 5 fixes --------- Co-authored-by: Guilhem <guilhemlemouel@gmail.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev> * select border (#5571) * fix: properly bind to array elements in Svelte each loops This commit fixes an issue where binding directly to loop variables in Svelte's #each loops doesn't properly update the original array. Instead of binding directly to the loop variable, we now bind to the array elements using index variables. The pattern used is: - Change: {#each arr as el} -> {#each arr as _, index} - Change: bind:value={el} -> bind:value={arr[index]} Modified files: - frontend/src/lib/components/ArrayTypeNarrowing.svelte - frontend/src/lib/components/apps/editor/AppInputs.svelte - frontend/src/lib/components/flows/content/FlowModuleWrapper.svelte * better app settings panel reactivity * fix: app editor table svelte 5 fixes * fix: select border --------- Co-authored-by: Guilhem <guilhemlemouel@gmail.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev> * feat: add windmill context to autocomplete (#5548) * add windmill context to autocomplete * fix formatting * remove console log * do not mention tool call for autocomplete * apply logic to php --------- Co-authored-by: HugoCasa <hugo@casademont.ch> * fix tabs selected behavior change from svelte 5 * fix: fix list jobs by tag * fix: tenant id to never be undefined on teams (#5572) * fix: tenant id to never be undefined * simplify azure oauth * simplify azure oauth * update ee ref * sqlx prepare * sqlx prepare * fix: legacy script gen model selection (#5574) * feat: add wildcards filter for worker/label/tags * fix: Dynamic select does not work with tag //native (#5576) closes #5490 * function takes 13 arguments but 14 arguments were supplied (#5577) * fix(frontend): prevent deploy popover to show if deploy dropdown is open (#5542) * prevent deploy popover to show if deploy dropdown is open * wip * Revert "wip" This reverts commit85434654af. * Revert "prevent deploy popover to show if deploy dropdown is open" This reverts commitedd9eda156. * add prop to hide popup fro dropdown * feat: button can have tooltip * improve deploy tooltip and dropdown behavior * rename tooltip to tooltipPopover * nit * add deploy button component * use svelte 5 runes * use new deploy button for script builder * add delay to deploy popover when dropdown is open * add delay to deploy popover when dropdown is open # Conflicts: # frontend/src/lib/components/DeployButton.svelte # frontend/src/lib/components/common/button/Button.svelte * Update frontend/src/lib/components/common/button/Button.svelte Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * remove unsused field * nit --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * chore: update hub sync script (#5579) * fix monaco suggestion z-index (#5578) * fix: validate saved module before passing to flow module editor (#5580) * fix: freeze when clicking script history diff button (#5581) * fix: validate saved module before passing to flow module editor * fix: freeze when clicking script history diff button * add space (#5582) * fix: binding not working in nested array script arg (#5585) * fix: mssql ca_cert deserializing (#5587) * fix: improve app image picker UX (#5589) * DBTableAction * delete table * fix intempestive error toasts * fullscreen mode * rename db explorer to db manager * use drawer open state instead of oo open method * create table btn * factor away sucess text * basic table creation form * uniq check * better select * better add btn * extra settings * create table works in pgsql * MySQL kinda works * CRUD works in mysql * fix lowercase * allow create table with no schema * handle default value * sql repl pane * execute sql queries * db ops opt in * SQL Repl v0 * ux * UX * better refresh * better placeholder sql * sql code clipboard copy * handle multiple primary keys in table creation * fix all fields being required on insert * fix postgres enum not properly converted * use InsertRowDrawerButton in App db studio * insert shortcut * fix mysql datetime parser for non tz dates * npm run check * Revert "fix all fields being required on insert" This reverts commit6bec952fb7. * fk ui * don't commit .env... * tweak * fk ui bindings * fk dropdowns right values * schema notation fixes * handle on delete / update cascade etc * better loading button without flicker * fix infinite loop caused by getDbSchemas * foreign key error validation * type error * cache col defs * fix label hover * fix fk select overflow * Fix Select styling * mssql fixes * fix wrong typecast failing with mssql * extract makeLoadTableMetaDataQuery * Fetch all col defs in one go (mysql) * loadAllTablesMetaData for postgres * for some reason factoring transformColumnDefs broke ag infinite table * mssql loads all coldefs at once * snowflake preload all col defs * filter out information schema snowflake * default schema select * fix original pg col def logic broken * Fix ugly flickers * fix updateGrid before grid ready * better auto sizing * smoother CRUD UI refreshes * fix col defs qury for bigquery * bigquery works * nits * do not change queries used in policies ! * fix runPreviewJobAndPollResult on WINDMILL_TOO_BIG * select padding * ellipsis typos * fix mysterious ugly red flash when mounting ag grid in dark mode only * Load on click * Remove schema explorer mode * repl min size * fix flash on dark mode * dirty fix ag grid not refreshing sometimes * sql repl history * fix ag theme * close sql repl result viewer by clicking outside * Select styling fix in dark mode * better default query sqlrepl * Buttons less aggressive --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev> Co-authored-by: centdix <40307056+centdix@users.noreply.github.com> Co-authored-by: HugoCasa <hugo@casademont.ch> Co-authored-by: Alexander Petric <alpetric@users.noreply.github.com> Co-authored-by: Guilhem <guilhemlemouel@gmail.com> Co-authored-by: Piyush मिश्र <piyushxcoder@gmail.com> Co-authored-by: Piyush मिश्र <piyush.raj.kit@gmail.com> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
229 lines
6.1 KiB
Svelte
229 lines
6.1 KiB
Svelte
<script lang="ts">
|
|
import { ResourceService } from '$lib/gen'
|
|
import { workspaceStore } from '$lib/stores'
|
|
import { createEventDispatcher, onMount } from 'svelte'
|
|
import Select from './apps/svelte-select/lib/index'
|
|
import { SELECT_INPUT_DEFAULT_STYLE } from '../defaults'
|
|
import AppConnect from './AppConnectDrawer.svelte'
|
|
import ResourceEditorDrawer from './ResourceEditorDrawer.svelte'
|
|
|
|
import { Button } from './common'
|
|
import DBManagerDrawerButton from './DBManagerDrawerButton.svelte'
|
|
import DarkModeObserver from './DarkModeObserver.svelte'
|
|
import { Pen, Plus, RotateCw } from 'lucide-svelte'
|
|
import { sendUserToast } from '$lib/toast'
|
|
import { isDbType } from './apps/components/display/dbtable/utils'
|
|
import { createDispatcherIfMounted } from '$lib/createDispatcherIfMounted'
|
|
|
|
const dispatch = createEventDispatcher()
|
|
const dispatchIfMounted = createDispatcherIfMounted(dispatch)
|
|
|
|
export let initialValue: string | undefined = undefined
|
|
export let value: string | undefined = initialValue
|
|
export let valueType: string | undefined = undefined
|
|
export let resourceType: string | undefined = undefined
|
|
export let disabled = false
|
|
export let disablePortal = false
|
|
export let showSchemaExplorer = false
|
|
export let selectFirst = false
|
|
export let expressOAuthSetup = false
|
|
export let defaultValues: Record<string, any> | undefined = undefined
|
|
export let placeholder: string | undefined = undefined
|
|
|
|
onMount(() => {
|
|
setTimeout(() => {
|
|
if (Object.keys(defaultValues ?? {}).length > 0 && resourceType) {
|
|
resourceEditor?.initNew?.(resourceType, defaultValues)
|
|
}
|
|
}, 500)
|
|
})
|
|
|
|
let valueSelect =
|
|
initialValue || value
|
|
? {
|
|
value: value ?? initialValue,
|
|
label: value ?? initialValue,
|
|
type: valueType
|
|
}
|
|
: undefined
|
|
|
|
$: if (value === undefined && initialValue) {
|
|
value = initialValue
|
|
}
|
|
|
|
let collection = valueSelect ? [valueSelect] : []
|
|
|
|
export async function askNewResource() {
|
|
appConnect?.open?.(resourceType)
|
|
}
|
|
|
|
let loading = true
|
|
async function loadResources(resourceType: string | undefined) {
|
|
loading = true
|
|
try {
|
|
const resourceTypesToQuery =
|
|
resourceType === 'snowflake' ? ['snowflake', 'snowflake_oauth'] : [resourceType]
|
|
|
|
const resources = await Promise.all(
|
|
resourceTypesToQuery.map((rt) =>
|
|
ResourceService.listResource({
|
|
workspace: $workspaceStore!,
|
|
resourceType: rt
|
|
})
|
|
)
|
|
)
|
|
const nc = resources
|
|
.flat()
|
|
.filter((x) => x.resource_type != 'state' && x.resource_type != 'cache')
|
|
.map((x) => ({
|
|
value: x.path,
|
|
label: x.path,
|
|
type: x.resource_type
|
|
}))
|
|
|
|
// TODO check if this is needed
|
|
if (!nc.find((x) => x.value == value) && (initialValue || value)) {
|
|
nc.push({ value: value ?? initialValue!, label: value ?? initialValue!, type: '' })
|
|
}
|
|
collection = nc
|
|
if (collection.length == 1 && selectFirst && valueSelect == undefined) {
|
|
value = collection[0].value
|
|
valueType = collection[0].type
|
|
valueSelect = collection[0]
|
|
}
|
|
} catch (e) {
|
|
sendUserToast('Failed to load resource types', true)
|
|
console.error(e)
|
|
}
|
|
loading = false
|
|
}
|
|
|
|
$: $workspaceStore && loadResources(resourceType)
|
|
|
|
$: dispatchIfMounted('change', value)
|
|
|
|
let appConnect: AppConnect
|
|
let resourceEditor: ResourceEditorDrawer
|
|
|
|
let darkMode: boolean = false
|
|
</script>
|
|
|
|
<DarkModeObserver bind:darkMode />
|
|
|
|
<AppConnect
|
|
on:refresh={async (e) => {
|
|
await loadResources(resourceType)
|
|
value = e.detail
|
|
valueType = collection.find((x) => x?.value == value)?.type
|
|
valueSelect = {
|
|
value: e.detail,
|
|
label: e.detail,
|
|
type: valueType ?? ''
|
|
}
|
|
}}
|
|
bind:this={appConnect}
|
|
{expressOAuthSetup}
|
|
/>
|
|
<ResourceEditorDrawer
|
|
bind:this={resourceEditor}
|
|
on:refresh={async (e) => {
|
|
await loadResources(resourceType)
|
|
if (e.detail) {
|
|
value = e.detail
|
|
valueType = collection.find((x) => x?.value == value)?.type
|
|
valueSelect = { value: e.detail, label: e.detail, type: valueType ?? '' }
|
|
}
|
|
}}
|
|
/>
|
|
|
|
<div class="flex flex-col w-full items-start min-h-9">
|
|
<div class="flex flex-row w-full items-center">
|
|
{#if collection?.length > 0}
|
|
<Select
|
|
{disabled}
|
|
portal={!disablePortal}
|
|
value={valueSelect}
|
|
on:change={(e) => {
|
|
value = e.detail.value
|
|
valueType = e.detail.type
|
|
valueSelect = e.detail
|
|
}}
|
|
on:clear={() => {
|
|
initialValue = undefined
|
|
value = undefined
|
|
valueType = undefined
|
|
valueSelect = undefined
|
|
dispatch('clear')
|
|
}}
|
|
items={collection}
|
|
class="text-clip grow min-w-0"
|
|
placeholder={placeholder ?? `${resourceType ?? 'any'} resource`}
|
|
inputStyles={SELECT_INPUT_DEFAULT_STYLE.inputStyles}
|
|
containerStyles={darkMode
|
|
? SELECT_INPUT_DEFAULT_STYLE.containerStylesDark
|
|
: SELECT_INPUT_DEFAULT_STYLE.containerStyles}
|
|
/>
|
|
{:else if !loading}
|
|
<div class="text-2xs text-tertiary mr-2">0 found</div>
|
|
{/if}
|
|
{#if !loading}
|
|
<div class="mx-0.5"></div>
|
|
{#if value && value != ''}
|
|
<Button
|
|
{disabled}
|
|
color="light"
|
|
variant="contained"
|
|
size="sm"
|
|
btnClasses="w-8 px-0.5 py-1.5"
|
|
on:click={() => resourceEditor?.initEdit?.(value ?? '')}
|
|
startIcon={{ icon: Pen }}
|
|
iconOnly
|
|
/>
|
|
{/if}
|
|
|
|
{#if resourceType?.includes(',')}
|
|
{#each resourceType.split(',') as rt}
|
|
<Button
|
|
{disabled}
|
|
color="light"
|
|
variant="contained"
|
|
size="sm"
|
|
btnClasses="w-8 px-0.5 py-1.5"
|
|
on:click={() => appConnect?.open?.(rt)}
|
|
startIcon={{ icon: Plus }}>{rt}</Button
|
|
>
|
|
{/each}
|
|
{:else}
|
|
<Button
|
|
{disabled}
|
|
color="light"
|
|
variant="border"
|
|
size="sm"
|
|
on:click={() => appConnect?.open?.(resourceType)}
|
|
startIcon={{ icon: Plus }}
|
|
iconOnly={collection?.length > 0}
|
|
>{#if collection?.length == 0}
|
|
Add a {resourceType} resource
|
|
{/if}</Button
|
|
>
|
|
<div class="mx-0.5"></div>
|
|
{/if}
|
|
{/if}
|
|
|
|
<Button
|
|
variant="contained"
|
|
color="light"
|
|
btnClasses="w-8 px-0.5 py-1.5"
|
|
size="sm"
|
|
on:click={() => {
|
|
loadResources(resourceType)
|
|
}}
|
|
startIcon={{ icon: RotateCw }}
|
|
iconOnly
|
|
/>
|
|
</div>
|
|
{#if showSchemaExplorer && isDbType(resourceType) && value}
|
|
<DBManagerDrawerButton {resourceType} resourcePath={value} />
|
|
{/if}
|
|
</div>
|