diff --git a/src/app/(dashboard)/peer/page.tsx b/src/app/(dashboard)/peer/page.tsx index 6119891d..d2474bef 100644 --- a/src/app/(dashboard)/peer/page.tsx +++ b/src/app/(dashboard)/peer/page.tsx @@ -32,6 +32,7 @@ import { FlagIcon, Globe, History, + LockIcon, MapPin, MonitorSmartphoneIcon, NetworkIcon, @@ -50,6 +51,7 @@ import PeerIcon from "@/assets/icons/PeerIcon"; import { useCountries } from "@/contexts/CountryProvider"; import PeerProvider, { usePeer } from "@/contexts/PeerProvider"; import RoutesProvider from "@/contexts/RoutesProvider"; +import { useLoggedInUser } from "@/contexts/UsersProvider"; import { useHasChanges } from "@/hooks/useHasChanges"; import { getOperatingSystem } from "@/hooks/useOperatingSystem"; import { OperatingSystem } from "@/interfaces/OperatingSystem"; @@ -124,6 +126,8 @@ function PeerOverview() { }); }; + const { isUser } = useLoggedInUser(); + return ( @@ -148,29 +152,31 @@ function PeerOverview() { /> - - -
- -
-
- { - setName(newName); - setShowEditNameModal(false); - }} - peer={peer} - initialName={name} - key={showEditNameModal ? 1 : 0} - /> -
+ {!isUser && ( + + +
+ +
+
+ { + setName(newName); + setShowEditNameModal(false); + }} + peer={peer} + initialName={name} + key={showEditNameModal ? 1 : 0} + /> +
+ )} @@ -192,7 +198,7 @@ function PeerOverview() { variant={"primary"} className={"w-full"} onClick={() => updatePeer()} - disabled={!hasChanges} + disabled={!hasChanges || isUser} > Save Changes @@ -210,18 +216,32 @@ function PeerOverview() { "flex gap-2 items-center !text-nb-gray-300 text-xs" } > - - - Login expiration is disabled for all peers added with an - setup-key. - + {!peer.user_id ? ( + <> + <> + + + Login expiration is disabled for all peers added + with an setup-key. + + + + ) : ( + <> + + + {`You don't have the required permissions to update this + setting.`} + + + )} } className={"w-full block"} - disabled={!!peer.user_id} + disabled={!!peer.user_id && !isUser} > - - !set - ? setSsh(false) - : openSSHDialog().then((confirm) => setSsh(confirm)) - } - label={ - <> - - SSH Access - - } - helpText={ - "Enable the SSH server on this peer to access the machine via an secure shell." + + + + {`You don't have the required permissions to update this + setting.`} + + } - /> + interactive={false} + className={"w-full block"} + disabled={!isUser} + > + + !set + ? setSsh(false) + : openSSHDialog().then((confirm) => setSsh(confirm)) + } + label={ + <> + + SSH Access + + } + helpText={ + "Enable the SSH server on this peer to access the machine via an secure shell." + } + /> + +
Use groups to control what this peer can access. - + + + + {`You don't have the required permissions to update this + setting.`} + +
+ } + interactive={false} + className={"w-full block"} + disabled={!isUser} + > + + @@ -269,7 +330,7 @@ function PeerOverview() { - {isLinux ? ( + {isLinux && !isUser ? (
diff --git a/src/app/(dashboard)/peers/page.tsx b/src/app/(dashboard)/peers/page.tsx index e31164db..5aeb401b 100644 --- a/src/app/(dashboard)/peers/page.tsx +++ b/src/app/(dashboard)/peers/page.tsx @@ -21,7 +21,7 @@ export default function Peers() { return ( - {isUser ? : } + ); } diff --git a/src/contexts/CountryProvider.tsx b/src/contexts/CountryProvider.tsx index 4c4ceffb..33b03d03 100644 --- a/src/contexts/CountryProvider.tsx +++ b/src/contexts/CountryProvider.tsx @@ -19,8 +19,14 @@ const CountryContext = React.createContext( export default function CountryProvider({ children }: Props) { const { isUser } = useLoggedInUser(); + const getRegionByPeer = (peer: Peer) => "Unknown"; + return isUser ? ( - children + + {children} + ) : ( {children} ); diff --git a/src/contexts/GroupsProvider.tsx b/src/contexts/GroupsProvider.tsx index 497ae1ea..c975cf0b 100644 --- a/src/contexts/GroupsProvider.tsx +++ b/src/contexts/GroupsProvider.tsx @@ -22,11 +22,7 @@ export default function GroupsProvider({ children }: Props) { const path = usePathname(); const { isUser } = useLoggedInUser(); - return isUser && path == "/peers" ? ( - children - ) : ( - {children} - ); + return {children}; } export function GroupsProviderContent({ children }: Props) { diff --git a/src/layouts/DashboardLayout.tsx b/src/layouts/DashboardLayout.tsx index c5fe617c..5ed7ed10 100644 --- a/src/layouts/DashboardLayout.tsx +++ b/src/layouts/DashboardLayout.tsx @@ -154,7 +154,7 @@ function DashboardPageContent({ children }: { children: React.ReactNode }) { height: `calc(100vh - ${headerHeight + bannerHeight}px)`, }} > - {!isUser && } + {children}
diff --git a/src/modules/common-table-rows/GroupsRow.tsx b/src/modules/common-table-rows/GroupsRow.tsx index 42509b60..18fd70bc 100644 --- a/src/modules/common-table-rows/GroupsRow.tsx +++ b/src/modules/common-table-rows/GroupsRow.tsx @@ -14,6 +14,7 @@ import { FolderGit2 } from "lucide-react"; import * as React from "react"; import { useMemo } from "react"; import { useGroups } from "@/contexts/GroupsProvider"; +import { useLoggedInUser } from "@/contexts/UsersProvider"; import { Group } from "@/interfaces/Group"; import { Peer } from "@/interfaces/Peer"; import useGroupHelper from "@/modules/groups/useGroupHelper"; @@ -38,6 +39,7 @@ export default function GroupsRow({ peer, }: Props) { const { groups: allGroups } = useGroups(); + const { isUser } = useLoggedInUser(); // Get the group by the id const foundGroups = useMemo(() => { @@ -54,7 +56,7 @@ export default function GroupsRow({ onClick={(e) => { e.preventDefault(); e.stopPropagation(); - setModal && setModal(true); + setModal && !isUser && setModal(true); }} > diff --git a/src/modules/peers/PeersTable.tsx b/src/modules/peers/PeersTable.tsx index 832c9515..715c2376 100644 --- a/src/modules/peers/PeersTable.tsx +++ b/src/modules/peers/PeersTable.tsx @@ -17,6 +17,7 @@ import React from "react"; import { useSWRConfig } from "swr"; import PeerIcon from "@/assets/icons/PeerIcon"; import PeerProvider from "@/contexts/PeerProvider"; +import { useLoggedInUser } from "@/contexts/UsersProvider"; import { useLocalStorage } from "@/hooks/useLocalStorage"; import { Group } from "@/interfaces/Group"; import { Peer } from "@/interfaces/Peer"; @@ -133,6 +134,7 @@ const PeersTableColumns: ColumnDef[] = [ ), }, { + id: "actions", accessorKey: "id", header: "", cell: ({ row }) => ( @@ -176,6 +178,8 @@ export default function PeersTable({ peers, isLoading }: Props) { "name", ) as Group[]) || ([] as Group[]); + const { isUser } = useLoggedInUser(); + return ( router.push("/peer?id=" + row.original.id)} @@ -193,6 +197,7 @@ export default function PeersTable({ peers, isLoading }: Props) { ip: false, user_name: false, user_email: false, + actions: !isUser, }} isLoading={isLoading} getStartedCard={