From 69ff6d6fdfbb9507c3bb5d675630139c0db9216a Mon Sep 17 00:00:00 2001 From: Colin Eberhardt Date: Tue, 28 Sep 2021 17:47:53 +0100 Subject: [PATCH] refactor: pulled out common interface components --- src/components/EditorWindow.tsx | 7 +++++-- src/components/ServerInterface.tsx | 15 +++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/components/EditorWindow.tsx b/src/components/EditorWindow.tsx index 8caf0b7..8d65413 100644 --- a/src/components/EditorWindow.tsx +++ b/src/components/EditorWindow.tsx @@ -22,13 +22,16 @@ import { editorWindow, editorWrapper } from "../style"; type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor; -interface EditorWindowProps { - onExecuteQuery: (query: string) => void; +export interface FileManagementProps { onFilenameChanged: (scriptName: string) => void; onUnsavedChangesChanged: (unsavedChanges: boolean) => void; filename?: string; } +interface EditorWindowProps extends FileManagementProps { + onExecuteQuery: (query: string) => void; +} + // Set some default options for the Monaco Editor const editorOptions = { minimap: { diff --git a/src/components/ServerInterface.tsx b/src/components/ServerInterface.tsx index cfc7d1e..ecdddc3 100644 --- a/src/components/ServerInterface.tsx +++ b/src/components/ServerInterface.tsx @@ -5,18 +5,15 @@ import { renderToStaticMarkup } from "react-dom/server"; import KdbConnection from "../server/kdb-connection"; import { grabberBar, stackTokens } from "../style"; import Result from "../types/results"; -import EditorWindow from "./EditorWindow"; +import EditorWindow, { FileManagementProps } from "./EditorWindow"; import ResultsWindow from "./ResultsWindow"; import TablePanel from "./TablePanel"; import Split from "react-split"; -type ServerInterfaceProps = { +interface ServerInterfaceProps extends FileManagementProps { connection: KdbConnection; visible: boolean; - filename?: string; - onFilenameChanged: (scriptName: string) => void; - onUnsavedChangesChanged: (unsavedChanges: boolean) => void; -}; +} const ServerInterface: FC = ({ connection, @@ -49,7 +46,7 @@ const ServerInterface: FC = ({ setResults({ script, data: null, - error: e, + error: e as string, }); } setIsLoading(false); @@ -103,9 +100,7 @@ const ServerInterface: FC = ({ >