Skip to content

Commit a806c36

Browse files
authored
Merge pull request #418 from objectstack-ai/copilot/fix-ci-build-and-test-another-one
2 parents 31eadf1 + e5d20dd commit a806c36

7 files changed

Lines changed: 76 additions & 86 deletions

File tree

packages/permissions/src/store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export function createPermissionStore(config: {
3636
userRoles: string[];
3737
user?: { id: string; [key: string]: unknown };
3838
}): PermissionStore {
39-
let { roles, permissions, userRoles, user } = config;
39+
const { roles, user } = config;
40+
let { permissions, userRoles } = config;
4041

4142
return {
4243
check: (object, action, record) =>

packages/permissions/src/useFieldPermissions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { useMemo } from 'react';
10-
import type { FieldLevelPermission } from '@object-ui/types';
1110
import { usePermissions } from './usePermissions';
1211

1312
/**

packages/permissions/src/usePermissions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import { useContext, useCallback } from 'react';
9+
import { useContext } from 'react';
1010
import type { PermissionAction, PermissionCheckResult } from '@object-ui/types';
1111
import { PermCtx, type PermissionContextValue } from './PermissionContext';
1212

packages/plugin-dashboard/src/DashboardGridLayout.tsx

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import * as React from 'react';
2-
import { Responsive, WidthProvider, Layout as RGLLayout } from 'react-grid-layout';
2+
import { ResponsiveGridLayout, useContainerWidth, type LayoutItem as RGLLayout, type Layout, type ResponsiveLayouts } from 'react-grid-layout';
33
import 'react-grid-layout/css/styles.css';
44
import { cn, Card, CardHeader, CardTitle, CardContent, Button } from '@object-ui/components';
55
import { Edit, GripVertical, Save, X } from 'lucide-react';
66
import { SchemaRenderer } from '@object-ui/react';
77
import type { DashboardSchema, DashboardWidgetSchema } from '@object-ui/types';
88

9-
const ResponsiveGridLayout = WidthProvider(Responsive);
10-
119
const CHART_COLORS = [
1210
'hsl(var(--chart-1))',
1311
'hsl(var(--chart-2))',
@@ -29,6 +27,7 @@ export const DashboardGridLayout: React.FC<DashboardGridLayoutProps> = ({
2927
onLayoutChange,
3028
persistLayoutKey = 'dashboard-layout',
3129
}) => {
30+
const { width, containerRef, mounted } = useContainerWidth();
3231
const [editMode, setEditMode] = React.useState(false);
3332
const [layouts, setLayouts] = React.useState<{ lg: RGLLayout[] }>(() => {
3433
// Try to load saved layout
@@ -56,9 +55,9 @@ export const DashboardGridLayout: React.FC<DashboardGridLayoutProps> = ({
5655
});
5756

5857
const handleLayoutChange = React.useCallback(
59-
(layout: RGLLayout[], allLayouts: { lg: RGLLayout[] }) => {
60-
setLayouts(allLayouts);
61-
onLayoutChange?.(layout);
58+
(layout: Layout, allLayouts: ResponsiveLayouts) => {
59+
setLayouts(allLayouts as { lg: RGLLayout[] });
60+
onLayoutChange?.(layout as RGLLayout[]);
6261
},
6362
[onLayoutChange]
6463
);
@@ -122,7 +121,7 @@ export const DashboardGridLayout: React.FC<DashboardGridLayoutProps> = ({
122121
}, []);
123122

124123
return (
125-
<div className={cn("w-full", className)} data-testid="grid-layout">
124+
<div ref={containerRef} className={cn("w-full", className)} data-testid="grid-layout">
126125
<div className="mb-4 flex items-center justify-between">
127126
<h2 className="text-2xl font-bold">{schema.title || 'Dashboard'}</h2>
128127
<div className="flex gap-2">
@@ -149,62 +148,64 @@ export const DashboardGridLayout: React.FC<DashboardGridLayoutProps> = ({
149148
</div>
150149
</div>
151150

152-
<ResponsiveGridLayout
153-
className="layout"
154-
layouts={layouts}
155-
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
156-
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
157-
rowHeight={60}
158-
isDraggable={editMode}
159-
isResizable={editMode}
160-
onLayoutChange={handleLayoutChange}
161-
draggableHandle=".drag-handle"
162-
>
163-
{schema.widgets?.map((widget, index) => {
164-
const widgetId = widget.id || `widget-${index}`;
165-
const componentSchema = getComponentSchema(widget);
166-
const isSelfContained = (widget as any).type === 'metric';
151+
{mounted && (
152+
<ResponsiveGridLayout
153+
className="layout"
154+
width={width}
155+
layouts={layouts}
156+
breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}
157+
cols={{ lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }}
158+
rowHeight={60}
159+
dragConfig={{ enabled: editMode, handle: ".drag-handle" }}
160+
resizeConfig={{ enabled: editMode }}
161+
onLayoutChange={handleLayoutChange}
162+
>
163+
{schema.widgets?.map((widget, index) => {
164+
const widgetId = widget.id || `widget-${index}`;
165+
const componentSchema = getComponentSchema(widget);
166+
const isSelfContained = (widget as any).type === 'metric';
167167

168-
return (
169-
<div key={widgetId} className="h-full">
170-
{isSelfContained ? (
171-
<div className="h-full w-full relative">
172-
{editMode && (
173-
<div className="drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border">
174-
<GripVertical className="h-4 w-4" />
175-
</div>
176-
)}
177-
<SchemaRenderer schema={componentSchema} className="h-full w-full" />
178-
</div>
179-
) : (
180-
<Card className={cn(
181-
"h-full overflow-hidden border-border/50 shadow-sm transition-all",
182-
"bg-card/50 backdrop-blur-sm",
183-
editMode && "ring-2 ring-primary/20"
184-
)}>
185-
{widget.title && (
186-
<CardHeader className="pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between">
187-
<CardTitle className="text-base font-medium tracking-tight truncate" title={widget.title}>
188-
{widget.title}
189-
</CardTitle>
190-
{editMode && (
191-
<div className="drag-handle cursor-move p-1 hover:bg-muted/40 rounded">
192-
<GripVertical className="h-4 w-4" />
193-
</div>
194-
)}
195-
</CardHeader>
196-
)}
197-
<CardContent className="p-0 h-full">
198-
<div className={cn("h-full w-full overflow-auto", !widget.title ? "p-4" : "p-4")}>
199-
<SchemaRenderer schema={componentSchema} />
200-
</div>
201-
</CardContent>
202-
</Card>
203-
)}
204-
</div>
205-
);
206-
})}
207-
</ResponsiveGridLayout>
168+
return (
169+
<div key={widgetId} className="h-full">
170+
{isSelfContained ? (
171+
<div className="h-full w-full relative">
172+
{editMode && (
173+
<div className="drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border">
174+
<GripVertical className="h-4 w-4" />
175+
</div>
176+
)}
177+
<SchemaRenderer schema={componentSchema} className="h-full w-full" />
178+
</div>
179+
) : (
180+
<Card className={cn(
181+
"h-full overflow-hidden border-border/50 shadow-sm transition-all",
182+
"bg-card/50 backdrop-blur-sm",
183+
editMode && "ring-2 ring-primary/20"
184+
)}>
185+
{widget.title && (
186+
<CardHeader className="pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between">
187+
<CardTitle className="text-base font-medium tracking-tight truncate" title={widget.title}>
188+
{widget.title}
189+
</CardTitle>
190+
{editMode && (
191+
<div className="drag-handle cursor-move p-1 hover:bg-muted/40 rounded">
192+
<GripVertical className="h-4 w-4" />
193+
</div>
194+
)}
195+
</CardHeader>
196+
)}
197+
<CardContent className="p-0 h-full">
198+
<div className={cn("h-full w-full overflow-auto p-4")}>
199+
<SchemaRenderer schema={componentSchema} />
200+
</div>
201+
</CardContent>
202+
</Card>
203+
)}
204+
</div>
205+
);
206+
})}
207+
</ResponsiveGridLayout>
208+
)}
208209
</div>
209210
);
210211
};

packages/plugin-designer/src/CollaborationProvider.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import React, { createContext, useContext, useState, useEffect, useCallback, useMemo } from 'react';
9+
import React, { createContext, useContext, useCallback, useMemo } from 'react';
1010
import type { CollaborationConfig, CollaborationPresence, CollaborationOperation } from '@object-ui/types';
1111

1212
export interface CollaborationContextValue {
@@ -48,31 +48,20 @@ export function CollaborationProvider({
4848
onOperation,
4949
children,
5050
}: CollaborationProviderProps) {
51-
const [users, setUsers] = useState<CollaborationPresence[]>([]);
52-
const [isConnected, setIsConnected] = useState(false);
53-
54-
// Add current user to presence list
55-
useEffect(() => {
56-
if (!config.enabled || !user) return;
57-
58-
const currentUser: CollaborationPresence = {
51+
const users = useMemo<CollaborationPresence[]>(() => {
52+
if (!config.enabled || !user) return [];
53+
return [{
5954
userId: user.id,
6055
userName: user.name,
6156
avatar: user.avatar,
6257
color: generateColor(user.id),
63-
status: 'active',
58+
status: 'active' as const,
6459
lastActivity: new Date().toISOString(),
65-
};
66-
67-
setUsers([currentUser]);
68-
setIsConnected(true);
69-
70-
return () => {
71-
setIsConnected(false);
72-
setUsers([]);
73-
};
60+
}];
7461
}, [config.enabled, user]);
7562

63+
const isConnected = config.enabled && !!user;
64+
7665
const sendOperation = useCallback(
7766
(operation: Omit<CollaborationOperation, 'id' | 'timestamp' | 'version'>) => {
7867
if (!isConnected || !user) return;

packages/plugin-designer/src/PageDesigner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function PageDesigner({
5757
}: PageDesignerProps) {
5858
const [components, setComponents] = useState<DesignerComponent[]>(initialComponents);
5959
const [selectedId, setSelectedId] = useState<string | null>(null);
60-
const [zoom, setZoom] = useState(canvas.zoom ?? 1);
60+
const [zoom, _setZoom] = useState(canvas.zoom ?? 1);
6161

6262
const selectedComponent = useMemo(
6363
() => components.find((c) => c.id === selectedId),

packages/plugin-designer/src/ProcessDesigner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import React, { useState, useCallback } from 'react';
1010
import type { BPMNNode, BPMNEdge, BPMNLane, DesignerCanvasConfig } from '@object-ui/types';
11-
import { Play, Square, Diamond, Plus, Trash2, GitBranch } from 'lucide-react';
11+
import { Play, Square, Diamond, Trash2, GitBranch } from 'lucide-react';
1212
import { clsx } from 'clsx';
1313
import { twMerge } from 'tailwind-merge';
1414

0 commit comments

Comments
 (0)