Skip to content

Commit

Permalink
Missed a few changes from comments (#6015)
Browse files Browse the repository at this point in the history
* Fixed a bug in the hosting config for emulators. Also fixed an issue
where an empty folder creates an issue loading the side panel.

* Missed some changes

* Update firebase-vscode/webviews/components/EmulatorPanel.tsx

Co-authored-by: joehan <joehanley@google.com>

---------

Co-authored-by: joehan <joehanley@google.com>
  • Loading branch information
christhompsongoogle and joehan authored Jun 21, 2023
1 parent 0561d36 commit 58c7c65
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion firebase-vscode/webviews/SidebarApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ServiceAccountUser } from "../common/types";
import { DeployPanel } from "./components/DeployPanel";
import { HostingState } from "./webview-types";
import { ChannelWithId } from "./messaging/types";
import { EmulatorPanel } from "./EmulatorPanel";
import { EmulatorPanel } from "./components/EmulatorPanel";

import { webLogger } from "./globals/web-logger";
import { InitFirebasePanel } from "./components/InitPanel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import {
VSCodeTextField,
} from "@vscode/webview-ui-toolkit/react";
import React, { useState } from "react";
import { Spacer } from "./components/ui/Spacer";
import { broker } from "./globals/html-broker";
import { PanelSection } from "./components/ui/PanelSection";
import { FirebaseConfig } from "../../src/firebaseConfig";
import { Spacer } from "./ui/Spacer";
import { broker } from "../globals/html-broker";
import { PanelSection } from "./ui/PanelSection";
import { FirebaseConfig } from "../../../src/firebaseConfig";
import {
RunningEmulatorInfo,
EmulatorUiSelections,
} from "../common/messaging/types";
} from "../../common/messaging/types";
import { VSCodeDropdown } from "@vscode/webview-ui-toolkit/react";
import { VSCodeOption } from "@vscode/webview-ui-toolkit/react";
import { EmulatorInfo } from "../../src/emulator/types";
import { webLogger } from "./globals/web-logger";
import { EmulatorInfo } from "../../../src/emulator/types";
import { webLogger } from "../globals/web-logger";

const DEFAULT_EMULATOR_UI_SELECTIONS: EmulatorUiSelections = {
projectId: "demo-something",
Expand All @@ -41,7 +41,7 @@ export function EmulatorPanel({
if (!firebaseJson) {
throw Error("Expected a valid FirebaseConfig.");
}
var defaultState = DEFAULT_EMULATOR_UI_SELECTIONS;
const defaultState = DEFAULT_EMULATOR_UI_SELECTIONS;
if (projectId) {
defaultState.projectId = getProjectIdForMode(projectId, defaultState.mode);
}
Expand Down Expand Up @@ -83,8 +83,11 @@ export function EmulatorPanel({
webLogger.debug(
`notifyEmulatorImportFolder received in sidebar: ${folder}`
);
emulatorUiSelections.importStateFolderPath = folder;
setEmulatorUiSelectionsAndSaveToWorkspace({ ...emulatorUiSelections }); // rerender clone
const newSelections = {
...emulatorUiSelections,
importStateFolderPath: folder,
};
setEmulatorUiSelectionsAndSaveToWorkspace(newSelections);
});

function launchEmulators() {
Expand Down Expand Up @@ -145,16 +148,22 @@ export function EmulatorPanel({

function emulatorModeChanged(event: React.ChangeEvent<HTMLSelectElement>) {
webLogger.debug("emulatorModeChanged: " + event.target.value);
const selections: EmulatorUiSelections = emulatorUiSelections;
selections.mode = event.target.value as typeof emulatorUiSelections.mode;
selections.projectId = getProjectIdForMode(projectId, selections.mode);
setEmulatorUiSelectionsAndSaveToWorkspace({...selections});
const newSelections: EmulatorUiSelections = { ...emulatorUiSelections };
newSelections.mode = event.target.value as typeof emulatorUiSelections.mode;
newSelections.projectId = getProjectIdForMode(
projectId,
newSelections.mode
);
setEmulatorUiSelectionsAndSaveToWorkspace(newSelections);
}

function clearImportFolder() {
console.log(`clearImportFolder`);
emulatorUiSelections.importStateFolderPath = "";
setEmulatorUiSelectionsAndSaveToWorkspace({ ...emulatorUiSelections });
const newSelections = {
...emulatorUiSelections,
importStateFolderPath: "",
};
setEmulatorUiSelectionsAndSaveToWorkspace(newSelections);
}

// Make it pretty for the screen. Filter out the logging emulator since it's
Expand Down Expand Up @@ -261,7 +270,7 @@ export function EmulatorPanel({

/**
* Formats a project ID with a demo prefix if we're in offline mode, or uses the
* regular ID if we're hosting.
* regular ID if we're in hosting only mode.
*/
function getProjectIdForMode(
projectId: string | undefined,
Expand All @@ -274,4 +283,4 @@ function getProjectIdForMode(
return projectId;
}
return "demo-" + projectId;
}
}

0 comments on commit 58c7c65

Please sign in to comment.