Skip to content

Commit

Permalink
Revert changes extracted into separate PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
rrousselGit committed Sep 25, 2024
1 parent 06e12ee commit 6c85a19
Show file tree
Hide file tree
Showing 27 changed files with 82 additions and 1,534 deletions.
3 changes: 0 additions & 3 deletions firebase-vscode/common/messaging/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export interface WebviewToExtensionParamsMap {
/** Calls the `firebase init` CLI */
runFirebaseInit: void;

/** Calls VScode's `openFolder` command */
openFolder: void;

/**
* Show a UI message using the vscode interface
*/
Expand Down
5 changes: 4 additions & 1 deletion firebase-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"categories": [
"Other"
],
"extensionDependencies": [
"graphql.vscode-graphql-syntax"
],
"activationEvents": [
"onStartupFinished",
"onLanguage:graphql",
Expand Down Expand Up @@ -120,7 +123,7 @@
"firebase": [
{
"type": "webview",
"id": "fdc_sidebar",
"id": "sidebar",
"name": "Config"
},
{
Expand Down
6 changes: 2 additions & 4 deletions firebase-vscode/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import * as commandUtils from "../../src/emulator/commandUtils";
import { currentUser } from "./core/user";
import { firstWhere } from "./utils/signal";
import { updateFirebaseRCProject } from "./data-connect/config";
import { currentProjectId } from "./core/project";
export { Emulators };

/**
Expand Down Expand Up @@ -87,9 +87,7 @@ export async function requireAuthWrapper(
// - we are calling CLI code that skips Command (where we normally call this)
currentOptions.value = optsCopy;
if (optsCopy.projectId) {
updateFirebaseRCProject({
projectAlias: { alias: "default", projectId: optsCopy.projectId },
});
currentProjectId.value = optsCopy.projectId;
}
setAccessToken(await getAccessToken());
if (userEmail) {
Expand Down
16 changes: 1 addition & 15 deletions firebase-vscode/src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import vscode, {
Disposable,
ExtensionContext,
QuickInput,
TelemetryLogger,
} from "vscode";
import vscode, { Disposable, ExtensionContext, TelemetryLogger } from "vscode";
import { ExtensionBrokerImpl } from "../extension-broker";
import { getRootFolders, registerConfig } from "./config";
import { EmulatorsController } from "./emulators";
Expand All @@ -16,7 +11,6 @@ import { registerProject } from "./project";
import { registerQuickstart } from "./quickstart";
import { registerOptions } from "../options";
import { upsertFile } from "../data-connect/file-utils";
import { setupExecuteCommandMockable } from "../utils/test_hooks";

export async function registerCore(
broker: ExtensionBrokerImpl,
Expand Down Expand Up @@ -45,14 +39,6 @@ export async function registerCore(
vscode.env.openExternal(vscode.Uri.parse(href));
});

const executeCommand = setupExecuteCommandMockable(context);

context.subscriptions.push({
dispose: broker.on("openFolder", () => {
return executeCommand.call("workbench.action.files.openFolder");
}),
});

const sub4 = broker.on("runFirebaseInit", async () => {
// Check if the user has a workspace open
if (
Expand Down
28 changes: 14 additions & 14 deletions firebase-vscode/src/core/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ export const projects = globalSignal<Record<string, FirebaseProjectMetadata[]>>(
);

/** Currently selected project ID */
export const currentProjectId = computed(() => {
const rc = firebaseRC.value?.tryReadValue;

return rc?.projects.default;
});
export const currentProjectId = globalSignal("");

const userScopedProjects = computed<FirebaseProjectMetadata[] | undefined>(
() => {
Expand Down Expand Up @@ -60,8 +56,17 @@ export function registerProject(broker: ExtensionBrokerImpl): Disposable {
}
});

// Initialize currentProjectId to default project ID
const sub4 = effect(() => {
if (!currentProjectId.value) {
currentProjectId.value = firebaseRC.value?.tryReadValue?.projects.default;
}
});

const sub5 = broker.on("getInitialData", () => {
let wantProjectId = currentProjectId.value;
let wantProjectId =
currentProjectId.value ||
firebaseRC.value?.tryReadValue?.projects["default"];
// Service accounts should only have one project
if (isServiceAccount.value) {
wantProjectId = userScopedProjects.value?.[0].projectId;
Expand All @@ -83,14 +88,8 @@ export function registerProject(broker: ExtensionBrokerImpl): Disposable {
try {
const projects = firstWhereDefined(userScopedProjects);

updateFirebaseRCProject({
projectAlias: {
alias: "default",
projectId:
(await _promptUserForProject(projects)) ??
currentProjectId.value,
},
});
currentProjectId.value =
(await _promptUserForProject(projects)) ?? currentProjectId.value;
} catch (e) {
vscode.window.showErrorMessage(e.message);
}
Expand All @@ -107,6 +106,7 @@ export function registerProject(broker: ExtensionBrokerImpl): Disposable {
{ dispose: sub1 },
{ dispose: sub2 },
{ dispose: sub3 },
{ dispose: sub4 },
{ dispose: sub5 },
{ dispose: sub6 },
);
Expand Down
2 changes: 1 addition & 1 deletion firebase-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
coreDisposable,
registerWebview({
name: "fdc_sidebar",
name: "sidebar",
broker,
context,
}),
Expand Down
25 changes: 2 additions & 23 deletions firebase-vscode/src/test/integration/empty/sidebar.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
import { browser } from "@wdio/globals";
import { FirebaseSidebar } from "../../utils/page_objects/sidebar";
import { getCommandsSpyCalls, spyCommands } from "../mock";

// it("Supports opening empty projects", async function () {
// const workbench = await browser.getWorkbench();
// const sidebar = new FirebaseSidebar(workbench);

// await sidebar.open();

// await sidebar.runInFirebaseViewContext(async (firebase) => {
// await firebase.connectProjectLinkElement.waitForDisplayed();
// });
// });

it("Supports `open folder` button", async () => {
it("Supports opening empty projects", async function () {
const workbench = await browser.getWorkbench();
const sidebar = new FirebaseSidebar(workbench);

await sidebar.open();

await spyCommands();

await sidebar.runInFirebaseViewContext(async (firebase) => {
await firebase.openFolderElement.waitForDisplayed();
await firebase.openFolderElement.click();

const calls = await getCommandsSpyCalls();

console.log('calls', calls);

expect(calls).toEqual([["workbench.action.files.openFolder"]]);
await firebase.connectProjectLinkElement.waitForDisplayed();
});
});
17 changes: 4 additions & 13 deletions firebase-vscode/src/test/integration/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,27 @@ export async function e2eSpy(key: string): Promise<void> {
}

export function getE2eSpyCalls(
key: "deploy",
key: "deploy"
): Promise<Array<Parameters<typeof cliDeploy>>>;
export function getE2eSpyCalls(key: "executeCommand"): Promise<Array<[string]>>;
export async function getE2eSpyCalls(key: string): Promise<Array<Array<any>>> {
return callBrowserSpyCommand(
key,
// We don't mock anything, just read the call list.
{ spy: undefined },
{ spy: undefined }
);
}

async function callBrowserSpyCommand(
key: string,
args: { spy: boolean | undefined },
args: { spy: boolean | undefined }
): Promise<Array<Array<any>>> {
const result = await browser.executeWorkbench(
(vs: typeof vscode, key, args) => {
return vs.commands.executeCommand(key, args);
},
`fdc-graphql.spy.${key}`,
args,
args
);

return result as Array<Array<any>>;
}

export async function spyCommands() {
await e2eSpy("executeCommand");
}

export async function getCommandsSpyCalls() {
return getE2eSpyCalls("executeCommand");
}
Binary file removed firebase-vscode/src/test/test_projects/fishfood.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
connectorId: a
authMode: PUBLIC
connectorId: "a"
authMode: "PUBLIC"
generate?:
outputDir: ../../a_connector_js_sdk
generate:
javascriptSdk:
outputDir: ../../../generated/javascript/a
package: "@firebasegen/a"
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ schema:
database: "emulator"
cloudSql:
instanceId: "dataconnect-test"
connectorDirs: ["./connectors/a"]
connectorDirs: ["./connectors"]

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6c85a19

Please sign in to comment.