@@ -25,6 +25,7 @@ import {
25
25
import { AuthProviderService } from "../auth/auth-provider-service" ;
26
26
import { AuthProviderEntry , AuthProviderInfo } from "@gitpod/gitpod-protocol" ;
27
27
import { Unauthenticated } from "./unauthenticated" ;
28
+ import { selectPage } from "./pagination" ;
28
29
29
30
@injectable ( )
30
31
export class AuthProviderServiceAPI implements ServiceImpl < typeof AuthProviderServiceInterface > {
@@ -98,10 +99,14 @@ export class AuthProviderServiceAPI implements ServiceImpl<typeof AuthProviderSe
98
99
? await this . authProviderService . getAuthProvidersOfOrg ( context . user . id , organizationId )
99
100
: await this . authProviderService . getAuthProvidersOfUser ( context . user . id ) ;
100
101
101
- const redacted = authProviders . map ( AuthProviderEntry . redact . bind ( AuthProviderEntry ) ) ;
102
+ const selectedProviders = selectPage ( authProviders , request . pagination ) ;
103
+ const redacted = selectedProviders . map ( AuthProviderEntry . redact . bind ( AuthProviderEntry ) ) ;
102
104
103
105
const result = new ListAuthProvidersResponse ( {
104
106
authProviders : redacted . map ( ( ap ) => this . apiConverter . toAuthProvider ( ap ) ) ,
107
+ pagination : {
108
+ total : redacted . length ,
109
+ } ,
105
110
} ) ;
106
111
return result ;
107
112
}
@@ -111,16 +116,19 @@ export class AuthProviderServiceAPI implements ServiceImpl<typeof AuthProviderSe
111
116
*/
112
117
@Unauthenticated ( )
113
118
async listAuthProviderDescriptions (
114
- _request : ListAuthProviderDescriptionsRequest ,
119
+ request : ListAuthProviderDescriptionsRequest ,
115
120
context : HandlerContext ,
116
121
) : Promise < ListAuthProviderDescriptionsResponse > {
117
122
const user = context . user ;
118
123
const aps = user
119
124
? await this . authProviderService . getAuthProviderDescriptions ( user )
120
125
: await this . authProviderService . getAuthProviderDescriptionsUnauthenticated ( ) ;
121
126
127
+ const selectedProviders = selectPage ( aps , request . pagination ) ;
122
128
return new ListAuthProviderDescriptionsResponse ( {
123
- descriptions : aps . map ( ( ap : AuthProviderInfo ) => this . apiConverter . toAuthProviderDescription ( ap ) ) ,
129
+ descriptions : selectedProviders . map ( ( ap : AuthProviderInfo ) =>
130
+ this . apiConverter . toAuthProviderDescription ( ap ) ,
131
+ ) ,
124
132
} ) ;
125
133
}
126
134
0 commit comments