forked from Guepard-Corp/qwery-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.navigation.config.tsx
More file actions
80 lines (71 loc) · 2.31 KB
/
project.navigation.config.tsx
File metadata and controls
80 lines (71 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Database, Home, MessageCircle, Notebook } from 'lucide-react';
import { z } from 'zod';
import { NavigationConfigSchema } from '@qwery/ui/navigation-schema';
import pathsConfig, { createPath } from './paths.config';
const iconClasses = 'w-4';
const getRoutes = (slug: string | undefined) => {
if (!slug) {
return [
{
label: 'common:routes.project',
children: [],
},
] satisfies z.infer<typeof NavigationConfigSchema>['routes'];
}
return [
{
label: 'common:routes.project',
children: [
{
label: 'common:routes.projectDashboard',
path: createPath(pathsConfig.app.project, slug),
Icon: <Home className={iconClasses} />,
end: true,
},
{
label: 'common:routes.projectConversation',
path: createPath(pathsConfig.app.projectConversation, slug),
Icon: <MessageCircle className={iconClasses} />,
end: true,
},
{
label: 'common:routes.datasources',
path: createPath(pathsConfig.app.projectDatasources, slug),
Icon: <Database className={iconClasses} />,
end: true,
},
{
label: 'common:routes.notebook',
path: createPath(pathsConfig.app.projectNotebooks, slug),
Icon: <Notebook className={iconClasses} />,
end: true,
},
],
},
] satisfies z.infer<typeof NavigationConfigSchema>['routes'];
};
export function createNavigationConfig(slug: string | undefined) {
return NavigationConfigSchema.parse({
routes: getRoutes(slug),
});
}
export function createDatasourcePath(slug: string, name: string) {
return createPath(pathsConfig.app.newProjectDatasource, slug).replace(
'[name]',
name,
);
}
export function createDatasourceViewPath(slug: string) {
return createPath(pathsConfig.app.projectDatasourceView, slug);
}
/** Build path to a specific table: /ds/{slug}/tables/{schema}/{tableName} */
export function createDatasourceTableViewPath(
slug: string,
schema: string,
tableName: string,
) {
const base = createPath(pathsConfig.app.datasourceTables, slug);
const encodedSchema = encodeURIComponent(schema || 'main');
const encodedTableName = encodeURIComponent(tableName);
return `${base}/${encodedSchema}/${encodedTableName}`;
}