From f25a927b44bcdfd7cb12775dc9a3b219abe2adad Mon Sep 17 00:00:00 2001 From: Guilhem Date: Sun, 11 Aug 2024 01:09:14 +0200 Subject: [PATCH] dev(frontend) move component options into editor menu (#4221) * dev(frontend) move component options into editor menu * dev(frontend) move component options into editor menu * dev(frontend) add editor menu popovers --------- Co-authored-by: Guilhem Le Mouel --- backend/windmill-api/src/settings.rs | 4 +- .../apps/editor/ComponentHeader.svelte | 303 ++++++++++-------- .../apps/editor/DecisionTreeDebug.svelte | 30 +- .../components/apps/editor/GridEditor.svelte | 54 ++-- .../apps/editor/GridEditorMenu.svelte | 133 ++++++-- .../components/apps/editor/TabsDebug.svelte | 27 +- .../apps/editor/component/Component.svelte | 3 + 7 files changed, 351 insertions(+), 203 deletions(-) diff --git a/backend/windmill-api/src/settings.rs b/backend/windmill-api/src/settings.rs index c0a8c2960f..63bb0b11ce 100644 --- a/backend/windmill-api/src/settings.rs +++ b/backend/windmill-api/src/settings.rs @@ -350,7 +350,7 @@ pub async fn renew_license_key() -> Result { pub async fn renew_license_key(Extension(db): Extension, authed: ApiAuthed) -> Result { require_super_admin(&db, &authed.email).await?; windmill_common::stats_ee::send_stats(&"manual".to_string(), &HTTP_CLIENT, &db).await?; - let result = windmill_common::ee::renew_license_key(&HTTP_CLIENT, &db).await; + let result = windmill_common::ee::renew_license_key(&HTTP_CLIENT, &db, None).await; if result != "success" { return Err(error::Error::BadRequest(format!( @@ -371,7 +371,7 @@ pub async fn create_customer_portal_session() -> Result { #[cfg(feature = "enterprise")] pub async fn create_customer_portal_session() -> Result { - let url = windmill_common::ee::create_customer_portal_session(&HTTP_CLIENT).await?; + let url = windmill_common::ee::create_customer_portal_session(&HTTP_CLIENT, None).await?; return Ok(url); } diff --git a/frontend/src/lib/components/apps/editor/ComponentHeader.svelte b/frontend/src/lib/components/apps/editor/ComponentHeader.svelte index 5d1fbd7b12..2f4ffe8b15 100644 --- a/frontend/src/lib/components/apps/editor/ComponentHeader.svelte +++ b/frontend/src/lib/components/apps/editor/ComponentHeader.svelte @@ -1,7 +1,7 @@ {#if connecting} @@ -54,142 +82,153 @@ {#if selected || hover} - { - dispatch('mouseover') - }} - on:mousedown|stopPropagation|capture - draggable="false" - title={`Id: ${component.id}`} - class={twMerge( - 'px-2 text-2xs font-semibold w-fit absolute shadow -top-[9px] -left-[8px] border rounded-sm z-50 cursor-move', - selected - ? 'bg-indigo-500/90 border-indigo-600 text-white' - : $connectingInput.opened - ? 'bg-red-500/90 border-red-600 text-white' - : 'bg-blue-500/90 border-blue-600 text-white' - )} - > - {component.id} - -{/if} - -{#if selected && !connecting} -
- {#if hasInlineEditor} - - {/if} - {#if component.type === 'conditionalwrapper'} - - {:else if component.type === 'steppercomponent' || (component.type === 'tabscomponent' && component.configuration.tabsKind.type === 'static' && component.configuration.tabsKind.value === 'invisibleOnView')} - - {:else if component.type === 'decisiontreecomponent'} - - - {/if} - - - - - - - - +
{ + dispatch('mouseover') + }} on:mousedown|stopPropagation|capture - class={classNames( - 'px-1 text-2xs py-0.5 font-bold w-fit border cursor-move rounded-sm', - 'bg-indigo-100 text-indigo-600 border-indigo-500 hover:bg-indigo-200 hover:text-indigo-800', - 'flex items-center justify-center' + draggable="false" + title={`Id: ${component.id}`} + class={twMerge( + 'py-0.5 text-2xs w-fit h-full min-h-5 border rounded z-50 cursor-move flex flex-row flex-nowrap font-semibold items-center shadow', + selected + ? 'bg-indigo-500/90 border-indigo-500 text-white' + : $connectingInput.opened + ? 'bg-red-500/90 border-red-600 text-white' + : 'bg-blue-500/90 border-blue-600 text-white' )} > - +
+ {component.id} +
+ {#if !connecting} +
+ + + +
+ {/if}
+ {#if selected && !connecting && checkComponentOptions()} +
+ {#if hasInlineEditor} + + {/if} + {#if component.type === 'conditionalwrapper'} + + {:else if component.type === 'steppercomponent' || (component.type === 'tabscomponent' && component.configuration.tabsKind.type === 'static' && component.configuration.tabsKind.value === 'invisibleOnView')} + + {:else if component.type === 'decisiontreecomponent'} + + + {/if} + + + + +
+ {/if}
{/if} diff --git a/frontend/src/lib/components/apps/editor/DecisionTreeDebug.svelte b/frontend/src/lib/components/apps/editor/DecisionTreeDebug.svelte index d2c525aecc..e35f648a26 100644 --- a/frontend/src/lib/components/apps/editor/DecisionTreeDebug.svelte +++ b/frontend/src/lib/components/apps/editor/DecisionTreeDebug.svelte @@ -6,10 +6,14 @@ import type { AppViewerContext } from '../types' import type { DecisionTreeNode } from './component' import { isDebugging } from './settingsPanel/decisionTree/utils' - import { X } from 'lucide-svelte' + import { X, Bug } from 'lucide-svelte' export let nodes: DecisionTreeNode[] = [] export let id: string + export let isSmall = false + export let componentIsDebugging = false + + $: componentIsDebugging = isDebugging($debuggingComponents, id) const { componentControl, debuggingComponents, worldStore } = getContext('AppViewerContext') @@ -71,20 +75,20 @@
- {:else} - {`Debug nodes (current node: ${currentNodeId})`} - {/if} + {:else if isSmall} +
+ {:else}
{`Debug nodes (current node: ${currentNodeId})`}
{/if} diff --git a/frontend/src/lib/components/apps/editor/GridEditor.svelte b/frontend/src/lib/components/apps/editor/GridEditor.svelte index b6c1323228..52602551d2 100644 --- a/frontend/src/lib/components/apps/editor/GridEditor.svelte +++ b/frontend/src/lib/components/apps/editor/GridEditor.svelte @@ -45,6 +45,23 @@ .flatMap((id) => dfs($app.grid, id, $app.subgrids ?? {})) .filter((x) => x != undefined) as string[] } + + function handleLock(id: string) { + const gridItem = findGridItem($app, id) + if (gridItem) { + toggleFixed(gridItem) + } + $app = $app + } + + function handleFillHeight(id: string) { + const gridItem = findGridItem($app, id) + const b = $breakpoint === 'sm' ? 3 : 12 + if (gridItem?.[b]) { + gridItem[b].fullHeight = !gridItem[b].fullHeight + } + $app = $app + }
@@ -137,7 +154,23 @@ Boolean($selectedComponent?.includes(dataItem.id)) ? 'active-grid-item' : '' )} > - + { + push(history, $app) + $selectedComponent = [dataItem.id] + expandGriditem($app.grid, dataItem.id, $breakpoint) + $app = $app + }} + on:lock={() => { + handleLock(dataItem.id) + }} + on:fillHeight={() => { + handleFillHeight(dataItem.id) + }} + locked={isFixed(dataItem)} + fullHeight={dataItem?.[$breakpoint === 'sm' ? 3 : 12]?.fullHeight} + > { - const gridItem = findGridItem($app, dataItem.id) - if (gridItem) { - toggleFixed(gridItem) - } - $app = $app - }} - on:expand={() => { - push(history, $app) - $selectedComponent = [dataItem.id] - expandGriditem($app.grid, dataItem.id, $breakpoint) - $app = $app + handleLock(dataItem.id) }} on:fillHeight={() => { - const gridItem = findGridItem($app, dataItem.id) - const b = $breakpoint === 'sm' ? 3 : 12 - if (gridItem?.[b]) { - gridItem[b].fullHeight = !gridItem[b].fullHeight - } - $app = $app + handleFillHeight(dataItem.id) }} /> diff --git a/frontend/src/lib/components/apps/editor/GridEditorMenu.svelte b/frontend/src/lib/components/apps/editor/GridEditorMenu.svelte index ef0aee70c7..778eee0067 100644 --- a/frontend/src/lib/components/apps/editor/GridEditorMenu.svelte +++ b/frontend/src/lib/components/apps/editor/GridEditorMenu.svelte @@ -1,5 +1,6 @@