Skip to content

Commit 08f577d

Browse files
committed
feat: add TODOs for user abilities checks in various pages within namespace
1 parent b1fa563 commit 08f577d

File tree

10 files changed

+58
-10
lines changed

10 files changed

+58
-10
lines changed

src/packages/ce/src/dashboard/member/MemberAddPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export const MemberAddPage: React.FC = () => {
6262
}
6363
})
6464

65+
//TODO: user abilities for add user as member within namespace
66+
6567
return <Flex mih={"100%"} miw={"100%"} align={"center"} justify={"center"}>
6668
<Col xs={4}>
6769
<Text size={"xl"} hierarchy={"primary"} display={"block"}>

src/packages/ce/src/dashboard/member/MembersView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import React from "react";
44
import {useParams} from "next/navigation";
5-
import {Button, DNamespaceMemberList, Flex, Spacing, Text, TextInput, useService, useStore} from "@code0-tech/pictor";
6-
import {IconSearch} from "@tabler/icons-react";
5+
import {Button, DNamespaceMemberList, Flex, Spacing, Text, useService, useStore} from "@code0-tech/pictor";
76
import Link from "next/link";
87
import {MemberService} from "@edition/member/Member.service";
98

@@ -32,6 +31,8 @@ export const MembersView: React.FC = () => {
3231
}} namespaceId={`gid://sagittarius/Namespace/${namespaceId}`}/>
3332
}, [namespaceId, memberStore])
3433

34+
//TODO: user abilities for add user as member within namespace
35+
3536
return <>
3637

3738
<Flex align={"center"} justify={"space-between"}>

src/packages/ce/src/dashboard/namespace/NamespaceProjectsCreatePage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const NamespaceProjectsCreatePage: React.FC = () => {
1717
const namespaceIndex = params?.namespaceId as string
1818
const namespaceId: Namespace['id'] = `gid://sagittarius/Namespace/${namespaceIndex as unknown as number}`
1919

20+
//TODO: user abilities for project creation within namespace
21+
2022
const [inputs, validate] = useForm({
2123
initialValues: {
2224
name: null,

src/packages/ce/src/dashboard/namespace/NamespaceProjectsView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33

44
import React from "react";
5-
import {Button, DNamespaceProjectList, Flex, Spacing, Text, TextInput} from "@code0-tech/pictor";
6-
import {IconSearch} from "@tabler/icons-react";
5+
import {Button, DNamespaceProjectList, Flex, Spacing, Text} from "@code0-tech/pictor";
76
import Link from "next/link";
87
import {useParams} from "next/navigation";
98

@@ -16,6 +15,8 @@ export const NamespaceProjectsView: React.FC = () => {
1615
return <DNamespaceProjectList namespaceId={`gid://sagittarius/Namespace/${namespaceId}`}/>
1716
}, [namespaceId])
1817

18+
//TODO: user abilities for project creation within namespace
19+
1920
return <>
2021

2122
<Flex align={"center"} justify={"space-between"}>

src/packages/ce/src/dashboard/organization/OrganizationSettingsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {OrganizationGeneralSettingsView} from "@edition/dashboard/organization/O
2626

2727
export const OrganizationSettingsPage: React.FC = () => {
2828

29+
//TODO: add ability check for organization settings access for every settings tab
30+
2931
const params = useParams()
3032
const namespaceService = useService(NamespaceService)
3133
const namespaceStore = useStore(NamespaceService)

src/packages/ce/src/dashboard/role/RoleCreatePage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {Button, Col, Flex, Spacing, Text, TextInput} from "@code0-tech/pictor";
55
import Link from "next/link";
66

77
export const RoleCreatePage: React.FC = () => {
8+
9+
//TODO: user abilities for add role within namespace
10+
811
return <Flex mih={"100%"} miw={"100%"} align={"center"} justify={"center"}>
912
<Col xs={4}>
1013
<Text size={"xl"} hierarchy={"primary"} display={"block"}>

src/packages/ce/src/dashboard/role/RoleSettingsPage.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ const permissionTemplates: PermissionTemplate[] = [
180180

181181
export const RoleSettingsPage: React.FC = () => {
182182

183+
//TODO: limit tabs based on user abilities for roles
184+
//TODO: add general adjustments tab for role name update
185+
//TODO: delete role functionality as tab
186+
183187
const params = useParams()
184188
const roleService = useService(RoleService)
185189
const roleStore = useStore(RoleService)

src/packages/ce/src/dashboard/role/RolesView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export const RolesView: React.FC = () => {
1919
}} namespaceId={`gid://sagittarius/Namespace/${namespaceId}`}/>
2020
}, [namespaceId])
2121

22+
//TODO: user abilities for add role within namespace
23+
2224
return <>
2325

2426
<Flex align={"center"} justify={"space-between"}>

src/packages/ce/src/dashboard/runtime/RuntimeCreatePage.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,49 @@
11
"use client"
22

33
import React from "react";
4-
import {Button, Col, Flex, Spacing, Text, TextInput, toast, useForm, useService} from "@code0-tech/pictor";
4+
import {
5+
Button,
6+
Col,
7+
Flex,
8+
Spacing,
9+
Text,
10+
TextInput,
11+
toast,
12+
useForm,
13+
useService,
14+
useStore,
15+
useUserSession
16+
} from "@code0-tech/pictor";
517
import Link from "next/link";
6-
import {useParams, useRouter} from "next/navigation";
18+
import {notFound, useParams, useRouter} from "next/navigation";
719
import {RuntimeService} from "@edition/runtime/Runtime.service";
20+
import {UserService} from "@edition/user/User.service";
21+
import {NamespaceService} from "@edition/namespace/Namespace.service";
822

923
export const RuntimeCreatePage: React.FC = () => {
1024

1125
const params = useParams()
12-
const namespaceId = params.namespaceId as any as number
26+
const namespaceIndex = params.namespaceId as any as number
1327

1428
const runtimeService = useService(RuntimeService)
1529
const [, startTransition] = React.useTransition()
1630
const [token, setToken] = React.useState<string | null | undefined>(undefined)
1731
const router = useRouter()
32+
const currentSession = useUserSession()
33+
const userStore = useStore(UserService)
34+
const userService = useService(UserService)
35+
const namespaceService = useService(NamespaceService)
36+
const namespaceStore = useStore(NamespaceService)
37+
38+
const currentUser = React.useMemo(() => userService.getById(currentSession?.user?.id), [userStore, currentSession])
39+
const namespace = React.useMemo(() => namespaceService.getById(`gid://sagittarius/Namespace/${namespaceIndex}`), [namespaceStore, namespaceIndex])
40+
41+
if (!namespaceIndex && currentUser && !currentUser.admin) {
42+
notFound()
43+
}
44+
45+
//TODO: user abilities for runtime creation within namespace
46+
// if (namespace.)
1847

1948
const [inputs, validate] = useForm({
2049
initialValues: {
@@ -36,7 +65,7 @@ export const RuntimeCreatePage: React.FC = () => {
3665
runtimeService.runtimeCreate({
3766
name: values.name as unknown as string,
3867
description: values.description as unknown as string,
39-
...(namespaceId ? {namespaceId: `gid://sagittarius/Namespace/${namespaceId}`} : {})
68+
...(namespaceIndex ? {namespaceId: `gid://sagittarius/Namespace/${namespaceIndex}`} : {})
4069
}).then(payload => {
4170
if ((payload?.errors?.length ?? 0) <= 0) {
4271
if (payload?.runtime?.token) {
@@ -47,7 +76,7 @@ export const RuntimeCreatePage: React.FC = () => {
4776
color: "error",
4877
dismissible: true,
4978
})
50-
router.push(namespaceId ? `/namespace/${namespaceId}/runtimes` : "/runtimes")
79+
router.push(namespaceIndex ? `/namespace/${namespaceIndex}/runtimes` : "/runtimes")
5180
}
5281
}
5382
})
@@ -90,7 +119,7 @@ export const RuntimeCreatePage: React.FC = () => {
90119
</>
91120
)}
92121
<Flex style={{gap: "0.35rem"}} justify={"space-between"}>
93-
<Link href={namespaceId ? `/namespace/${namespaceId}/runtimes` : "/runtimes"}>
122+
<Link href={namespaceIndex ? `/namespace/${namespaceIndex}/runtimes` : "/runtimes"}>
94123
<Button color={"primary"}>
95124
Go back to runtimes
96125
</Button>

src/packages/ce/src/dashboard/runtime/RuntimeSettingsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import CardSection from "@code0-tech/pictor/dist/components/card/CardSection";
2121

2222
export const RuntimeSettingsPage: React.FC = () => {
2323

24+
//TODO: add ability check for runtime settings access for every settings tab
25+
2426
const params = useParams()
2527
const namespaceId = params.namespaceId as any as number
2628
const runtimeId = params.runtimeId as any as number

0 commit comments

Comments
 (0)