Skip to content

Commit

Permalink
refactor: pulled out common interface components
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinEberhardt committed Sep 28, 2021
1 parent e99a4bb commit 69ff6d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/components/EditorWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
15 changes: 5 additions & 10 deletions src/components/ServerInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerInterfaceProps> = ({
connection,
Expand Down Expand Up @@ -49,7 +46,7 @@ const ServerInterface: FC<ServerInterfaceProps> = ({
setResults({
script,
data: null,
error: e,
error: e as string,
});
}
setIsLoading(false);
Expand Down Expand Up @@ -103,9 +100,7 @@ const ServerInterface: FC<ServerInterfaceProps> = ({
>
<EditorWindow
onExecuteQuery={executeQuery}
onFilenameChanged={onFilenameChanged}
filename={filename}
onUnsavedChangesChanged={onUnsavedChangesChanged}
{...{ filename, onFilenameChanged, onUnsavedChangesChanged }}
/>
<ResultsWindow
results={results}
Expand Down

0 comments on commit 69ff6d6

Please sign in to comment.