diff --git a/src/app/[orgId]/settings/access/users/[userId]/access-controls/page.tsx b/src/app/[orgId]/settings/access/users/[userId]/access-controls/page.tsx index a13d08ca..4c82ec64 100644 --- a/src/app/[orgId]/settings/access/users/[userId]/access-controls/page.tsx +++ b/src/app/[orgId]/settings/access/users/[userId]/access-controls/page.tsx @@ -59,7 +59,7 @@ export default function AccessControlsPage() { const formSchema = z.object({ username: z.string(), - roleId: z.string().min(1, { message: t('accessRoleSelectPlease') }), + roleId: z.string().min(1, { message: t("accessRoleSelectPlease") }), autoProvisioned: z.boolean() }); @@ -80,10 +80,10 @@ export default function AccessControlsPage() { console.error(e); toast({ variant: "destructive", - title: t('accessRoleErrorFetch'), + title: t("accessRoleErrorFetch"), description: formatAxiosError( e, - t('accessRoleErrorFetchDescription') + t("accessRoleErrorFetchDescription") ) }); }); @@ -105,7 +105,9 @@ export default function AccessControlsPage() { try { // Execute both API calls simultaneously const [roleRes, userRes] = await Promise.all([ - api.post>(`/role/${values.roleId}/add/${user.userId}`), + api.post>( + `/role/${values.roleId}/add/${user.userId}` + ), api.post(`/org/${orgId}/user/${user.userId}`, { autoProvisioned: values.autoProvisioned }) @@ -114,17 +116,17 @@ export default function AccessControlsPage() { if (roleRes.status === 200 && userRes.status === 200) { toast({ variant: "default", - title: t('userSaved'), - description: t('userSavedDescription') + title: t("userSaved"), + description: t("userSavedDescription") }); } } catch (e) { toast({ variant: "destructive", - title: t('accessRoleErrorAdd'), + title: t("accessRoleErrorAdd"), description: formatAxiosError( e, - t('accessRoleErrorAddDescription') + t("accessRoleErrorAddDescription") ) }); } @@ -136,9 +138,11 @@ export default function AccessControlsPage() { - {t('accessControls')} + + {t("accessControls")} + - {t('accessControlsDescription')} + {t("accessControlsDescription")} @@ -151,38 +155,48 @@ export default function AccessControlsPage() { id="access-controls-form" > {/* IDP Type Display */} - {user.type !== UserType.Internal && user.idpType && ( -
- - {t("idp")}: - - -
- )} + {user.type !== UserType.Internal && + user.idpType && ( +
+ + {t("idp")}: + + +
+ )} ( - {t('role')} + {t("role")} - - - - )} - /> - -
-
- {t('expireIn')} -
- ( - - - - - )} - /> - - ( - - - - - - - )} - /> -
-
- -
- - setNeverExpire( - val as boolean - ) - } - /> - -
- -

- {t('shareExpireDescription')} -

-
- - - )} - {link && ( -
-

- {t('shareSeeOnce')} -

-

- {t('shareAccessHint')} -

- -
- -
- - -
- -
-
- - - -
- - {accessTokenId && accessToken && ( -
-
- -
-
- )} -
-
-
- )} - - - - - - - - - - - - ); -} diff --git a/src/app/[orgId]/settings/share-links/ShareLinksTable.tsx b/src/app/[orgId]/settings/share-links/ShareLinksTable.tsx deleted file mode 100644 index 2943311f..00000000 --- a/src/app/[orgId]/settings/share-links/ShareLinksTable.tsx +++ /dev/null @@ -1,298 +0,0 @@ -"use client"; - -import { ColumnDef } from "@tanstack/react-table"; -import { ShareLinksDataTable } from "@app/components/ShareLinksDataTable"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger -} from "@app/components/ui/dropdown-menu"; -import { Button } from "@app/components/ui/button"; -import { - Copy, - ArrowRight, - ArrowUpDown, - MoreHorizontal, - Check, - ArrowUpRight, - ShieldOff, - ShieldCheck -} from "lucide-react"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -// import CreateResourceForm from "./CreateResourceForm"; -import { useState } from "react"; -import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog"; -import { formatAxiosError } from "@app/lib/api"; -import { toast } from "@app/hooks/useToast"; -import { createApiClient } from "@app/lib/api"; -import { useEnvContext } from "@app/hooks/useEnvContext"; -import { ArrayElement } from "@server/types/ArrayElement"; -import { ListAccessTokensResponse } from "@server/routers/accessToken"; -import moment from "moment"; -import CreateShareLinkForm from "@app/components/CreateShareLinkForm"; -import { constructShareLink } from "@app/lib/shareLinks"; -import { useTranslations } from "next-intl"; - -export type ShareLinkRow = { - accessTokenId: string; - resourceId: number; - resourceName: string; - title: string | null; - createdAt: number; - expiresAt: number | null; -}; - -type ShareLinksTableProps = { - shareLinks: ShareLinkRow[]; - orgId: string; -}; - -export default function ShareLinksTable({ - shareLinks, - orgId -}: ShareLinksTableProps) { - const router = useRouter(); - const t = useTranslations(); - - const api = createApiClient(useEnvContext()); - - const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); - const [rows, setRows] = useState(shareLinks); - - function formatLink(link: string) { - return link.substring(0, 20) + "..." + link.substring(link.length - 20); - } - - async function deleteSharelink(id: string) { - await api.delete(`/access-token/${id}`).catch((e) => { - toast({ - title: t("shareErrorDelete"), - description: formatAxiosError(e, t("shareErrorDeleteMessage")) - }); - }); - - const newRows = rows.filter((r) => r.accessTokenId !== id); - setRows(newRows); - - toast({ - title: t("shareDeleted"), - description: t("shareDeletedDescription") - }); - } - - const columns: ColumnDef[] = [ - { - accessorKey: "resourceName", - header: ({ column }) => { - return ( - - ); - }, - cell: ({ row }) => { - const r = row.original; - return ( - - - - ); - } - }, - { - accessorKey: "title", - header: ({ column }) => { - return ( - - ); - } - }, - // { - // accessorKey: "domain", - // header: "Link", - // cell: ({ row }) => { - // const r = row.original; - // - // const link = constructShareLink( - // r.resourceId, - // r.accessTokenId, - // r.tokenHash - // ); - // - // return ( - //
- // - // {formatLink(link)} - // - // - //
- // ); - // } - // }, - { - accessorKey: "createdAt", - header: ({ column }) => { - return ( - - ); - }, - cell: ({ row }) => { - const r = row.original; - return moment(r.createdAt).format("lll"); - } - }, - { - accessorKey: "expiresAt", - header: ({ column }) => { - return ( - - ); - }, - cell: ({ row }) => { - const r = row.original; - if (r.expiresAt) { - return moment(r.expiresAt).format("lll"); - } - return t("never"); - } - }, - { - id: "delete", - cell: ({ row }) => { - const resourceRow = row.original; - return ( -
- {/* */} - {/* */} - {/* */} - {/* */} - {/* */} - {/* { */} - {/* deleteSharelink( */} - {/* resourceRow.accessTokenId */} - {/* ); */} - {/* }} */} - {/* > */} - {/* */} - {/* */} - {/* */} - {/* */} - -
- ); - } - } - ]; - - return ( - <> - { - setRows([val, ...rows]); - }} - /> - - { - setIsCreateModalOpen(true); - }} - /> - - ); -} diff --git a/src/app/[orgId]/settings/share-links/page.tsx b/src/app/[orgId]/settings/share-links/page.tsx index be561acd..caf02b83 100644 --- a/src/app/[orgId]/settings/share-links/page.tsx +++ b/src/app/[orgId]/settings/share-links/page.tsx @@ -8,7 +8,6 @@ import { GetOrgResponse } from "@server/routers/org"; import OrgProvider from "@app/providers/OrgProvider"; import { ListAccessTokensResponse } from "@server/routers/accessToken"; import ShareLinksTable, { ShareLinkRow } from "../../../../components/ShareLinksTable"; -import ShareableLinksSplash from "../../../../components/ShareLinksSplash"; import { getTranslations } from "next-intl/server"; type ShareLinksPageProps = {