Skip to content

Commit

Permalink
Further pruned <KnowledgeBase />
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Mar 25, 2024
1 parent b528853 commit 5c96a2c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 50 deletions.
9 changes: 0 additions & 9 deletions kraken_frontend/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,6 @@ export const ROUTES = {
</ContentWithMenu>
),
}),
KNOWLEDGE_BASE: ROUTER.add({
url: "knowledge",
parser: {},
render: () => (
<ContentWithMenu>
<KnowledgeBase />
</ContentWithMenu>
),
}),
FINDING_DEFINITION_LIST: ROUTER.add({
url: "knowledge/finding-definition",
parser: {},
Expand Down
4 changes: 2 additions & 2 deletions kraken_frontend/src/utils/monaco.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { loader, Monaco } from "@monaco-editor/react";
import React from "react";

export const MONACO_PROMISE = loader.init().then(configure);
export const MONACO_PROMISE = loader.init().then(configureMonaco);

export let MONACO: Monaco | null = null;
MONACO_PROMISE.then((monaco) => {
MONACO = monaco;
});

function configure(monaco: Monaco): Monaco {
export function configureMonaco(monaco: Monaco): Monaco {
monaco.editor.defineTheme("kraken", {
base: "vs-dark",
inherit: true,
Expand Down
37 changes: 2 additions & 35 deletions kraken_frontend/src/views/knowledge-base.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React, { useState } from "react";
import React from "react";
import "../styling/knowledge-base.css";
import { ROUTES } from "../routes";
import { Editor, Monaco } from "@monaco-editor/react";

type KnowledgeBaseProps = {};

export default function KnowledgeBase(props: KnowledgeBaseProps) {
const [userInput, setUserInput] = useState("# heading");

return (
<div className={"knowledge-base-container"}>
<div className={"pane"}>
Expand All @@ -16,18 +13,7 @@ export default function KnowledgeBase(props: KnowledgeBaseProps) {
<div className={"pane knowledge-base-content"}>
<div className={"knowledge-base-mask"}></div>
<div className={"knowledge-base-eyes"}></div>
<div>
<Editor
theme={"custom"}
value={userInput}
language={"markdown"}
onChange={(value) => {
setUserInput(value !== undefined ? value : "");
}}
className={"knowledge-base-editor"}
beforeMount={setupMonaco}
/>
</div>
<div />
<div>
<button className={"button"} {...ROUTES.FINDING_DEFINITION_LIST.clickHandler({})}>
Finding Definitions
Expand All @@ -37,22 +23,3 @@ export default function KnowledgeBase(props: KnowledgeBaseProps) {
</div>
);
}

let setup = false;
export function setupMonaco(monaco: Monaco) {
if (setup) return;
setup = true;

monaco.editor.defineTheme("custom", {
base: "vs-dark",
inherit: true,
rules: [],
colors: {
"editor.foreground": "#C5C8C6",
"editor.background": "#00ccff10",
"editor.selectionBackground": "#33ccff40",
"editor.editorLineNumber": "#ffffff",
"editorCursor.foreground": "#AEAFAD",
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Input from "../../components/input";
import PlusIcon from "../../svg/plus";
import { Api } from "../../api/api";
import { handleApiError } from "../../utils/helper";
import "../styling/knowledge-base.css";

type ListFindingDefinitionProps = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import EditIcon from "../../../svg/edit";
import React, { ReactNode } from "react";
import Popup from "reactjs-popup";
import { Editor } from "@monaco-editor/react";
import { setupMonaco } from "../../knowledge-base";
import "../../../styling/markdown-editor-popup.css";
import { GithubMarkdown } from "../../../components/github-markdown";
import PlusIcon from "../../../svg/plus";
import { configureMonaco } from "../../../utils/monaco";

type MarkdownEditorPopupProps = {
label: ReactNode;
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function MarkdownEditorPopup(props: MarkdownEditorPopupProps) {
<Editor
className={"knowledge-base-editor"}
theme={"custom"}
beforeMount={setupMonaco}
beforeMount={configureMonaco}
language={"markdown"}
value={content}
onChange={(value, event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import InformationIcon from "../../../svg/information";
import RelationLeftRightIcon from "../../../svg/relation-left-right";
import ScreenshotIcon from "../../../svg/screenshot";
import { handleApiError } from "../../../utils/helper";
import { setupMonaco } from "../../knowledge-base";
import CollapsibleSection from "../components/collapsible-section";
import Domain from "../components/domain";
import { FileInput } from "../components/file-input";
Expand All @@ -38,6 +37,7 @@ import TagList, { TagClickCallback } from "../components/tag-list";
import { WORKSPACE_CONTEXT } from "../workspace";
import WorkspaceFindingDataTable, { WorkspaceFindingDataTableRef } from "./workspace-finding-data-table";
import EditingTreeGraph, { EditingTreeGraphRef } from "./workspace-finding-editing-tree";
import { configureMonaco } from "../../../utils/monaco";

export type CreateFindingObject =
| { domain: FullDomain }
Expand Down Expand Up @@ -126,7 +126,7 @@ export function WorkspaceCreateFinding(props: CreateFindingProps) {
<Editor
className={"knowledge-base-editor"}
theme={"custom"}
beforeMount={setupMonaco}
beforeMount={configureMonaco}
language={"markdown"}
value={details}
onChange={(value, event) => {
Expand Down

0 comments on commit 5c96a2c

Please sign in to comment.