Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}