mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
fix(app): make custom components available in public apps
This commit is contained in:
@@ -370,24 +370,19 @@ async fn explain_resource_perm_error(
|
||||
}
|
||||
|
||||
async fn custom_component(
|
||||
authed: ApiAuthed,
|
||||
Extension(user_db): Extension<UserDB>,
|
||||
Extension(db): Extension<DB>,
|
||||
Path((w_id, name)): Path<(String, String)>,
|
||||
) -> Result<Response> {
|
||||
let mut tx = user_db.begin(&authed).await?;
|
||||
|
||||
let cc_o = sqlx::query_scalar!(
|
||||
"SELECT value->>'js' FROM resource
|
||||
WHERE path = $1 AND workspace_id = $2",
|
||||
format!("f/app_custom/{name}"),
|
||||
&w_id
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.fetch_optional(&db)
|
||||
.await?
|
||||
.flatten();
|
||||
|
||||
tx.commit().await?;
|
||||
|
||||
let cc = not_found_if_none(cc_o, "Custom Component", name)?;
|
||||
let res = Response::builder().header(header::CONTENT_TYPE, "text/javascript");
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import type { AppInput } from '../../inputType'
|
||||
import { RunnableWrapper } from '../helpers'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import type { CustomComponentConfig } from '../../editor/component'
|
||||
import { Loader2 } from 'lucide-svelte'
|
||||
|
||||
@@ -29,7 +28,7 @@
|
||||
export let customComponent: CustomComponentConfig
|
||||
|
||||
let divId = `custom-component-${id}`
|
||||
const { worldStore } = getContext<AppViewerContext>('AppViewerContext')
|
||||
const { worldStore, workspace } = getContext<AppViewerContext>('AppViewerContext')
|
||||
|
||||
const outputs = initOutput($worldStore, id, {
|
||||
result: undefined,
|
||||
@@ -75,7 +74,7 @@
|
||||
//@ts-ignore
|
||||
await import(
|
||||
/* @vite-ignore */
|
||||
`/api/w/${$workspaceStore ?? 'NO_W'}/resources_u/custom_component/${customComponent.name}`
|
||||
`/api/w/${workspace ?? 'NO_W'}/resources_u/custom_component/${customComponent.name}`
|
||||
)
|
||||
loaded = true
|
||||
try {
|
||||
@@ -105,7 +104,6 @@
|
||||
</script>
|
||||
|
||||
<InitializeComponent {id} />
|
||||
|
||||
{#if render}
|
||||
<div class="w-full h-full overflow-auto {customComponent?.name ?? 'no_name'}">
|
||||
<RunnableWrapper {outputs} {render} autoRefresh {componentInput} {id} bind:result>
|
||||
|
||||
Reference in New Issue
Block a user