-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* convert Login.ts * extract auth provider utils into protocol * complete migration from useAuthProviders to useAuthProviderDescriptions * fixup import of scopes util * revert rename * migrate useDeleteOrgAuthProviderMutation * migrate Org Git Integrations * fix label for authprovider types * wip migration user-level git integrations * WIP updateProviderEntry * wip migration * fixup: label of auth provider types * fixup: dont render Unknown type * fix label * fix this undefined * bump CACHE_VERSION * fixup allow to change the `clientId` only * fixup add AuthProviderClasses to supported messages --------- Co-authored-by: Huiwen <[email protected]>
- Loading branch information
1 parent
bde844b
commit 21bb3c1
Showing
33 changed files
with
827 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
components/dashboard/src/data/auth-providers/auth-provider-descriptions-query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useQuery } from "@tanstack/react-query"; | ||
import { authProviderClient } from "../../service/public-api"; | ||
import { useCurrentUser } from "../../user-context"; | ||
import { | ||
AuthProviderDescription, | ||
ListAuthProviderDescriptionsRequest, | ||
} from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; | ||
|
||
export const useAuthProviderDescriptions = () => { | ||
const user = useCurrentUser(); | ||
const query = useQuery<AuthProviderDescription[]>({ | ||
queryKey: getAuthProviderDescriptionsQueryKey(), | ||
queryFn: async () => { | ||
const params = new ListAuthProviderDescriptionsRequest(); | ||
if (user) { | ||
params.id = { | ||
case: "userId", | ||
value: user.id, | ||
}; | ||
} | ||
const response = await authProviderClient.listAuthProviderDescriptions(params); | ||
return response.descriptions; | ||
}, | ||
}); | ||
return query; | ||
}; | ||
|
||
export const getAuthProviderDescriptionsQueryKey = () => ["auth-provider-descriptions", {}]; |
18 changes: 0 additions & 18 deletions
18
components/dashboard/src/data/auth-providers/auth-provider-query.ts
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
components/dashboard/src/data/auth-providers/create-org-auth-provider-mutation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { getOrgAuthProvidersQueryKey } from "./org-auth-providers-query"; | ||
import { CreateAuthProviderRequest } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; | ||
import { authProviderClient } from "../../service/public-api"; | ||
|
||
type CreateAuthProviderArgs = { | ||
provider: Pick<CreateAuthProviderRequest, "host" | "type"> & { | ||
clientId: string; | ||
clientSecret: string; | ||
orgId: string; | ||
}; | ||
}; | ||
export const useCreateOrgAuthProviderMutation = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ provider }: CreateAuthProviderArgs) => { | ||
const response = await authProviderClient.createAuthProvider( | ||
new CreateAuthProviderRequest({ | ||
owner: { case: "organizationId", value: provider.orgId }, | ||
host: provider.host, | ||
oauth2Config: { | ||
clientId: provider.clientId, | ||
clientSecret: provider.clientSecret, | ||
}, | ||
type: provider.type, | ||
}), | ||
); | ||
return response.authProvider!; | ||
}, | ||
onSuccess(provider) { | ||
const orgId = provider?.owner?.value; | ||
if (!orgId) { | ||
return; | ||
} | ||
|
||
queryClient.invalidateQueries({ queryKey: getOrgAuthProvidersQueryKey(orgId) }); | ||
}, | ||
}); | ||
}; |
46 changes: 46 additions & 0 deletions
46
components/dashboard/src/data/auth-providers/create-user-auth-provider-mutation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { CreateAuthProviderRequest } from "@gitpod/public-api/lib/gitpod/v1/authprovider_pb"; | ||
import { authProviderClient } from "../../service/public-api"; | ||
import { getUserAuthProvidersQueryKey } from "./user-auth-providers-query"; | ||
|
||
type CreateAuthProviderArgs = { | ||
provider: Pick<CreateAuthProviderRequest, "host" | "type"> & { | ||
clientId: string; | ||
clientSecret: string; | ||
userId: string; | ||
}; | ||
}; | ||
export const useCreateUserAuthProviderMutation = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ provider }: CreateAuthProviderArgs) => { | ||
const response = await authProviderClient.createAuthProvider( | ||
new CreateAuthProviderRequest({ | ||
owner: { case: "ownerId", value: provider.userId }, | ||
host: provider.host, | ||
oauth2Config: { | ||
clientId: provider.clientId, | ||
clientSecret: provider.clientSecret, | ||
}, | ||
type: provider.type, | ||
}), | ||
); | ||
return response.authProvider!; | ||
}, | ||
onSuccess(provider) { | ||
const userId = provider?.owner?.value; | ||
if (!userId) { | ||
return; | ||
} | ||
|
||
queryClient.invalidateQueries({ queryKey: getUserAuthProvidersQueryKey(userId) }); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.