import './snippetsModal.component.scss'; import { OnInit } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { PartialProfile, PartialProfileGroup, Profile, ProfileGroup } from 'tabby-core'; import { SidebarSnippet } from '../configProvider'; import { SidebarPlusSnippetsService, SnippetVariableRow } from '../snippets.service'; /** What the caller is asked to do once the modal closes — it owns the sessions and the settings tab, this does not. */ export type SnippetsModalResult = { action: 'run'; snippet: SidebarSnippet; } | { action: 'library'; }; /** * Everything a profile or folder says about snippets, in one centred modal. * * A modal rather than the popup this started as, at the user's request and for * the reason they gave: a 300px box anchored to the cursor is a poor place to * read commands and fill in a form. The context menu keeps one entry that opens * this. * * It deliberately runs nothing itself. Writing into a session means finding the * tab, focusing it and expanding the command — all of which the tree component * already does — so the chosen snippet is handed back through the modal result * and the caller acts on it. Closing on run is the right behaviour anyway: the * command lands at a prompt the user then has to look at. */ export declare class SnippetsModalComponent implements OnInit { private snippets; private modalInstance; /** The profile the modal was opened on, or null when it was a folder. */ profile: PartialProfile | null; group: PartialProfileGroup | null; chain: string[]; ownerId: string; ownerName: string; /** Only a profile has a session to write into; on a folder this is a definition screen. */ canRun: boolean; constructor(snippets: SidebarPlusSnippetsService, modalInstance: NgbActiveModal); ngOnInit(): void; get ownSnippets(): SidebarSnippet[]; /** * Snippets from the folders above, with the folder each is attached to and * whether it is switched off here. * * Anything already attached to this very item is filtered out: attached to * both, a snippet used to be listed twice, once as its own and once as * inherited. Detaching is offered where the attachment is, never here — * from a profile it would take the snippet from every other profile of that * folder — which is exactly what muting is for. */ get inheritedSnippets(): { source: string; snippet: SidebarSnippet; muted: boolean; }[]; /** Switches an inherited snippet off here, or back on — the folder keeps it either way. */ toggleMuted(snippet: SidebarSnippet): Promise; /** Library snippets not already offered here — anything inherited is excluded, it would show twice. */ get attachable(): SidebarSnippet[]; /** The placeholders one snippet reads, with what answers them here. */ variablesOf(snippet: SidebarSnippet): SnippetVariableRow[]; /** * How many required variables this snippet still has no answer for. * * Shown as a badge on the folded button: the panel holds what has to be * filled in, so something has to say it needs opening. Zero renders * nothing. */ missingCount(snippet: SidebarSnippet): number; setVariable(snippet: SidebarSnippet, name: string, value: string): Promise; /** Keeps the rows' DOM across change detection — without it the `` being typed into is rebuilt and loses focus. */ trackByName(_index: number, row: { name: string; }): string; trackById(_index: number, row: SidebarSnippet): string; trackByInherited(_index: number, row: { snippet: SidebarSnippet; }): string; run(snippet: SidebarSnippet, muted?: boolean): void; openLibrary(): void; attach(snippet: SidebarSnippet): Promise; detach(snippet: SidebarSnippet): Promise; /** Which snippet's own settings are unfolded, if any — one at a time keeps the modal readable. */ tuning: string | null; toggleTuning(snippet: SidebarSnippet): void; /** This snippet's answer *on this item*, `inherit` when it follows what the item says for all of them. */ override(snippetId: string, key: 'autoLaunch' | 'execute'): 'inherit' | 'yes' | 'no'; setOverride(snippetId: string, key: 'autoLaunch' | 'execute', choice: string): Promise; /** What "Suivre" resolves to for this snippet — the item's own answer, then its folders. */ resolvedFor(snippetId: string, key: 'autoLaunch' | 'execute'): boolean; overrideDelay(snippetId: string): string; setOverrideDelay(snippetId: string, raw: string): Promise; /** Whether this snippet can open a session here — decides if its wait is worth showing. */ launchesFor(snippetId: string): boolean; setting(key: 'autoLaunch' | 'execute'): 'inherit' | 'yes' | 'no'; /** What "Hériter" resolves to right now, spelled out in the option so the choice is never blind. */ inherited(key: 'autoLaunch' | 'execute'): boolean; setSetting(key: 'autoLaunch' | 'execute', choice: string): Promise; get autoLaunchOn(): boolean; get delay(): string; get inheritedDelay(): number; setDelay(raw: string): Promise; close(): void; }