Skip to content

Commit 0c0da21

Browse files
committed
feat: add function worker entry and service count
1 parent d1bb53b commit 0c0da21

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

src/client/components/layout/DesktopLayout.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
LuWifi,
1010
LuTabletSmartphone,
1111
LuBrainCircuit,
12+
LuSquareFunction,
1213
} from 'react-icons/lu';
1314
import {
1415
ResizableHandle,
@@ -32,6 +33,8 @@ import { WorkspacePauseTip } from '../workspace/WorkspacePauseTip';
3233
import { FreeTierTip } from '../FreeTierTip';
3334
import { DevContainer } from '../DevContainer';
3435
import { AIPanel } from '../ai/AIPanel';
36+
import { compact } from 'lodash-es';
37+
import { useGlobalConfig } from '@/hooks/useConfig';
3538

3639
const defaultLayout: [number, number, number] = [15, 25, 60];
3740

@@ -56,6 +59,7 @@ export const DesktopLayout: React.FC<LayoutProps> = React.memo((props) => {
5659
}
5760
);
5861
const { t } = useTranslation();
62+
const { alphaMode, enableFunctionWorker } = useGlobalConfig();
5963

6064
const navbar = (
6165
<>
@@ -89,7 +93,7 @@ export const DesktopLayout: React.FC<LayoutProps> = React.memo((props) => {
8993

9094
<Nav
9195
isCollapsed={isCollapsed}
92-
links={[
96+
links={compact([
9397
{
9498
title: t('Website'),
9599
label: String(serviceCount?.website ?? ''),
@@ -144,7 +148,14 @@ export const DesktopLayout: React.FC<LayoutProps> = React.memo((props) => {
144148
icon: LuBrainCircuit,
145149
to: '/aiGateway',
146150
},
147-
]}
151+
alphaMode &&
152+
enableFunctionWorker && {
153+
title: t('Function'),
154+
label: String(serviceCount?.functionWorker ?? ''),
155+
icon: LuSquareFunction,
156+
to: '/worker',
157+
},
158+
])}
148159
/>
149160

150161
<Separator />

src/client/routes/insights/index.tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,29 @@ function PageComponent() {
7474
<SelectValue placeholder={t('Please select target')} />
7575
</SelectTrigger>
7676
<SelectContent>
77-
<SelectGroup>
78-
<SelectLabel>{t('Websites')}</SelectLabel>
79-
{websites.map((item) => (
80-
<SelectItem key={item.id} value={item.id}>
81-
{item.name}
82-
</SelectItem>
83-
))}
84-
</SelectGroup>
85-
<SelectGroup>
86-
<SelectLabel>{t('Surveys')}</SelectLabel>
87-
{surveys.map((item) => (
88-
<SelectItem key={item.id} value={item.id}>
89-
{item.name}
90-
</SelectItem>
91-
))}
92-
</SelectGroup>
77+
{websites.length > 0 && (
78+
<SelectGroup>
79+
<SelectLabel>{t('Websites')}</SelectLabel>
80+
81+
{websites.map((item) => (
82+
<SelectItem key={item.id} value={item.id}>
83+
{item.name}
84+
</SelectItem>
85+
))}
86+
</SelectGroup>
87+
)}
88+
89+
{surveys.length > 0 && (
90+
<SelectGroup>
91+
<SelectLabel>{t('Surveys')}</SelectLabel>
92+
{surveys.map((item) => (
93+
<SelectItem key={item.id} value={item.id}>
94+
{item.name}
95+
</SelectItem>
96+
))}
97+
</SelectGroup>
98+
)}
99+
93100
{warehouseApplicationIds.length > 0 && (
94101
<SelectGroup>
95102
<SelectLabel>{t('Warehouse')}</SelectLabel>

src/server/model/workspace.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export async function getWorkspaceServiceCount(workspaceId: string) {
8484
survey,
8585
feed,
8686
aiGateway,
87+
functionWorker,
8788
] = await Promise.all([
8889
prisma.website.count({
8990
where: {
@@ -125,6 +126,11 @@ export async function getWorkspaceServiceCount(workspaceId: string) {
125126
workspaceId,
126127
},
127128
}),
129+
prisma.functionWorker.count({
130+
where: {
131+
workspaceId,
132+
},
133+
}),
128134
]);
129135

130136
return {
@@ -136,6 +142,7 @@ export async function getWorkspaceServiceCount(workspaceId: string) {
136142
survey,
137143
feed,
138144
aiGateway,
145+
functionWorker,
139146
};
140147
}
141148

src/server/trpc/routers/workspace.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ export const workspaceRouter = router({
521521
survey: z.number(),
522522
feed: z.number(),
523523
aiGateway: z.number(),
524+
functionWorker: z.number(),
524525
})
525526
)
526527
.query(async ({ input }) => {
@@ -540,6 +541,7 @@ export const workspaceRouter = router({
540541
survey,
541542
feed,
542543
aiGateway,
544+
functionWorker,
543545
} = serviceCount;
544546

545547
return {
@@ -552,6 +554,7 @@ export const workspaceRouter = router({
552554
survey,
553555
feed,
554556
aiGateway,
557+
functionWorker,
555558
};
556559
}),
557560
/**

0 commit comments

Comments
 (0)