Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphql.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ documents: '**/*.graphql'
extensions:
endpoints:
Default GraphQL Endpoint:
url: http://localhost:3098/graphql
url: http://localhost:80/graphql
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@apollo/client": "^4.0.9",
"@code0-tech/pictor": "^0.7.2",
"@code0-tech/triangulum": "^0.14.6",
"@code0-tech/triangulum": "^0.15.0",
"@codemirror/lang-javascript": "^6.2.5",
"@codemirror/lint": "^6.9.5",
"@opentelemetry/api": "^1.9.1",
Expand Down
4 changes: 2 additions & 2 deletions src/app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ import {GraphqlClient} from "@core/util/graphql-client";
import Image from "next/image";
import React from "react";
import {usePersistentReactiveArrayService} from "@/hooks/usePersistentReactiveArrayService";
import {UserView} from "@edition/user/services/User.view";
import {FullScreen} from "@code0-tech/pictor/dist/components/fullscreen/FullScreen";
import {useUserSession} from "@edition/user/hooks/User.session.hook";
import {OrganizationView} from "@edition/organization/services/Organization.view";
import {OrganizationService} from "@edition/organization/services/Organization.service";
import {User} from "@code0-tech/sagittarius-graphql-types";

export default function AuthLayout({children}: Readonly<{ children: React.ReactNode }>) {

const client = useApolloClient()
const currentSession = useUserSession()
const graphqlClient = React.useMemo(() => new GraphqlClient(client), [client])

const [store, service] = usePersistentReactiveArrayService<UserView, UserService>("auth-users", (store) => new UserService(graphqlClient, store))
const [store, service] = usePersistentReactiveArrayService<User, UserService>("auth-users", (store) => new UserService(graphqlClient, store))
const organization = usePersistentReactiveArrayService<OrganizationView, OrganizationService>(`dashboard::organizations::${currentSession?.id}`, (store) => new OrganizationService(graphqlClient, store))

return (
Expand Down
5 changes: 2 additions & 3 deletions src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ import {RoleService} from "@edition/role/services/Role.service";
import Image from "next/image";
import {Application, ApplicationService} from "@edition/application/services/Application.service";
import {useUserSession} from "@edition/user/hooks/User.session.hook";
import {UserView} from "@edition/user/services/User.view";
import {OrganizationView} from "@edition/organization/services/Organization.view";
import {MemberView} from "@edition/member/services/Member.view";
import {ProjectView} from "@edition/project/services/Project.view";
import {RoleView} from "@edition/role/services/Role.view";
import {Layout} from "@code0-tech/pictor/dist/components/layout/Layout";
import {Namespace, Runtime} from "@code0-tech/sagittarius-graphql-types";
import {Namespace, Runtime, User} from "@code0-tech/sagittarius-graphql-types";

interface ApplicationLayoutProps {
children: React.ReactNode
Expand All @@ -42,7 +41,7 @@ const ApplicationLayout: React.FC<ApplicationLayoutProps> = ({children, bar, tab

const graphqlClient = React.useMemo(() => new GraphqlClient(client), [client])

const user = usePersistentReactiveArrayService<UserView, UserService>(`dashboard::users::${currentSession?.id}`, (store) => new UserService(graphqlClient, store))
const user = usePersistentReactiveArrayService<User, UserService>(`dashboard::users::${currentSession?.id}`, (store) => new UserService(graphqlClient, store))
const organization = usePersistentReactiveArrayService<OrganizationView, OrganizationService>(`dashboard::organizations::${currentSession?.id}`, (store) => new OrganizationService(graphqlClient, store))
const member = usePersistentReactiveArrayService<MemberView, MemberService>(`dashboard::members::${currentSession?.id}`, (store) => new MemberService(graphqlClient, store))
const namespace = usePersistentReactiveArrayService<Namespace, NamespaceService>(`dashboard::namespaces::${currentSession?.id}`, (store) => new NamespaceService(graphqlClient, store))
Expand Down
5 changes: 2 additions & 3 deletions src/app/(flow)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FunctionDefinition,
Namespace,
NamespaceProject,
Runtime
Runtime, User
} from "@code0-tech/sagittarius-graphql-types";
import {usePersistentReactiveArrayService} from "@/hooks/usePersistentReactiveArrayService";
import {UserService} from "@edition/user/services/User.service";
Expand All @@ -27,7 +27,6 @@ import {FunctionService} from "@edition/function/services/Function.service";
import {DatatypeService} from "@edition/datatype/services/Datatype.service";
import {FlowTypeService} from "@edition/flowtype/services/FlowType.service";
import Image from "next/image";
import {UserView} from "@edition/user/services/User.view";
import {OrganizationView} from "@edition/organization/services/Organization.view";
import {MemberView} from "@edition/member/services/Member.view";
import {ProjectView} from "@edition/project/services/Project.view";
Expand Down Expand Up @@ -56,7 +55,7 @@ export default function FlowLayout({bar, tab, children}: {

if (currentSession === null) router.push("/login")

const user = usePersistentReactiveArrayService<UserView, UserService>(`dashboard::users::${currentSession?.id}`, (store) => new UserService(graphqlClient, store))
const user = usePersistentReactiveArrayService<User, UserService>(`dashboard::users::${currentSession?.id}`, (store) => new UserService(graphqlClient, store))
const organization = usePersistentReactiveArrayService<OrganizationView, OrganizationService>(`dashboard::organizations::${currentSession?.id}`, (store) => new OrganizationService(graphqlClient, store))
const member = usePersistentReactiveArrayService<MemberView, MemberService>(`dashboard::members::${currentSession?.id}`, (store) => new MemberService(graphqlClient, store))
const namespace = usePersistentReactiveArrayService<Namespace, NamespaceService>(`dashboard::namespaces::${currentSession?.id}`, (store) => new NamespaceService(graphqlClient, store))
Expand Down
5 changes: 2 additions & 3 deletions src/packages/ce/src/member/pages/MemberAddPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import React from "react";
import {Button, Col, Flex, Spacing, Text, useForm, useService, useStore} from "@code0-tech/pictor";
import {MemberService} from "@edition/member/services/Member.service";
import {useParams, useRouter} from "next/navigation";
import {Namespace} from "@code0-tech/sagittarius-graphql-types";
import {Namespace, User} from "@code0-tech/sagittarius-graphql-types";
import Link from "next/link";
import {UserService} from "@edition/user/services/User.service";
import {InputSyntaxSegment} from "@code0-tech/pictor/dist/components/form/Input.syntax.hook";
import {UserInputComponent} from "@edition/user/components/UserInputComponent";
import {UserView} from "@edition/user/services/User.view";

export const MemberAddPage: React.FC = () => {

Expand All @@ -27,7 +26,7 @@ export const MemberAddPage: React.FC = () => {
const members = React.useMemo(() => memberService.values({namespaceId: namespaceId}), [memberStore, userStore])
const formInitialValues = React.useMemo(() => ({users: null}), [])
const filteredUsers = React.useMemo(() => {
return (user: UserView) => {
return (user: User) => {
return !members.find(m => m.user?.id === user.id)
}
}, [members])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const UserDataTableComponent: React.FC<UserDataTableComponentProps> = (pr
</Text>
</DataTableColumn>}
onSelect={(item) => item && onSelect?.(item)}
data={users.map(u => u.json()).filter(preFilter)}>
data={users.filter(preFilter)}>
{(runtime, index) => {
return <UserDataTableRowComponent userId={runtime.id}/>
}}
Expand Down
4 changes: 2 additions & 2 deletions src/packages/ce/src/user/components/UserInputComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import {IconArrowDown, IconArrowUp, IconCornerDownLeft} from "@tabler/icons-react";
import {UserView} from "@edition/user/services/User.view";
import {
Badge,
Flex,
Expand All @@ -16,9 +15,10 @@ import {
useStore
} from "@code0-tech/pictor";
import {UserService} from "@edition/user/services/User.service";
import {User} from "@code0-tech/sagittarius-graphql-types";

export interface UserInputComponentProps extends TextInputProps {
filter?: (user: UserView, index: number) => boolean
filter?: (user: User, index: number) => boolean
}

export const UserInputComponent: React.FC<UserInputComponentProps> = (props) => {
Expand Down
23 changes: 11 additions & 12 deletions src/packages/ce/src/user/services/User.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,36 @@ import usersQuery from "./queries/Users.query.graphql";
import userByUsernameQuery from "./queries/User.byUsername.query.graphql";
import userByIdQuery from "./queries/User.byId.query.graphql";
import {View} from "@code0-tech/pictor/dist/utils/view";
import {UserView} from "@edition/user/services/User.view";

export class UserService extends ReactiveArrayService<UserView> {
export class UserService extends ReactiveArrayService<User> {

private readonly client: GraphqlClient
private i = 0;

constructor(client: GraphqlClient, store: ReactiveArrayStore<View<UserView>>) {
constructor(client: GraphqlClient, store: ReactiveArrayStore<View<User>>) {
super(store);
this.client = client
}

values(): UserView[] {
values(): User[] {
if (super.values().length > 0) return super.values();
this.client.query<Query>({
query: usersQuery
}).then(result => {
const data = result.data
if (!data) return

if (data && data.currentUser && !this.hasById(data.currentUser.id)) this.set(this.i++, new View(new UserView(data.currentUser)))
if (data && data.currentUser && !this.hasById(data.currentUser.id)) this.set(this.i++, new View(data.currentUser))
if (data.users && data.users.nodes) {
data.users.nodes.forEach((user) => {
if (user && !(user.id === data.currentUser?.id) && !this.hasById(user.id)) this.set(this.i++, new View(new UserView(user)))
if (user && !(user.id === data.currentUser?.id) && !this.hasById(user.id)) this.set(this.i++, new View(user))
})
}
})
return super.values();
}

getById(id: User["id"]): UserView | undefined {
getById(id: User["id"]): User | undefined {
const user = this.values().find(user => user && user.id === id)
if (user) return user

Expand All @@ -85,14 +84,14 @@ export class UserService extends ReactiveArrayService<UserView> {
const data = result.data
if (!data) return

if (data && data.user && !this.hasById(data.user.id)) this.set(this.i++, new View(new UserView(data.user)))
if (data && data.user && !this.hasById(data.user.id)) this.set(this.i++, new View(data.user))
})
}

return this.values().find(user => user && user.id === id)
}

getByUsername(username: User["username"]): UserView | undefined {
getByUsername(username: User["username"]): User | undefined {
if (this.values().find(user => user && user.username === username)) return this.values().find(user => user && user.username === username)

this.client.query<Query>({
Expand All @@ -104,7 +103,7 @@ export class UserService extends ReactiveArrayService<UserView> {
const data = result.data
if (!data) return

if (data && data.user && !this.hasById(data.user.id)) this.set(this.i++, new View(new UserView(data.user)))
if (data && data.user && !this.hasById(data.user.id)) this.set(this.i++, new View(data.user))
})

return this.values().find(user => user && user.username === username)
Expand Down Expand Up @@ -165,7 +164,7 @@ export class UserService extends ReactiveArrayService<UserView> {
})

if (result.data && result.data.usersLogin && result.data.usersLogin.userSession?.user && !this.hasById(result.data.usersLogin.userSession?.user.id)) {
this.add(new View(new UserView(result.data.usersLogin.userSession.user)))
this.add(new View(result.data.usersLogin.userSession.user))
}

return result.data?.usersLogin ?? undefined
Expand Down Expand Up @@ -233,7 +232,7 @@ export class UserService extends ReactiveArrayService<UserView> {
})

if (result.data && result.data.usersRegister && result.data.usersRegister.userSession?.user && !this.hasById(result.data.usersRegister.userSession?.user.id)) {
this.add(new View(new UserView(result.data.usersRegister.userSession.user)))
this.add(new View(result.data.usersRegister.userSession.user))
}

return result.data?.usersRegister ?? undefined
Expand Down
Loading