Skip to content

Commit

Permalink
[dashboard] Allow granting a user 20 extra hours from the admin dashb…
Browse files Browse the repository at this point in the history
…oard (gitpod-io#3929)

Co-authored-by: George Tsiolis <tsiolis.g@gmail.com>
  • Loading branch information
2 people authored and MatthewFagan committed Nov 2, 2021
1 parent aae568d commit 9951f43
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/dashboard/src/admin/UserDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,22 @@ export default function UserDetail(p: { user: User }) {
accountStatement && [{
label: 'View Account Statement',
onClick: () => setViewAccountStatement(true)
}, {
label: 'Grant 20 Extra Hours',
onClick: async () => {
await getGitpodService().server.adminGrantExtraHours(user.id, 20);
setAccountStatement(await getGitpodService().server.adminGetAccountStatement(user.id));
}
}]
}
>{accountStatement?.remainingHours ? accountStatement?.remainingHours.toString() : '---'}</Property>
<Property
name="Plan"
actions={accountStatement && [{
label: (isProfessionalOpenSource ? 'Disable' : 'Enable') + ' Professional OSS',
onClick: () => {
getGitpodService().server.adminSetProfessionalOpenSource(user.id, !isProfessionalOpenSource);
onClick: async () => {
await getGitpodService().server.adminSetProfessionalOpenSource(user.id, !isProfessionalOpenSource);
setAccountStatement(await getGitpodService().server.adminGetAccountStatement(user.id));
}
}]}
>{accountStatement?.subscriptions ? accountStatement.subscriptions.filter(s => Subscription.isActive(s, new Date().toISOString())).map(s => Plans.getById(s.planId)?.name).join(', ') : '---'}</Property>
Expand Down Expand Up @@ -255,4 +262,4 @@ function getRopEntries(user: User, updateUser: UpdateUserFunction): Entry[] {
...Object.entries(Permissions).map(e => createRopEntry(e[0] as RoleOrPermission)),
...Object.entries(Roles).map(e => createRopEntry(e[0] as RoleOrPermission, true))
];
};
};
1 change: 1 addition & 0 deletions components/gitpod-protocol/src/admin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface AdminServer {
adminSetProfessionalOpenSource(userId: string, shouldGetProfOSS: boolean): Promise<void>;
adminIsStudent(userId: string): Promise<boolean>;
adminAddStudentEmailDomain(userId: string, domain: string): Promise<void>;
adminGrantExtraHours(userId: string, extraHours: number): Promise<void>;
}

export interface AdminGetListRequest<T> {
Expand Down
1 change: 1 addition & 0 deletions components/server/src/auth/rate-limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function readConfig(): RateLimiterConfig {
"adminGetAccountStatement": { group: "default", points: 1 },
"adminIsStudent": { group: "default", points: 1 },
"adminSetProfessionalOpenSource": { group: "default", points: 1 },
"adminGrantExtraHours": { group: "default", points: 1 },
"checkout": { group: "default", points: 1 },
"createPortalSession": { group: "default", points: 1 },
"getAccountStatement": { group: "default", points: 1 },
Expand Down
3 changes: 3 additions & 0 deletions components/server/src/workspace/gitpod-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,9 @@ export class GitpodServerImpl<Client extends GitpodClient, Server extends Gitpod
async adminAddStudentEmailDomain(userId: string, domain: string): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async adminGrantExtraHours(userId: string, extraHours: number): Promise<void> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
async isStudent(): Promise<boolean> {
throw new ResponseError(ErrorCodes.SAAS_FEATURE, `Not implemented in this version`);
}
Expand Down

0 comments on commit 9951f43

Please sign in to comment.