diff --git a/frontend/README_DEV.md b/frontend/README_DEV.md index 7e9c285c62..48a76a1b5e 100644 --- a/frontend/README_DEV.md +++ b/frontend/README_DEV.md @@ -28,23 +28,20 @@ docker compose up db windmill_server windmill_worker - Install llvm **On OSX:** - ```bash brew install llvm caddy gsed - + # make LLVM tools available on PATH echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc - + # now, restart your shell. You should now have the `lld` binary on your PATH. ``` - - To test that you have Rust and Cargo installed run `cargo --version` - In your terminal, go to the backend directory and run `cargo build` - Run `cargo run` **Known issue on M1 Mac while running `cargo build`** - - You may encounter `linking with cc failed` build time error. - To solve this run: ```bash @@ -52,6 +49,7 @@ docker compose up db windmill_server windmill_worker source ~/.zshrc ``` + **Do a Frontend Build** In order to run the backend, you need to have a frontend build inside `frontend/build/`. @@ -72,14 +70,11 @@ npm run build ``` **Known issue while running `npm run build`** - - You may encounter `FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory` error. - To solve this run: - ```bash export NODE_OPTIONS=--max_old_space_size=8096 ``` - - run `npm run build` again In the root folder: @@ -151,13 +146,13 @@ Recommended config for VS Code: - turn _format on save_ on + ## Building The project is built with [SvelteKit](https://kit.svelte.dev/) and uses as output static files. There are others adapters for sveltekit, but we use the static adapter. To build the frontend as static assets, use: - ``` npm run build ``` @@ -165,11 +160,10 @@ npm run build The output is in the `build` folder. The default build assume you serve every non static files as the 200.html file which is catchall. If you prefer a normal layout, you can use: - ``` NOTCATCHALL=true npm run build ``` - which will generate an index.html and allow you to serve the frontend with any static server. Env variables used for build are set in .env file. See [https://vitejs.dev/guide/env-and-mode.html#env-files](https://vitejs.dev/guide/env-and-mode.html#env-files) for more details. + diff --git a/frontend/src/lib/components/EditorBar.svelte b/frontend/src/lib/components/EditorBar.svelte index ab03d241de..3a00e8c6dc 100644 --- a/frontend/src/lib/components/EditorBar.svelte +++ b/frontend/src/lib/components/EditorBar.svelte @@ -26,11 +26,11 @@ import DrawerContent from './common/drawer/DrawerContent.svelte' import { Badge, Drawer } from './common' import WorkspaceScriptPicker from './flows/pickers/WorkspaceScriptPicker.svelte' + import PickHubScript from './flows/pickers/PickHubScript.svelte' import ToggleHubWorkspace from './ToggleHubWorkspace.svelte' import Skeleton from './common/skeleton/Skeleton.svelte' import Popover from './Popover.svelte' import Kbd from './common/kbd/Kbd.svelte' - import PickHubItems from './flows/pickers/PickHubItems.svelte' export let lang: 'python3' | 'deno' | 'go' | 'bash' export let editor: Editor | undefined @@ -86,9 +86,9 @@ {#if pick_existing == 'hub'} - + - + {:else} diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte index 2d43e15f3e..5eb2272998 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/EmptyInlineScript.svelte @@ -2,6 +2,7 @@ import type { Schema } from '$lib/common' import { Button, Drawer, DrawerContent, Tab, Tabs } from '$lib/components/common' import FlowScriptPicker from '$lib/components/flows/pickers/FlowScriptPicker.svelte' + import PickHubScript from '$lib/components/flows/pickers/PickHubScript.svelte' import Tooltip from '$lib/components/Tooltip.svelte' import { Script, type Preview } from '$lib/gen' import { inferArgs } from '$lib/infer' @@ -15,7 +16,6 @@ import { defaultCode } from '../component' import InlineScriptList from '../settingsPanel/mainInput/InlineScriptList.svelte' import WorkspaceScriptList from '../settingsPanel/mainInput/WorkspaceScriptList.svelte' - import PickHubItems from '$lib/components/flows/pickers/PickHubItems.svelte' export let name: string export let componentType: string | undefined = undefined @@ -130,11 +130,7 @@ {:else if tab == 'workspacescripts'} pickScript(e.detail)} /> {:else if tab == 'hubscripts'} - pickHubScript(e.detail.path)} - /> + pickHubScript(e.detail.path)} /> {/if} diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte index 377847f10e..daa0abc0b5 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte @@ -1,6 +1,7 @@ - +{#if hubApps} + {#if filteredItems.length == 0} + + {:else} +
    + {#each filteredItems as item (item)} +
  • + +
  • + {/each} +
+ {/if} +{:else} +
+ {#each Array(10).fill(0) as _} + + {/each} +{/if} diff --git a/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte b/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte index 4bd0edb947..debcdd2c20 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubFlow.svelte @@ -1,34 +1,82 @@ - +{#if hubFlows} + {#if filteredItems.length == 0} + + {:else} +
    + {#each filteredItems as item (item)} +
  • + +
  • + {/each} +
+ {/if} +{:else} +
+ + {#each Array(10).fill(0) as _} + + {/each} +{/if} diff --git a/frontend/src/lib/components/flows/pickers/PickHubItems.svelte b/frontend/src/lib/components/flows/pickers/PickHubItems.svelte deleted file mode 100644 index ebfadd2b68..0000000000 --- a/frontend/src/lib/components/flows/pickers/PickHubItems.svelte +++ /dev/null @@ -1,150 +0,0 @@ - - - - x.data.summary} /> -
- {#if selectedKind === undefined} - - -
- - Scripts -
-
- -
- - Flows -
-
- -
- - Apps -
-
-
- {/if} - - -
- - - -{#if Array.isArray(prefilteredItems)} - {#if notLoaded} - {#each Array(10).fill(0) as _} - - {/each} - {:else if filteredItems.length == 0} - - {:else} -
    - {#each filteredItems as item, index (index)} -
  • - {#if item.itemType === 'script'} - dispatch('pickScript', item.data)} - {kind} - /> - {:else if item.itemType === 'flow'} - dispatch('pickFlow', item.data)} /> - {:else if item.itemType === 'app'} - dispatch('pickApp', item.data)} /> - {/if} -
  • - {/each} -
- {/if} -{:else} -
- {#each Array(10).fill(0) as _} - - {/each} -{/if} diff --git a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte index 9f75116963..2189e34b34 100644 --- a/frontend/src/lib/components/flows/pickers/PickHubScript.svelte +++ b/frontend/src/lib/components/flows/pickers/PickHubScript.svelte @@ -1,44 +1,95 @@ - + + {/each} + {/if} - + {#if filteredItems.length > maxItems} +
+ There are more items ({filteredItems.length}) than being displayed. Refine your search. +
+ {/if} +{:else} +
+ {#each Array(10).fill(0) as _} + + {/each} +{/if} diff --git a/frontend/src/lib/stores.ts b/frontend/src/lib/stores.ts index a535a6b6cd..045700fc46 100644 --- a/frontend/src/lib/stores.ts +++ b/frontend/src/lib/stores.ts @@ -52,42 +52,17 @@ export const userWorkspaces: Readable< return originalWorkspaces } }) - -export type HubScript = { - path: string - summary: string - approved: boolean - kind: string - app: string - ask_id: number -} - -export type HubFlow = { - id: number - flow_id: number - summary: string - apps: string[] - approved: boolean - votes: number -} - -export type HubApp = { - id: number - app_id: number - summary: string - apps: Array - approved: boolean - votes: number -} - -export type HubItem = - | { itemType: 'script'; data: HubScript & { marked?: string } } - | { itemType: 'flow'; data: HubFlow & { marked?: string } } - | { itemType: 'app'; data: HubApp & { marked?: string } } - -export const hubScripts = writable | undefined>(undefined) -export const hubFlows = writable | undefined>(undefined) -export const hubApps = writable | undefined>(undefined) +export const hubScripts = writable< + | Array<{ + path: string + summary: string + approved: boolean + kind: string + app: string + ask_id: number + }> + | undefined +>(undefined) if (browser) { workspaceStore.subscribe(async (workspace) => { diff --git a/frontend/src/routes/(root)/(logged)/+page.svelte b/frontend/src/routes/(root)/(logged)/+page.svelte index 12fa90d485..5a1a8a3f4f 100644 --- a/frontend/src/routes/(root)/(logged)/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/+page.svelte @@ -8,19 +8,20 @@ import { getScriptByPath } from '$lib/utils' import type { HubItem } from '$lib/components/flows/pickers/model' import { faCodeFork } from '@fortawesome/free-solid-svg-icons' - + import PickHubScript from '$lib/components/flows/pickers/PickHubScript.svelte' + import PickHubFlow from '$lib/components/flows/pickers/PickHubFlow.svelte' import FlowViewer from '$lib/components/FlowViewer.svelte' import HighlightCode from '$lib/components/HighlightCode.svelte' import { Building, Globe2 } from 'lucide-svelte' import ItemsList from '$lib/components/home/ItemsList.svelte' import CreateActionsApp from '$lib/components/flows/CreateActionsApp.svelte' + import PickHubApp from '$lib/components/flows/pickers/PickHubApp.svelte' import AppPreview from '$lib/components/apps/editor/AppPreview.svelte' import { writable } from 'svelte/store' import type { EditorBreakpoint } from '$lib/components/apps/types' - import PickHubItems from '$lib/components/flows/pickers/PickHubItems.svelte' - type Tab = 'hub' | 'workspace' + type Tab = 'hubscripts' | 'hubflows' | 'hubapps' | 'workspace' let tab: Tab = window.location.hash?.includes('#') ? (window.location.hash?.replace('#', '') as Tab) @@ -202,10 +203,22 @@ Workspace
- +
- Hub + Hub Scripts +
+
+ +
+ + Hub Flows +
+
+ +
+ + Hub Apps
@@ -214,17 +227,24 @@
- {#if tab == 'hub'} - viewApp(e.detail)} - on:pickFlow={(e) => viewFlow(e.detail)} - on:pickScript={(e) => viewCode(e.detail)} + {#if tab == 'hubscripts'} + viewCode(e.detail)} + > + {:else if tab == 'hubflows'} + viewFlow(e.detail)} + > + {:else if tab == 'hubapps'} + viewApp(e.detail)} + > - - {/if}