Skip to content

Commit 927dadd

Browse files
committed
Fixed formatting
1 parent cdbf663 commit 927dadd

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

packages/firestore/src/lite-api/database.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ export class Firestore implements FirestoreService {
145145
this._settingsFrozen = true;
146146
updateEmulatorBanner(
147147
'Firestore',
148-
(this._settings as PrivateSettings).emulatorOptions !== null &&
149-
(this._settings as PrivateSettings).emulatorOptions !== undefined
148+
this._settings.isUsingEmulator || isCloudWorkstation(this._settings.host)
150149
);
151150
return this._settings;
152151
}
@@ -363,7 +362,7 @@ export function connectFirestoreEmulator(
363362

364363
if (useSsl) {
365364
void pingServer(`https://${newHostSetting}`);
366-
updateEmulatorBanner('firestore', true);
365+
updateEmulatorBanner('Firestore', true);
367366
}
368367

369368
if (options.mockUserToken) {

packages/util/src/emulator.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,25 @@ interface EmulatorStatuses {
146146
}
147147
const emulatorStatus: EmulatorStatuses = {};
148148

149+
interface EmulatorSummary {
150+
prod: string[];
151+
emulator: string[];
152+
}
153+
149154
// Checks whether any products are running on an emulator
150-
function areRunningEmulator(): boolean {
151-
let runningEmulator = false;
155+
function getEmulatorSummary(): EmulatorSummary {
156+
const summary: EmulatorSummary = {
157+
prod: [],
158+
emulator: []
159+
};
152160
for (const key of Object.keys(emulatorStatus)) {
153161
if (emulatorStatus[key]) {
154-
runningEmulator = true;
162+
summary.emulator.push(key);
163+
} else {
164+
summary.prod.push(key);
155165
}
156166
}
157-
return runningEmulator;
167+
return summary;
158168
}
159169

160170
function getOrCreateEl(id: string): { created: boolean; element: HTMLElement } {
@@ -188,10 +198,8 @@ export function updateEmulatorBanner(
188198

189199
emulatorStatus[name] = isRunningEmulator;
190200
const bannerId = '__firebase__banner';
191-
if (!areRunningEmulator()) {
192-
tearDown();
193-
return;
194-
}
201+
const summary = getEmulatorSummary();
202+
const showError = summary.prod.length > 0;
195203

196204
function tearDown(): void {
197205
const element = document.getElementById(bannerId);
@@ -225,10 +233,17 @@ export function updateEmulatorBanner(
225233
};
226234
bannerEl.appendChild(firebaseText);
227235
bannerEl.appendChild(closeBtn);
228-
document.body.appendChild(banner.element);
236+
document.body.appendChild(bannerEl);
237+
}
238+
if (showError) {
239+
banner.element.style.background = '#cd5c5c';
240+
firebaseText.innerText = `Product${
241+
summary.prod.length > 0 ? 's' : ''
242+
} Running in Production: ${summary.prod.join(', ')}`;
243+
} else {
244+
firebaseText.innerText = 'Running in this workspace';
229245
}
230246
firebaseText.setAttribute('id', '__firebase__text');
231-
firebaseText.innerText = 'Running in this workspace';
232247
}
233248
if (document.readyState === 'loading') {
234249
window.addEventListener('DOMContentLoaded', setupDom);

0 commit comments

Comments
 (0)