Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

feat(self-service): sidebars + table abstraction + structure refactor #17

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ The Qovery and Torii projects are two different projects with different goals:
Here is a features table to help you understand the difference:

| Feature | Qovery (Internal Developer Platform) | Torii (Internal Developer Portal) |
|-----------------------|--------------------------------------|-----------------------------------|
| Build | βœ… | ❌ |
| Deploy | βœ… | ❌ |
| Run | βœ… | ❌ |
| Ephemeral Environment | βœ… | ❌ |
| Self-Service | βœ… | βœ… |
| Catalogs Service | ❌ | βœ… |
| Scorecard Service | ❌ | βœ… |
| Workflow Service | Partial with the concept of Pipeline | βœ… |
| --------------------- | ------------------------------------ | --------------------------------- |
| Build | βœ… | ❌ |
| Deploy | βœ… | ❌ |
| Run | βœ… | ❌ |
| Ephemeral Environment | βœ… | ❌ |
| Self-Service | βœ… | βœ… |
| Catalogs Service | ❌ | βœ… |
| Scorecard Service | ❌ | βœ… |
| Workflow Service | Partial with the concept of Pipeline | βœ… |

### Why Torii?

Expand Down
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_API_URL=http://localhost:9999
VITE_API_URL=http://localhost:9998
38 changes: 38 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"@tanstack/query-core": "^5.29.0",
"@tanstack/react-query": "^5.13.4",
"@tanstack/react-query-devtools": "^5.29.0",
"@tanstack/react-table": "^8.16.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"dayjs": "^1.11.10",
"jotai-devtools": "^0.8.0",
"jotai-tanstack-query": "^0.8.5",
"localforage": "^1.10.0",
Expand Down
24 changes: 0 additions & 24 deletions frontend/src/atoms/catalog.atoms.ts

This file was deleted.

4 changes: 0 additions & 4 deletions frontend/src/atoms/dialog.atoms.ts

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/atoms/navigation.atoms.ts

This file was deleted.

17 changes: 0 additions & 17 deletions frontend/src/atoms/run.atoms.ts

This file was deleted.

30 changes: 0 additions & 30 deletions frontend/src/components/AppShell.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions frontend/src/components/Badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ThemeColors } from "@/enums/theme-colors.enum";
import clsx from "clsx";

export interface BadgeProps {
status: ThemeColors;
text: string;
}

export const Badge = ({ status, text }: BadgeProps) => {
const config = {
[ThemeColors.PRIMARY]: ["text-blue-400", "bg-blue-100"],
[ThemeColors.SECONDARY]: ["text-gray-400", "bg-gray-100"],
[ThemeColors.SUCCESS]: ["text-green-400", "bg-green-100"],
[ThemeColors.WARNING]: ["text-orange-400", "bg-orange-100"],
[ThemeColors.DANGER]: ["text-red-400", "bg-red-100"],
};

return (
<span
className={clsx(
"inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",
config[status],
)}
>
{text}
</span>
);
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dialogOpenedAtomFamily } from "@/atoms/dialog.atoms";
import { DialogIds } from "@/enums/dialog-ids.enum";
import { ThemeColors } from "@/enums/theme-colors.enum";
import { Dialog as HeadlessDialog, Transition } from "@headlessui/react";
import { XMarkIcon } from "@heroicons/react/24/outline";
import { useAtom } from "jotai";
import { Fragment, ReactNode } from "react";
import { Button } from "./Button";
import { dialogOpenedAtomFamily } from "@/pages/atoms";

export interface DialogProps {
id: DialogIds;
Expand Down Expand Up @@ -89,7 +89,7 @@ export default function Dialog({
</button>
</div>
<div className="sm:flex sm:items-start">
<div className="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left">
<div className="mt-3 text-center sm:mt-0 sm:text-left">
<HeadlessDialog.Title
as="h3"
className="text-base font-semibold leading-6 text-gray-900"
Expand Down
29 changes: 29 additions & 0 deletions frontend/src/components/DynamicField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Field } from "@/types/catalog.type";
import SwitchField from "./SwitchField";
import TextField from "./TextField";
import TextareaField from "./TextareaField";

export interface DynamicFieldProps {
field: Field;
initialFocus?: {
name: string;
};
}

export function DynamicField({ field, initialFocus }: DynamicFieldProps) {
const focused = initialFocus?.name === field.slug;

if (field.type === "text") {
return <TextField field={field} focused={focused} />;
} else if (field.type === "number") {
return <TextField field={field} inputMode="numeric" focused={focused} />;
} else if (field.type === "textarea") {
return <TextareaField field={field} focused={focused} />;
} else if (field.type === "boolean") {
return <SwitchField field={field} />;
}

return <p>'{field.type}' is not a supported field</p>;
}

export default DynamicField;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface DynamicFieldsProps {
fields: Field[];
initialFocus?: {
name: string;
ref: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | null>;
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { userAtom } from "@/atoms/user.atoms";
import { Disclosure, Menu, Transition } from "@headlessui/react";
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline";
import clsx from "clsx";
Expand All @@ -7,17 +6,22 @@ import { BellIcon } from "lucide-react";
import { Fragment } from "react";
import { MobileNav, Nav } from "./Nav";
import { RouteItem } from "./NavigationItem";
import { userAtom } from "@/pages/atoms";

export interface HeaderProps {
routes: RouteItem[];
userMenu: RouteItem[];
}

export function Header({ routes, userMenu }: HeaderProps) {
/** @TODO This shoud be deleted and place at top level when the back end supports users */
const user = useAtomValue(userAtom);

return (
<Disclosure as="nav" className="bg-white shadow-sm">
<Disclosure
as="nav"
className="border-b border-gray-200 bg-white shadow-sm"
>
{({ open }) => (
<>
<div className="px-4 sm:px-6 lg:px-8">
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/components/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { InputHTMLAttributes, useEffect } from "react";
import { useFormContext } from "react-hook-form";

export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
label?: string;
focused?: boolean;
}

export const Input = ({ label, focused, ...props }: InputProps) => {
const { register, setFocus } = useFormContext();

useEffect(() => {
if (focused && props.id) {
setFocus(props.id);
}
}, [props.id, setFocus, focused]);

return (
<div className="space-y-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:space-y-2 sm:py-5">
{label && (
<label
htmlFor={props.id}
className="block text-sm font-medium leading-6 text-gray-900 sm:mt-1.5"
>
{label}
</label>
)}
<div className="sm:col-span-3">
<input
{...props}
className="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
{...register(props.id as string)}
/>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { userAtom } from "@/atoms/user.atoms";
import { Disclosure } from "@headlessui/react";
import clsx from "clsx";
import { useAtomValue } from "jotai";
import { BellIcon } from "lucide-react";
import NavigationItem, { RouteItem } from "./NavigationItem";
import { userAtom } from "@/pages/atoms";

export interface NavProps {
routes: RouteItem[];
Expand All @@ -14,6 +14,7 @@ export interface MobileNavProps extends NavProps {
}

export function MobileNav({ routes, userMenu }: MobileNavProps) {
/** @TODO This shoud be deleted and place at top level when the back end supports users */
const user = useAtomValue(userAtom);

return (
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/components/Subheader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface SubheaderProps {
pageTitle: string;
}

export function Subheader({ pageTitle }: SubheaderProps) {
return (
<header>
<h1 className="text-3xl font-bold leading-tight tracking-tight text-gray-900">
{pageTitle}
</h1>
</header>
);
}

export default Subheader;
Loading
Loading