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

Add region and public ip to peer table and detailed peer view #340

Merged
merged 53 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7c8cb65
Init Dashboard V2
heisbrot Jan 29, 2024
0695d44
Update README.md
heisbrot Jan 29, 2024
ea4a207
use dedicated var and prevent push on PRs
mlsmaycon Jan 29, 2024
dbd3feb
Fix redirect link to event streaming docs
heisbrot Feb 1, 2024
54e66d4
Add iOS operating system icon
heisbrot Feb 2, 2024
90d80c3
Refactor
heisbrot Feb 2, 2024
879d24d
Add autocomplete input
heisbrot Feb 2, 2024
dda557c
Use idtoken source for token
heisbrot Feb 2, 2024
877c0d1
Add posture check modal with checks
heisbrot Feb 2, 2024
707ada6
Fix peer last seen in detail view
heisbrot Feb 6, 2024
b6a777a
Fix last seen date of user
heisbrot Feb 6, 2024
b980047
Add sliding tabs ui component
heisbrot Feb 6, 2024
a819510
Add posture check ui cards
heisbrot Feb 6, 2024
7b27112
Add draft for operating system check ui
heisbrot Feb 8, 2024
9c3b0cb
Add better ui for locations
heisbrot Feb 9, 2024
7169d52
Add better ui for os check
heisbrot Feb 12, 2024
117057d
Merge branch 'main' into feature/posture-checks
heisbrot Feb 12, 2024
22e94a4
Add create posture checks, add select posture check (draft)
heisbrot Feb 13, 2024
6a634fe
Add posture check selection
heisbrot Feb 13, 2024
153a37c
Update posture checks selection modal
heisbrot Feb 13, 2024
a22e800
Add radix radio group
heisbrot Feb 13, 2024
7639f56
Add edit and browse posture checks
heisbrot Feb 14, 2024
ef4f08a
Add posture check cell to access control
heisbrot Feb 14, 2024
0ead53e
Optimize select dropdown performance
heisbrot Feb 14, 2024
e7cb586
Add posture check page
heisbrot Feb 16, 2024
00ff4a9
Update workflow
heisbrot Feb 16, 2024
fe40a5e
Merge branch 'main' into feature/posture-checks
heisbrot Feb 16, 2024
2b79496
Return no results if source_posture_checks is undefined
heisbrot Feb 16, 2024
433bae0
Add flag icons
heisbrot Feb 16, 2024
f1cd664
Add loading indicator and fix some ui issues
heisbrot Feb 16, 2024
085662c
Add loading indicator for country and cities
heisbrot Feb 16, 2024
d70e873
Disable select dropdown while loading
heisbrot Feb 16, 2024
c5564c3
Disable select dropdown while loading, add tooltip for description
heisbrot Feb 16, 2024
3a5799b
Merge branch 'main' into feature/posture-checks
heisbrot Feb 16, 2024
9392e32
Add MaxMind licence information and refactor code
heisbrot Feb 19, 2024
eae8249
Add tooltips for checks, refactor posture check modal
heisbrot Feb 20, 2024
67896ca
Remove unused state
heisbrot Feb 20, 2024
f1b84e6
Disable delete button when posture check is assigned to policies
heisbrot Feb 21, 2024
97e6bac
Add semantic version input validation for operating-system and netbir…
heisbrot Feb 21, 2024
40b6f89
Restore build_and_push.yml
heisbrot Feb 21, 2024
d7fe14f
Fix group badge icon size
heisbrot Feb 22, 2024
cb1d6ce
Fix copy icon size
heisbrot Feb 22, 2024
771dd27
Add region information to peer table and single peer view
heisbrot Feb 22, 2024
d059b77
Merge branch 'main' into feature/peer-region
heisbrot Feb 22, 2024
a2308be
Push to docker
heisbrot Feb 22, 2024
303d2d6
Change login expired icon size
heisbrot Feb 23, 2024
5b114b9
Fix country flag in single peer view
heisbrot Feb 23, 2024
8d74504
Change country flag size in peer table
heisbrot Feb 23, 2024
a6ca799
Disable revalidation for countries
heisbrot Feb 23, 2024
ac6e9b9
Fix icon size on peer detail view
heisbrot Feb 23, 2024
ad5630c
Rollback workflow
heisbrot Feb 23, 2024
d581127
Merge branch 'main' into feature/peer-region
heisbrot Feb 23, 2024
98ba1c6
Revert login expiration
heisbrot Feb 23, 2024
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
Prev Previous commit
Next Next commit
Refactor
  • Loading branch information
heisbrot committed Feb 2, 2024
commit 90d80c33e54373e8704cc96c0bad3f7f8b9f5e8b
20 changes: 20 additions & 0 deletions src/assets/countries/CountryDERounded.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Image from "next/image";
import * as React from "react";
import deIcon from "@/assets/countries/de.svg";

export const CountryDERounded = () => {
return (
<div
className={
"w-5 h-5 overflow-hidden rounded-full relative shadow-2xl border border-nb-gray-600 flex items-center justify-center"
}
>
<Image
src={deIcon}
alt={"de"}
fill={true}
className={"object-cover object-center"}
/>
</div>
);
};
25 changes: 25 additions & 0 deletions src/assets/countries/RoundedFlag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Image from "next/image";
import * as React from "react";
import { memo } from "react";

type Props = {
country: string;
};
const RoundedFlag = ({ country }: Props) => {
return (
<div
className={
"w-5 h-5 shrink-0 overflow-hidden rounded-full relative shadow-2xl border border-nb-gray-800 flex items-center justify-center"
}
>
<Image
src={`/assets/flags/4x3/${country.toLowerCase()}.svg`}
alt={country}
fill={true}
className={"object-cover object-center"}
/>
</div>
);
};

export default memo(RoundedFlag);
2 changes: 1 addition & 1 deletion src/components/PeerSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function PeerSelector({

const [dropdownOptions, setDropdownOptions] = useState<Peer[]>([]);
const searchRef = React.useRef<HTMLInputElement>(null);
const [inputRef, { width }] = useElementSize<HTMLButtonElement>();
const [search, setSearch] = useState("");
const [inputRef, { width }] = useElementSize<HTMLButtonElement>();

// Update dropdown options when peers change
useEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/SquareIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const iconVariant = cva(
red: "bg-red-950 border-red-500 text-red-500",
gray: "bg-nb-gray-930 border-nb-gray-800 text-gray-500",
green: "bg-green-950 border-green-500 text-green-500",
purple: "bg-purple-950 border-purple-500 text-purple-500",
indigo: "bg-indigo-950 border-indigo-500 text-indigo-500",
},
size: {
small: "w-8 h-8",
Expand Down
18 changes: 15 additions & 3 deletions src/components/VerticalTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,29 @@ function VerticalTabs({ value, onChange, children }: Props) {
);
}

function List({ children }: { children: React.ReactNode }) {
function List({
children,
fullHeight = true,
border = true,
className,
}: {
children: React.ReactNode;
fullHeight?: boolean;
border?: boolean;
className?: string;
}) {
const isLg = useIsLg();
return (
<Tabs.List
className={cn(
"px-4 py-4 whitespace-nowrap overflow-y-hidden shrink-0 no-scrollbar",
"lg:h-full items-start bg-nb-gray border-b border-nb-gray-930",
"lg:h-full items-start bg-nb-gray border-nb-gray-930",
"flex lg:flex-col lg:gap-1",
border && "border-b",
className,
)}
style={{
height: isLg ? "calc(100vh - 75px)" : "auto",
height: isLg && fullHeight ? "calc(100vh - 75px)" : "auto",
}}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function ModalHeader({
margin = "mt-0",
}: Props) {
return (
<div className={className}>
<div className={cn(className, "relative z-[1]")}>
<div className={"flex items-start gap-5 pr-10"}>
{icon && <SquareIcon color={color} icon={icon} />}
<div>
Expand Down
60 changes: 53 additions & 7 deletions src/components/select/SelectDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ import Button from "@components/Button";
import { CommandItem } from "@components/Command";
import { Popover, PopoverContent, PopoverTrigger } from "@components/Popover";
import { ScrollArea } from "@components/ScrollArea";
import { SelectDropdownSearchInput } from "@components/select/SelectDropdownSearchInput";
import { cn } from "@utils/helpers";
import { Command, CommandGroup, CommandList } from "cmdk";
import { trim } from "lodash";
import { ChevronsUpDown } from "lucide-react";
import * as React from "react";
import { useState } from "react";
import { useEffect, useState } from "react";
import { useElementSize } from "@/hooks/useElementSize";

export interface SelectOption {
label: string | React.ReactNode;
value: string;
icon?: React.ComponentType<{ size: number; width: number }>;
icon?: React.ComponentType<{
size?: number;
width?: number;
country?: string;
}>;
}

interface SelectDropdownProps {
Expand All @@ -21,6 +27,8 @@ interface SelectDropdownProps {
disabled?: boolean;
popoverWidth?: "auto" | number;
options: SelectOption[];
showSearch?: boolean;
placeholder?: string;
}

export function SelectDropdown({
Expand All @@ -29,6 +37,8 @@ export function SelectDropdown({
disabled = false,
popoverWidth = "auto",
options,
showSearch = false,
placeholder,
}: SelectDropdownProps) {
const [inputRef, { width }] = useElementSize<HTMLButtonElement>();

Expand All @@ -38,17 +48,40 @@ export function SelectDropdown({
} else {
onChange && onChange(selectedValue);
}
setTimeout(() => {
setSearch("");
}, 100);
setOpen(false);
};

const [open, setOpen] = useState(false);

const [slice, setSlice] = useState(10);

useEffect(() => {
if (open) {
setTimeout(() => {
setSlice(options.length);
}, 100);
} else {
setSlice(10);
}
}, [open, options]);

const selected = options.find((o) => o.value === value);

const searchRef = React.useRef<HTMLInputElement>(null);
const [search, setSearch] = useState("");

return (
<Popover
open={open}
onOpenChange={(isOpen) => {
if (!isOpen) {
setTimeout(() => {
setSearch("");
}, 100);
}
setOpen(isOpen);
}}
>
Expand Down Expand Up @@ -99,18 +132,31 @@ export function SelectDropdown({
}}
>
<CommandList className={"w-full"}>
{showSearch && (
<SelectDropdownSearchInput
search={search}
setSearch={setSearch}
ref={searchRef}
placeholder={placeholder}
/>
)}

<ScrollArea
className={
"max-h-[380px] overflow-y-auto flex flex-col gap-1 pl-2 py-2 pr-3"
}
className={cn(
"max-h-[380px] overflow-y-auto flex flex-col gap-1 pl-2 pb-2 pr-3",
!showSearch && "pt-2",
)}
>
<CommandGroup>
<div className={"grid grid-cols-1 gap-1"}>
{options.map((option) => {
{options.slice(0, slice).map((option) => {
return (
<CommandItem
key={option.value}
value={option.value}
value={
((option.label as string) || "") +
(option.value || "")
}
className={"py-1 px-2"}
onSelect={() => toggle(option.value)}
onClick={(e) => e.preventDefault()}
Expand Down
56 changes: 56 additions & 0 deletions src/components/select/SelectDropdownSearchInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { IconArrowBack } from "@tabler/icons-react";
import { cn } from "@utils/helpers";
import { CommandInput } from "cmdk";
import { SearchIcon } from "lucide-react";
import * as React from "react";
import { forwardRef } from "react";

type Props = {
search: string;
setSearch: React.Dispatch<React.SetStateAction<string>>;
placeholder?: string;
};

export const SelectDropdownSearchInput = forwardRef<HTMLInputElement, Props>(
(
{
search,
setSearch,
placeholder = "Search for peers by name or ip...",
}: Props,
ref,
) => {
return (
<div className={"relative"}>
<CommandInput
className={cn(
"min-h-[42px] w-full relative",
"border-b-0 border-t-0 border-r-0 border-l-0 border-neutral-200 dark:border-nb-gray-700 items-center",
"bg-transparent text-sm outline-none focus-visible:outline-none ring-0 focus-visible:ring-0",
"dark:placeholder:text-nb-gray-400 font-light placeholder:text-neutral-500 pl-10",
)}
ref={ref}
value={search}
onValueChange={setSearch}
placeholder={placeholder}
/>
<div className={"absolute left-0 top-0 h-full flex items-center pl-4"}>
<div className={"flex items-center"}>
<SearchIcon size={14} />
</div>
</div>
<div className={"absolute right-0 top-0 h-full flex items-center pr-4"}>
<div
className={
"flex items-center bg-nb-gray-800 py-1 px-1.5 rounded-[4px] border border-nb-gray-500"
}
>
<IconArrowBack size={10} />
</div>
</div>
</div>
);
},
);

SelectDropdownSearchInput.displayName = "SelectDropdownSearchInput";
5 changes: 4 additions & 1 deletion src/modules/peers/PeerOSCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
TooltipTrigger,
} from "@components/Tooltip";
import Image from "next/image";
import { useMemo } from "react";
import React, { useMemo } from "react";
import { FaWindows } from "react-icons/fa6";
import { FcAndroidOs, FcLinux } from "react-icons/fc";
import IOSIcon from "@/assets/icons/IOSIcon";
import AppleLogo from "@/assets/os-icons/apple.svg";
import { getOperatingSystem } from "@/hooks/useOperatingSystem";
import { OperatingSystem } from "@/interfaces/OperatingSystem";
Expand Down Expand Up @@ -48,6 +49,8 @@ function OSLogo({ os }: { os: string }) {
return <FaWindows className={"text-white text-lg"} />;
if (icon === OperatingSystem.APPLE)
return <Image src={AppleLogo} alt={""} width={14} />;
if (icon === OperatingSystem.IOS)
return <IOSIcon className={"fill-white"} size={20} />;
if (icon === OperatingSystem.ANDROID)
return <FcAndroidOs className={"text-white text-2xl brightness-200"} />;

Expand Down
13 changes: 2 additions & 11 deletions src/modules/users/UserInviteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { notify } from "@components/Notification";
import Paragraph from "@components/Paragraph";
import { PeerGroupSelector } from "@components/PeerGroupSelector";
import { GradientFadedBackground } from "@components/ui/GradientFadedBackground";
import { IconMailForward } from "@tabler/icons-react";
import { useApiCall } from "@utils/api";
import { cn, validator } from "@utils/helpers";
Expand Down Expand Up @@ -90,17 +91,7 @@ export function UserInviteModalContent({ onSuccess }: ModalProps) {

return (
<ModalContent maxWidthClass={"max-w-md relative"} showClose={true}>
<div
className={
"h-full w-full absolute left-0 top-0 rounded-md overflow-hidden z-0"
}
>
<div
className={
"bg-gradient-to-b from-nb-gray-900/20 via-transparent to-transparent w-full h-full rounded-md"
}
></div>
</div>
<GradientFadedBackground />
<UserAvatars />

<div
Expand Down