Skip to content

Commit

Permalink
Merge pull request #23 from l3montree-dev/risk-identification
Browse files Browse the repository at this point in the history
Adds Risk-Identification Page, Adds SCA Example Dialog
  • Loading branch information
seb-kw authored Jun 6, 2024
2 parents c590fc1 + f40d41e commit 3758810
Show file tree
Hide file tree
Showing 32 changed files with 1,431 additions and 76 deletions.
397 changes: 397 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"react-dom": "18.2.0",
"react-hook-form": "^7.48.2",
"react-markdown": "^9.0.1",
"react-syntax-highlighter": "^15.5.0",
"reactflow": "^11.11.0",
"sass": "^1.69.5",
"sharp": "^0.33.2",
Expand All @@ -44,11 +45,12 @@
"zustand": "^4.4.6"
},
"devDependencies": {
"@types/lodash": "^4.17.0",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/tinycolor2": "^1.4.6",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.13",
"@types/lodash": "^4.17.0",
"@types/tinycolor2": "^1.4.6"
"prettier-plugin-tailwindcss": "^0.5.13"
}
}
}
19 changes: 19 additions & 0 deletions public/assets/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/assets/gitlab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/project-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/repo-secret.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { classNames } from "@/utils/common";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { FunctionComponent } from "react";

interface Props {
Expand All @@ -37,6 +38,7 @@ const Main: FunctionComponent<Props> = ({
Menu,
fullscreen,
}) => {
const router = useRouter();
return (
<main>
<header
Expand All @@ -62,10 +64,15 @@ const Main: FunctionComponent<Props> = ({
<div className="mt-2 flex flex-row gap-6 text-sm">
{Menu.map((item) => (
<Link
className="cursor:pointer hover:no-underline"
className={classNames(
"cursor:pointer relative hover:no-underline",
)}
key={item.title}
href={item.href}
>
{router.asPath === item.href && (
<div className="absolute -bottom-3 -left-2 -right-2 h-0.5 bg-amber-400" />
)}
<div className="mt-4 flex flex-row items-center gap-1">
<item.Icon className="h-5 w-5 text-gray-400" />
<span className="text-white ">{item.title}</span>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Page = (props: PropsWithChildren<PageProps>) => {
<Head>
<title>{props.title}</title>
</Head>
<Toaster />

<Transition.Root show={sidebarOpen} as={Fragment}>
<Dialog
as="div"
Expand Down Expand Up @@ -132,6 +132,7 @@ const Page = (props: PropsWithChildren<PageProps>) => {
</aside>
)}
</div>
<Toaster />
</>
);
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/Toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Msg = ({
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="pointer-events-auto w-full max-w-sm overflow-hidden rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 dark:bg-gray-800 dark:text-white">
<div className="pointer-events-auto w-full max-w-sm overflow-hidden rounded-md bg-white text-black shadow-lg ring-1 ring-black ring-opacity-5 dark:bg-gray-800 dark:text-white">
<div className="flex flex-row items-start p-4">
<div className="flex-shrink-0">{getIcon(intent)}</div>
<div className="ml-3 flex-1 pt-0.5">
Expand All @@ -85,7 +85,7 @@ const Msg = ({
<div className="ml-4 flex flex-shrink-0">
<button
type="button"
className="inline-flex rounded-md bg-white text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-offset-2 dark:bg-gray-700 dark:text-white"
className="inline-flex rounded-md bg-white p-1 text-gray-700 dark:bg-gray-700 dark:text-white"
onClick={() => {
setShow(false);
setTimeout(onRemove, 1000);
Expand Down Expand Up @@ -118,7 +118,7 @@ const Toaster = () => {
};
}, []);
return (
<div className="toaster fixed right-4 top-4 flex flex-col gap-2">
<div className="toaster fixed right-4 top-4 z-20 flex flex-col gap-2">
{msgs.map((msg, i) => (
<Msg
key={msg.id}
Expand Down
1 change: 1 addition & 0 deletions src/components/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const Button: FunctionComponent<
variant: variant + "+" + intent,
}),
rest.disabled ? "cursor-not-allowed opacity-75" : "",
!Boolean(Icon) ? "justify-center" : "justify-between",
className,
)}
{...rest}
Expand Down
55 changes: 55 additions & 0 deletions src/components/common/CopyCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (C) 2024 Tim Bastin, l3montree UG (haftungsbeschränkt)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import React, { FunctionComponent } from "react";
import { toast } from "../Toaster";
import dynamic from "next/dynamic";
const Highlighter = dynamic(() => import("./Highlighter"), { ssr: false });

interface Props {
codeString: string;
language: "yaml" | "shell";
}
const CopyCode: FunctionComponent<Props> = (props) => {
const handleCopy = () => {
navigator.clipboard.writeText(props.codeString);
toast({
msg: "The code has been copied to your clipboard.",
intent: "info",
title: "Copied to clipboard",
});
};
return (
<div
style={{
height: 14 /*padding*/ + props.codeString.split("\n").length * 20,
}}
className="relative w-full overflow-hidden rounded-lg"
>
<div className="absolute bottom-0 left-0 right-0 top-0 animate-pulse bg-gray-800" />
<button
onClick={handleCopy}
className="absolute right-1 top-1 z-10 rounded-lg bg-white/10 p-1 px-2 text-xs text-white transition-all hover:bg-white/30"
>
Copy
</button>
<div className="relative">
<Highlighter codeString={props.codeString} language={props.language} />
</div>
</div>
);
};

export default CopyCode;
24 changes: 24 additions & 0 deletions src/components/common/CustomTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { classNames } from "@/utils/common";
import { Tab as BaseTab } from "@headlessui/react";
import { Fragment, FunctionComponent, PropsWithChildren } from "react";
const CustomTab: FunctionComponent<PropsWithChildren<{}>> = (props) => {
console.log(props);
return (
<BaseTab as={Fragment}>
{({ selected }) => (
<div
className={classNames(
"mr-2 inline-block cursor-pointer rounded-lg px-2 py-2 text-sm transition-all",
selected
? "bg-zinc-200 dark:bg-slate-800"
: "hover:bg-zinc-200 dark:hover:bg-slate-800",
)}
>
{props.children}
</div>
)}
</BaseTab>
);
};

export default CustomTab;
42 changes: 42 additions & 0 deletions src/components/common/Highlighter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (C) 2024 Tim Bastin, l3montree UG (haftungsbeschränkt)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import React, { FunctionComponent } from "react";
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
import yaml from "react-syntax-highlighter/dist/esm/languages/hljs/yaml";
import shell from "react-syntax-highlighter/dist/esm/languages/hljs/bash";
import docco from "react-syntax-highlighter/dist/esm/styles/hljs/an-old-hope";

SyntaxHighlighter.registerLanguage("yaml", yaml);
SyntaxHighlighter.registerLanguage("shell", shell);
const Highlighter: FunctionComponent<{
codeString: string;
language: "yaml" | "shell";
}> = (props) => {
return (
<div className="w-full bg-slate-800">
<SyntaxHighlighter
showLineNumbers
lineNumberStyle={{ color: "rgba(255, 255, 255, 0.3)" }}
language={props.language}
style={docco}
>
{props.codeString}
</SyntaxHighlighter>
</div>
);
};

export default Highlighter;
17 changes: 5 additions & 12 deletions src/components/common/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ interface Props {
open: boolean;
title: string;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
Help?: React.ReactNode;
}
const Modal: FunctionComponent<PropsWithChildren<Props>> = ({
open,
setOpen,
title,
children,
Help,
}) => {
return (
<Transition.Root show={open} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={setOpen}>
<Dialog as="div" className="relative" onClose={setOpen}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
Expand All @@ -30,7 +28,7 @@ const Modal: FunctionComponent<PropsWithChildren<Props>> = ({
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-50 transition-opacity" />
<div className="fixed inset-0 z-10 bg-black bg-opacity-50 transition-opacity" />
</Transition.Child>

<div className="fixed inset-0 z-10 w-screen overflow-y-auto">
Expand All @@ -45,11 +43,11 @@ const Modal: FunctionComponent<PropsWithChildren<Props>> = ({
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<Dialog.Panel className={"bg-transparent shadow-none"}>
<div className="w-screen-md relative z-10 w-96 transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left text-black shadow-xl transition-all dark:border dark:border-gray-800 dark:bg-gray-900 dark:text-white sm:p-6">
<div className="w-screen-md modal relative z-10 my-10 transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left text-black shadow-xl transition-all dark:border dark:border-gray-800 dark:bg-gray-900 dark:text-white sm:p-6">
<div className="absolute right-0 top-0 hidden pr-4 pt-4 sm:block">
<button
type="button"
className="rounded-sm bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:bg-gray-800"
className="rounded-lg bg-white p-1 text-gray-400 hover:text-gray-500 dark:bg-gray-800"
onClick={() => setOpen(false)}
>
<span className="sr-only">Close</span>
Expand All @@ -60,18 +58,13 @@ const Modal: FunctionComponent<PropsWithChildren<Props>> = ({
<div className="mt-3 text-center sm:mt-0 sm:text-left">
<Dialog.Title
as="h3"
className="text-base font-semibold leading-6"
className="mb-5 mt-5 text-3xl font-semibold leading-6"
>
{title}
</Dialog.Title>
<div className="mt-2">{children}</div>
</div>
</div>
{Boolean(Help) && (
<div className="absolute right-2 top-0 translate-x-full rounded-br-lg rounded-tr-lg bg-yellow-400 p-4">
{Help}
</div>
)}
</Dialog.Panel>
</Transition.Child>
</div>
Expand Down
15 changes: 12 additions & 3 deletions src/components/common/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,35 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { classNames } from "@/utils/common";
import React, { FunctionComponent, ReactNode } from "react";

interface Props {
title: string;
description?: ReactNode;
children: React.ReactNode;
id?: string;
highlightBg?: boolean;
}
const Section: FunctionComponent<Props> = (props) => {
return (
<div id={props.id} className="mb-6 pb-6">
<h2 className="text-base font-semibold leading-7 text-blue-950 dark:text-white">
<div
id={props.id}
className={classNames(
props.highlightBg
? "rounded-lg bg-zinc-200 p-3 dark:bg-slate-800"
: "mb-6 pb-6",
)}
>
<h2 className="text-base font-semibold leading-7 text-black dark:text-white">
{props.title}
</h2>
{props.description !== undefined && (
<p className="mt-1 text-sm leading-6 text-black/80 dark:text-white">
{props.description}
</p>
)}
<div className="mt-6">{props.children}</div>
<div className="mt-4">{props.children}</div>
</div>
);
};
Expand Down
25 changes: 25 additions & 0 deletions src/components/common/Small.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2024 Tim Bastin, l3montree UG (haftungsbeschränkt)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import React, { FunctionComponent, PropsWithChildren } from "react";

const Small: FunctionComponent<PropsWithChildren> = ({ children }) => {
return (
<small className="text-sm text-zinc-600 dark:text-slate-200">
{children}
</small>
);
};

export default Small;
Loading

0 comments on commit 3758810

Please sign in to comment.