feat(breadcrumb_badges): integrate query/script tab

This commit is contained in:
Elian Doran 2025-12-11 17:43:00 +02:00
parent fa8287269f
commit a9b453c27a
No known key found for this signature in database
5 changed files with 29 additions and 3 deletions

View File

@ -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_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.", "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": "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."
} }
} }

View File

@ -35,6 +35,7 @@
&.share-badge { --color: #3b82f6; } &.share-badge { --color: #3b82f6; }
&.clipped-note-badge { --color: #57a2a5; } &.clipped-note-badge { --color: #57a2a5; }
&.backlinks-badge { color: var(--badge-text-color); } &.backlinks-badge { color: var(--badge-text-color); }
&.execute-badge { --color: #f59e0b; }
a { a {
color: inherit !important; color: inherit !important;

View File

@ -8,7 +8,7 @@ import { t } from "../services/i18n";
import { formatDateTime } from "../utils/formatters"; import { formatDateTime } from "../utils/formatters";
import { BacklinksList, useBacklinkCount } from "./FloatingButtonsDefinitions"; import { BacklinksList, useBacklinkCount } from "./FloatingButtonsDefinitions";
import Dropdown, { DropdownProps } from "./react/Dropdown"; 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 Icon from "./react/Icon";
import { NoteSizeWidget, useNoteMetadata } from "./ribbon/NoteInfoTab"; import { NoteSizeWidget, useNoteMetadata } from "./ribbon/NoteInfoTab";
import { useShareInfo } from "./shared_info"; import { useShareInfo } from "./shared_info";
@ -21,6 +21,7 @@ export default function BreadcrumbBadges() {
<ShareBadge /> <ShareBadge />
<BacklinksBadge /> <BacklinksBadge />
<ClippedNoteBadge /> <ClippedNoteBadge />
<ExecuteBadge />
</div> </div>
); );
} }
@ -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) &&
<Badge
className="execute-badge"
icon="bx bx-play"
text={isScript ? t("breadcrumb_badges.execute_script") : t("breadcrumb_badges.execute_sql")}
tooltip={executeDescription || (isScript ? t("breadcrumb_badges.execute_script_description") : t("breadcrumb_badges.execute_sql_description"))}
onClick={() => parentComponent.triggerCommand("runActiveNote")}
/>
);
}
interface BadgeProps { interface BadgeProps {
text?: string; text?: string;
icon?: string; icon?: string;

View File

@ -38,7 +38,7 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [
icon: "bx bx-play", icon: "bx bx-play",
content: ScriptTab, content: ScriptTab,
activate: true, activate: true,
show: ({ note }) => note && show: ({ note }) => note && !isNewLayout &&
(note.isTriliumScript() || note.isTriliumSqlite()) && (note.isTriliumScript() || note.isTriliumSqlite()) &&
(note.hasLabel("executeDescription") || note.hasLabel("executeButton")) (note.hasLabel("executeDescription") || note.hasLabel("executeButton"))
}, },

View File

@ -5,6 +5,7 @@ type Labels = {
color: string; color: string;
iconClass: string; iconClass: string;
workspaceIconClass: string; workspaceIconClass: string;
executeButton: boolean;
executeDescription: string; executeDescription: string;
executeTitle: string; executeTitle: string;
limit: string; // should be probably be number limit: string; // should be probably be number