mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 08:04:25 +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>
170 lines
4.6 KiB
TypeScript
170 lines
4.6 KiB
TypeScript
import {
|
|
getLanguageByResourceType,
|
|
type ColumnDef,
|
|
type DbType
|
|
} from './apps/components/display/dbtable/utils'
|
|
import { makeSelectQuery } from './apps/components/display/dbtable/queries/select'
|
|
import { runPreviewJobAndPollResult } from './jobs/utils'
|
|
import { makeCountQuery } from './apps/components/display/dbtable/queries/count'
|
|
import { makeUpdateQuery } from './apps/components/display/dbtable/queries/update'
|
|
import { makeDeleteQuery } from './apps/components/display/dbtable/queries/delete'
|
|
import { makeInsertQuery } from './apps/components/display/dbtable/queries/insert'
|
|
import { Trash2 } from 'lucide-svelte'
|
|
import { makeDeleteTableQuery } from './apps/components/display/dbtable/queries/deleteTable'
|
|
|
|
export type IDbTableOps = {
|
|
resourcePath: string
|
|
resourceType: DbType
|
|
tableKey: string
|
|
colDefs: ColumnDef[]
|
|
|
|
getRows: (params: {
|
|
offset: number
|
|
limit: number
|
|
quicksearch: string
|
|
order_by: string
|
|
is_desc: boolean
|
|
}) => Promise<unknown[]>
|
|
getCount: (params: { quicksearch: string }) => Promise<number>
|
|
onUpdate?: (
|
|
row: { values: object },
|
|
colDef: { field: string; datatype: string },
|
|
newValue: string
|
|
) => Promise<void>
|
|
onDelete?: (row: { values: object }) => Promise<void>
|
|
onInsert?: (row: { values: object }) => Promise<void>
|
|
}
|
|
|
|
export function dbTableOpsWithPreviewScripts({
|
|
resourcePath,
|
|
resourceType,
|
|
tableKey,
|
|
colDefs,
|
|
workspace
|
|
}: {
|
|
resourcePath: string
|
|
resourceType: DbType
|
|
tableKey: string
|
|
colDefs: ColumnDef[]
|
|
workspace: string
|
|
}): IDbTableOps {
|
|
return {
|
|
resourcePath,
|
|
resourceType,
|
|
tableKey,
|
|
colDefs,
|
|
getCount: async ({ quicksearch }) => {
|
|
const countQuery = makeCountQuery(resourceType, tableKey, undefined, colDefs)
|
|
const result = await runPreviewJobAndPollResult({
|
|
workspace,
|
|
requestBody: {
|
|
args: { database: '$res:' + resourcePath, quicksearch },
|
|
language: getLanguageByResourceType(resourceType),
|
|
content: countQuery
|
|
}
|
|
})
|
|
const count = result?.[0].count as number
|
|
return count
|
|
},
|
|
getRows: async (params) => {
|
|
const query = makeSelectQuery(tableKey, colDefs, undefined, resourceType as DbType)
|
|
let items = (await runPreviewJobAndPollResult({
|
|
workspace,
|
|
requestBody: {
|
|
args: { database: '$res:' + resourcePath, ...params },
|
|
language: getLanguageByResourceType(resourceType),
|
|
content: query
|
|
}
|
|
})) as unknown[]
|
|
if (resourceType === 'ms_sql_server') items = items?.[0] as unknown[]
|
|
if (!items || !Array.isArray(items)) {
|
|
throw 'items is not an array'
|
|
}
|
|
return items
|
|
},
|
|
onUpdate: async ({ values }, colDef, newValue) => {
|
|
const updateQuery = makeUpdateQuery(tableKey, colDef, colDefs, resourceType)
|
|
|
|
await runPreviewJobAndPollResult({
|
|
workspace,
|
|
requestBody: {
|
|
args: {
|
|
database: '$res:' + resourcePath,
|
|
value_to_update: newValue,
|
|
...values
|
|
},
|
|
language: getLanguageByResourceType(resourceType),
|
|
content: updateQuery
|
|
}
|
|
})
|
|
},
|
|
onDelete: async ({ values }) => {
|
|
const deleteQuery = makeDeleteQuery(tableKey, colDefs, resourceType)
|
|
|
|
await runPreviewJobAndPollResult({
|
|
workspace,
|
|
requestBody: {
|
|
args: { database: '$res:' + resourcePath, ...values },
|
|
language: getLanguageByResourceType(resourceType),
|
|
content: deleteQuery
|
|
}
|
|
})
|
|
},
|
|
onInsert: async ({ values }) => {
|
|
const insertQuery = makeInsertQuery(tableKey, colDefs, resourceType)
|
|
runPreviewJobAndPollResult({
|
|
workspace,
|
|
requestBody: {
|
|
args: { database: '$res:' + resourcePath, ...values },
|
|
language: getLanguageByResourceType(resourceType),
|
|
content: insertQuery
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
export type DbTableAction = {
|
|
action: () => void | Promise<void>
|
|
displayName: string
|
|
confirmTitle?: string
|
|
confirmBtnText?: string
|
|
icon?: any
|
|
successText?: string
|
|
}
|
|
|
|
export type DbTableActionFactory = (params: {
|
|
tableKey: string
|
|
refresh: () => void
|
|
}) => DbTableAction
|
|
|
|
export function dbDeleteTableActionWithPreviewScript({
|
|
workspace,
|
|
resourcePath,
|
|
resourceType
|
|
}: {
|
|
workspace: string
|
|
resourcePath: string
|
|
resourceType: DbType
|
|
}): DbTableActionFactory {
|
|
return ({ tableKey, refresh }) => ({
|
|
confirmTitle: `Are you sure you want to delete '${tableKey}' ? This action is irreversible`,
|
|
displayName: 'Delete',
|
|
confirmBtnText: `Delete permanently`,
|
|
icon: Trash2,
|
|
successText: `Table '${tableKey}' deleted successfully`,
|
|
action: async () => {
|
|
const deleteQuery = makeDeleteTableQuery(tableKey, resourceType)
|
|
await runPreviewJobAndPollResult({
|
|
workspace,
|
|
requestBody: {
|
|
args: { database: '$res:' + resourcePath },
|
|
language: getLanguageByResourceType(resourceType),
|
|
content: deleteQuery
|
|
}
|
|
})
|
|
refresh()
|
|
}
|
|
})
|
|
}
|