Skip to content

Commit

Permalink
✨ Added widget handling
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed May 21, 2024
1 parent 60f7927 commit 1399c7c
Show file tree
Hide file tree
Showing 16 changed files with 466 additions and 115 deletions.
2 changes: 0 additions & 2 deletions apps/client-ts/src/app/(Dashboard)/api-keys/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ interface TSApiKeys {
id_api_key: string;
name : string;
token : string;
created : string;
}

export default function Page() {
Expand All @@ -66,7 +65,6 @@ export default function Page() {
id_api_key: key.id_api_key,
name: key.name || "",
token: key.api_key_hash,
created: new Date().toISOString()
}))
setTSApiKeys(temp_tsApiKeys)
},[apiKeys])
Expand Down
56 changes: 46 additions & 10 deletions apps/client-ts/src/app/(Dashboard)/configuration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/comp
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { HelpCircle } from "lucide-react";
import { Button } from "@/components/ui/button";
import { LoadingSpinner } from "@/components/ui/loading-spinner";
import { CatalogWidget } from "@/components/Configuration/Catalog/CatalogWidget";
import { CopySnippet } from "@/components/Configuration/Catalog/CopySnippet";

export default function Page() {

Expand Down Expand Up @@ -97,6 +100,9 @@ export default function Page() {
<TabsTrigger value="webhooks">
Webhooks
</TabsTrigger>
<TabsTrigger value="catalog">
Manage Catalog Widget
</TabsTrigger>
<TabsTrigger value="custom">
Manage Connectors
</TabsTrigger>
Expand All @@ -121,8 +127,10 @@ export default function Page() {
</PopoverTrigger>
<PopoverContent className="flex w-[420px] p-0">
<div className="flex flex-col gap-2 px-2 py-4">
<div className="grid min-w-[250px] gap-1 ">
<p className="font-bold text-sm">What are linked accounts ? </p>
<div className="grid min-w-[250px] gap-1 gap-y-2">
<p className="font-bold text-md">What are linked accounts ? </p>
<p className="text-sm">The linked-user object represents your end-user entity inside our system.</p>
<p className="text-sm">It is a mirror of the end-user that exist in your backend. It helps Panora have the same source of truth about your user’s information. </p>
</div>
</div>
</PopoverContent>
Expand All @@ -131,8 +139,8 @@ export default function Page() {
</Tooltip>
</TooltipProvider>
</CardTitle>
<CardDescription className="text-left">
You connected {linkedUsers ? linkedUsers.length : <Skeleton className="w-[20px] h-[12px] rounded-md" />} linked accounts.
<CardDescription className="text-left flex flex-row items-center">
You connected {linkedUsers ? linkedUsers.length : <LoadingSpinner className="w-4 mr-2"/>} linked accounts.
</CardDescription>
</CardHeader>
<Separator className="mb-10"/>
Expand Down Expand Up @@ -162,8 +170,18 @@ export default function Page() {
</PopoverTrigger>
<PopoverContent className="flex w-[420px] p-0">
<div className="flex flex-col gap-2 px-2 py-4">
<div className="grid min-w-[250px] gap-1 ">
<p className="font-bold text-sm">What are field mappings ? </p>
<div className="grid min-w-[250px] gap-1 gap-y-2 ">
<p className="font-bold text-md">What are field mappings ? </p>
<p className="text-sm">
By default, our unified models are predefined as you can see in the API reference. <br/>
</p>
<p className="text-sm">Now with field mappings, you have the option to map your custom fields (that may exist in your end-customer&apos;s tools) to our unified model !</p>
<p className="text-sm">
It is done in 2 steps. First you must define your custom field so it is recognized by Panora. Lastly, you must map this field to your remote field that exist in a 3rd party.
</p>
<p className="text-sm">
<br/>That way, Panora can retrieve the newly created custom field directly within the unified model.
</p>
</div>
</div>
</PopoverContent>
Expand All @@ -172,8 +190,8 @@ export default function Page() {
</Tooltip>
</TooltipProvider>
</CardTitle>
<CardDescription className="text-left">
You built {mappings ? mappings.length : <Skeleton className="w-[20px] h-[12px] rounded-md" />} fields mappings.
<CardDescription className="text-left flex flex-row items-center">
You built {mappings ? mappings.length : <LoadingSpinner className="w-4 mr-2"/>} fields mappings.
<a href="https://docs.panora.dev/core-concepts/custom-fields" className="font-bold" target="_blank" rel="noopener noreferrer"> Learn more about custom field mappings in our docs !</a>
</CardDescription>
</CardHeader>
Expand All @@ -191,8 +209,8 @@ export default function Page() {
<Card className="col-span-12">
<CardHeader>
<CardTitle className="text-left">Your Webhooks</CardTitle>
<CardDescription className="text-left">
You enabled {webhooks ? webhooks.length : <Skeleton className="w-[20px] h-[12px] rounded-md" />} webhooks.
<CardDescription className="text-left flex flex-row items-center">
You enabled {webhooks ? webhooks.length : <LoadingSpinner className="w-4 mr-2"/>} webhooks.
<a href="https://docs.panora.dev/webhooks/overview" target="_blank" rel="noopener noreferrer"><strong> Read more about webhooks from our documentation</strong></a>
</CardDescription>
</CardHeader>
Expand All @@ -207,6 +225,24 @@ export default function Page() {
<TabsContent value="custom" className="space-y-4">
<CustomConnectorPage />
</TabsContent>

<TabsContent value="catalog" className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-12">
<CopySnippet/>
<Card className="col-span-12">
<CardHeader>
<CardTitle className="text-left">Customize Your Embedded Widget</CardTitle>
<CardDescription className="text-left flex flex-row items-center">
Select connectors you would like to have in the UI widget catalog. By default, they are all displayed.
</CardDescription>
</CardHeader>
<Separator className="mb-[15px]"/>
<CardContent>
<CatalogWidget/>
</CardContent>
</Card>
</div>
</TabsContent>
</Tabs>
</div>

Expand Down
10 changes: 0 additions & 10 deletions apps/client-ts/src/components/ApiKeys/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,6 @@ export function useColumns() {
);
},
},
{
accessorKey: "created",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Created" />
),
cell: ({ row }) => <div><Badge variant="outline">{row.getValue("created")}</Badge></div>,
filterFn: (row, id, value) => {
return value.includes(row.getValue(id))
},
},
{
id: "actions",
cell: ({ row }) => <DataTableRowActions row={row} object={"api-key"}/>,
Expand Down
1 change: 0 additions & 1 deletion apps/client-ts/src/components/ApiKeys/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const apiKeySchema = z.object({
id_api_key: z.string(),
name: z.string(),
token: z.string(),
created: z.string(),
})

export type ApiKey = z.infer<typeof apiKeySchema>
130 changes: 130 additions & 0 deletions apps/client-ts/src/components/Configuration/Catalog/CatalogWidget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { ComponentProps, useState } from "react"
import { cn } from "@/lib/utils"
import { Badge } from "@/components/ui/badge"
import { ScrollArea } from "@/components/ui/scroll-area"
import { AuthStrategy, categoriesVerticals, Provider, providersArray } from "@panora/shared"
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { Button } from "@/components/ui/button"
import { ListFilter } from "lucide-react"
import { Card } from "@/components/ui/card"
import { Switch } from "@/components/ui/switch"
import { Label } from "@/components/ui/label"

export const verticals = categoriesVerticals as string[];

export function CatalogWidget() {
const [vertical, setVertical] = useState("All")
const filteredConnectors = vertical === "All"
? providersArray()
: providersArray(vertical);

const handleCheckboxChange = (vertical: string) => {
setVertical(vertical);
};
return (
<>
<div className="flex items-center justify-between w-full">

<div className="flex items-center gap-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="sm"
className="h-7 gap-2 text-sm px-4 mb-2"
>
<ListFilter className="h-3.5 w-3.5" />
<span className="sr-only sm:not-sr-only">Filter By Category</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Filter by</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuCheckboxItem
key={"All"}
checked={vertical == "All"}
onCheckedChange={() => handleCheckboxChange("All")}
>
All
</DropdownMenuCheckboxItem>
<DropdownMenuSeparator />
{verticals.map((v) => (
<DropdownMenuCheckboxItem
key={v}
checked={vertical == v}
onCheckedChange={() => handleCheckboxChange(v)}
>
{v}
</DropdownMenuCheckboxItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</div>

<Label
htmlFor="mute"
className="flex items-center gap-2 text-xs font-bold"
>
<Switch id="mute" aria-label="Mute thread" /> Apply to Magic Link Catalog
</Label>

</div>

<ScrollArea className="h-full max-h-[calc(100vh-150px)] overflow-y-auto mt-2">
<div className="flex flex-col gap-2 pt-0">
{filteredConnectors.map((item) => (
<Card
key={`${item.vertical}-${item.name}`}
className={cn(
"flex flex-col items-start gap-2 rounded-lg border p-3 text-left text-sm transition-all",
"border"
)}
>
<div className="flex w-full items-start justify-between">
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2">
<img src={item.logoPath} className="w-8 h-8 rounded-lg" />
<div className="font-semibold">{`${item.name.substring(0, 1).toUpperCase()}${item.name.substring(1)}`}</div>
</div>
<div className="line-clamp-2 text-xs text-muted-foreground">
{item.description!.substring(0, 300)}
</div>
<div className="flex items-center gap-2 mt-2">
{item.vertical &&
<Badge key={item.vertical} variant={getBadgeVariantFromLabel(item.vertical)}>
{item.vertical}
</Badge>
}
{item.authStrategy &&
<Badge key={item.authStrategy} variant={getBadgeVariantFromLabel(item.authStrategy)}>
{item.authStrategy}
</Badge>
}
</div>
</div>
<div>
<Switch
className="data-[state=checked]:bg-sky-700"
id="necessary"
// checked={row.getValue('active')}
// onCheckedChange={() => disableWebhook(row.original.id_webhook_endpoint, !row.getValue('active')) }
/>
</div>
</div>
</Card>

))}
</div>
</ScrollArea>
</>
)
}

function getBadgeVariantFromLabel(
label?: string
): ComponentProps<typeof Badge>["variant"] {
if (label === AuthStrategy.oauth2) {
return "secondary"
}
return "default"
}
Loading

0 comments on commit 1399c7c

Please sign in to comment.