Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deployment #498

Merged
merged 1 commit into from
Apr 1, 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
118 changes: 22 additions & 96 deletions app/src/app/_components/CmdK/CmdK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
const page = pages[pages.length - 1];

const showSpynet =
authentication.authorize([
{
resource: "citizen",
operation: "read",
},
]) ||
authentication.authorize([
{
resource: "organization",
operation: "read",
},
]);
authentication.authorize("citizen", "read") ||
authentication.authorize("organization", "read");

return (
<Command.Dialog
Expand Down Expand Up @@ -86,18 +76,8 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
</Command.Item>
</Command.Group>

{(authentication.authorize([
{
resource: "orgFleet",
operation: "read",
},
]) ||
authentication.authorize([
{
resource: "ship",
operation: "manage",
},
])) && (
{(authentication.authorize("orgFleet", "read") ||
authentication.authorize("ship", "manage")) && (
<Command.Group heading="Flotte">
<Command.Item
keywords={["Flotte", "Fleet", "Schiffe", "Ships", "Overview"]}
Expand Down Expand Up @@ -158,61 +138,19 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
</Command.Group>
)}

{(authentication.authorize([
{
resource: "user",
operation: "read",
},
]) ||
authentication.authorize([
{
resource: "role",
operation: "manage",
},
]) ||
authentication.authorize([
{
resource: "classificationLevel",
operation: "manage",
},
]) ||
authentication.authorize([
{
resource: "noteType",
operation: "manage",
},
]) ||
authentication.authorize([
{
resource: "analytics",
operation: "manage",
},
]) ||
authentication.authorize([
{
resource: "manufacturersSeriesAndVariants",
operation: "manage",
},
])) && (
{(authentication.authorize("user", "read") ||
authentication.authorize("role", "manage") ||
authentication.authorize("classificationLevel", "manage") ||
authentication.authorize("noteType", "manage") ||
authentication.authorize("analytics", "manage") ||
authentication.authorize(
"manufacturersSeriesAndVariants",
"manage",
)) && (
<Command.Group heading="Admin">
{(authentication.authorize([
{
resource: "noteType",
operation: "manage",
},
]) ||
authentication.authorize([
{
resource: "classificationLevel",
operation: "manage",
},
]) ||
authentication.authorize([
{
resource: "analytics",
operation: "manage",
},
])) && (
{(authentication.authorize("noteType", "manage") ||
authentication.authorize("classificationLevel", "manage") ||
authentication.authorize("analytics", "manage")) && (
<Command.Item
keywords={["Admin", "Settings"]}
onSelect={() => {
Expand All @@ -226,12 +164,7 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
</Command.Item>
)}

{authentication.authorize([
{
resource: "role",
operation: "manage",
},
]) && (
{authentication.authorize("role", "manage") && (
<Command.Item
keywords={["Admin", "Berechtigungen"]}
onSelect={() => {
Expand All @@ -245,12 +178,10 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
</Command.Item>
)}

{authentication.authorize([
{
resource: "manufacturersSeriesAndVariants",
operation: "manage",
},
]) && (
{authentication.authorize(
"manufacturersSeriesAndVariants",
"manage",
) && (
<Command.Item
keywords={["Admin", "Ships"]}
onSelect={() => {
Expand All @@ -264,12 +195,7 @@ export const CmdK = ({ open, setOpen, disableAlgolia }: Props) => {
</Command.Item>
)}

{authentication.authorize([
{
resource: "user",
operation: "read",
},
]) && (
{authentication.authorize("user", "read") && (
<Command.Item
keywords={["Admin", "Users"]}
onSelect={() => {
Expand Down
37 changes: 18 additions & 19 deletions app/src/app/_components/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
"use client";

import clsx from "clsx";
import { type ReactNode } from "react";
import { type UseFormRegisterReturn } from "react-hook-form";
import { forwardRef } from "react";

interface Props {
register: UseFormRegisterReturn;
children?: ReactNode;
id?: string;
className?: string;
}
type Props = JSX.IntrinsicElements["select"];

const Select = ({ register, id, children, className }: Readonly<Props>) => {
return (
<select
id={id}
{...register}
className={clsx(className, "bg-neutral-900 rounded px-4 h-11 w-full")}
>
{children}
</select>
);
};
const Select = forwardRef<HTMLSelectElement, Props>(
function Select(props, ref) {
return (
<select
className={clsx(
props.className,
"bg-neutral-900 rounded px-4 h-11 w-full",
)}
ref={ref}
{...props}
>
{props.children}
</select>
);
},
);

export default Select;
Loading