Skip to content

Commit 8c3f4fd

Browse files
Merge branch 'main' into ft/focus-targets
2 parents 86318d0 + 95e4f5d commit 8c3f4fd

40 files changed

+279
-1377
lines changed

components/dashboard/src/components/UsageBasedBillingConfig.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ export default function UsageBasedBillingConfig({ hideSubheading = false }: Prop
196196
const showBalance = !showSpinner;
197197
const showUpgradeTeam =
198198
!showSpinner && AttributionId.parse(attributionId)?.kind === "team" && !stripeSubscriptionId;
199-
const showUpgradeUser =
200-
!showSpinner && AttributionId.parse(attributionId)?.kind === "user" && !stripeSubscriptionId;
201199
const showManageBilling = !showSpinner && !!stripeSubscriptionId;
202200

203201
const updateUsageLimit = useCallback(
@@ -230,13 +228,7 @@ export default function UsageBasedBillingConfig({ hideSubheading = false }: Prop
230228

231229
return (
232230
<div className="mb-16">
233-
{!hideSubheading && (
234-
<Subheading>
235-
{attributionId && AttributionId.parse(attributionId)?.kind === "user"
236-
? "Manage billing for your personal account."
237-
: "Manage billing for your organization."}
238-
</Subheading>
239-
)}
231+
{!hideSubheading && <Subheading>Manage billing for your organization.</Subheading>}
240232
<div className="max-w-xl flex flex-col">
241233
{errorMessage && (
242234
<Alert className="max-w-xl mt-2" closable={false} showIcon={true} type="error">
@@ -305,7 +297,7 @@ export default function UsageBasedBillingConfig({ hideSubheading = false }: Prop
305297
</div>
306298
</div>
307299
)}
308-
{(showUpgradeTeam || showUpgradeUser) && (
300+
{showUpgradeTeam && (
309301
<>
310302
<div className="flex flex-col mt-4 p-4 rounded-t-xl bg-gray-50 dark:bg-gray-800">
311303
<div className="uppercase text-sm text-gray-400 dark:text-gray-500">Current Plan</div>
@@ -391,11 +383,7 @@ export default function UsageBasedBillingConfig({ hideSubheading = false }: Prop
391383
)}
392384
{showUpdateLimitModal && (
393385
<UpdateLimitModal
394-
minValue={
395-
AttributionId.parse(attributionId || "")?.kind === "user"
396-
? BASE_USAGE_LIMIT_FOR_STRIPE_USERS
397-
: 0
398-
}
386+
minValue={0}
399387
currentValue={usageLimit}
400388
onClose={() => setShowUpdateLimitModal(false)}
401389
onUpdate={async (newLimit) => await updateUsageLimit(newLimit)}

components/dashboard/src/workspaces/CreateWorkspacePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export function CreateWorkspacePage() {
181181
const [selectAccountError, setSelectAccountError] = useState<SelectAccountPayload | undefined>(undefined);
182182

183183
const createWorkspace = useCallback(
184-
async (options?: Omit<GitpodServer.CreateWorkspaceOptions, "contextUrl">) => {
184+
async (options?: Omit<GitpodServer.CreateWorkspaceOptions, "contextUrl" | "organizationId">) => {
185185
// add options from search params
186186
const opts = options || {};
187187

components/gitpod-cli/cmd/ssh.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License.AGPL.txt in the project root for license information.
4+
5+
package cmd
6+
7+
import (
8+
"context"
9+
"fmt"
10+
"os"
11+
"strings"
12+
"time"
13+
14+
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/gitpod"
15+
16+
"github.com/spf13/cobra"
17+
)
18+
19+
// todo(ft): distribute this common metadata from the root command to all subcommands to reduce latency
20+
var gitpodHost = os.Getenv("GITPOD_HOST")
21+
22+
// sshCmd represents the ssh command
23+
var sshCmd = &cobra.Command{
24+
Use: "ssh",
25+
Short: "Show the SSH connection command for the current workspace",
26+
Long: fmt.Sprintf(`Displays a command with which you can connect to the current workspace.
27+
The returned command requires SSH keys to be configured with Gitpod.
28+
See %s/user/keys for a guide on setting them up.
29+
`, gitpodHost), RunE: func(cmd *cobra.Command, args []string) error {
30+
ctx, cancel := context.WithTimeout(cmd.Context(), 10*time.Second)
31+
defer cancel()
32+
33+
wsInfo, err := gitpod.GetWSInfo(ctx)
34+
if err != nil {
35+
return fmt.Errorf("cannot get workspace info: %w", err)
36+
}
37+
38+
host := strings.Replace(wsInfo.WorkspaceUrl, wsInfo.WorkspaceId, wsInfo.WorkspaceId+".ssh", -1)
39+
sshKeyHost := fmt.Sprintf(`%s@%s`, wsInfo.WorkspaceId, host)
40+
41+
sshCommand := fmt.Sprintf(`ssh '%s'`, sshKeyHost)
42+
fmt.Println(sshCommand)
43+
44+
return nil
45+
},
46+
}
47+
48+
func init() {
49+
rootCmd.AddCommand(sshCmd)
50+
}

components/gitpod-db/src/project-db.spec.db.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class ProjectDBSpec {
5151
slug: "some-project",
5252
cloneUrl: "some-random-clone-url",
5353
userId: user.id,
54+
teamId: "team-1",
5455
appInstallationId: "app-1",
5556
});
5657
const searchTerm = "rand";

components/gitpod-db/src/team-db.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import {
1212
OrganizationSettings,
1313
} from "@gitpod/gitpod-protocol";
1414
import { DBTeamMembership } from "./typeorm/entity/db-team-membership";
15+
import { TransactionalDB } from "./typeorm/transactional-db-impl";
1516

1617
export const TeamDB = Symbol("TeamDB");
17-
export interface TeamDB {
18+
export interface TeamDB extends TransactionalDB<TeamDB> {
1819
findTeams(
1920
offset: number,
2021
limit: number,

components/gitpod-db/src/typeorm/entity/db-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class DBProject {
3030
transformer: Transformer.MAP_EMPTY_STR_TO_UNDEFINED,
3131
})
3232
@Index("ind_teamId")
33-
teamId?: string;
33+
teamId: string;
3434

3535
@Column({
3636
default: "",

components/gitpod-db/src/typeorm/entity/db-workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class DBWorkspace implements Workspace {
3636
transformer: Transformer.MAP_NULL_TO_UNDEFINED,
3737
})
3838
@Index()
39-
organizationId?: string;
39+
organizationId: string;
4040

4141
@Column(TypeORM.UUID_COLUMN_TYPE)
4242
@Index()

components/gitpod-db/src/typeorm/migration/1686907204398-FreeCredits.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
*/
66

77
import { MigrationInterface, QueryRunner } from "typeorm";
8+
import { tableExists } from "./helper/helper";
89

910
export class FreeCredits1686907204398 implements MigrationInterface {
1011
public async up(queryRunner: QueryRunner): Promise<void> {
12+
if (await tableExists(queryRunner, "d_b_free_credits")) {
13+
return;
14+
}
15+
1116
await queryRunner.query(
1217
`
1318
CREATE TABLE d_b_free_credits (

components/gitpod-db/src/typeorm/team-db-impl.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import {
1212
OrganizationSettings,
1313
User,
1414
} from "@gitpod/gitpod-protocol";
15-
import { inject, injectable } from "inversify";
16-
import { TypeORM } from "./typeorm";
17-
import { Repository } from "typeorm";
15+
import { inject, injectable, optional } from "inversify";
16+
import { EntityManager, Repository } from "typeorm";
1817
import { v4 as uuidv4 } from "uuid";
1918
import { randomBytes } from "crypto";
2019
import { TeamDB } from "../team-db";
@@ -26,13 +25,16 @@ import { ResponseError } from "vscode-jsonrpc";
2625
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
2726
import slugify from "slugify";
2827
import { DBOrgSettings } from "./entity/db-team-settings";
28+
import { TransactionalDBImpl, UndefinedEntityManager } from "./transactional-db-impl";
2929

3030
@injectable()
31-
export class TeamDBImpl implements TeamDB {
32-
@inject(TypeORM) typeORM: TypeORM;
31+
export class TeamDBImpl extends TransactionalDBImpl<TeamDB> implements TeamDB {
32+
constructor(@inject(UndefinedEntityManager) @optional() transactionalEM: EntityManager | undefined) {
33+
super(transactionalEM);
34+
}
3335

34-
protected async getEntityManager() {
35-
return (await this.typeORM.getConnection()).manager;
36+
protected createTransactionalDB(transactionalEM: EntityManager): TeamDB {
37+
return new TeamDBImpl(transactionalEM);
3638
}
3739

3840
protected async getTeamRepo(): Promise<Repository<DBTeam>> {

components/gitpod-db/src/user-db.spec.db.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ namespace TestData {
287287
deleted: false,
288288
readonly: false,
289289
};
290+
export const organizationId: string = "org1";
290291
export const ID1: Identity = { ...DEFAULT, authId: "2345" };
291292
export const ID2: Identity = { ...DEFAULT, authId: "3456", authProviderId: "Public-GitLab" };
292293
export const ID3: Identity = { ...DEFAULT, authId: "4567", authProviderId: "ACME" };
@@ -301,6 +302,7 @@ namespace TestData {
301302
image: "",
302303
tasks: [],
303304
},
305+
organizationId,
304306
context: { title: "example" },
305307
contextURL: "example.org",
306308
description: "blabla",

0 commit comments

Comments
 (0)