Files
windmill/frontend/src/lib/components/sidebar/OperatorMenu.svelte
Tristan TR 3699ce7a8f feat: new live onboarding for flows (#7194)
* Start workspace onboarding

* Add pictures to tutorial steps

* Remove unecessary step

* Continue tutorial by creating a flow together

* Add image into the Create Flow tutorial pop up

* Generate flow from frontend

* Set pause between each node

* Add automatic scripts overview

* Simplify tutorial, and add step to show the code

* Add input step

* Autoremove last step after 5 seconds

* Add flow typing when opening code editor

* Remove lock field from json file

* Add Guides tab on left menu

* Add /guides page

* Add tutorial card in Guides tab

* Add step to show data connector

* Add second text input to show 2 types of inputs and fill them dynamically

* Improve tutorial chronology

* Add flow input connexion with first sctript

* Improve overlay

* Improve wording

* Add new tutorial step to show node b

* Add test step

* Add cursor to pick typescript

* Improve end of tutorial

* Refactor

* Highlight bottom right corner for 5 and 6

* Fix last step overlay

* change home tutorial button

* guidelines nits

* Automate onNext() trigger on step 3

* Improve fakr cursor for Test this step button

* Improve overlay transitions

* Merge data connectors and test step steps

* Improve live code writing in step 3

* Add a step to complete the flow

* Improve the step where we generate remaining scripts

* Refactor

* Add blocking behavior on step 3

* nit about delay

* Prevent clicking on Next while code not generated

* Sharpen wordings

* Remove Svelte 4 and migrate to Svelte 5

* Remove unecesary helper function

* Add toast if the user clicks on Next button before code finished generating

* Add toasts to each step

* Improve tutorial trigger timing

* Improve delays

* Add cursor movement to Test Flow button

* Block previous on certain steps to prevent bug

* Fix for github npm check

* Fix for github npm check

* Unlike workspace onboarding and flow tutorial

* Rename flow tutorial with better name

* Remove the automatic trigger for flow previous and broken tutorial

* Push tutorials to Help sectionof the sidebar

* Fix redirection t /tutorials page

* Add tutorials page and update workspace onboarding flow

- Rename guides to tutorials page (/tutorials)
- Add workspace onboarding tutorial to tutorials page
- Remove Tutorial button from homepage
- Add welcome cards for empty workspace with 3 tutorial options
- Update workspace onboarding to redirect to homepage before starting
- Clean up URL parameter after tutorial completion
- Move Tutorials to Help menu in sidebar
- Remove automatic "action" tutorial trigger for new flows
- Add flow-live-tutorial (renamed from workspace-onboarding-continue)
- Add Previous button blocking with toast notifications in flow tutorial

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add tutorials to workspace homepage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Start tutorials for Run/logs section

* Fix data connector

* Add flow execution graph from Run drawer

* Add tabs highlighting in drawer

* Improve tutorial on run drawer

* Add mouse cursor moving from graph tab

* Add cursor click on script in Drawer Graph tabs

* Add troubleshooting flow in tutorial

* Add step to show logs of failed step

* add step 7 to invite the user to fix by himself and se the new results

* Improve wording

* Nit improvements

* Nits

* Refactor

* Refactor

* Rename the tutorial

* Remove deleted file

* Improve wording

* Improve first step of troubleshooting flow tutorial

* Add tutorials to /tutorials page and create component

* Remove previous Flow tutorials

* Fixes, and improve tutorial button design

* Improve status in Tutorial button

* Align tutorial button to brand guidelines

* Add skip all to onboarding workspace tutorial

* Add skipped_all to tutorial_progress

* Connect backend and frontend for tutorial progress

* Add store and helper to display or not Tutorials from left menu

* Add reminder at the end of each tutorial

* Add tutorial banner

* Remove tutorials from elpty workspace

* Improve Tutorials page

* Align banner to guidelines

* Add reset tutorials buttons

* Refactor

* Refactor to make it easy to add new tutorials and tabs

* Improve tutorial config to make it easy to add new tutorials

* Refactor and remove hardcoded indexes

* Add getTutorialIndex in tutorial config file

* Nit

* Add Mark all as complete button in tutorial page

* Add skip tutorial button in banner toast

* Replace if else in tutorials router by map to make it easier to maintain and scale

* Delete broken simple app tutorial

* Add Guide flow guide buttons inside the Create Flow page

* Add flow editor tutorials into flow builder page

* Update existing app tutorials with new tutorial system

* Create a dedicated tutorial category for app editor

* Add global progress bar

* Add Reset & Skip at tutorial category level

* Add progress to tab title

* Nits on design

* Make progress bar a props and design nits

* Add active props for Tutorial Category

* Display tutorials according to the user role

* Adapt progress bar to the user role

* Add roles array for each tutorial

* Add Tutorials tab in Operator menu

* Edge case if no Category and no Tutorial available for my role

* Allow the user to reset a single tutorial

* Allow a user to mark as completed a single tutorial

* Nit on hoovering tutorial status

* Allow admins to see which tutorials are available per role

* Create utils that allow admins to see which tutorials can access other roles of their organization

* Refactor resetSingleTutorial and completeSingleTutorial into one function

* Improve role system

* Remove hardcoded MAX_TUTORIAL_ID

* Fix type assertion

* Remove console log

* Reduce recalculations when unrelated state changes

* Add console.error

* Remove unused function

* Add tutorial wrapper and better router

* Nits to pass npm checks

* Fix typescripts and lint errors

* Add SQLx query cache for tutorial_progress queries

* Improve wording for workspace tutorial

---------

Co-authored-by: Diego Imbert <diego@windmill.dev>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2025-12-08 16:42:35 +00:00

375 lines
8.9 KiB
Svelte

<script lang="ts">
import {
Home,
Menu as MenuIcon,
Play,
Settings,
LogOut,
Moon,
Sun,
Code2,
LayoutDashboard,
Building,
Calendar,
ServerCog,
GraduationCap
} from 'lucide-svelte'
import { base } from '$lib/base'
import MultiplayerMenu from './MultiplayerMenu.svelte'
import {
clearWorkspaceFromStorage,
enterpriseLicense,
superadmin,
userWorkspaces,
workspaceStore,
tutorialsToDo,
skippedAll
} from '$lib/stores'
import { twMerge } from 'tailwind-merge'
import { USER_SETTINGS_HASH } from './settings'
import { logout } from '$lib/logout'
import DarkModeObserver from '../DarkModeObserver.svelte'
import BarsStaggered from '../icons/BarsStaggered.svelte'
import { Menu, Menubar, MenuItem } from '$lib/components/meltComponents'
import MenuButton, { sidebarClasses } from './MenuButton.svelte'
import MenuLink from './MenuLink.svelte'
import { onDestroy } from 'svelte'
let darkMode: boolean = $state(false)
interface Props {
isCollapsed?: boolean
favoriteLinks?: any
}
let {
isCollapsed = false,
favoriteLinks = [] as {
label: string
href: string
kind: 'script' | 'flow' | 'app' | 'raw_app'
}[]
}: Props = $props()
let mainMenuLinks = $derived(
[
{ label: 'Home', id: 'home', href: `${base}/`, icon: Home },
{ label: 'Runs', id: 'runs', href: `${base}/runs`, icon: Play },
{ label: 'Schedules', id: 'schedules', href: `${base}/schedules`, icon: Calendar },
// Add Tutorials to main menu only if not all completed and not skipped
...($tutorialsToDo.length > 0 && !$skippedAll
? [
{
label: 'Tutorials',
id: 'tutorials',
href: `${base}/tutorials`,
icon: GraduationCap
}
]
: [])
].filter(
(link) =>
link.id === 'home' ||
link.id === 'tutorials' ||
($userWorkspaces &&
$workspaceStore &&
$userWorkspaces.find((_) => _.id === $workspaceStore)?.operator_settings?.[link.id] ===
true)
)
)
let secondMenuLinks = $derived(
[
{
label: 'Resources',
id: 'resources',
href: `${base}/resources`
},
{
label: 'Variables',
id: 'variables',
href: `${base}/variables`
},
{
label: 'Assets',
id: 'assets',
href: `${base}/assets`
},
{
label: 'Custom HTTP routes',
id: 'triggers',
href: `${base}/routes`
},
{
label: 'Websocket triggers',
id: 'triggers',
href: `${base}/websocket_triggers`
},
{
label: 'Postgres triggers',
id: 'triggers',
href: `${base}/postgres_triggers`
},
{
label: 'Kafka triggers',
id: 'triggers',
href: `${base}/kafka_triggers`
},
{
label: 'NATS triggers',
id: 'triggers',
href: `${base}/nats_triggers`
},
{
label: 'SQS triggers',
id: 'triggers',
href: `${base}/sqs_triggers`
},
{
label: 'GCP Pub/Sub triggers',
id: 'triggers',
href: `${base}/gcp_triggers`
},
{
label: 'MQTT triggers',
id: 'triggers',
href: `${base}/mqtt_triggers`
},
{
label: 'Email triggers',
id: 'triggers',
href: `${base}/email_triggers`
},
{
label: 'Audit logs',
id: 'audit_logs',
href: `${base}/audit_logs`
},
{
label: 'Groups',
id: 'groups',
href: `${base}/groups`
},
{
label: 'Folders',
id: 'folders',
href: `${base}/folders`
},
{
label: 'Workers',
id: 'workers',
href: `${base}/workers`
}
].filter((link) => {
if (!$userWorkspaces || !$workspaceStore) return false
return (
$userWorkspaces.find((_) => _.id === $workspaceStore)?.operator_settings?.[link.id] === true
)
})
)
let moreOpen = $state(false)
let moreOpenTimeout: number | undefined = $state()
function debouncedSetMoreOpen(value: boolean) {
if (moreOpenTimeout) {
clearTimeout(moreOpenTimeout)
}
moreOpenTimeout = setTimeout(() => {
moreOpen = value
}, 150) // 150ms debounce
}
onDestroy(() => {
if (moreOpenTimeout) {
clearTimeout(moreOpenTimeout)
}
})
</script>
<Menubar>
{#snippet children({ createMenu })}
<Menu {createMenu} usePointerDownOutside>
{#snippet triggr({ trigger })}
<MenuButton
class="!text-xs"
icon={MenuIcon}
{isCollapsed}
lightMode
label={undefined}
{trigger}
/>
{/snippet}
{#snippet children({ item })}
<div class="w-full max-w-full">
{#each favoriteLinks ?? [] as favorite (favorite.href)}
<MenuItem
href={favorite.href}
{item}
class={twMerge(
'w-full inline-flex flex-row px-2 py-2 hover:bg-surface-hover',
'data-[highlighted]:bg-surface-hover'
)}
>
<span class="center-center">
{#if favorite.kind == 'script'}
<Code2 size={16} />
{:else if favorite.kind == 'flow'}
<BarsStaggered size={16} />
{:else if favorite.kind == 'app' || favorite.kind == 'raw_app'}
<LayoutDashboard size={16} />
{/if}
</span>
<span class="text-primary ml-2 grow min-w-0 text-xs truncate">
{favorite.label}
</span>
</MenuItem>
{/each}
</div>
{#each mainMenuLinks as menuLink (menuLink.href ?? menuLink.label)}
<MenuLink class="!text-xs" {...menuLink} {isCollapsed} {item} lightMode />
{/each}
<div class="divide-y" role="none">
<div role="none">
<MenuItem
href={USER_SETTINGS_HASH}
class={twMerge(
'flex flex-row gap-3.5 items-center px-2 py-2',
sidebarClasses.text,
sidebarClasses.hoverBg
)}
lightMode
{item}
>
<Settings size={14} />
Account settings
</MenuItem>
</div>
<div role="none">
<MenuItem
onClick={() => {
if (!document.documentElement.classList.contains('dark')) {
document.documentElement.classList.add('dark')
window.localStorage.setItem('dark-mode', 'dark')
} else {
document.documentElement.classList.remove('dark')
window.localStorage.setItem('dark-mode', 'light')
}
}}
lightMode
class={twMerge(
'w-full flex gap-3.5 px-2 py-2',
sidebarClasses.hoverBg,
sidebarClasses.text
)}
{item}
>
{#if darkMode}
<Sun size={14} />
{:else}
<Moon size={14} />
{/if}
Switch theme
</MenuItem>
<MenuItem
href="{base}/user/workspaces"
onClick={() => clearWorkspaceFromStorage()}
lightMode
class={twMerge('flex gap-3.5 px-2 py-2', sidebarClasses.hoverBg, sidebarClasses.text)}
{item}
>
<Building size={14} />
All workspaces
</MenuItem>
{#if $superadmin}
<MenuItem
href="#superadmin-settings"
class={twMerge(
'flex flex-row gap-3.5 items-center px-2 py-2 ',
'text-secondary text-xs',
'hover:bg-surface-hover hover:text-primary cursor-pointer',
'data-[highlighted]:bg-surface-hover data-[highlighted]:text-primary'
)}
{item}
>
<ServerCog size={14} />
Instance settings
</MenuItem>
{/if}
<MenuItem
onClick={() => logout()}
class={twMerge(
'flex flex-row gap-3.5 items-center px-2 py-2 w-full',
'text-secondary text-xs',
'hover:bg-surface-hover hover:text-primary cursor-pointer',
'data-[highlighted]:bg-surface-hover data-[highlighted]:text-primary'
)}
{item}
>
<LogOut size={14} />
Sign out
</MenuItem>
</div>
<div
onmouseenter={() => debouncedSetMoreOpen(true)}
onmouseleave={() => debouncedSetMoreOpen(false)}
role="none"
>
<MenuItem
onFocusIn={() => debouncedSetMoreOpen(true)}
onFocusOut={() => debouncedSetMoreOpen(false)}
{item}
>
{#if !moreOpen || secondMenuLinks.length === 0}
<div class="px-2 py-2 text-primary text-2xs">More...</div>
{/if}
</MenuItem>
{#if moreOpen && secondMenuLinks.length > 0}
{#each secondMenuLinks as menuLink (menuLink.href ?? menuLink.label)}
<div>
<MenuItem
href={menuLink.href}
class={twMerge(
'flex flex-row gap-3.5 items-center px-2 py-2 text-secondary text-2xs hover:bg-surface-hover hover:text-primary cursor-pointer',
'data-[highlighted]:bg-surface-hover data-[highlighted]:text-primary'
)}
{item}
onFocusIn={() => debouncedSetMoreOpen(true)}
onFocusOut={() => debouncedSetMoreOpen(false)}
>
{menuLink.label}
</MenuItem>
</div>
{/each}
{/if}
</div>
</div>
{#if $enterpriseLicense}
<div
onmouseenter={() => {
if (moreOpenTimeout) {
setTimeout(() => {
clearTimeout(moreOpenTimeout)
}, 15)
}
}}
onmouseleave={() => {
debouncedSetMoreOpen(false)
}}
role="none"
>
<MultiplayerMenu />
</div>
{/if}
{/snippet}
</Menu>
{/snippet}
</Menubar>
<DarkModeObserver bind:darkMode />