mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 08:01:25 +00:00
Filter script kinds in the backend (#2450)
This commit is contained in:
committed by
GitHub
parent
ad75e78228
commit
bcdff7d6f1
@@ -3820,10 +3820,10 @@ paths:
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
- name: kind
|
||||
- name: kinds
|
||||
description: |
|
||||
(default regardless)
|
||||
script kind
|
||||
script kinds to filter, split by comma
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
|
||||
@@ -2773,10 +2773,10 @@ paths:
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
- name: kind
|
||||
- name: kinds
|
||||
description: |
|
||||
(default regardless)
|
||||
script kind
|
||||
script kinds to filter, split by comma
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
|
||||
@@ -218,8 +218,15 @@ async fn list_scripts(
|
||||
if let Some(it) = &lq.is_template {
|
||||
sqlb.and_where_eq("is_template", it);
|
||||
}
|
||||
if let Some(k) = &lq.kind {
|
||||
sqlb.and_where_eq("kind", "?".bind(&k.to_lowercase()));
|
||||
if let Some(kinds_val) = &lq.kinds {
|
||||
let lowercased_kinds: Vec<String> = kinds_val
|
||||
.split(",")
|
||||
.map(&str::to_lowercase)
|
||||
.map(sql_builder::quote)
|
||||
.collect();
|
||||
if lowercased_kinds.len() > 0 {
|
||||
sqlb.and_where_in("kind", lowercased_kinds.as_slice());
|
||||
}
|
||||
}
|
||||
if lq.starred_only.unwrap_or(false) {
|
||||
sqlb.and_where_is_not_null("favorite.path");
|
||||
|
||||
@@ -231,7 +231,7 @@ pub struct ListScriptQuery {
|
||||
pub order_by: Option<String>,
|
||||
pub order_desc: Option<bool>,
|
||||
pub is_template: Option<bool>,
|
||||
pub kind: Option<String>,
|
||||
pub kinds: Option<String>,
|
||||
pub starred_only: Option<bool>,
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
<ScriptPicker
|
||||
disabled={!isEditable}
|
||||
initialPath={customInitialScriptPath}
|
||||
kinds={[Script.kind.SCRIPT]}
|
||||
kinds={[Script.kind.SCRIPT, Script.kind.FAILURE]}
|
||||
allowFlow={true}
|
||||
bind:scriptPath={handlerPath}
|
||||
bind:itemKind={customHandlerKind}
|
||||
|
||||
@@ -48,23 +48,12 @@
|
||||
label: `${flow.path}${flow.summary ? ` | ${truncate(flow.summary, 20)}` : ''}`
|
||||
}))
|
||||
} else if (itemKind == 'script') {
|
||||
if (kinds.length === 1) {
|
||||
items = (await ScriptService.listScripts({ workspace: $workspaceStore!, kind: kinds[0]})).map(
|
||||
items = (await ScriptService.listScripts({ workspace: $workspaceStore!, kinds: kinds.join(",")})).map(
|
||||
(script) => ({
|
||||
value: script.path,
|
||||
label: `${script.path}${script.summary ? ` | ${truncate(script.summary, 20)}` : ''}`
|
||||
})
|
||||
)
|
||||
} else {
|
||||
items = (await ScriptService.listScripts({ workspace: $workspaceStore! })).filter(
|
||||
(script) => kinds.includes(script.kind)
|
||||
).map(
|
||||
(script) => ({
|
||||
value: script.path,
|
||||
label: `${script.path}${script.summary ? ` | ${truncate(script.summary, 20)}` : ''}`
|
||||
})
|
||||
)
|
||||
}
|
||||
} else {
|
||||
items =
|
||||
$hubScripts?.map((x) => ({
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
async function loadItems(): Promise<Item[]> {
|
||||
return await ScriptService.listScripts({ workspace: $workspaceStore!, kind })
|
||||
return await ScriptService.listScripts({ workspace: $workspaceStore!, kinds: kind })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
$: $workspaceStore && kind && loadItems()
|
||||
|
||||
async function loadItems(): Promise<void> {
|
||||
items = await ScriptService.listScripts({ workspace: $workspaceStore!, kind, isTemplate })
|
||||
items = await ScriptService.listScripts({ workspace: $workspaceStore!, kinds: kind, isTemplate })
|
||||
}
|
||||
|
||||
let ownerFilter: string | undefined = undefined
|
||||
|
||||
Reference in New Issue
Block a user