diff --git a/src/app/(main)/SideNav.tsx b/src/app/(main)/SideNav.tsx
index aadf8670f..55ff27cd1 100644
--- a/src/app/(main)/SideNav.tsx
+++ b/src/app/(main)/SideNav.tsx
@@ -10,6 +10,7 @@ import {
TooltipTrigger,
} from '@umami/react-zen';
import Link from 'next/link';
+import { AdminNav } from '@/app/(main)/admin/AdminNav';
import { SettingsNav } from '@/app/(main)/settings/SettingsNav';
import { WebsiteNav } from '@/app/(main)/websites/[websiteId]/WebsiteNav';
import { IconLabel } from '@/components/common/IconLabel';
@@ -103,6 +104,8 @@ export function SideNav(props: any) {
) : pathname.includes('/settings') ? (
+ ) : pathname.includes('/admin') ? (
+
) : (
{links.map(({ id, path, label, icon }) => {
diff --git a/src/app/(main)/admin/AdminLayout.tsx b/src/app/(main)/admin/AdminLayout.tsx
index 681ba3f03..92d316ac5 100644
--- a/src/app/(main)/admin/AdminLayout.tsx
+++ b/src/app/(main)/admin/AdminLayout.tsx
@@ -1,9 +1,7 @@
'use client';
-import { Column, Grid } from '@umami/react-zen';
import type { ReactNode } from 'react';
import { PageBody } from '@/components/common/PageBody';
import { useLoginQuery } from '@/components/hooks';
-import { AdminNav } from './AdminNav';
export function AdminLayout({ children }: { children: ReactNode }) {
const { user } = useLoginQuery();
@@ -12,21 +10,5 @@ export function AdminLayout({ children }: { children: ReactNode }) {
return null;
}
- return (
-
-
-
-
-
- {children}
-
-
- );
+ return {children};
}
diff --git a/src/app/(main)/admin/AdminNav.tsx b/src/app/(main)/admin/AdminNav.tsx
index edcfb4c62..064305cfa 100644
--- a/src/app/(main)/admin/AdminNav.tsx
+++ b/src/app/(main)/admin/AdminNav.tsx
@@ -1,9 +1,9 @@
-import { Column, Focusable, Row, Tooltip, TooltipTrigger } from '@umami/react-zen';
-import Link from 'next/link';
import { IconLabel } from '@/components/common/IconLabel';
import { NavMenu } from '@/components/common/NavMenu';
import { useMessages, useNavigation } from '@/components/hooks';
import { ArrowLeft, Globe, User, Users } from '@/components/icons';
+import { Column, Focusable, Row, Tooltip, TooltipTrigger } from '@umami/react-zen';
+import Link from 'next/link';
export function AdminNav({ onItemClick }: { onItemClick?: () => void }) {
const { t, labels } = useMessages();
@@ -41,7 +41,7 @@ export function AdminNav({ onItemClick }: { onItemClick?: () => void }) {
return (
-
+
void }) {
- {type === 'pixel' ? : type === 'link' ? : }
+ {type === 'pixel' ? (
+
+ ) : type === 'link' ? (
+
+ ) : (
+
+ )}
{name}
diff --git a/src/app/(main)/boards/[boardId]/BoardComponentRenderer.tsx b/src/app/(main)/boards/[boardId]/BoardComponentRenderer.tsx
index f6449fbd4..ec2a30df1 100644
--- a/src/app/(main)/boards/[boardId]/BoardComponentRenderer.tsx
+++ b/src/app/(main)/boards/[boardId]/BoardComponentRenderer.tsx
@@ -6,9 +6,11 @@ import { getComponentDefinition } from '../boardComponentRegistry';
function BoardComponentRendererComponent({
config,
websiteId,
+ entityType,
}: {
config: BoardComponentConfig;
websiteId?: string;
+ entityType?: string;
}) {
const definition = getComponentDefinition(config.type);
@@ -20,7 +22,8 @@ function BoardComponentRendererComponent({
);
}
- const Component = definition.component;
+ const Component =
+ (entityType && definition.componentByEntityType?.[entityType]) || definition.component;
if (!websiteId && definition.requiresWebsite !== false) {
return (
@@ -36,7 +39,9 @@ function BoardComponentRendererComponent({
export const BoardComponentRenderer = memo(
BoardComponentRendererComponent,
(prevProps, nextProps) =>
- prevProps.websiteId === nextProps.websiteId && prevProps.config === nextProps.config,
+ prevProps.websiteId === nextProps.websiteId &&
+ prevProps.entityType === nextProps.entityType &&
+ prevProps.config === nextProps.config,
);
BoardComponentRenderer.displayName = 'BoardComponentRenderer';
diff --git a/src/app/(main)/boards/[boardId]/BoardComponentSelect.tsx b/src/app/(main)/boards/[boardId]/BoardComponentSelect.tsx
index 16c77d269..3a03ffea0 100644
--- a/src/app/(main)/boards/[boardId]/BoardComponentSelect.tsx
+++ b/src/app/(main)/boards/[boardId]/BoardComponentSelect.tsx
@@ -177,14 +177,16 @@ export function BoardComponentSelect({
onSelect(config);
};
- const previewConfig: BoardComponentConfig | null = selectedDef
- ? {
- type: selectedDef.type,
- title,
- description,
- props: { ...selectedDef.defaultProps, ...configValues },
- }
- : null;
+ const previewConfig: BoardComponentConfig | null = useMemo(
+ () =>
+ selectedDef
+ ? {
+ type: selectedDef.type,
+ props: { ...selectedDef.defaultProps, ...configValues },
+ }
+ : null,
+ [selectedDef, configValues],
+ );
const canSave = !!selectedDef && isSelectedDefSupported && (!needsWebsite || !!resolvedEntityId);
const availableDefinitions = useMemo(
@@ -274,12 +276,16 @@ export function BoardComponentSelect({
)}
@@ -364,7 +370,7 @@ export function BoardComponentSelect({
Preview
{hasSelectedEntity && previewConfig && (!needsWebsite || resolvedEntityId) ? (
-
+
) : (
diff --git a/src/app/(main)/boards/[boardId]/BoardEditColumn.tsx b/src/app/(main)/boards/[boardId]/BoardEditColumn.tsx
index e0d3395da..0a89ea25c 100644
--- a/src/app/(main)/boards/[boardId]/BoardEditColumn.tsx
+++ b/src/app/(main)/boards/[boardId]/BoardEditColumn.tsx
@@ -1,3 +1,8 @@
+import { Panel } from '@/components/common/Panel';
+import { useBoard, useMessages, useNavigation } from '@/components/hooks';
+import { Pencil, Plus, X } from '@/components/icons';
+import { getBoardEntity, getBoardType, getResolvedComponentEntity } from '@/lib/boards';
+import type { BoardComponentConfig } from '@/lib/types';
import {
Box,
Button,
@@ -10,11 +15,6 @@ import {
TooltipTrigger,
} from '@umami/react-zen';
import { useMemo, useState } from 'react';
-import { Panel } from '@/components/common/Panel';
-import { useBoard, useMessages, useNavigation } from '@/components/hooks';
-import { Pencil, Plus, X } from '@/components/icons';
-import { getBoardEntity, getBoardType, getResolvedComponentEntity } from '@/lib/boards';
-import type { BoardComponentConfig } from '@/lib/types';
import { getComponentDefinition } from '../boardComponentRegistry';
import { BoardComponentRenderer } from './BoardComponentRenderer';
import { BoardComponentSelect } from './BoardComponentSelect';
@@ -42,14 +42,14 @@ export function BoardEditColumn({
const boardType = getBoardType(board);
const { entityType: boardEntityType, entityId: boardEntityId } = getBoardEntity(board);
const definition = component ? getComponentDefinition(component.type) : undefined;
- const { entityId } = getResolvedComponentEntity(board, component);
+ const { entityType, entityId } = getResolvedComponentEntity(board, component);
const renderedComponent = useMemo(() => {
if (!component || (!entityId && definition?.requiresWebsite !== false)) {
return null;
}
- return ;
- }, [component, definition?.requiresWebsite, entityId]);
+ return ;
+ }, [component, definition?.requiresWebsite, entityId, entityType]);
const handleSelect = (config: BoardComponentConfig) => {
onSetComponent(id, config);
@@ -79,7 +79,7 @@ export function BoardEditColumn({
onMouseEnter={() => setShowActions(true)}
onMouseLeave={() => setShowActions(false)}
>
- {canEdit && canRemoveAction && showActions && (
+ {canEdit && (showActions || !hasComponent) && (
-
- {hasComponent && (
-
-
- {t(labels.edit)}
-
- )}
+
-
+ {canRemoveAction && (
+
+
+
+
+
+
+ {t(labels.remove)}
+
+ )}
)}
- {renderedComponent ? (
+ {renderedComponent && (
{renderedComponent}
- ) : (
- canEdit && (
-
- setShowSelect(true)}>
-
-
-
-
-
- )
)}