From 92a6127e8408efe4d85575f300013c014e969412 Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 03:31:10 +0530 Subject: [PATCH 01/25] - workspace update name - workspace read team members --- .../components/GeneralSettings.tsx | 44 ++++++++--- .../components/MembersSettings.tsx | 11 +-- ui/src/lib/gql/__gen__/gql.ts | 4 +- ui/src/lib/gql/__gen__/graphql.ts | 47 ++++++++++-- .../gql/__gen__/plugins/graphql-request.ts | 76 +++++++++++++++++-- ui/src/lib/gql/workspace/queries.graphql | 33 ++++++++ ui/src/lib/gql/workspace/useApi.ts | 40 +++++++--- ui/src/lib/gql/workspace/useQueries.ts | 52 +++++++++---- ui/src/types/member.ts | 4 +- ui/src/types/workspace.ts | 12 ++- 10 files changed, 262 insertions(+), 61 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx index 1c3a90c2b..fef819b54 100644 --- a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx @@ -6,25 +6,41 @@ import { useWorkspace } from "@flow/lib/gql"; import { useT } from "@flow/lib/i18n"; import { useCurrentWorkspace } from "@flow/stores"; +type Errors = "delete" | "update"; + const GeneralSettings: React.FC = () => { const t = useT(); const [currentWorkspace] = useCurrentWorkspace(); - const { deleteWorkspace } = useWorkspace(); + const { deleteWorkspace, updateWorkspace } = useWorkspace(); const navigate = useNavigate(); - const [showError, setShowError] = useState(false); + const [showError, setShowError] = useState(undefined); + const [workspaceName, setWorkspaceName] = useState(currentWorkspace?.name); + const [loading, setLoading] = useState(false); const handleDeleteWorkspace = async () => { - setShowError(false); + setLoading(true); + setShowError(undefined); if (!currentWorkspace) return; - // TODO: this trigger a pop up for confirming + // TODO: this should trigger a pop up for confirming const { workspaceId } = await deleteWorkspace(currentWorkspace.id); if (!workspaceId) { - setShowError(true); + setShowError("delete"); return; } navigate({ to: "/workspace" }); }; + + const handleUpdateWorkspace = async () => { + setLoading(true); + setShowError(undefined); + if (!currentWorkspace?.id || !workspaceName) return; + const { workspace } = await updateWorkspace(currentWorkspace?.id, workspaceName); + setLoading(false); + if (!workspace) { + setShowError("update"); + } + }; return (

{t("General Settings")}

@@ -34,9 +50,9 @@ const GeneralSettings: React.FC = () => { setWorkspaceName(e.target.value)} />
{/*
@@ -47,16 +63,22 @@ const GeneralSettings: React.FC = () => { defaultValue={currentWorkspace?.description} />
*/} - +
- {t("Failed to delete workspace")} + {showError === "delete" && t("Failed to delete Workspace")} + {showError === "update" && t("Failed to update Workspace")}
diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 204cf66ef..68df0e610 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -15,7 +15,7 @@ import { Role, UserMember } from "@flow/types"; type Filter = "all" | Role; -const roles = ["admin", "reader", "writer"]; +const roles: Role[] = ["MAINTAINER", "OWNER", "READER", "WRITER"]; const MembersSettings: React.FC = () => { const t = useT(); @@ -25,9 +25,10 @@ const MembersSettings: React.FC = () => { const filters: { id: Filter; title: string }[] = [ { id: "all", title: t("All") }, - { id: "admin", title: t("Admin") }, - { id: "reader", title: t("Reader") }, - { id: "writer", title: t("Writer") }, + { id: "OWNER", title: t("Owner") }, + { id: "READER", title: t("Reader") }, + { id: "MAINTAINER", title: t("Maintainer") }, + { id: "WRITER", title: t("Writer") }, ]; const members = @@ -118,7 +119,7 @@ const MembersSettings: React.FC = () => { ) } /> -

{member.user.name}

+

{member.user?.name}

{member.role}

))} diff --git a/ui/src/lib/gql/__gen__/gql.ts b/ui/src/lib/gql/__gen__/gql.ts index 645f1b79e..183df8868 100644 --- a/ui/src/lib/gql/__gen__/gql.ts +++ b/ui/src/lib/gql/__gen__/gql.ts @@ -15,7 +15,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ const documents = { "fragment Project on Project {\n id\n name\n description\n createdAt\n updatedAt\n workspaceId\n}\n\nmutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n project {\n ...Project\n }\n }\n}\n\nquery GetProjects($workspaceId: ID!, $first: Int!) {\n projects(workspaceId: $workspaceId, first: $first) {\n totalCount\n nodes {\n ...Project\n }\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n }\n}\n\nquery GetProjectById($projectId: ID!) {\n node(id: $projectId, type: PROJECT) {\n __typename\n ...Project\n }\n}\n\nmutation UpdateProject($input: UpdateProjectInput!) {\n updateProject(input: $input) {\n project {\n ...Project\n }\n }\n}\n\nmutation DeleteProject($input: DeleteProjectInput!) {\n deleteProject(input: $input) {\n projectId\n }\n}": types.ProjectFragmentDoc, "query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}": types.GetMeDocument, - "fragment Workspace on Workspace {\n id\n name\n personal\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}": types.WorkspaceFragmentDoc, + "fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}": types.WorkspaceFragmentDoc, }; /** @@ -43,7 +43,7 @@ export function graphql(source: "query GetMe {\n me {\n id\n name\n em /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "fragment Workspace on Workspace {\n id\n name\n personal\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}"): (typeof documents)["fragment Workspace on Workspace {\n id\n name\n personal\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}"]; +export function graphql(source: "fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}"): (typeof documents)["fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/ui/src/lib/gql/__gen__/graphql.ts b/ui/src/lib/gql/__gen__/graphql.ts index f4abcbec3..da5205742 100644 --- a/ui/src/lib/gql/__gen__/graphql.ts +++ b/ui/src/lib/gql/__gen__/graphql.ts @@ -511,7 +511,7 @@ export type GetMeQueryVariables = Exact<{ [key: string]: never; }>; export type GetMeQuery = { __typename?: 'Query', me?: { __typename?: 'Me', id: string, name: string, email: string, myWorkspaceId: string } | null }; -export type WorkspaceFragment = { __typename?: 'Workspace', id: string, name: string, personal: boolean } & { ' $fragmentName'?: 'WorkspaceFragment' }; +export type WorkspaceFragment = { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } & { ' $fragmentName'?: 'WorkspaceFragment' }; export type CreateWorkspaceMutationVariables = Exact<{ input: CreateWorkspaceInput; @@ -558,16 +558,49 @@ export type DeleteWorkspaceMutationVariables = Exact<{ export type DeleteWorkspaceMutation = { __typename?: 'Mutation', deleteWorkspace?: { __typename?: 'DeleteWorkspacePayload', workspaceId: string } | null }; +export type AddMemberToWorkspaceMutationVariables = Exact<{ + input: AddMemberToWorkspaceInput; +}>; + + +export type AddMemberToWorkspaceMutation = { __typename?: 'Mutation', addMemberToWorkspace?: { __typename?: 'AddMemberToWorkspacePayload', workspace: ( + { __typename?: 'Workspace' } + & { ' $fragmentRefs'?: { 'WorkspaceFragment': WorkspaceFragment } } + ) } | null }; + +export type RemoveMemberToWorkspaceMutationVariables = Exact<{ + input: RemoveMemberFromWorkspaceInput; +}>; + + +export type RemoveMemberToWorkspaceMutation = { __typename?: 'Mutation', removeMemberFromWorkspace?: { __typename?: 'RemoveMemberFromWorkspacePayload', workspace: ( + { __typename?: 'Workspace' } + & { ' $fragmentRefs'?: { 'WorkspaceFragment': WorkspaceFragment } } + ) } | null }; + +export type UpdateMemberToWorkspaceMutationVariables = Exact<{ + input: UpdateMemberOfWorkspaceInput; +}>; + + +export type UpdateMemberToWorkspaceMutation = { __typename?: 'Mutation', updateMemberOfWorkspace?: { __typename?: 'UpdateMemberOfWorkspacePayload', workspace: ( + { __typename?: 'Workspace' } + & { ' $fragmentRefs'?: { 'WorkspaceFragment': WorkspaceFragment } } + ) } | null }; + export const ProjectFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Project"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]} as unknown as DocumentNode; -export const WorkspaceFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}}]}}]} as unknown as DocumentNode; +export const WorkspaceFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; export const CreateProjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateProject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateProjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createProject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"project"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Project"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Project"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]} as unknown as DocumentNode; export const GetProjectsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProjects"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"first"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"projects"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"workspaceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"first"},"value":{"kind":"Variable","name":{"kind":"Name","value":"first"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"totalCount"}},{"kind":"Field","name":{"kind":"Name","value":"nodes"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Project"}}]}},{"kind":"Field","name":{"kind":"Name","value":"pageInfo"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"startCursor"}},{"kind":"Field","name":{"kind":"Name","value":"endCursor"}},{"kind":"Field","name":{"kind":"Name","value":"hasNextPage"}},{"kind":"Field","name":{"kind":"Name","value":"hasPreviousPage"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Project"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]} as unknown as DocumentNode; export const GetProjectByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetProjectById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"projectId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"projectId"}}},{"kind":"Argument","name":{"kind":"Name","value":"type"},"value":{"kind":"EnumValue","value":"PROJECT"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"Project"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Project"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]} as unknown as DocumentNode; export const UpdateProjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateProject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateProjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateProject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"project"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Project"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Project"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]} as unknown as DocumentNode; export const DeleteProjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteProject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteProjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteProject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"projectId"}}]}}]}}]} as unknown as DocumentNode; export const GetMeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetMe"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"myWorkspaceId"}}]}}]}}]} as unknown as DocumentNode; -export const CreateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}}]}}]} as unknown as DocumentNode; -export const GetWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}}]}}]} as unknown as DocumentNode; -export const GetWorkspaceByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaceById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"type"},"value":{"kind":"EnumValue","value":"WORKSPACE"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}}]}}]} as unknown as DocumentNode; -export const UpdateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}}]}}]} as unknown as DocumentNode; -export const DeleteWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file +export const CreateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const GetWorkspaceByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaceById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"type"},"value":{"kind":"EnumValue","value":"WORKSPACE"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const UpdateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const DeleteWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]}}]} as unknown as DocumentNode; +export const AddMemberToWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AddMemberToWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"AddMemberToWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addMemberToWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const RemoveMemberToWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RemoveMemberToWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RemoveMemberFromWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"removeMemberFromWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const UpdateMemberToWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateMemberToWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateMemberOfWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateMemberOfWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/ui/src/lib/gql/__gen__/plugins/graphql-request.ts b/ui/src/lib/gql/__gen__/plugins/graphql-request.ts index e2c0ddac0..5f168e3f2 100644 --- a/ui/src/lib/gql/__gen__/plugins/graphql-request.ts +++ b/ui/src/lib/gql/__gen__/plugins/graphql-request.ts @@ -500,33 +500,33 @@ export type GetMeQueryVariables = Exact<{ [key: string]: never; }>; export type GetMeQuery = { __typename?: 'Query', me?: { __typename?: 'Me', id: string, name: string, email: string, myWorkspaceId: string } | null }; -export type WorkspaceFragment = { __typename?: 'Workspace', id: string, name: string, personal: boolean }; +export type WorkspaceFragment = { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> }; export type CreateWorkspaceMutationVariables = Exact<{ input: CreateWorkspaceInput; }>; -export type CreateWorkspaceMutation = { __typename?: 'Mutation', createWorkspace?: { __typename?: 'CreateWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean } } | null }; +export type CreateWorkspaceMutation = { __typename?: 'Mutation', createWorkspace?: { __typename?: 'CreateWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; export type GetWorkspacesQueryVariables = Exact<{ [key: string]: never; }>; -export type GetWorkspacesQuery = { __typename?: 'Query', me?: { __typename?: 'Me', workspaces: Array<{ __typename?: 'Workspace', id: string, name: string, personal: boolean }> } | null }; +export type GetWorkspacesQuery = { __typename?: 'Query', me?: { __typename?: 'Me', workspaces: Array<{ __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> }> } | null }; export type GetWorkspaceByIdQueryVariables = Exact<{ workspaceId: Scalars['ID']['input']; }>; -export type GetWorkspaceByIdQuery = { __typename?: 'Query', node?: { __typename: 'Asset' } | { __typename: 'Project' } | { __typename: 'User' } | { __typename: 'Workspace', id: string, name: string, personal: boolean } | null }; +export type GetWorkspaceByIdQuery = { __typename?: 'Query', node?: { __typename: 'Asset' } | { __typename: 'Project' } | { __typename: 'User' } | { __typename: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } | null }; export type UpdateWorkspaceMutationVariables = Exact<{ input: UpdateWorkspaceInput; }>; -export type UpdateWorkspaceMutation = { __typename?: 'Mutation', updateWorkspace?: { __typename?: 'UpdateWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean } } | null }; +export type UpdateWorkspaceMutation = { __typename?: 'Mutation', updateWorkspace?: { __typename?: 'UpdateWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; export type DeleteWorkspaceMutationVariables = Exact<{ input: DeleteWorkspaceInput; @@ -535,6 +535,27 @@ export type DeleteWorkspaceMutationVariables = Exact<{ export type DeleteWorkspaceMutation = { __typename?: 'Mutation', deleteWorkspace?: { __typename?: 'DeleteWorkspacePayload', workspaceId: string } | null }; +export type AddMemberToWorkspaceMutationVariables = Exact<{ + input: AddMemberToWorkspaceInput; +}>; + + +export type AddMemberToWorkspaceMutation = { __typename?: 'Mutation', addMemberToWorkspace?: { __typename?: 'AddMemberToWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; + +export type RemoveMemberToWorkspaceMutationVariables = Exact<{ + input: RemoveMemberFromWorkspaceInput; +}>; + + +export type RemoveMemberToWorkspaceMutation = { __typename?: 'Mutation', removeMemberFromWorkspace?: { __typename?: 'RemoveMemberFromWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; + +export type UpdateMemberToWorkspaceMutationVariables = Exact<{ + input: UpdateMemberOfWorkspaceInput; +}>; + + +export type UpdateMemberToWorkspaceMutation = { __typename?: 'Mutation', updateMemberOfWorkspace?: { __typename?: 'UpdateMemberOfWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; + export const ProjectFragmentDoc = gql` fragment Project on Project { id @@ -550,6 +571,15 @@ export const WorkspaceFragmentDoc = gql` id name personal + members { + userId + role + user { + id + email + name + } + } } `; export const CreateProjectDocument = gql` @@ -653,6 +683,33 @@ export const DeleteWorkspaceDocument = gql` } } `; +export const AddMemberToWorkspaceDocument = gql` + mutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) { + addMemberToWorkspace(input: $input) { + workspace { + ...Workspace + } + } +} + ${WorkspaceFragmentDoc}`; +export const RemoveMemberToWorkspaceDocument = gql` + mutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) { + removeMemberFromWorkspace(input: $input) { + workspace { + ...Workspace + } + } +} + ${WorkspaceFragmentDoc}`; +export const UpdateMemberToWorkspaceDocument = gql` + mutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) { + updateMemberOfWorkspace(input: $input) { + workspace { + ...Workspace + } + } +} + ${WorkspaceFragmentDoc}`; export type SdkFunctionWrapper = (action: (requestHeaders?:Record) => Promise, operationName: string, operationType?: string, variables?: any) => Promise; @@ -693,6 +750,15 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = }, DeleteWorkspace(variables: DeleteWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { return withWrapper((wrappedRequestHeaders) => client.request(DeleteWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'DeleteWorkspace', 'mutation', variables); + }, + AddMemberToWorkspace(variables: AddMemberToWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { + return withWrapper((wrappedRequestHeaders) => client.request(AddMemberToWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'AddMemberToWorkspace', 'mutation', variables); + }, + RemoveMemberToWorkspace(variables: RemoveMemberToWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { + return withWrapper((wrappedRequestHeaders) => client.request(RemoveMemberToWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'RemoveMemberToWorkspace', 'mutation', variables); + }, + UpdateMemberToWorkspace(variables: UpdateMemberToWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { + return withWrapper((wrappedRequestHeaders) => client.request(UpdateMemberToWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'UpdateMemberToWorkspace', 'mutation', variables); } }; } diff --git a/ui/src/lib/gql/workspace/queries.graphql b/ui/src/lib/gql/workspace/queries.graphql index 76089dfd8..f44b518be 100644 --- a/ui/src/lib/gql/workspace/queries.graphql +++ b/ui/src/lib/gql/workspace/queries.graphql @@ -2,6 +2,15 @@ fragment Workspace on Workspace { id name personal + members { + userId + role + user { + id + email + name + } + } } mutation CreateWorkspace($input: CreateWorkspaceInput!) { @@ -41,3 +50,27 @@ mutation DeleteWorkspace($input: DeleteWorkspaceInput!) { workspaceId } } + +mutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) { + addMemberToWorkspace(input: $input) { + workspace { + ...Workspace + } + } +} + +mutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) { + removeMemberFromWorkspace(input: $input) { + workspace { + ...Workspace + } + } +} + +mutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) { + updateMemberOfWorkspace(input: $input) { + workspace { + ...Workspace + } + } +} diff --git a/ui/src/lib/gql/workspace/useApi.ts b/ui/src/lib/gql/workspace/useApi.ts index 496624784..3abec48ee 100644 --- a/ui/src/lib/gql/workspace/useApi.ts +++ b/ui/src/lib/gql/workspace/useApi.ts @@ -1,4 +1,10 @@ -import { GetWorkspaces, CreateWorkspace, DeleteWorkspace, GetWorkspace } from "@flow/types"; +import { + GetWorkspaces, + CreateWorkspace, + DeleteWorkspace, + GetWorkspace, + UpdateWorkspace, +} from "@flow/types"; import { useQueries } from "./useQueries"; @@ -13,6 +19,7 @@ export const useWorkspace = () => { useGetWorkspacesQuery, deleteWorkspaceMutation, useGetWorkspaceByIdQuery, + updateWorkspaceMutation, } = useQueries(); const createWorkspace = async (name: string): Promise => { @@ -25,16 +32,6 @@ export const useWorkspace = () => { } }; - const deleteWorkspace = async (workspaceId: string): Promise => { - const { mutateAsync, ...rest } = deleteWorkspaceMutation; - try { - const data = await mutateAsync(workspaceId); - return { workspaceId: data, ...rest }; - } catch (err) { - return { workspaceId: undefined, ...rest }; - } - }; - const useGetWorkspaces = (): GetWorkspaces => { const { data: workspaces, ...rest } = useGetWorkspacesQuery(); return { @@ -51,10 +48,31 @@ export const useWorkspace = () => { }; }; + const updateWorkspace = async (workspaceId: string, name: string): Promise => { + const { mutateAsync, ...rest } = updateWorkspaceMutation; + try { + const data = await mutateAsync({ workspaceId, name }); + return { workspace: data, ...rest }; + } catch (err) { + return { workspace: undefined, ...rest }; + } + }; + + const deleteWorkspace = async (workspaceId: string): Promise => { + const { mutateAsync, ...rest } = deleteWorkspaceMutation; + try { + const data = await mutateAsync(workspaceId); + return { workspaceId: data, ...rest }; + } catch (err) { + return { workspaceId: undefined, ...rest }; + } + }; + return { createWorkspace, useGetWorkspaces, useGetWorkspace, deleteWorkspace, + updateWorkspace, }; }; diff --git a/ui/src/lib/gql/workspace/useQueries.ts b/ui/src/lib/gql/workspace/useQueries.ts index 6d12a404c..77693dab7 100644 --- a/ui/src/lib/gql/workspace/useQueries.ts +++ b/ui/src/lib/gql/workspace/useQueries.ts @@ -2,9 +2,9 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useCallback } from "react"; import { useGraphQLContext } from "@flow/lib/gql"; -import { Workspace } from "@flow/types"; +import { Member, Workspace } from "@flow/types"; -import { WorkspaceFragment } from "../__gen__/graphql"; +import { UpdateWorkspaceInput, WorkspaceFragment } from "../__gen__/graphql"; import { WorkspaceQueryKeys } from "./useApi"; @@ -18,6 +18,19 @@ export const useQueries = () => { id: w.id, name: w.name, personal: w.personal, + members: w.members.map( + (m): Member => ({ + userId: m.userId, + role: m.role, + user: m.user + ? { + id: m.user?.id, + name: m.user?.name, + email: m.user?.email, + } + : undefined, + }), + ), }), [], ); @@ -30,11 +43,10 @@ export const useQueries = () => { createNewWorkspaceObject(data?.createWorkspace?.workspace) ); }, - onSuccess: createdWorkspace => { - queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => [ - ...data, - createdWorkspace, - ]); + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [WorkspaceQueryKeys.GetWorkspaces], + }); }, }); @@ -55,18 +67,29 @@ export const useQueries = () => { staleTime: Infinity, }); + const updateWorkspaceMutation = useMutation({ + mutationFn: async (input: UpdateWorkspaceInput) => { + const data = await graphQLContext?.UpdateWorkspace({ input }); + return ( + data?.updateWorkspace?.workspace && + createNewWorkspaceObject(data?.updateWorkspace?.workspace) + ); + }, + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [WorkspaceQueryKeys.GetWorkspaces], + }); + }, + }); + const deleteWorkspaceMutation = useMutation({ mutationFn: async (workspaceId: string) => { const data = await graphQLContext?.DeleteWorkspace({ input: { workspaceId } }); return data?.deleteWorkspace?.workspaceId; }, - onSuccess: deletedWorkspaceId => { - queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => { - data.splice( - data.findIndex(w => w.id === deletedWorkspaceId), - 1, - ); - return [...data]; + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [WorkspaceQueryKeys.GetWorkspaces], }); }, }); @@ -76,5 +99,6 @@ export const useQueries = () => { useGetWorkspacesQuery, useGetWorkspaceByIdQuery, deleteWorkspaceMutation, + updateWorkspaceMutation, }; }; diff --git a/ui/src/types/member.ts b/ui/src/types/member.ts index c8b8ffe82..eddeb9d86 100644 --- a/ui/src/types/member.ts +++ b/ui/src/types/member.ts @@ -1,12 +1,12 @@ import { IntegrationMember } from "./integration"; import { User } from "./user"; -export type Role = "reader" | "writer" | "admin"; +export type Role = "MAINTAINER" | "OWNER" | "READER" | "WRITER"; export type UserMember = { userId: string; role: Role; - user: User; + user?: User; }; export type Member = UserMember | IntegrationMember; diff --git a/ui/src/types/workspace.ts b/ui/src/types/workspace.ts index 5a71a31c2..2d228b249 100644 --- a/ui/src/types/workspace.ts +++ b/ui/src/types/workspace.ts @@ -4,16 +4,20 @@ export type Workspace = { id: string; name: string; personal: boolean; - members?: Member[]; + members: Member[]; projects?: Project[]; }; export type CreateWorkspace = { - workspace: Workspace | undefined; + workspace?: Workspace; +} & ApiResponse; + +export type UpdateWorkspace = { + workspace?: Workspace; } & ApiResponse; export type GetWorkspaces = { - workspaces: Workspace[] | undefined; + workspaces?: Workspace[]; isLoading: boolean; } & ApiResponse; @@ -23,5 +27,5 @@ export type GetWorkspace = { } & ApiResponse; export type DeleteWorkspace = { - workspaceId: string | undefined; + workspaceId?: string; } & ApiResponse; From 287fcb56ec7696e1b961e51b2b2e3a35f6341cae Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:50:33 +0530 Subject: [PATCH 02/25] - setCurrentWorkspace to update in navigation --- .../WorkspaceSettings/components/GeneralSettings.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx index fef819b54..3a68fa0a7 100644 --- a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx @@ -10,7 +10,7 @@ type Errors = "delete" | "update"; const GeneralSettings: React.FC = () => { const t = useT(); - const [currentWorkspace] = useCurrentWorkspace(); + const [currentWorkspace, setCurrentWorkspace] = useCurrentWorkspace(); const { deleteWorkspace, updateWorkspace } = useWorkspace(); const navigate = useNavigate(); const [showError, setShowError] = useState(undefined); @@ -39,7 +39,10 @@ const GeneralSettings: React.FC = () => { setLoading(false); if (!workspace) { setShowError("update"); + return; } + // TODO: Not sure if this is correct to set here + setCurrentWorkspace(workspace); }; return (
From 029e57c5b06c51d495744a800f6f919fdf43046d Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:53:21 +0530 Subject: [PATCH 03/25] - role type fix --- .../components/IntegrationsSettings.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx b/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx index 97d2be95b..97cc6d763 100644 --- a/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx @@ -16,7 +16,7 @@ import { IntegrationMember } from "@flow/types/integration"; type Filter = "all" | Role; -const roles = ["admin", "reader", "writer"]; +const roles: Role[] = ["OWNER", "MAINTAINER", "READER", "WRITER"]; const IntegrationsSettings: React.FC = () => { const t = useT(); @@ -26,9 +26,10 @@ const IntegrationsSettings: React.FC = () => { const filters: { id: Filter; title: string }[] = [ { id: "all", title: t("All") }, - { id: "admin", title: t("Admin") }, - { id: "reader", title: t("Reader") }, - { id: "writer", title: t("Writer") }, + { id: "OWNER", title: t("Owner") }, + { id: "READER", title: t("Reader") }, + { id: "MAINTAINER", title: t("Maintainer") }, + { id: "WRITER", title: t("Writer") }, ]; const integrations: IntegrationMember[] = From d80e5a849397024a0efdfb315bc33834aa873bcc Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:46:57 +0530 Subject: [PATCH 04/25] - typescript errors --- .../features/WorkspaceSettings/components/MembersSettings.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 68df0e610..10b36da21 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -8,6 +8,7 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, + Input, } from "@flow/components"; import { useT } from "@flow/lib/i18n"; import { useCurrentWorkspace } from "@flow/stores"; @@ -43,6 +44,9 @@ const MembersSettings: React.FC = () => {

{t("Members Settings")}

+
+
+
From b810efd55e837209c3171dd83e754cc1b23baf10 Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:20:15 +0530 Subject: [PATCH 05/25] - Minor changes to type - Add methods for members Crud on workspace --- ui/src/lib/gql/__gen__/gql.ts | 8 +- ui/src/lib/gql/__gen__/graphql.ts | 20 +++- .../gql/__gen__/plugins/graphql-request.ts | 43 +++++-- ui/src/lib/gql/workspace/queries.graphql | 4 +- ui/src/lib/gql/workspace/useApi.ts | 60 ++++++++-- ui/src/lib/gql/workspace/useQueries.ts | 106 +++++++++++++----- ui/src/types/workspace.ts | 5 +- 7 files changed, 181 insertions(+), 65 deletions(-) diff --git a/ui/src/lib/gql/__gen__/gql.ts b/ui/src/lib/gql/__gen__/gql.ts index 183df8868..2be40b08f 100644 --- a/ui/src/lib/gql/__gen__/gql.ts +++ b/ui/src/lib/gql/__gen__/gql.ts @@ -14,8 +14,8 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ */ const documents = { "fragment Project on Project {\n id\n name\n description\n createdAt\n updatedAt\n workspaceId\n}\n\nmutation CreateProject($input: CreateProjectInput!) {\n createProject(input: $input) {\n project {\n ...Project\n }\n }\n}\n\nquery GetProjects($workspaceId: ID!, $first: Int!) {\n projects(workspaceId: $workspaceId, first: $first) {\n totalCount\n nodes {\n ...Project\n }\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n }\n}\n\nquery GetProjectById($projectId: ID!) {\n node(id: $projectId, type: PROJECT) {\n __typename\n ...Project\n }\n}\n\nmutation UpdateProject($input: UpdateProjectInput!) {\n updateProject(input: $input) {\n project {\n ...Project\n }\n }\n}\n\nmutation DeleteProject($input: DeleteProjectInput!) {\n deleteProject(input: $input) {\n projectId\n }\n}": types.ProjectFragmentDoc, - "query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}": types.GetMeDocument, - "fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}": types.WorkspaceFragmentDoc, + "query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}\n\nquery SearchUser($email: String!) {\n searchUser(nameOrEmail: $email) {\n id\n name\n email\n }\n}": types.GetMeDocument, + "fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberFromWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberOfWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}": types.WorkspaceFragmentDoc, }; /** @@ -39,11 +39,11 @@ export function graphql(source: "fragment Project on Project {\n id\n name\n /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}"): (typeof documents)["query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}"]; +export function graphql(source: "query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}\n\nquery SearchUser($email: String!) {\n searchUser(nameOrEmail: $email) {\n id\n name\n email\n }\n}"): (typeof documents)["query GetMe {\n me {\n id\n name\n email\n myWorkspaceId\n }\n}\n\nquery SearchUser($email: String!) {\n searchUser(nameOrEmail: $email) {\n id\n name\n email\n }\n}"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}"): (typeof documents)["fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}"]; +export function graphql(source: "fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberFromWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberOfWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}"): (typeof documents)["fragment Workspace on Workspace {\n id\n name\n personal\n members {\n userId\n role\n user {\n id\n email\n name\n }\n }\n}\n\nmutation CreateWorkspace($input: CreateWorkspaceInput!) {\n createWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaces {\n me {\n workspaces {\n ...Workspace\n }\n }\n}\n\nquery GetWorkspaceById($workspaceId: ID!) {\n node(id: $workspaceId, type: WORKSPACE) {\n __typename\n ...Workspace\n }\n}\n\nmutation UpdateWorkspace($input: UpdateWorkspaceInput!) {\n updateWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation DeleteWorkspace($input: DeleteWorkspaceInput!) {\n deleteWorkspace(input: $input) {\n workspaceId\n }\n}\n\nmutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) {\n addMemberToWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation RemoveMemberFromWorkspace($input: RemoveMemberFromWorkspaceInput!) {\n removeMemberFromWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}\n\nmutation UpdateMemberOfWorkspace($input: UpdateMemberOfWorkspaceInput!) {\n updateMemberOfWorkspace(input: $input) {\n workspace {\n ...Workspace\n }\n }\n}"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/ui/src/lib/gql/__gen__/graphql.ts b/ui/src/lib/gql/__gen__/graphql.ts index da5205742..fae66f2c9 100644 --- a/ui/src/lib/gql/__gen__/graphql.ts +++ b/ui/src/lib/gql/__gen__/graphql.ts @@ -511,6 +511,13 @@ export type GetMeQueryVariables = Exact<{ [key: string]: never; }>; export type GetMeQuery = { __typename?: 'Query', me?: { __typename?: 'Me', id: string, name: string, email: string, myWorkspaceId: string } | null }; +export type SearchUserQueryVariables = Exact<{ + email: Scalars['String']['input']; +}>; + + +export type SearchUserQuery = { __typename?: 'Query', searchUser?: { __typename?: 'User', id: string, name: string, email: string } | null }; + export type WorkspaceFragment = { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } & { ' $fragmentName'?: 'WorkspaceFragment' }; export type CreateWorkspaceMutationVariables = Exact<{ @@ -568,22 +575,22 @@ export type AddMemberToWorkspaceMutation = { __typename?: 'Mutation', addMemberT & { ' $fragmentRefs'?: { 'WorkspaceFragment': WorkspaceFragment } } ) } | null }; -export type RemoveMemberToWorkspaceMutationVariables = Exact<{ +export type RemoveMemberFromWorkspaceMutationVariables = Exact<{ input: RemoveMemberFromWorkspaceInput; }>; -export type RemoveMemberToWorkspaceMutation = { __typename?: 'Mutation', removeMemberFromWorkspace?: { __typename?: 'RemoveMemberFromWorkspacePayload', workspace: ( +export type RemoveMemberFromWorkspaceMutation = { __typename?: 'Mutation', removeMemberFromWorkspace?: { __typename?: 'RemoveMemberFromWorkspacePayload', workspace: ( { __typename?: 'Workspace' } & { ' $fragmentRefs'?: { 'WorkspaceFragment': WorkspaceFragment } } ) } | null }; -export type UpdateMemberToWorkspaceMutationVariables = Exact<{ +export type UpdateMemberOfWorkspaceMutationVariables = Exact<{ input: UpdateMemberOfWorkspaceInput; }>; -export type UpdateMemberToWorkspaceMutation = { __typename?: 'Mutation', updateMemberOfWorkspace?: { __typename?: 'UpdateMemberOfWorkspacePayload', workspace: ( +export type UpdateMemberOfWorkspaceMutation = { __typename?: 'Mutation', updateMemberOfWorkspace?: { __typename?: 'UpdateMemberOfWorkspacePayload', workspace: ( { __typename?: 'Workspace' } & { ' $fragmentRefs'?: { 'WorkspaceFragment': WorkspaceFragment } } ) } | null }; @@ -596,11 +603,12 @@ export const GetProjectByIdDocument = {"kind":"Document","definitions":[{"kind": export const UpdateProjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateProject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateProjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateProject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"project"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Project"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Project"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Project"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]} as unknown as DocumentNode; export const DeleteProjectDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteProject"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteProjectInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteProject"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"projectId"}}]}}]}}]} as unknown as DocumentNode; export const GetMeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetMe"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"myWorkspaceId"}}]}}]}}]} as unknown as DocumentNode; +export const SearchUserDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"SearchUser"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"searchUser"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"nameOrEmail"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}}]}}]}}]} as unknown as DocumentNode; export const CreateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetWorkspacesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"me"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaces"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; export const GetWorkspaceByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetWorkspaceById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"node"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"workspaceId"}}},{"kind":"Argument","name":{"kind":"Name","value":"type"},"value":{"kind":"EnumValue","value":"WORKSPACE"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"__typename"}},{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; export const UpdateWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; export const DeleteWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DeleteWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspaceId"}}]}}]}}]} as unknown as DocumentNode; export const AddMemberToWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AddMemberToWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"AddMemberToWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addMemberToWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; -export const RemoveMemberToWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RemoveMemberToWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RemoveMemberFromWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"removeMemberFromWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; -export const UpdateMemberToWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateMemberToWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateMemberOfWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateMemberOfWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file +export const RemoveMemberFromWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RemoveMemberFromWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RemoveMemberFromWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"removeMemberFromWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; +export const UpdateMemberOfWorkspaceDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateMemberOfWorkspace"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateMemberOfWorkspaceInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateMemberOfWorkspace"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"workspace"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Workspace"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"Workspace"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Workspace"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"personal"}},{"kind":"Field","name":{"kind":"Name","value":"members"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/ui/src/lib/gql/__gen__/plugins/graphql-request.ts b/ui/src/lib/gql/__gen__/plugins/graphql-request.ts index 5f168e3f2..32ad538fa 100644 --- a/ui/src/lib/gql/__gen__/plugins/graphql-request.ts +++ b/ui/src/lib/gql/__gen__/plugins/graphql-request.ts @@ -500,6 +500,13 @@ export type GetMeQueryVariables = Exact<{ [key: string]: never; }>; export type GetMeQuery = { __typename?: 'Query', me?: { __typename?: 'Me', id: string, name: string, email: string, myWorkspaceId: string } | null }; +export type SearchUserQueryVariables = Exact<{ + email: Scalars['String']['input']; +}>; + + +export type SearchUserQuery = { __typename?: 'Query', searchUser?: { __typename?: 'User', id: string, name: string, email: string } | null }; + export type WorkspaceFragment = { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> }; export type CreateWorkspaceMutationVariables = Exact<{ @@ -542,19 +549,19 @@ export type AddMemberToWorkspaceMutationVariables = Exact<{ export type AddMemberToWorkspaceMutation = { __typename?: 'Mutation', addMemberToWorkspace?: { __typename?: 'AddMemberToWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; -export type RemoveMemberToWorkspaceMutationVariables = Exact<{ +export type RemoveMemberFromWorkspaceMutationVariables = Exact<{ input: RemoveMemberFromWorkspaceInput; }>; -export type RemoveMemberToWorkspaceMutation = { __typename?: 'Mutation', removeMemberFromWorkspace?: { __typename?: 'RemoveMemberFromWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; +export type RemoveMemberFromWorkspaceMutation = { __typename?: 'Mutation', removeMemberFromWorkspace?: { __typename?: 'RemoveMemberFromWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; -export type UpdateMemberToWorkspaceMutationVariables = Exact<{ +export type UpdateMemberOfWorkspaceMutationVariables = Exact<{ input: UpdateMemberOfWorkspaceInput; }>; -export type UpdateMemberToWorkspaceMutation = { __typename?: 'Mutation', updateMemberOfWorkspace?: { __typename?: 'UpdateMemberOfWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; +export type UpdateMemberOfWorkspaceMutation = { __typename?: 'Mutation', updateMemberOfWorkspace?: { __typename?: 'UpdateMemberOfWorkspacePayload', workspace: { __typename?: 'Workspace', id: string, name: string, personal: boolean, members: Array<{ __typename?: 'WorkspaceMember', userId: string, role: Role, user?: { __typename?: 'User', id: string, email: string, name: string } | null }> } } | null }; export const ProjectFragmentDoc = gql` fragment Project on Project { @@ -641,6 +648,15 @@ export const GetMeDocument = gql` } } `; +export const SearchUserDocument = gql` + query SearchUser($email: String!) { + searchUser(nameOrEmail: $email) { + id + name + email + } +} + `; export const CreateWorkspaceDocument = gql` mutation CreateWorkspace($input: CreateWorkspaceInput!) { createWorkspace(input: $input) { @@ -692,8 +708,8 @@ export const AddMemberToWorkspaceDocument = gql` } } ${WorkspaceFragmentDoc}`; -export const RemoveMemberToWorkspaceDocument = gql` - mutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) { +export const RemoveMemberFromWorkspaceDocument = gql` + mutation RemoveMemberFromWorkspace($input: RemoveMemberFromWorkspaceInput!) { removeMemberFromWorkspace(input: $input) { workspace { ...Workspace @@ -701,8 +717,8 @@ export const RemoveMemberToWorkspaceDocument = gql` } } ${WorkspaceFragmentDoc}`; -export const UpdateMemberToWorkspaceDocument = gql` - mutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) { +export const UpdateMemberOfWorkspaceDocument = gql` + mutation UpdateMemberOfWorkspace($input: UpdateMemberOfWorkspaceInput!) { updateMemberOfWorkspace(input: $input) { workspace { ...Workspace @@ -736,6 +752,9 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = GetMe(variables?: GetMeQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { return withWrapper((wrappedRequestHeaders) => client.request(GetMeDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'GetMe', 'query', variables); }, + SearchUser(variables: SearchUserQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { + return withWrapper((wrappedRequestHeaders) => client.request(SearchUserDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'SearchUser', 'query', variables); + }, CreateWorkspace(variables: CreateWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { return withWrapper((wrappedRequestHeaders) => client.request(CreateWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'CreateWorkspace', 'mutation', variables); }, @@ -754,11 +773,11 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = AddMemberToWorkspace(variables: AddMemberToWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { return withWrapper((wrappedRequestHeaders) => client.request(AddMemberToWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'AddMemberToWorkspace', 'mutation', variables); }, - RemoveMemberToWorkspace(variables: RemoveMemberToWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { - return withWrapper((wrappedRequestHeaders) => client.request(RemoveMemberToWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'RemoveMemberToWorkspace', 'mutation', variables); + RemoveMemberFromWorkspace(variables: RemoveMemberFromWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { + return withWrapper((wrappedRequestHeaders) => client.request(RemoveMemberFromWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'RemoveMemberFromWorkspace', 'mutation', variables); }, - UpdateMemberToWorkspace(variables: UpdateMemberToWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { - return withWrapper((wrappedRequestHeaders) => client.request(UpdateMemberToWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'UpdateMemberToWorkspace', 'mutation', variables); + UpdateMemberOfWorkspace(variables: UpdateMemberOfWorkspaceMutationVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise { + return withWrapper((wrappedRequestHeaders) => client.request(UpdateMemberOfWorkspaceDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'UpdateMemberOfWorkspace', 'mutation', variables); } }; } diff --git a/ui/src/lib/gql/workspace/queries.graphql b/ui/src/lib/gql/workspace/queries.graphql index f44b518be..3f38ac2c6 100644 --- a/ui/src/lib/gql/workspace/queries.graphql +++ b/ui/src/lib/gql/workspace/queries.graphql @@ -59,7 +59,7 @@ mutation AddMemberToWorkspace($input: AddMemberToWorkspaceInput!) { } } -mutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) { +mutation RemoveMemberFromWorkspace($input: RemoveMemberFromWorkspaceInput!) { removeMemberFromWorkspace(input: $input) { workspace { ...Workspace @@ -67,7 +67,7 @@ mutation RemoveMemberToWorkspace($input: RemoveMemberFromWorkspaceInput!) { } } -mutation UpdateMemberToWorkspace($input: UpdateMemberOfWorkspaceInput!) { +mutation UpdateMemberOfWorkspace($input: UpdateMemberOfWorkspaceInput!) { updateMemberOfWorkspace(input: $input) { workspace { ...Workspace diff --git a/ui/src/lib/gql/workspace/useApi.ts b/ui/src/lib/gql/workspace/useApi.ts index 3abec48ee..185c173eb 100644 --- a/ui/src/lib/gql/workspace/useApi.ts +++ b/ui/src/lib/gql/workspace/useApi.ts @@ -1,10 +1,4 @@ -import { - GetWorkspaces, - CreateWorkspace, - DeleteWorkspace, - GetWorkspace, - UpdateWorkspace, -} from "@flow/types"; +import { GetWorkspaces, DeleteWorkspace, GetWorkspace, Role, WorkspaceMutation } from "@flow/types"; import { useQueries } from "./useQueries"; @@ -20,9 +14,12 @@ export const useWorkspace = () => { deleteWorkspaceMutation, useGetWorkspaceByIdQuery, updateWorkspaceMutation, + addMemberToWorkspaceMutation, + removeMemberFromWorkspaceMutation, + updateMemberOfWorkspaceMutation, } = useQueries(); - const createWorkspace = async (name: string): Promise => { + const createWorkspace = async (name: string): Promise => { const { mutateAsync, ...rest } = createWorkspaceMutation; try { const data = await mutateAsync(name); @@ -48,7 +45,7 @@ export const useWorkspace = () => { }; }; - const updateWorkspace = async (workspaceId: string, name: string): Promise => { + const updateWorkspace = async (workspaceId: string, name: string): Promise => { const { mutateAsync, ...rest } = updateWorkspaceMutation; try { const data = await mutateAsync({ workspaceId, name }); @@ -68,11 +65,56 @@ export const useWorkspace = () => { } }; + // Members in the Workspace + const addMemberToWorkspace = async ( + workspaceId: string, + userId: string, + role: Role, + ): Promise => { + const { mutateAsync, ...rest } = addMemberToWorkspaceMutation; + try { + const data = await mutateAsync({ workspaceId, userId, role }); + return { workspace: data, ...rest }; + } catch (err) { + return { workspace: undefined, ...rest }; + } + }; + + const removeMemberFromWorkspace = async ( + workspaceId: string, + userId: string, + ): Promise => { + const { mutateAsync, ...rest } = removeMemberFromWorkspaceMutation; + try { + const data = await mutateAsync({ workspaceId, userId }); + return { workspace: data, ...rest }; + } catch (err) { + return { workspace: undefined, ...rest }; + } + }; + + const updateMemberOfWorkspace = async ( + workspaceId: string, + userId: string, + role: Role, + ): Promise => { + const { mutateAsync, ...rest } = updateMemberOfWorkspaceMutation; + try { + const data = await mutateAsync({ workspaceId, userId, role }); + return { workspace: data, ...rest }; + } catch (err) { + return { workspace: undefined, ...rest }; + } + }; + return { createWorkspace, useGetWorkspaces, useGetWorkspace, deleteWorkspace, updateWorkspace, + addMemberToWorkspace, + removeMemberFromWorkspace, + updateMemberOfWorkspace, }; }; diff --git a/ui/src/lib/gql/workspace/useQueries.ts b/ui/src/lib/gql/workspace/useQueries.ts index 77693dab7..9d9c8dd7b 100644 --- a/ui/src/lib/gql/workspace/useQueries.ts +++ b/ui/src/lib/gql/workspace/useQueries.ts @@ -4,7 +4,13 @@ import { useCallback } from "react"; import { useGraphQLContext } from "@flow/lib/gql"; import { Member, Workspace } from "@flow/types"; -import { UpdateWorkspaceInput, WorkspaceFragment } from "../__gen__/graphql"; +import { + AddMemberToWorkspaceInput, + RemoveMemberFromWorkspaceInput, + UpdateMemberOfWorkspaceInput, + UpdateWorkspaceInput, + WorkspaceFragment, +} from "../__gen__/graphql"; import { WorkspaceQueryKeys } from "./useApi"; @@ -14,34 +20,34 @@ export const useQueries = () => { const queryClient = useQueryClient(); const createNewWorkspaceObject = useCallback( - (w: WorkspaceFragment): Workspace => ({ - id: w.id, - name: w.name, - personal: w.personal, - members: w.members.map( - (m): Member => ({ - userId: m.userId, - role: m.role, - user: m.user - ? { - id: m.user?.id, - name: m.user?.name, - email: m.user?.email, - } - : undefined, - }), - ), - }), + (w: WorkspaceFragment | undefined): Workspace | undefined => + w + ? { + id: w.id, + name: w.name, + personal: w.personal, + members: w.members.map( + (m): Member => ({ + userId: m.userId, + role: m.role, + user: m.user + ? { + id: m.user?.id, + name: m.user?.name, + email: m.user?.email, + } + : undefined, + }), + ), + } + : undefined, [], ); const createWorkspaceMutation = useMutation({ mutationFn: async (name: string) => { const data = await graphQLContext?.CreateWorkspace({ input: { name } }); - return ( - data?.createWorkspace?.workspace && - createNewWorkspaceObject(data?.createWorkspace?.workspace) - ); + return createNewWorkspaceObject(data?.createWorkspace?.workspace); }, onSuccess: () => { queryClient.invalidateQueries({ @@ -54,7 +60,8 @@ export const useQueries = () => { useQuery({ queryKey: [WorkspaceQueryKeys.GetWorkspaces], queryFn: () => graphQLContext?.GetWorkspaces(), - select: data => data?.me?.workspaces.map(w => createNewWorkspaceObject(w)), + select: data => + data?.me?.workspaces.map(w => createNewWorkspaceObject(w)).flatMap(w => (w ? [w] : [])), staleTime: Infinity, }); @@ -70,10 +77,7 @@ export const useQueries = () => { const updateWorkspaceMutation = useMutation({ mutationFn: async (input: UpdateWorkspaceInput) => { const data = await graphQLContext?.UpdateWorkspace({ input }); - return ( - data?.updateWorkspace?.workspace && - createNewWorkspaceObject(data?.updateWorkspace?.workspace) - ); + return createNewWorkspaceObject(data?.updateWorkspace?.workspace); }, onSuccess: () => { queryClient.invalidateQueries({ @@ -94,11 +98,57 @@ export const useQueries = () => { }, }); + // Members in the Workspace + const addMemberToWorkspaceMutation = useMutation({ + mutationFn: async (input: AddMemberToWorkspaceInput) => { + const data = await graphQLContext?.AddMemberToWorkspace({ + input, + }); + return createNewWorkspaceObject(data?.addMemberToWorkspace?.workspace); + }, + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [WorkspaceQueryKeys.GetWorkspaces], + }); + }, + }); + + const removeMemberFromWorkspaceMutation = useMutation({ + mutationFn: async (input: RemoveMemberFromWorkspaceInput) => { + const data = await graphQLContext?.RemoveMemberFromWorkspace({ + input, + }); + return createNewWorkspaceObject(data?.removeMemberFromWorkspace?.workspace); + }, + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [WorkspaceQueryKeys.GetWorkspaces], + }); + }, + }); + + const updateMemberOfWorkspaceMutation = useMutation({ + mutationFn: async (input: UpdateMemberOfWorkspaceInput) => { + const data = await graphQLContext?.UpdateMemberOfWorkspace({ + input, + }); + return createNewWorkspaceObject(data?.updateMemberOfWorkspace?.workspace); + }, + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: [WorkspaceQueryKeys.GetWorkspaces], + }); + }, + }); + return { createWorkspaceMutation, useGetWorkspacesQuery, useGetWorkspaceByIdQuery, deleteWorkspaceMutation, updateWorkspaceMutation, + addMemberToWorkspaceMutation, + removeMemberFromWorkspaceMutation, + updateMemberOfWorkspaceMutation, }; }; diff --git a/ui/src/types/workspace.ts b/ui/src/types/workspace.ts index 2d228b249..0a7d57d6a 100644 --- a/ui/src/types/workspace.ts +++ b/ui/src/types/workspace.ts @@ -8,13 +8,10 @@ export type Workspace = { projects?: Project[]; }; -export type CreateWorkspace = { +export type WorkspaceMutation { workspace?: Workspace; } & ApiResponse; -export type UpdateWorkspace = { - workspace?: Workspace; -} & ApiResponse; export type GetWorkspaces = { workspaces?: Workspace[]; From 20fffbf24427b41fe3f87c4a10d85ab92593bc78 Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:20:40 +0530 Subject: [PATCH 06/25] - search user query implementation --- ui/src/lib/gql/user/queries.graphql | 8 ++++++++ ui/src/lib/gql/user/useApi.ts | 14 ++++++++++++-- ui/src/lib/gql/user/useQueries.ts | 21 +++++++++++++++++++-- ui/src/types/user.ts | 4 ++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ui/src/lib/gql/user/queries.graphql b/ui/src/lib/gql/user/queries.graphql index e0f5482d2..d323a2895 100644 --- a/ui/src/lib/gql/user/queries.graphql +++ b/ui/src/lib/gql/user/queries.graphql @@ -6,3 +6,11 @@ query GetMe { myWorkspaceId } } + +query SearchUser($email: String!) { + searchUser(nameOrEmail: $email) { + id + name + email + } +} diff --git a/ui/src/lib/gql/user/useApi.ts b/ui/src/lib/gql/user/useApi.ts index 0ce60e741..17915db64 100644 --- a/ui/src/lib/gql/user/useApi.ts +++ b/ui/src/lib/gql/user/useApi.ts @@ -1,13 +1,14 @@ -import { GetMe } from "@flow/types/user"; +import { GetMe, SearchUser } from "@flow/types/user"; import { useQueries } from "./useQueries"; export enum UserQueryKeys { GetMe = "getMe", + SearchUser = "User", } export const useUser = () => { - const { getMeQuery } = useQueries(); + const { getMeQuery, useSearchUserQuery } = useQueries(); const getMe = (): GetMe => { const { data, ...rest } = getMeQuery; @@ -17,7 +18,16 @@ export const useUser = () => { }; }; + const useSearchUser = (email: string): SearchUser => { + const { data, ...rest } = useSearchUserQuery(email); + return { + user: data, + ...rest, + }; + }; + return { getMe, + useSearchUser, }; }; diff --git a/ui/src/lib/gql/user/useQueries.ts b/ui/src/lib/gql/user/useQueries.ts index b9c991978..94f30ae85 100644 --- a/ui/src/lib/gql/user/useQueries.ts +++ b/ui/src/lib/gql/user/useQueries.ts @@ -1,9 +1,9 @@ import { useQuery } from "@tanstack/react-query"; import { useGraphQLContext } from "@flow/lib/gql"; -import { Me } from "@flow/types/user"; +import { Me, User } from "@flow/types/user"; -import { GetMeQuery } from "../__gen__/graphql"; +import { GetMeQuery, SearchUserQuery } from "../__gen__/graphql"; import { UserQueryKeys } from "./useApi"; @@ -26,7 +26,24 @@ export const useQueries = () => { staleTime: Infinity, }); + const useSearchUserQuery = (email: string) => + useQuery({ + queryKey: [UserQueryKeys.SearchUser, email], + queryFn: () => graphQLContext?.SearchUser({ email }), + select: (data: SearchUserQuery | undefined): User | undefined => { + if (!data?.searchUser) return undefined; + const user = data.searchUser; + return { + id: user.id, + name: user.name, + email: user.email, + }; + }, + staleTime: Infinity, + }); + return { getMeQuery, + useSearchUserQuery, }; }; diff --git a/ui/src/types/user.ts b/ui/src/types/user.ts index 8ffb319b1..4b23a3819 100644 --- a/ui/src/types/user.ts +++ b/ui/src/types/user.ts @@ -16,3 +16,7 @@ export type User = { name: string; email: string; }; + +export type SearchUser = { + user?: User; +} & ApiResponse; From 18a6c9e1310a6acba5ceb7af6b00ed7096f84fc1 Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:21:48 +0530 Subject: [PATCH 07/25] - update type on Role and related changes --- .../components/IntegrationsSettings.tsx | 10 +++--- .../components/MembersSettings.tsx | 34 ++++++++++++++----- ui/src/types/member.ts | 7 +++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx b/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx index 97cc6d763..02be2cf0a 100644 --- a/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/IntegrationsSettings.tsx @@ -16,7 +16,7 @@ import { IntegrationMember } from "@flow/types/integration"; type Filter = "all" | Role; -const roles: Role[] = ["OWNER", "MAINTAINER", "READER", "WRITER"]; +const roles: Role[] = Object.values(Role); const IntegrationsSettings: React.FC = () => { const t = useT(); @@ -26,10 +26,10 @@ const IntegrationsSettings: React.FC = () => { const filters: { id: Filter; title: string }[] = [ { id: "all", title: t("All") }, - { id: "OWNER", title: t("Owner") }, - { id: "READER", title: t("Reader") }, - { id: "MAINTAINER", title: t("Maintainer") }, - { id: "WRITER", title: t("Writer") }, + { id: Role.Owner, title: t("Owner") }, + { id: Role.Reader, title: t("Reader") }, + { id: Role.Reader, title: t("Maintainer") }, + { id: Role.Writer, title: t("Writer") }, ]; const integrations: IntegrationMember[] = diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 10b36da21..a8fa91640 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -10,26 +10,30 @@ import { DropdownMenuTrigger, Input, } from "@flow/components"; +// import { useUser, useWorkspace } from "@flow/lib/gql"; import { useT } from "@flow/lib/i18n"; import { useCurrentWorkspace } from "@flow/stores"; import { Role, UserMember } from "@flow/types"; type Filter = "all" | Role; -const roles: Role[] = ["MAINTAINER", "OWNER", "READER", "WRITER"]; +const roles: Role[] = Object.values(Role); const MembersSettings: React.FC = () => { const t = useT(); const [currentWorkspace] = useCurrentWorkspace(); + // const { useSearchUser } = useUser(); + + const [email, setEmail] = useState(); const [currentFilter, setFilter] = useState("all"); const filters: { id: Filter; title: string }[] = [ { id: "all", title: t("All") }, - { id: "OWNER", title: t("Owner") }, - { id: "READER", title: t("Reader") }, - { id: "MAINTAINER", title: t("Maintainer") }, - { id: "WRITER", title: t("Writer") }, + { id: Role.Owner, title: t("Owner") }, + { id: Role.Reader, title: t("Reader") }, + { id: Role.Reader, title: t("Maintainer") }, + { id: Role.Writer, title: t("Writer") }, ]; const members = @@ -39,15 +43,29 @@ const MembersSettings: React.FC = () => { const [selectedMembers, setSelectedMembers] = useState([]); + const handleAddMember = async () => { + if (!email || currentWorkspace?.id) return; + // const user = useSearchUser(email); + // const { workspace } = await addMemberToWorkspace(); + }; + return (

{t("Members Settings")}

-
- - +
+ {/* TODO: This will be a dialog component */} + setEmail(e.target.value)} + /> +
diff --git a/ui/src/types/member.ts b/ui/src/types/member.ts index eddeb9d86..1907a4059 100644 --- a/ui/src/types/member.ts +++ b/ui/src/types/member.ts @@ -1,7 +1,12 @@ import { IntegrationMember } from "./integration"; import { User } from "./user"; -export type Role = "MAINTAINER" | "OWNER" | "READER" | "WRITER"; +export enum Role { + Maintainer = "MAINTAINER", + Owner = "OWNER", + Reader = "READER", + Writer = "WRITER", +} export type UserMember = { userId: string; From d76262fde363fa283223c5a22345af2cd004b2a9 Mon Sep 17 00:00:00 2001 From: json singh <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:22:24 +0530 Subject: [PATCH 08/25] - type error --- ui/src/types/workspace.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/src/types/workspace.ts b/ui/src/types/workspace.ts index 0a7d57d6a..9793ae2e4 100644 --- a/ui/src/types/workspace.ts +++ b/ui/src/types/workspace.ts @@ -8,11 +8,10 @@ export type Workspace = { projects?: Project[]; }; -export type WorkspaceMutation { +export type WorkspaceMutation = { workspace?: Workspace; } & ApiResponse; - export type GetWorkspaces = { workspaces?: Workspace[]; isLoading: boolean; From b3c17453ee9013da42206fac98020afc07b9b88d Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:01:32 +0530 Subject: [PATCH 09/25] - language stuff --- ui/src/lib/i18n/locales/en.json | 9 ++++++--- ui/src/lib/i18n/locales/es.json | 9 ++++++--- ui/src/lib/i18n/locales/fr.json | 9 ++++++--- ui/src/lib/i18n/locales/ja.json | 9 ++++++--- ui/src/lib/i18n/locales/zh.json | 9 ++++++--- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ui/src/lib/i18n/locales/en.json b/ui/src/lib/i18n/locales/en.json index a283f71af..b8c13705e 100644 --- a/ui/src/lib/i18n/locales/en.json +++ b/ui/src/lib/i18n/locales/en.json @@ -117,10 +117,12 @@ "Workspace Name": "", "Save": "", "Delete Workspace": "", - "Failed to delete workspace": "", + "Failed to delete Workspace": "", + "Failed to update Workspace": "", "All": "", - "Admin": "", + "Owner": "", "Reader": "", + "Maintainer": "", "Writer": "", "Integrations Settings": "", "Connect Integration": "", @@ -130,7 +132,8 @@ "Change role": "", "Remove selected": "", "Members Settings": "", - "Add Members": "", + "Enter email": "", + "Add Member": "", "Members": "", "General": "" } diff --git a/ui/src/lib/i18n/locales/es.json b/ui/src/lib/i18n/locales/es.json index 403195773..59dd82acb 100644 --- a/ui/src/lib/i18n/locales/es.json +++ b/ui/src/lib/i18n/locales/es.json @@ -117,10 +117,12 @@ "Workspace Name": "", "Save": "", "Delete Workspace": "", - "Failed to delete workspace": "", + "Failed to delete Workspace": "", + "Failed to update Workspace": "", "All": "", - "Admin": "", + "Owner": "", "Reader": "", + "Maintainer": "", "Writer": "", "Integrations Settings": "", "Connect Integration": "", @@ -130,7 +132,8 @@ "Change role": "", "Remove selected": "", "Members Settings": "", - "Add Members": "", + "Enter email": "", + "Add Member": "", "Members": "", "General": "" } diff --git a/ui/src/lib/i18n/locales/fr.json b/ui/src/lib/i18n/locales/fr.json index ae9b5ccec..17f850583 100644 --- a/ui/src/lib/i18n/locales/fr.json +++ b/ui/src/lib/i18n/locales/fr.json @@ -117,10 +117,12 @@ "Workspace Name": "", "Save": "", "Delete Workspace": "", - "Failed to delete workspace": "", + "Failed to delete Workspace": "", + "Failed to update Workspace": "", "All": "", - "Admin": "", + "Owner": "", "Reader": "", + "Maintainer": "", "Writer": "", "Integrations Settings": "", "Connect Integration": "", @@ -130,7 +132,8 @@ "Change role": "", "Remove selected": "", "Members Settings": "", - "Add Members": "", + "Enter email": "", + "Add Member": "", "Members": "", "General": "" } diff --git a/ui/src/lib/i18n/locales/ja.json b/ui/src/lib/i18n/locales/ja.json index 080f728ec..5c14f9b82 100644 --- a/ui/src/lib/i18n/locales/ja.json +++ b/ui/src/lib/i18n/locales/ja.json @@ -117,10 +117,12 @@ "Workspace Name": "ワークスペース名", "Save": "保存", "Delete Workspace": "ワークスペースを削除", - "Failed to delete workspace": "ワークスペースの削除に失敗しました", + "Failed to delete Workspace": "", + "Failed to update Workspace": "", "All": "", - "Admin": "", + "Owner": "", "Reader": "", + "Maintainer": "", "Writer": "", "Integrations Settings": "", "Connect Integration": "", @@ -130,7 +132,8 @@ "Change role": "", "Remove selected": "", "Members Settings": "", - "Add Members": "", + "Enter email": "", + "Add Member": "", "Members": "", "General": "" } diff --git a/ui/src/lib/i18n/locales/zh.json b/ui/src/lib/i18n/locales/zh.json index f06d30b89..0ff4f2deb 100644 --- a/ui/src/lib/i18n/locales/zh.json +++ b/ui/src/lib/i18n/locales/zh.json @@ -117,10 +117,12 @@ "Workspace Name": "", "Save": "", "Delete Workspace": "", - "Failed to delete workspace": "", + "Failed to delete Workspace": "", + "Failed to update Workspace": "", "All": "", - "Admin": "", + "Owner": "", "Reader": "", + "Maintainer": "", "Writer": "", "Integrations Settings": "", "Connect Integration": "", @@ -130,7 +132,8 @@ "Change role": "", "Remove selected": "", "Members Settings": "", - "Add Members": "", + "Enter email": "", + "Add Member": "", "Members": "", "General": "" } From 036d20fe27508e4b0c9522c8d6e505c4846b3803 Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 20:18:39 +0530 Subject: [PATCH 10/25] - updated workspace crud --- .../components/MembersSettings.tsx | 134 +++++++++--------- ui/src/lib/gql/user/useApi.ts | 9 +- ui/src/lib/gql/user/useQueries.ts | 31 ++-- ui/src/types/user.ts | 2 +- 4 files changed, 90 insertions(+), 86 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index a8fa91640..79d13102b 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -3,14 +3,13 @@ import { useState } from "react"; import { Button, - Checkbox, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Input, } from "@flow/components"; -// import { useUser, useWorkspace } from "@flow/lib/gql"; +import { useUser, useWorkspace } from "@flow/lib/gql"; import { useT } from "@flow/lib/i18n"; import { useCurrentWorkspace } from "@flow/stores"; import { Role, UserMember } from "@flow/types"; @@ -21,12 +20,13 @@ const roles: Role[] = Object.values(Role); const MembersSettings: React.FC = () => { const t = useT(); - const [currentWorkspace] = useCurrentWorkspace(); - // const { useSearchUser } = useUser(); - - const [email, setEmail] = useState(); - + const [currentWorkspace, setCurrentWorkspace] = useCurrentWorkspace(); + const { addMemberToWorkspace, removeMemberFromWorkspace, updateMemberOfWorkspace } = + useWorkspace(); + const { searchUser } = useUser(); + const [email, setEmail] = useState(""); const [currentFilter, setFilter] = useState("all"); + const [error, setError] = useState(); const filters: { id: Filter; title: string }[] = [ { id: "all", title: t("All") }, @@ -41,12 +41,42 @@ const MembersSettings: React.FC = () => { m => "userId" in m && (currentFilter !== "all" ? m.role === currentFilter : true), ) as UserMember[]) ?? []; - const [selectedMembers, setSelectedMembers] = useState([]); + const handleAddMember = async (email: string) => { + setError(undefined); + const { user } = await searchUser(email); + if (!user) { + setError(t("Could not find the user")); + return; + } + if (!currentWorkspace?.id) return; + const { workspace } = await addMemberToWorkspace(currentWorkspace.id, user.id, Role.Reader); - const handleAddMember = async () => { - if (!email || currentWorkspace?.id) return; - // const user = useSearchUser(email); - // const { workspace } = await addMemberToWorkspace(); + if (!workspace) { + setError(t("Failed to add member")); + return; + } + setCurrentWorkspace(workspace); + }; + + const handleChangeRole = async (userId: string, role: Role) => { + if (!currentWorkspace?.id) return; + const { workspace } = await updateMemberOfWorkspace(currentWorkspace.id, userId, role); + if (!workspace) { + setError(t("Failed to change role of the member")); + return; + } + setCurrentWorkspace(workspace); + }; + + const handleRemoveMembers = async (userId: string) => { + setError(undefined); + if (!currentWorkspace?.id) return; + const { workspace } = await removeMemberFromWorkspace(currentWorkspace.id, userId); + if (!workspace) { + setError(t("Failed to remove member")); + return; + } + setCurrentWorkspace(workspace); }; return ( @@ -63,50 +93,16 @@ const MembersSettings: React.FC = () => { value={email} onChange={e => setEmail(e.target.value)} /> -
- - setSelectedMembers( - selectedMembers.length !== members.length ? members.map(m => m.userId) : [], - ) - } - /> -

- {selectedMembers.length - ? `${selectedMembers.length} ${selectedMembers.length === 1 ? t("member selected") : t("members selected")}` - : `${members.length} ${t("Members")}`} -

+

{`${members.length} ${t("Members")}`}

- {selectedMembers.length > 0 && ( -
- - -

{t("Change role")}

- -
- - - {roles.map((role, idx) => ( - console.log(role)}> - {role} - - ))} - -
- -
- )}
@@ -128,26 +124,36 @@ const MembersSettings: React.FC = () => {
- {members.map(member => ( -
- - setSelectedMembers(prev => - prev.includes(member.userId) - ? [...prev.filter(pm => pm !== member.userId)] - : [...prev, member.userId], - ) - } - /> -

{member.user?.name}

-

{member.role}

+ {members.map(m => ( +
+

{m.user?.name}

+

{m.role}

+ + +

{t("Change role")}

+ +
+ + + {roles.map((role, idx) => ( + handleChangeRole(m.userId, role)}> + {role} + + ))} + +
+
))}
- +

{error}

); diff --git a/ui/src/lib/gql/user/useApi.ts b/ui/src/lib/gql/user/useApi.ts index 17915db64..1bf12b435 100644 --- a/ui/src/lib/gql/user/useApi.ts +++ b/ui/src/lib/gql/user/useApi.ts @@ -8,7 +8,7 @@ export enum UserQueryKeys { } export const useUser = () => { - const { getMeQuery, useSearchUserQuery } = useQueries(); + const { getMeQuery, searchUserQuery } = useQueries(); const getMe = (): GetMe => { const { data, ...rest } = getMeQuery; @@ -18,16 +18,15 @@ export const useUser = () => { }; }; - const useSearchUser = (email: string): SearchUser => { - const { data, ...rest } = useSearchUserQuery(email); + const searchUser = async (email: string): Promise => { + const data = await searchUserQuery(email); return { user: data, - ...rest, }; }; return { getMe, - useSearchUser, + searchUser, }; }; diff --git a/ui/src/lib/gql/user/useQueries.ts b/ui/src/lib/gql/user/useQueries.ts index 94f30ae85..beefee3d7 100644 --- a/ui/src/lib/gql/user/useQueries.ts +++ b/ui/src/lib/gql/user/useQueries.ts @@ -26,24 +26,23 @@ export const useQueries = () => { staleTime: Infinity, }); - const useSearchUserQuery = (email: string) => - useQuery({ - queryKey: [UserQueryKeys.SearchUser, email], - queryFn: () => graphQLContext?.SearchUser({ email }), - select: (data: SearchUserQuery | undefined): User | undefined => { - if (!data?.searchUser) return undefined; - const user = data.searchUser; - return { - id: user.id, - name: user.name, - email: user.email, - }; - }, - staleTime: Infinity, - }); + // Not using react-query because it was returning a hook and a function was needed + const searchUserQuery = async (email: string) => { + try { + const data = await graphQLContext?.SearchUser({ email }); + if (!data?.searchUser) return; + return { + id: data.searchUser.id, + name: data.searchUser.name, + email: data.searchUser.email, + }; + } catch (err) { + return; + } + }; return { getMeQuery, - useSearchUserQuery, + searchUserQuery, }; }; diff --git a/ui/src/types/user.ts b/ui/src/types/user.ts index 4b23a3819..3456982eb 100644 --- a/ui/src/types/user.ts +++ b/ui/src/types/user.ts @@ -19,4 +19,4 @@ export type User = { export type SearchUser = { user?: User; -} & ApiResponse; +}; From df32b2063fc61a149d55c3b2ecdfcae1e761223e Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 20:20:31 +0530 Subject: [PATCH 11/25] - updated comment - fixed type --- ui/src/lib/gql/user/useQueries.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/lib/gql/user/useQueries.ts b/ui/src/lib/gql/user/useQueries.ts index beefee3d7..665805a77 100644 --- a/ui/src/lib/gql/user/useQueries.ts +++ b/ui/src/lib/gql/user/useQueries.ts @@ -1,9 +1,9 @@ import { useQuery } from "@tanstack/react-query"; import { useGraphQLContext } from "@flow/lib/gql"; -import { Me, User } from "@flow/types/user"; +import { Me } from "@flow/types/user"; -import { GetMeQuery, SearchUserQuery } from "../__gen__/graphql"; +import { GetMeQuery } from "../__gen__/graphql"; import { UserQueryKeys } from "./useApi"; @@ -26,7 +26,7 @@ export const useQueries = () => { staleTime: Infinity, }); - // Not using react-query because it was returning a hook and a function was needed + // Not using react-query because no observers are needed on this const searchUserQuery = async (email: string) => { try { const data = await graphQLContext?.SearchUser({ email }); From e90819e61edd0bbd69657e319f252df4d2918f7c Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 20:35:28 +0530 Subject: [PATCH 12/25] - sort the members --- .../WorkspaceSettings/components/MembersSettings.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 79d13102b..840a1c3d3 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -37,9 +37,11 @@ const MembersSettings: React.FC = () => { ]; const members = - (currentWorkspace?.members?.filter( - m => "userId" in m && (currentFilter !== "all" ? m.role === currentFilter : true), - ) as UserMember[]) ?? []; + ( + currentWorkspace?.members?.filter( + m => "userId" in m && (currentFilter !== "all" ? m.role === currentFilter : true), + ) as UserMember[] + ).sort((a, b) => a.user?.name.localeCompare(b.user?.name ?? "") ?? 0) ?? []; const handleAddMember = async (email: string) => { setError(undefined); @@ -56,6 +58,7 @@ const MembersSettings: React.FC = () => { return; } setCurrentWorkspace(workspace); + setEmail(""); }; const handleChangeRole = async (userId: string, role: Role) => { From 84f2a86d3b7f866fd67c49e176349719412287cf Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Wed, 19 Jun 2024 20:47:02 +0530 Subject: [PATCH 13/25] - a single comma can ruin the layout --- ui/src/routes/workspace_.$workspaceId_.settings.$tab.lazy.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/routes/workspace_.$workspaceId_.settings.$tab.lazy.tsx b/ui/src/routes/workspace_.$workspaceId_.settings.$tab.lazy.tsx index 77ddd1bf1..1b26b5563 100644 --- a/ui/src/routes/workspace_.$workspaceId_.settings.$tab.lazy.tsx +++ b/ui/src/routes/workspace_.$workspaceId_.settings.$tab.lazy.tsx @@ -6,7 +6,7 @@ import { WorkspaceSettings } from "@flow/pages"; export const Route = createLazyFileRoute("/workspace/$workspaceId/settings/$tab")({ component: () => ( - , + ), }); From 1f3d2670fc111e4ed566ec83df5a681aed66f073 Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:48:53 +0530 Subject: [PATCH 14/25] - minor changes --- ui/src/lib/gql/workspace/useQueries.ts | 47 ++++++++++++-------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/ui/src/lib/gql/workspace/useQueries.ts b/ui/src/lib/gql/workspace/useQueries.ts index 9d9c8dd7b..1564377cf 100644 --- a/ui/src/lib/gql/workspace/useQueries.ts +++ b/ui/src/lib/gql/workspace/useQueries.ts @@ -19,30 +19,27 @@ export const useQueries = () => { const graphQLContext = useGraphQLContext(); const queryClient = useQueryClient(); - const createNewWorkspaceObject = useCallback( - (w: WorkspaceFragment | undefined): Workspace | undefined => - w - ? { - id: w.id, - name: w.name, - personal: w.personal, - members: w.members.map( - (m): Member => ({ - userId: m.userId, - role: m.role, - user: m.user - ? { - id: m.user?.id, - name: m.user?.name, - email: m.user?.email, - } - : undefined, - }), - ), - } - : undefined, - [], - ); + const createNewWorkspaceObject = useCallback((w?: WorkspaceFragment): Workspace | undefined => { + if (!w) return; + return { + id: w.id, + name: w.name, + personal: w.personal, + members: w.members.map( + (m): Member => ({ + userId: m.userId, + role: m.role, + user: m.user + ? { + id: m.user?.id, + name: m.user?.name, + email: m.user?.email, + } + : undefined, + }), + ), + }; + }, []); const createWorkspaceMutation = useMutation({ mutationFn: async (name: string) => { @@ -61,7 +58,7 @@ export const useQueries = () => { queryKey: [WorkspaceQueryKeys.GetWorkspaces], queryFn: () => graphQLContext?.GetWorkspaces(), select: data => - data?.me?.workspaces.map(w => createNewWorkspaceObject(w)).flatMap(w => (w ? [w] : [])), + data?.me?.workspaces.flatMap(w => (w ? [createNewWorkspaceObject(w) as Workspace] : [])), staleTime: Infinity, }); From 81cd26a1c6e6bfe013cee3083183d9ed4fabc60b Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:50:16 +0530 Subject: [PATCH 15/25] - revert back --- .../features/WorkspaceSettings/components/MembersSettings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 840a1c3d3..bf4fc6fda 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -39,7 +39,7 @@ const MembersSettings: React.FC = () => { const members = ( currentWorkspace?.members?.filter( - m => "userId" in m && (currentFilter !== "all" ? m.role === currentFilter : true), + m => "userId" in m && (currentFilter === "all" || m.role === currentFilter), ) as UserMember[] ).sort((a, b) => a.user?.name.localeCompare(b.user?.name ?? "") ?? 0) ?? []; From fe433a81e4ede604387da0c9d1dabcf3df7d01df Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:52:16 +0530 Subject: [PATCH 16/25] - an actual bug --- .../features/WorkspaceSettings/components/MembersSettings.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index bf4fc6fda..455e0ca1b 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -32,7 +32,7 @@ const MembersSettings: React.FC = () => { { id: "all", title: t("All") }, { id: Role.Owner, title: t("Owner") }, { id: Role.Reader, title: t("Reader") }, - { id: Role.Reader, title: t("Maintainer") }, + { id: Role.Maintainer, title: t("Maintainer") }, { id: Role.Writer, title: t("Writer") }, ]; From b4fd0d087553261ebf4dff07face7441761aca96 Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:32:35 +0530 Subject: [PATCH 17/25] - using local cache rather than api calls --- ui/src/features/PageWrapper/WorkspaceId.tsx | 5 +- .../components/GeneralSettings.tsx | 4 +- ui/src/lib/gql/workspace/useQueries.ts | 50 +++++++++++++------ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/ui/src/features/PageWrapper/WorkspaceId.tsx b/ui/src/features/PageWrapper/WorkspaceId.tsx index cc5309293..e2da499a5 100644 --- a/ui/src/features/PageWrapper/WorkspaceId.tsx +++ b/ui/src/features/PageWrapper/WorkspaceId.tsx @@ -12,7 +12,7 @@ type Props = { }; const WorkspaceIdWrapper: React.FC = ({ children }) => { - const [currentWorkspace, setCurrentWorkspace] = useCurrentWorkspace(); + const [_, setCurrentWorkspace] = useCurrentWorkspace(); const { workspaceId }: { workspaceId: string } = useParams({ strict: false, @@ -23,11 +23,10 @@ const WorkspaceIdWrapper: React.FC = ({ children }) => { useEffect(() => { if (!workspace) return; - if (currentWorkspace?.id === workspace.id) return; setCurrentWorkspace(workspace); return; - }, [workspace, currentWorkspace, setCurrentWorkspace]); + }, [workspace, setCurrentWorkspace]); if (isLoading) return ; diff --git a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx index 3a68fa0a7..1223f442f 100644 --- a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx @@ -10,7 +10,7 @@ type Errors = "delete" | "update"; const GeneralSettings: React.FC = () => { const t = useT(); - const [currentWorkspace, setCurrentWorkspace] = useCurrentWorkspace(); + const [currentWorkspace] = useCurrentWorkspace(); const { deleteWorkspace, updateWorkspace } = useWorkspace(); const navigate = useNavigate(); const [showError, setShowError] = useState(undefined); @@ -41,8 +41,6 @@ const GeneralSettings: React.FC = () => { setShowError("update"); return; } - // TODO: Not sure if this is correct to set here - setCurrentWorkspace(workspace); }; return (
diff --git a/ui/src/lib/gql/workspace/useQueries.ts b/ui/src/lib/gql/workspace/useQueries.ts index 1564377cf..adf09367b 100644 --- a/ui/src/lib/gql/workspace/useQueries.ts +++ b/ui/src/lib/gql/workspace/useQueries.ts @@ -46,28 +46,35 @@ export const useQueries = () => { const data = await graphQLContext?.CreateWorkspace({ input: { name } }); return createNewWorkspaceObject(data?.createWorkspace?.workspace); }, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [WorkspaceQueryKeys.GetWorkspaces], - }); + onSuccess: createdWorkspace => { + queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => [ + ...data, + createdWorkspace, + ]); }, }); const useGetWorkspacesQuery = () => useQuery({ queryKey: [WorkspaceQueryKeys.GetWorkspaces], - queryFn: () => graphQLContext?.GetWorkspaces(), - select: data => - data?.me?.workspaces.flatMap(w => (w ? [createNewWorkspaceObject(w) as Workspace] : [])), + queryFn: async () => { + const data = await graphQLContext?.GetWorkspaces(); + return data?.me?.workspaces.flatMap(w => + w ? [createNewWorkspaceObject(w) as Workspace] : [], + ); + }, staleTime: Infinity, }); const useGetWorkspaceByIdQuery = (workspaceId: string) => useQuery({ queryKey: [WorkspaceQueryKeys.GetWorkspace, workspaceId], - queryFn: () => graphQLContext?.GetWorkspaceById({ workspaceId }), - select: data => - data?.node?.__typename === "Workspace" ? createNewWorkspaceObject(data.node) : undefined, + queryFn: async () => { + const data = await graphQLContext?.GetWorkspaceById({ workspaceId }); + return data?.node?.__typename === "Workspace" + ? createNewWorkspaceObject(data.node) + : undefined; + }, staleTime: Infinity, }); @@ -76,10 +83,17 @@ export const useQueries = () => { const data = await graphQLContext?.UpdateWorkspace({ input }); return createNewWorkspaceObject(data?.updateWorkspace?.workspace); }, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [WorkspaceQueryKeys.GetWorkspaces], + onSuccess: workspace => { + if (!workspace) return; + queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => { + data.splice( + data.findIndex(w => w.id === workspace?.id), + 1, + workspace, + ); + return [...data]; }); + queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspace, workspace.id], () => workspace); }, }); @@ -88,9 +102,13 @@ export const useQueries = () => { const data = await graphQLContext?.DeleteWorkspace({ input: { workspaceId } }); return data?.deleteWorkspace?.workspaceId; }, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [WorkspaceQueryKeys.GetWorkspaces], + onSuccess: deletedWorkspaceId => { + queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => { + data.splice( + data.findIndex(w => w.id === deletedWorkspaceId), + 1, + ); + return [...data]; }); }, }); From 2614e90029f4c8d21634291225857a0121555ebc Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:47:01 +0530 Subject: [PATCH 18/25] - fixes and fixes --- .../components/MembersSettings.tsx | 15 +++---- ui/src/lib/gql/workspace/useQueries.ts | 44 +++++++------------ 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 455e0ca1b..d769b1a6b 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -36,39 +36,35 @@ const MembersSettings: React.FC = () => { { id: Role.Writer, title: t("Writer") }, ]; - const members = - ( - currentWorkspace?.members?.filter( - m => "userId" in m && (currentFilter === "all" || m.role === currentFilter), - ) as UserMember[] - ).sort((a, b) => a.user?.name.localeCompare(b.user?.name ?? "") ?? 0) ?? []; + const members = currentWorkspace?.members?.filter( + m => "userId" in m && (currentFilter === "all" || m.role === currentFilter), + ) as UserMember[]; const handleAddMember = async (email: string) => { setError(undefined); + if (!currentWorkspace?.id) return; const { user } = await searchUser(email); if (!user) { setError(t("Could not find the user")); return; } - if (!currentWorkspace?.id) return; const { workspace } = await addMemberToWorkspace(currentWorkspace.id, user.id, Role.Reader); if (!workspace) { setError(t("Failed to add member")); return; } - setCurrentWorkspace(workspace); setEmail(""); }; const handleChangeRole = async (userId: string, role: Role) => { + setError(undefined); if (!currentWorkspace?.id) return; const { workspace } = await updateMemberOfWorkspace(currentWorkspace.id, userId, role); if (!workspace) { setError(t("Failed to change role of the member")); return; } - setCurrentWorkspace(workspace); }; const handleRemoveMembers = async (userId: string) => { @@ -79,7 +75,6 @@ const MembersSettings: React.FC = () => { setError(t("Failed to remove member")); return; } - setCurrentWorkspace(workspace); }; return ( diff --git a/ui/src/lib/gql/workspace/useQueries.ts b/ui/src/lib/gql/workspace/useQueries.ts index adf09367b..e84c9911e 100644 --- a/ui/src/lib/gql/workspace/useQueries.ts +++ b/ui/src/lib/gql/workspace/useQueries.ts @@ -41,6 +41,19 @@ export const useQueries = () => { }; }, []); + const updateWorkspace = (workspace?: Workspace) => { + if (!workspace) return; + queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => { + data.splice( + data.findIndex(w => w.id === workspace?.id), + 1, + workspace, + ); + return [...data]; + }); + queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspace, workspace.id], () => workspace); + }; + const createWorkspaceMutation = useMutation({ mutationFn: async (name: string) => { const data = await graphQLContext?.CreateWorkspace({ input: { name } }); @@ -83,18 +96,7 @@ export const useQueries = () => { const data = await graphQLContext?.UpdateWorkspace({ input }); return createNewWorkspaceObject(data?.updateWorkspace?.workspace); }, - onSuccess: workspace => { - if (!workspace) return; - queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspaces], (data: Workspace[]) => { - data.splice( - data.findIndex(w => w.id === workspace?.id), - 1, - workspace, - ); - return [...data]; - }); - queryClient.setQueryData([WorkspaceQueryKeys.GetWorkspace, workspace.id], () => workspace); - }, + onSuccess: updateWorkspace, }); const deleteWorkspaceMutation = useMutation({ @@ -121,11 +123,7 @@ export const useQueries = () => { }); return createNewWorkspaceObject(data?.addMemberToWorkspace?.workspace); }, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [WorkspaceQueryKeys.GetWorkspaces], - }); - }, + onSuccess: updateWorkspace, }); const removeMemberFromWorkspaceMutation = useMutation({ @@ -135,11 +133,7 @@ export const useQueries = () => { }); return createNewWorkspaceObject(data?.removeMemberFromWorkspace?.workspace); }, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [WorkspaceQueryKeys.GetWorkspaces], - }); - }, + onSuccess: updateWorkspace, }); const updateMemberOfWorkspaceMutation = useMutation({ @@ -149,11 +143,7 @@ export const useQueries = () => { }); return createNewWorkspaceObject(data?.updateMemberOfWorkspace?.workspace); }, - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: [WorkspaceQueryKeys.GetWorkspaces], - }); - }, + onSuccess: updateWorkspace, }); return { From 3c9a3a28a2217fb083aedf4fab464b619e17a294 Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:48:27 +0530 Subject: [PATCH 19/25] - remove workspace description --- .../WorkspaceSettings/components/GeneralSettings.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx index 1223f442f..2abc8be88 100644 --- a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx @@ -56,14 +56,6 @@ const GeneralSettings: React.FC = () => { onChange={e => setWorkspaceName(e.target.value)} />
- {/*
- - -
*/}
@@ -127,7 +132,9 @@ const MembersSettings: React.FC = () => {

{m.user?.name}

{m.role}

- +

{t("Change role")}

@@ -144,6 +151,7 @@ const MembersSettings: React.FC = () => { className="flex-1 h-[25px]" size="sm" variant="outline" + disabled={m.userId === me.me?.id} onClick={() => handleRemoveMembers(m.userId)}> {t("Remove")} From 72b0a0e8a4f921034d6677e7d4ccdfd2d424489b Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:41:25 +0530 Subject: [PATCH 21/25] - Minor refactor --- ui/src/features/NotFoundPage/index.tsx | 4 +-- .../components/UserNavigation.tsx | 8 ++--- .../components/MembersSettings.tsx | 10 +++--- ui/src/lib/gql/user/useApi.ts | 8 ++--- ui/src/lib/gql/user/useQueries.ts | 36 +++++++++---------- ui/src/pages/LoadingPage.tsx | 4 +-- 6 files changed, 34 insertions(+), 36 deletions(-) diff --git a/ui/src/features/NotFoundPage/index.tsx b/ui/src/features/NotFoundPage/index.tsx index da16a6b22..f91064d75 100644 --- a/ui/src/features/NotFoundPage/index.tsx +++ b/ui/src/features/NotFoundPage/index.tsx @@ -10,8 +10,8 @@ type Props = { const NotFoundPage: React.FC = ({ message }) => { const t = useT(); - const { getMe } = useUser(); - const { me } = getMe(); + const { useGetMe } = useUser(); + const { me } = useGetMe(); return (
diff --git a/ui/src/features/TopNavigation/components/UserNavigation.tsx b/ui/src/features/TopNavigation/components/UserNavigation.tsx index b8565252f..cbd2bf6cc 100644 --- a/ui/src/features/TopNavigation/components/UserNavigation.tsx +++ b/ui/src/features/TopNavigation/components/UserNavigation.tsx @@ -33,8 +33,8 @@ const UserNavigation: React.FC = ({ const t = useT(); const [, setDialogType] = useDialogType(); const { logout: handleLogout, user } = useAuth(); - const { getMe } = useUser(); - const data = getMe().me; + const { useGetMe } = useUser(); + const { me } = useGetMe(); const { tosUrl, documentationUrl } = config(); @@ -47,12 +47,12 @@ const UserNavigation: React.FC = ({
- {data?.name ? data?.name.charAt(0).toUpperCase() : "F"} + {me?.name ? me.name.charAt(0).toUpperCase() : "F"} {!iconOnly ? (

- {data?.name ? data?.name : "User"} + {me?.name ? me.name : "User"}

diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index 629b5281b..d6867e1d5 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -23,12 +23,12 @@ const MembersSettings: React.FC = () => { const [currentWorkspace] = useCurrentWorkspace(); const { addMemberToWorkspace, removeMemberFromWorkspace, updateMemberOfWorkspace } = useWorkspace(); - const { searchUser, getMe } = useUser(); + const { searchUser, useGetMe } = useUser(); const [email, setEmail] = useState(""); const [currentFilter, setFilter] = useState("all"); const [error, setError] = useState(); - const me = getMe(); + const { me } = useGetMe(); const filters: { id: Filter; title: string }[] = [ { id: "all", title: t("All") }, @@ -133,8 +133,8 @@ const MembersSettings: React.FC = () => {

{m.role}

+ disabled={m.userId === me?.id} + className={`flex-1 flex items-center gap-1 ${m.userId === me?.id ? "opacity-50" : ""}`}>

{t("Change role")}

@@ -151,7 +151,7 @@ const MembersSettings: React.FC = () => { className="flex-1 h-[25px]" size="sm" variant="outline" - disabled={m.userId === me.me?.id} + disabled={m.userId === me?.id} onClick={() => handleRemoveMembers(m.userId)}> {t("Remove")} diff --git a/ui/src/lib/gql/user/useApi.ts b/ui/src/lib/gql/user/useApi.ts index 1bf12b435..2964037eb 100644 --- a/ui/src/lib/gql/user/useApi.ts +++ b/ui/src/lib/gql/user/useApi.ts @@ -8,10 +8,10 @@ export enum UserQueryKeys { } export const useUser = () => { - const { getMeQuery, searchUserQuery } = useQueries(); + const { useGetMeQuery, searchUserQuery } = useQueries(); - const getMe = (): GetMe => { - const { data, ...rest } = getMeQuery; + const useGetMe = (): GetMe => { + const { data, ...rest } = useGetMeQuery(); return { me: data, ...rest, @@ -26,7 +26,7 @@ export const useUser = () => { }; return { - getMe, + useGetMe, searchUser, }; }; diff --git a/ui/src/lib/gql/user/useQueries.ts b/ui/src/lib/gql/user/useQueries.ts index 665805a77..445469e13 100644 --- a/ui/src/lib/gql/user/useQueries.ts +++ b/ui/src/lib/gql/user/useQueries.ts @@ -1,30 +1,28 @@ import { useQuery } from "@tanstack/react-query"; import { useGraphQLContext } from "@flow/lib/gql"; -import { Me } from "@flow/types/user"; - -import { GetMeQuery } from "../__gen__/graphql"; import { UserQueryKeys } from "./useApi"; export const useQueries = () => { const graphQLContext = useGraphQLContext(); - const getMeQuery = useQuery({ - queryKey: [UserQueryKeys.GetMe], - queryFn: () => graphQLContext?.GetMe(), - select: (data: GetMeQuery | undefined): Me | undefined => { - if (!data?.me) return undefined; - const me = data.me; - return { - id: me.id, - name: me.name, - email: me.email, - myWorkspaceId: me.myWorkspaceId, - }; - }, - staleTime: Infinity, - }); + const useGetMeQuery = () => + useQuery({ + queryKey: [UserQueryKeys.GetMe], + queryFn: async () => { + const data = await graphQLContext?.GetMe(); + if (!data?.me) return; + const me = data.me; + return { + id: me.id, + name: me.name, + email: me.email, + myWorkspaceId: me.myWorkspaceId, + }; + }, + staleTime: Infinity, + }); // Not using react-query because no observers are needed on this const searchUserQuery = async (email: string) => { @@ -42,7 +40,7 @@ export const useQueries = () => { }; return { - getMeQuery, + useGetMeQuery, searchUserQuery, }; }; diff --git a/ui/src/pages/LoadingPage.tsx b/ui/src/pages/LoadingPage.tsx index ccc131a7c..22672da67 100644 --- a/ui/src/pages/LoadingPage.tsx +++ b/ui/src/pages/LoadingPage.tsx @@ -6,8 +6,8 @@ import { useUser } from "@flow/lib/gql"; const LoadingPage: React.FC = () => { const navigate = useNavigate(); - const { getMe } = useUser(); - const { isLoading, me } = getMe(); + const { useGetMe } = useUser(); + const { me, isLoading } = useGetMe(); if (isLoading) return ; From 272dcc97c2ccbb27d0f6fc5c34e9a0421f752e0a Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:21:06 +0530 Subject: [PATCH 22/25] - minor fix --- .../WorkspaceSettings/components/GeneralSettings.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx index 2abc8be88..5566b61e7 100644 --- a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx @@ -1,5 +1,5 @@ import { useNavigate } from "@tanstack/react-router"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Button, Input, Label } from "@flow/components"; import { useWorkspace } from "@flow/lib/gql"; @@ -42,6 +42,11 @@ const GeneralSettings: React.FC = () => { return; } }; + + useEffect(() => { + setWorkspaceName(currentWorkspace?.name); + }, [currentWorkspace]); + return (

{t("General Settings")}

From 3a2b6174116c6ae7f4ac2eb5179d173a450571ec Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:23:29 +0530 Subject: [PATCH 23/25] - added a comment --- ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx index 5566b61e7..7b9c65c01 100644 --- a/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/GeneralSettings.tsx @@ -43,6 +43,7 @@ const GeneralSettings: React.FC = () => { } }; + // currentWorkspace can be changed from the navigation useEffect(() => { setWorkspaceName(currentWorkspace?.name); }, [currentWorkspace]); From fcff46d68cbaf101616ccece47c443f5f3d4c5d8 Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Mon, 1 Jul 2024 21:41:59 +0530 Subject: [PATCH 24/25] - minor change --- .../WorkspaceSettings/components/MembersSettings.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx index d6867e1d5..c00547fa5 100644 --- a/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx +++ b/ui/src/features/WorkspaceSettings/components/MembersSettings.tsx @@ -45,6 +45,14 @@ const MembersSettings: React.FC = () => { const handleAddMember = async (email: string) => { setError(undefined); if (!currentWorkspace?.id) return; + + const alreadyExists = members.find(m => m.user?.email === email); + + if (alreadyExists) { + setError("User already exists"); + return; + } + const { user } = await searchUser(email); if (!user) { setError(t("Could not find the user")); From 7f282728922d210661bcc43768cc693038efdf37 Mon Sep 17 00:00:00 2001 From: jashan <20891087+jashanbhullar@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:41:08 +0530 Subject: [PATCH 25/25] - removed flatmap --- ui/src/lib/gql/project/useQueries.ts | 7 ++++--- ui/src/lib/gql/workspace/useQueries.ts | 8 +++++--- ui/src/lib/utils.ts | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ui/src/lib/gql/project/useQueries.ts b/ui/src/lib/gql/project/useQueries.ts index d0135ff40..a2faa03c2 100644 --- a/ui/src/lib/gql/project/useQueries.ts +++ b/ui/src/lib/gql/project/useQueries.ts @@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useCallback } from "react"; import { useGraphQLContext } from "@flow/lib/gql"; +import { isDefined } from "@flow/lib/utils"; import { Project } from "@flow/types"; import { @@ -54,9 +55,9 @@ export const useQueries = () => { projects: { nodes, ...rest }, } = data; - const projects: Project[] = nodes.flatMap(project => - project ? [createNewProjectObject(project)] : [], - ); + const projects: Project[] = nodes + .filter(isDefined) + .map(project => createNewProjectObject(project)); return { projects, meta: rest }; }, }); diff --git a/ui/src/lib/gql/workspace/useQueries.ts b/ui/src/lib/gql/workspace/useQueries.ts index e84c9911e..6fd7d5a4b 100644 --- a/ui/src/lib/gql/workspace/useQueries.ts +++ b/ui/src/lib/gql/workspace/useQueries.ts @@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useCallback } from "react"; import { useGraphQLContext } from "@flow/lib/gql"; +import { isDefined } from "@flow/lib/utils"; import { Member, Workspace } from "@flow/types"; import { @@ -72,9 +73,10 @@ export const useQueries = () => { queryKey: [WorkspaceQueryKeys.GetWorkspaces], queryFn: async () => { const data = await graphQLContext?.GetWorkspaces(); - return data?.me?.workspaces.flatMap(w => - w ? [createNewWorkspaceObject(w) as Workspace] : [], - ); + + return data?.me?.workspaces + .filter(isDefined) + .map(w => createNewWorkspaceObject(w) as Workspace); }, staleTime: Infinity, }); diff --git a/ui/src/lib/utils.ts b/ui/src/lib/utils.ts index cffaf97a5..f9def1a16 100644 --- a/ui/src/lib/utils.ts +++ b/ui/src/lib/utils.ts @@ -5,3 +5,7 @@ import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } + +export function isDefined(argument: T | undefined | null): argument is T { + return argument !== undefined || argument !== null; +}