From a9b453c27a636a6ad794a036587c3d03ae98f454 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 11 Dec 2025 17:43:00 +0200 Subject: [PATCH] feat(breadcrumb_badges): integrate query/script tab --- .../src/translations/en/translation.json | 6 ++++- apps/client/src/widgets/BreadcrumbBadges.css | 1 + apps/client/src/widgets/BreadcrumbBadges.tsx | 22 ++++++++++++++++++- .../src/widgets/ribbon/RibbonDefinition.ts | 2 +- packages/commons/src/lib/attribute_names.ts | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index d92e21d26..1159a8bf8 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -2148,6 +2148,10 @@ "backlinks_description_one": "This note is linked from {{count}} other note.\n\nClick to view the list of backlinks.", "backlinks_description_other": "This note is linked from {{count}} other notes.\n\nClick to view the list of backlinks.", "clipped_note": "Web clip", - "clipped_note_description": "This note was originally taken from {{url}}.\n\nClick to navigate to the source webpage." + "clipped_note_description": "This note was originally taken from {{url}}.\n\nClick to navigate to the source webpage.", + "execute_script": "Run script", + "execute_script_description": "This note is a script note. Click to execute the script.", + "execute_sql": "Run SQL", + "execute_sql_description": "This note is a SQL note. Click to execute the SQL query." } } diff --git a/apps/client/src/widgets/BreadcrumbBadges.css b/apps/client/src/widgets/BreadcrumbBadges.css index ae8b4cad1..758678b01 100644 --- a/apps/client/src/widgets/BreadcrumbBadges.css +++ b/apps/client/src/widgets/BreadcrumbBadges.css @@ -35,6 +35,7 @@ &.share-badge { --color: #3b82f6; } &.clipped-note-badge { --color: #57a2a5; } &.backlinks-badge { color: var(--badge-text-color); } + &.execute-badge { --color: #f59e0b; } a { color: inherit !important; diff --git a/apps/client/src/widgets/BreadcrumbBadges.tsx b/apps/client/src/widgets/BreadcrumbBadges.tsx index 42aaea065..a7ccbae9f 100644 --- a/apps/client/src/widgets/BreadcrumbBadges.tsx +++ b/apps/client/src/widgets/BreadcrumbBadges.tsx @@ -8,7 +8,7 @@ import { t } from "../services/i18n"; import { formatDateTime } from "../utils/formatters"; import { BacklinksList, useBacklinkCount } from "./FloatingButtonsDefinitions"; import Dropdown, { DropdownProps } from "./react/Dropdown"; -import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useStaticTooltip } from "./react/hooks"; +import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useStaticTooltip } from "./react/hooks"; import Icon from "./react/Icon"; import { NoteSizeWidget, useNoteMetadata } from "./ribbon/NoteInfoTab"; import { useShareInfo } from "./shared_info"; @@ -21,6 +21,7 @@ export default function BreadcrumbBadges() { + ); } @@ -130,6 +131,25 @@ function ClippedNoteBadge() { ); } +function ExecuteBadge() { + const { note, parentComponent } = useNoteContext(); + const isScript = note?.isTriliumScript(); + const isSql = note?.isTriliumSqlite(); + const isExecutable = isScript || isSql; + const [ executeDescription ] = useNoteLabel(note, "executeDescription"); + const [ executeButton ] = useNoteLabelBoolean(note, "executeButton"); + + return (note && isExecutable && (executeDescription || executeButton) && + parentComponent.triggerCommand("runActiveNote")} + /> + ); +} + interface BadgeProps { text?: string; icon?: string; diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.ts index 284547639..766f07df7 100644 --- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts +++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts @@ -38,7 +38,7 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [ icon: "bx bx-play", content: ScriptTab, activate: true, - show: ({ note }) => note && + show: ({ note }) => note && !isNewLayout && (note.isTriliumScript() || note.isTriliumSqlite()) && (note.hasLabel("executeDescription") || note.hasLabel("executeButton")) }, diff --git a/packages/commons/src/lib/attribute_names.ts b/packages/commons/src/lib/attribute_names.ts index 0295af0b2..ebbe22123 100644 --- a/packages/commons/src/lib/attribute_names.ts +++ b/packages/commons/src/lib/attribute_names.ts @@ -5,6 +5,7 @@ type Labels = { color: string; iconClass: string; workspaceIconClass: string; + executeButton: boolean; executeDescription: string; executeTitle: string; limit: string; // should be probably be number