Skip to content

Commit

Permalink
Merge pull request #455 from ejgallego/441-error-msg
Browse files Browse the repository at this point in the history
[code] ui: Add divider between errors and goals (#441)
  • Loading branch information
ejgallego authored Mar 29, 2023
2 parents ab6c26a + 43b9470 commit 446707f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
12 changes: 5 additions & 7 deletions editor/code/views/info/ErrorBrowser.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { PpString } from "../../lib/types";
import { CoqPp } from "./CoqPp";
import { Details } from "./Details";

export type ErrorBrowserParams = { error?: PpString };
export type ErrorBrowserParams = { error: PpString };

export function ErrorBrowser({ error }: ErrorBrowserParams) {
if (!error) return null;

return (
<Details summary={"Error Browser"}>
<CoqPp content={error} inline={true} />
</Details>
<>
<header>Errors:</header>
<CoqPp content={error} inline={true} />;
</>
);
}
36 changes: 27 additions & 9 deletions editor/code/views/info/Info.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState, lazy, Suspense } from "react";
import { GoalAnswer, GoalRequest, PpString } from "../../lib/types";

// import "./media/info.css";

// Main panel components
import { FileInfo } from "./FileInfo";
import { Goals } from "./Goals";
import { Messages } from "./Messages";
import { ErrorBrowser } from "./ErrorBrowser";
import { Program } from "./Program";

import "./media/info.css";

// Dynamic import because the project uses CommonJS and the module is an ECMAScript module
// Top level await is supported with other `module` options in tsconfig.json
const VSCodeDivider = lazy(async () => {
const { VSCodeDivider } = await import("@vscode/webview-ui-toolkit/react");
return { default: VSCodeDivider };
});

// First part, which should be split out is the protocol definition, second part is the UI.
function doWaitingForInfo(info: GoalRequest) {
console.log("doWaitingForInfo", info);
Expand Down Expand Up @@ -64,12 +71,23 @@ export function InfoPanel() {
if (!goals) return null;

return (
<FileInfo textDocument={goals.textDocument} position={goals.position}>
<Goals goals={goals.goals} />
<Program program={goals.program} />
<Messages messages={goals.messages} />
<ErrorBrowser error={goals.error} />
</FileInfo>
<div className="info-panel-container">
<div className="info-panel">
<FileInfo textDocument={goals.textDocument} position={goals.position}>
<Goals goals={goals.goals} />
<Program program={goals.program} />
<Messages messages={goals.messages} />
</FileInfo>
</div>
{!goals.error ? null : (
<div className="error-browser">
<Suspense>
<VSCodeDivider />
</Suspense>
<ErrorBrowser error={goals.error} />
</div>
)}
</div>
);
}

Expand Down
4 changes: 0 additions & 4 deletions editor/code/views/info/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// This is the script that is loaded by Coq's webview
import { WebviewApi } from "vscode-webview";

import React from "react";
import { createRoot } from "react-dom/client";

import InfoPanel from "./Info";
import "./media/index.css";

interface CoqInfoViewState {}
const vscode: WebviewApi<CoqInfoViewState> = acquireVsCodeApi();

const container = document.getElementById("root");
const root = createRoot(container!); // createRoot(container!) if you use TypeScript
root.render(
Expand Down
4 changes: 4 additions & 0 deletions editor/code/views/info/media/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ body {
font-family: var(--vscode-editor-font-family);
/* font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; */
}

#root {
height: 100vh;
}
13 changes: 13 additions & 0 deletions editor/code/views/info/media/info.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.error-browser {
flex: 1 1 0%;
}

.info-panel-container {
display: flex;
flex-direction: column;
height: 100%;
}

.info-panel {
overflow: auto;
}

0 comments on commit 446707f

Please sign in to comment.