Skip to content

Commit

Permalink
Merge pull request #366 from ajthinking/table-view
Browse files Browse the repository at this point in the history
Prepare full screen table view
  • Loading branch information
ajthinking authored Jan 12, 2025
2 parents d534cad + 2312f53 commit 0271c8f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/ds-ext/src/DiagramEditorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { observeNodeStatus } from './messageHandlers/observeNodeStatus';
import { observeLinkUpdate } from './messageHandlers/observeLinkUpdate';
import { getDataFromStorage } from './messageHandlers/getDataFromStorage';
import { cancelObservation } from './messageHandlers/cancelObservation';
import { onEdgeDoubleClick } from './messageHandlers/onEdgeDoubleClick';
import { DuckDBStorage } from './duckDBStorage';
import { FileStorage } from './fileStorage';
import { loadConfig } from './loadConfig';
Expand Down Expand Up @@ -113,6 +114,7 @@ export class DiagramEditorProvider implements vscode.CustomEditorProvider<Diagra
observeLinkUpdate,
getDataFromStorage,
cancelObservation,
onEdgeDoubleClick,
};

const handler = handlers[event.type];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { VsCodeToast } from './VsCodeToast';
import { onDrop } from './onDrop';
import { createVsCodeClient } from './createVsCodeClient';

export default function App() {
export default function DiagramApp() {
const client = createVsCodeClient(window.vscode);

const handleChange = useCallback(
Expand Down
9 changes: 9 additions & 0 deletions packages/ds-ext/src/app/TableApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export default function TableApp() {
return (
<div style={{ width: '100%', height: '100vh' }}>
This is the TableApp
</div>
);
}
6 changes: 4 additions & 2 deletions packages/ds-ext/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import DiagramApp from './DiagramApp';
import TableApp from './TableApp';

// TypeScript null-check or assertion for the root element
const rootElement = document.getElementById('root') as HTMLElement | null;
Expand All @@ -10,7 +11,8 @@ if (rootElement) {
const root = ReactDOM.createRoot(rootElement);
root.render(
<React.StrictMode>
<App />
<DiagramApp />
{/* <TableApp /> */}
</React.StrictMode>
);
} else {
Expand Down
16 changes: 16 additions & 0 deletions packages/ds-ext/src/messageHandlers/onEdgeDoubleClick.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MessageHandler } from '../MessageHandler';
import * as vscode from 'vscode';
import * as path from 'path';
import * as fs from 'fs';

export const onEdgeDoubleClick: MessageHandler = async ({ event }) => {
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || '';
const tempFilePath = path.join(workspaceRoot, 'temp_table_view.txt');

const content = `TODO: open the Table component here. Use the edge id (${event.edgeId}) to get the relevant data`;

fs.writeFileSync(tempFilePath, content);

const document = await vscode.workspace.openTextDocument(tempFilePath);
await vscode.window.showTextDocument(document, { preview: false });
};
4 changes: 4 additions & 0 deletions packages/ui/src/components/DataStory/DataStoryCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ const Flow = ({
onNodeDoubleClick={(_, node) => {
onNodeDoubleClick?.(node);
}}
onEdgeDoubleClick={(event, edge) => {
if (!client) return;
if(client.onEdgeDoubleClick) client.onEdgeDoubleClick(edge.id);
}}
onEdgesChange={(changes: EdgeChange[]) => {
onEdgesChange(changes);
if (onChange) onChange(toDiagram())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ export class WorkspaceApiClient implements WorkspaceApiClientImplement {
msg$.subscribe(this.receivedMsg$);
}

onEdgeDoubleClick(edgeId: string): void {
this.transport.sendAndReceive({
type: 'onEdgeDoubleClick',
edgeId
});
}

//<editor-fold desc="Message init">
private initExecutionResult() {
return this.receivedMsg$.pipe(filter(matchMsgType('ExecutionResult')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export interface WorkspaceApiClientImplement {
observeNodeStatus?: (params: ObserveNodeStatus) => Subscription;
getDataFromStorage?: (params: GetDataFromStorageParams) => Promise<Record<LinkId, ItemValue[]>>;
cancelObservation?:(params: CancelObservation) => Promise<void>;
onEdgeDoubleClick?: (edgeId: string) => void;
}

0 comments on commit 0271c8f

Please sign in to comment.