feat: phase 1 of python scripting
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Tab } from '../store/appStore';
|
||||
import type { SidebarView } from './sidebarViewRegistry';
|
||||
|
||||
export type ActivityId = 'posts' | 'pages' | 'media' | 'tags' | 'chat' | 'import' | 'git' | 'settings';
|
||||
export type ActivityId = 'posts' | 'pages' | 'media' | 'scripts' | 'tags' | 'chat' | 'import' | 'git' | 'settings';
|
||||
|
||||
export interface ActivitySnapshot {
|
||||
activeView: SidebarView;
|
||||
@@ -43,6 +43,13 @@ const ACTIVITY_CONFIG: Record<ActivityId, ActivityConfig> = {
|
||||
activeStrategy: 'sidebar-owner',
|
||||
clickStrategy: 'sidebar-toggle',
|
||||
},
|
||||
scripts: {
|
||||
id: 'scripts',
|
||||
view: 'scripts',
|
||||
labelKey: 'activity.scripts',
|
||||
activeStrategy: 'sidebar-owner',
|
||||
clickStrategy: 'sidebar-toggle',
|
||||
},
|
||||
tags: {
|
||||
id: 'tags',
|
||||
view: 'tags',
|
||||
|
||||
@@ -14,7 +14,8 @@ export type EditorRoute =
|
||||
| 'metadata-diff'
|
||||
| 'git-diff'
|
||||
| 'documentation'
|
||||
| 'site-validation';
|
||||
| 'site-validation'
|
||||
| 'scripts';
|
||||
|
||||
export const EDITOR_TAB_ROUTE_REGISTRY: Record<TabType, Exclude<EditorRoute, 'dashboard'>> = {
|
||||
post: 'post',
|
||||
@@ -29,6 +30,7 @@ export const EDITOR_TAB_ROUTE_REGISTRY: Record<TabType, Exclude<EditorRoute, 'da
|
||||
'git-diff': 'git-diff',
|
||||
documentation: 'documentation',
|
||||
'site-validation': 'site-validation',
|
||||
scripts: 'scripts',
|
||||
};
|
||||
|
||||
export interface EditorRouteResolution {
|
||||
|
||||
@@ -2,6 +2,7 @@ export const SIDEBAR_VIEW_REGISTRY = [
|
||||
'posts',
|
||||
'pages',
|
||||
'media',
|
||||
'scripts',
|
||||
'settings',
|
||||
'tags',
|
||||
'chat',
|
||||
|
||||
@@ -4,6 +4,7 @@ export type SingletonToolTabKey =
|
||||
| 'settings'
|
||||
| 'tags'
|
||||
| 'style'
|
||||
| 'scripts'
|
||||
| 'menu-editor'
|
||||
| 'documentation'
|
||||
| 'metadata-diff'
|
||||
@@ -17,12 +18,14 @@ export interface CanonicalTabSpec {
|
||||
|
||||
export type EntityTabType = 'post' | 'media';
|
||||
export type EntityTabOpenIntent = 'preview' | 'pin';
|
||||
export type ScriptTabOpenIntent = 'preview' | 'pin';
|
||||
export type GitDiffResourceOpenIntent = 'preview' | 'pin';
|
||||
|
||||
const SINGLETON_TOOL_TAB_REGISTRY: Record<SingletonToolTabKey, CanonicalTabSpec> = {
|
||||
settings: { type: 'settings', id: 'settings', isTransient: false },
|
||||
tags: { type: 'tags', id: 'tags', isTransient: false },
|
||||
style: { type: 'style', id: 'style', isTransient: false },
|
||||
scripts: { type: 'scripts', id: 'scripts', isTransient: false },
|
||||
'menu-editor': { type: 'menu-editor', id: 'menu-editor', isTransient: false },
|
||||
documentation: { type: 'documentation', id: 'documentation', isTransient: false },
|
||||
'metadata-diff': { type: 'metadata-diff', id: 'metadata-diff', isTransient: false },
|
||||
@@ -91,6 +94,22 @@ export function openImportTab(
|
||||
openTab(getImportTabSpec(definitionId));
|
||||
}
|
||||
|
||||
export function getScriptTabSpec(scriptId: string, intent: ScriptTabOpenIntent): CanonicalTabSpec {
|
||||
return {
|
||||
type: 'scripts',
|
||||
id: scriptId,
|
||||
isTransient: intent === 'preview',
|
||||
};
|
||||
}
|
||||
|
||||
export function openScriptTab(
|
||||
openTab: (tab: CanonicalTabSpec) => void,
|
||||
scriptId: string,
|
||||
intent: ScriptTabOpenIntent,
|
||||
): void {
|
||||
openTab(getScriptTabSpec(scriptId, intent));
|
||||
}
|
||||
|
||||
export function getGitDiffFileTabId(filePath: string): string {
|
||||
return `git-diff:${filePath}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user