From 20e1b5c00e86f6f643763c3687790198bb3f1040 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Tue, 25 Nov 2025 09:37:19 -0800 Subject: [PATCH] Fix dialog and invalid variable style --- .../template-function-1password/src/index.ts | 5 +- src-web/commands/commands.tsx | 162 ++++++++++-------- src-web/components/core/Dialog.tsx | 14 +- .../core/Editor/twig/templateTags.ts | 5 +- 4 files changed, 99 insertions(+), 87 deletions(-) diff --git a/plugins/template-function-1password/src/index.ts b/plugins/template-function-1password/src/index.ts index dd495d8f..af920185 100644 --- a/plugins/template-function-1password/src/index.ts +++ b/plugins/template-function-1password/src/index.ts @@ -33,9 +33,10 @@ export const plugin: PluginDefinition = { name: 'token', type: 'text', label: '1Password Service Account Token', - description: '', + description: + 'Token can be generated from the 1Password website by visiting Developer > Service Accounts', // biome-ignore lint/suspicious/noTemplateCurlyInString: Yaak template syntax - defaultValue: '${[ONEPASSWORD_TOKEN]}', + defaultValue: '${[1PASSWORD_TOKEN]}', password: true, }, { diff --git a/src-web/commands/commands.tsx b/src-web/commands/commands.tsx index 979a9ba4..53eea3c3 100644 --- a/src-web/commands/commands.tsx +++ b/src-web/commands/commands.tsx @@ -1,6 +1,7 @@ import { createWorkspaceModel, type Folder, modelTypeLabel } from '@yaakapp-internal/models'; import { applySync, calculateSync } from '@yaakapp-internal/sync'; import { Banner } from '../components/core/Banner'; +import { Button } from '../components/core/Button'; import { InlineCode } from '../components/core/InlineCode'; import { Table, @@ -13,7 +14,7 @@ import { } from '../components/core/Table'; import { activeWorkspaceIdAtom } from '../hooks/useActiveWorkspace'; import { createFastMutation } from '../hooks/useFastMutation'; -import { showConfirm } from '../lib/confirm'; +import { showDialog } from '../lib/dialog'; import { jotaiStore } from '../lib/jotai'; import { pluralizeCount } from '../lib/pluralize'; import { showPrompt } from '../lib/prompt'; @@ -78,81 +79,92 @@ export const syncWorkspace = createFastMutation< console.log('Directory changes detected', { dbOps, ops }); - const confirmed = force - ? true - : await showConfirm({ - id: 'commit-sync', - title: 'Changes Detected', - size: 'md', - confirmText: 'Apply Changes', - color: isDeletingWorkspace ? 'danger' : 'primary', - description: ( -
- {isDeletingWorkspace ? ( - - 🚨 Changes contain a workspace deletion! - - ) : ( - - )} -

- {pluralizeCount('file', dbOps.length)} in the directory{' '} - {dbOps.length === 1 ? 'has' : 'have'} changed. Do you want to update your workspace? -

- - - - Type - Name - Operation - - - - {dbOps.map((op, i) => { - let name: string; - let label: string; - let color: string; - let model: string; - - if (op.type === 'dbCreate') { - label = 'create'; - name = resolvedModelNameWithFolders(op.fs.model); - color = 'text-success'; - model = modelTypeLabel(op.fs.model); - } else if (op.type === 'dbUpdate') { - label = 'update'; - name = resolvedModelNameWithFolders(op.fs.model); - color = 'text-info'; - model = modelTypeLabel(op.fs.model); - } else if (op.type === 'dbDelete') { - label = 'delete'; - name = resolvedModelNameWithFolders(op.model); - color = 'text-danger'; - model = modelTypeLabel(op.model); - } else { - return null; - } - - return ( - // biome-ignore lint/suspicious/noArrayIndexKey: none - - {model} - - {name} - - - {label} - - - ); - })} - -
-
- ), - }); - if (confirmed) { + if (force) { await applySync(workspaceId, syncDir, ops); + return; } + + showDialog({ + id: 'commit-sync', + title: 'Changes Detected', + size: 'md', + render: ({ hide }) => ( +
{ + e.preventDefault(); + await applySync(workspaceId, syncDir, ops); + hide(); + }} + > + {isDeletingWorkspace ? ( + + 🚨 Changes contain a workspace deletion! + + ) : ( + + )} +

+ {pluralizeCount('file', dbOps.length)} in the directory{' '} + {dbOps.length === 1 ? 'has' : 'have'} changed. Do you want to update your workspace? +

+ + + + Type + Name + Operation + + + + {dbOps.map((op, i) => { + let name: string; + let label: string; + let color: string; + let model: string; + + if (op.type === 'dbCreate') { + label = 'create'; + name = resolvedModelNameWithFolders(op.fs.model); + color = 'text-success'; + model = modelTypeLabel(op.fs.model); + } else if (op.type === 'dbUpdate') { + label = 'update'; + name = resolvedModelNameWithFolders(op.fs.model); + color = 'text-info'; + model = modelTypeLabel(op.fs.model); + } else if (op.type === 'dbDelete') { + label = 'delete'; + name = resolvedModelNameWithFolders(op.model); + color = 'text-danger'; + model = modelTypeLabel(op.model); + } else { + return null; + } + + return ( + // biome-ignore lint/suspicious/noArrayIndexKey: none + + {model} + {name} + + {label} + + + ); + })} + +
+
+ + +
+ + ), + }); }, }); diff --git a/src-web/components/core/Dialog.tsx b/src-web/components/core/Dialog.tsx index 15b30352..dd0c26e3 100644 --- a/src-web/components/core/Dialog.tsx +++ b/src-web/components/core/Dialog.tsx @@ -69,11 +69,7 @@ export function Dialog({ animate={{ top: 0, scale: 1 }} className={classNames( className, - 'grid', - title != null && description != null && 'grid-rows-[auto_minmax(0,1fr)_minmax_(0,1fr)]', - title == null && description != null && 'grid-rows-[auto_minmax(0,1fr)]', - title != null && description == null && 'grid-rows-[auto_minmax(0,1fr)]', - title == null && description == null && 'grid-rows-[minmax(0,1fr)]', + 'grid grid-rows-[auto_auto_minmax(0,1fr)]', 'grid-cols-1', // must be here for inline code blocks to correctly break words 'relative bg-surface pointer-events-auto', 'rounded-lg', @@ -87,16 +83,20 @@ export function Dialog({ size === 'dynamic' && 'min-w-[20rem] max-w-[100vw]', )} > - {title && ( + {title ? ( {title} + ) : ( + )} - {description && ( + {description ? (
{description}
+ ) : ( + )}