-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(2915): admin front-end for tenant support #3254
base: 2893/multi-tenancy-v1
Are you sure you want to change the base?
Changes from all commits
99d6982
344e21a
657780f
3ce9128
15cb387
4aafebb
9072e02
e4a6e6c
45dcb5b
59d4638
993e4c4
ac04fa6
9cd9899
8bc7d7f
b7ea593
ef3601f
4de527d
3258767
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import { gql } from '@apollo/client' | ||
import type { | ||
CreateTenantInput, | ||
CreateTenantMutation, | ||
UpdateTenantMutationVariables, | ||
UpdateTenantInput, | ||
UpdateTenantMutation, | ||
CreateTenantMutationVariables, | ||
QueryTenantsArgs, | ||
ListTenantsQuery, | ||
ListTenantsQueryVariables, | ||
DeleteTenantMutationVariables, | ||
DeleteTenantMutation, | ||
QueryTenantArgs, | ||
GetTenantQuery, | ||
GetTenantQueryVariables | ||
} from '~/generated/graphql' | ||
import { getApolloClient } from '../apollo.server' | ||
|
||
export const listTenants = async (request: Request, args: QueryTenantsArgs) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.query< | ||
ListTenantsQuery, | ||
ListTenantsQueryVariables | ||
>({ | ||
query: gql` | ||
query ListTenantsQuery( | ||
$after: String | ||
$before: String | ||
$first: Int | ||
$last: Int | ||
) { | ||
tenants(after: $after, before: $before, first: $first, last: $last) { | ||
edges { | ||
node { | ||
id | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
publicName | ||
createdAt | ||
deletedAt | ||
isOperator | ||
} | ||
} | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
hasNextPage | ||
hasPreviousPage | ||
} | ||
} | ||
} | ||
`, | ||
variables: args | ||
}) | ||
return response.data.tenants | ||
} | ||
|
||
export const createTenant = async ( | ||
request: Request, | ||
args: CreateTenantInput | ||
) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.mutate< | ||
CreateTenantMutation, | ||
CreateTenantMutationVariables | ||
>({ | ||
mutation: gql` | ||
mutation CreateTenantMutation($input: CreateTenantInput!) { | ||
createTenant(input: $input) { | ||
tenant { | ||
id | ||
publicName | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
} | ||
} | ||
} | ||
`, | ||
variables: { | ||
input: args | ||
} | ||
}) | ||
|
||
return response.data?.createTenant | ||
} | ||
|
||
export const updateTenant = async ( | ||
request: Request, | ||
args: UpdateTenantInput | ||
koekiebox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.mutate< | ||
UpdateTenantMutation, | ||
UpdateTenantMutationVariables | ||
>({ | ||
mutation: gql` | ||
mutation UpdateTenantMutation($input: UpdateTenantInput!) { | ||
updateTenant(input: $input) { | ||
tenant { | ||
id | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
publicName | ||
} | ||
} | ||
} | ||
`, | ||
variables: { | ||
input: args | ||
} | ||
}) | ||
|
||
return response.data?.updateTenant | ||
} | ||
|
||
export const deleteTenant = async (request: Request, args: string) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.mutate< | ||
DeleteTenantMutation, | ||
DeleteTenantMutationVariables | ||
>({ | ||
mutation: gql` | ||
mutation DeleteTenantMutation($id: String!) { | ||
deleteTenant(id: $id) { | ||
success | ||
} | ||
} | ||
`, | ||
variables: { | ||
id: args | ||
} | ||
}) | ||
|
||
return response.data?.deleteTenant | ||
} | ||
|
||
export const getTenantInfo = async ( | ||
request: Request, | ||
args: QueryTenantArgs | ||
) => { | ||
const apolloClient = await getApolloClient(request) | ||
const response = await apolloClient.query< | ||
GetTenantQuery, | ||
GetTenantQueryVariables | ||
>({ | ||
query: gql` | ||
query GetTenantQuery($id: String!) { | ||
tenant(id: $id) { | ||
id | ||
apiSecret | ||
idpConsentUrl | ||
idpSecret | ||
publicName | ||
createdAt | ||
deletedAt | ||
isOperator | ||
} | ||
} | ||
`, | ||
variables: args | ||
}) | ||
return response.data.tenant | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really in the scope of this PR but related: #3276
not suggesting any changes here